mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-15 03:44:38 +02:00
Merge branch 'main' into main
This commit is contained in:
commit
1a34fc6c3a
63 changed files with 1832 additions and 625 deletions
|
@ -13,6 +13,11 @@ M.actions = {
|
|||
return true
|
||||
end
|
||||
end,
|
||||
snippet_stop = function()
|
||||
if vim.snippet then
|
||||
vim.snippet.stop()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
---@param actions string[]
|
||||
|
@ -100,20 +105,6 @@ function M.add_missing_snippet_docs(window)
|
|||
end
|
||||
end
|
||||
|
||||
function M.visible()
|
||||
---@module 'blink.cmp'
|
||||
local blink = package.loaded["blink.cmp"]
|
||||
if blink then
|
||||
return blink.windows and blink.windows.autocomplete.win:is_open()
|
||||
end
|
||||
---@module 'cmp'
|
||||
local cmp = package.loaded["cmp"]
|
||||
if cmp then
|
||||
return cmp.core.view:visible()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- This is a better implementation of `cmp.confirm`:
|
||||
-- * check if the completion menu is visible without waiting for running sources
|
||||
-- * create an undo point before confirming
|
||||
|
|
|
@ -13,6 +13,12 @@ M.moved = {
|
|||
ui = {
|
||||
statuscolumn = { "Snacks.statuscolumn" },
|
||||
bufremove = { "Snacks.bufdelete" },
|
||||
fg = {
|
||||
"{ fg = Snacks.util.color(...) }",
|
||||
fn = function(...)
|
||||
return { fg = Snacks.util.color(...) }
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -33,6 +39,9 @@ function M.decorate(name, mod)
|
|||
if M.moved[name][k] then
|
||||
local to = M.moved[name][k][1]
|
||||
LazyVim.deprecate("LazyVim." .. name .. "." .. k, to)
|
||||
if M.moved[name][k].fn then
|
||||
return M.moved[name][k].fn
|
||||
end
|
||||
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -265,4 +265,13 @@ function M.memoize(fn)
|
|||
end
|
||||
end
|
||||
|
||||
---@return "nvim-cmp" | "blink.cmp"
|
||||
function M.cmp_engine()
|
||||
vim.g.lazyvim_cmp = vim.g.lazyvim_cmp or "auto"
|
||||
if vim.g.lazyvim_cmp == "auto" then
|
||||
return LazyVim.has_extra("coding.nvim-cmp") and "nvim-cmp" or "blink.cmp"
|
||||
end
|
||||
return vim.g.lazyvim_cmp
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -17,7 +17,7 @@ function M.status(icon, status)
|
|||
return status() ~= nil
|
||||
end,
|
||||
color = function()
|
||||
return LazyVim.ui.fg(colors[status()] or colors.ok)
|
||||
return { fg = Snacks.util.color(colors[status()] or colors.ok) }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
@ -157,7 +157,7 @@ function M.root_dir(opts)
|
|||
other = true,
|
||||
icon = " ",
|
||||
color = function()
|
||||
return LazyVim.ui.fg("Special")
|
||||
return { fg = Snacks.util.color("Special") }
|
||||
end,
|
||||
}, opts or {})
|
||||
|
||||
|
|
|
@ -1,47 +1,6 @@
|
|||
---@class lazyvim.util.mini
|
||||
local M = {}
|
||||
|
||||
---@alias Mini.ai.loc {line:number, col:number}
|
||||
---@alias Mini.ai.region {from:Mini.ai.loc, to:Mini.ai.loc}
|
||||
|
||||
-- Mini.ai indent text object
|
||||
-- For "a", it will include the non-whitespace line surrounding the indent block.
|
||||
-- "a" is line-wise, "i" is character-wise.
|
||||
function M.ai_indent(ai_type)
|
||||
local spaces = (" "):rep(vim.o.tabstop)
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||
local indents = {} ---@type {line: number, indent: number, text: string}[]
|
||||
|
||||
for l, line in ipairs(lines) do
|
||||
if not line:find("^%s*$") then
|
||||
indents[#indents + 1] = { line = l, indent = #line:gsub("\t", spaces):match("^%s*"), text = line }
|
||||
end
|
||||
end
|
||||
|
||||
local ret = {} ---@type (Mini.ai.region | {indent: number})[]
|
||||
|
||||
for i = 1, #indents do
|
||||
if i == 1 or indents[i - 1].indent < indents[i].indent then
|
||||
local from, to = i, i
|
||||
for j = i + 1, #indents do
|
||||
if indents[j].indent < indents[i].indent then
|
||||
break
|
||||
end
|
||||
to = j
|
||||
end
|
||||
from = ai_type == "a" and from > 1 and from - 1 or from
|
||||
to = ai_type == "a" and to < #indents and to + 1 or to
|
||||
ret[#ret + 1] = {
|
||||
indent = indents[i].indent,
|
||||
from = { line = indents[from].line, col = ai_type == "a" and 1 or indents[from].indent + 1 },
|
||||
to = { line = indents[to].line, col = #indents[to].text },
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
-- taken from MiniExtra.gen_ai_spec.buffer
|
||||
function M.ai_buffer(ai_type)
|
||||
local start_line, end_line = 1, vim.fn.line("$")
|
||||
|
@ -92,6 +51,7 @@ function M.ai_whichkey(opts)
|
|||
{ "}", desc = "{} with ws" },
|
||||
}
|
||||
|
||||
---@type wk.Spec[]
|
||||
local ret = { mode = { "o", "x" } }
|
||||
---@type table<string, string>
|
||||
local mappings = vim.tbl_extend("force", {}, {
|
||||
|
|
|
@ -42,10 +42,13 @@ function M.register(picker)
|
|||
return true
|
||||
end
|
||||
|
||||
---@return "telescope" | "fzf" | "snacks"
|
||||
function M.want()
|
||||
vim.g.lazyvim_picker = vim.g.lazyvim_picker or "auto"
|
||||
if vim.g.lazyvim_picker == "auto" then
|
||||
return LazyVim.has_extra("editor.fzf") and "fzf" or "telescope"
|
||||
return LazyVim.has_extra("editor.snacks_picker") and "snacks"
|
||||
or LazyVim.has_extra("editor.telescope") and "telescope"
|
||||
or "fzf"
|
||||
end
|
||||
return vim.g.lazyvim_picker
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---@class lazyvim.util.root
|
||||
---@overload fun(): string
|
||||
local M = setmetatable({}, {
|
||||
__call = function(m)
|
||||
return m.get()
|
||||
__call = function(m, ...)
|
||||
return m.get(...)
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
|
@ -24,52 +24,4 @@ function M.foldexpr()
|
|||
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or "0"
|
||||
end
|
||||
|
||||
---@return {fg?:string}?
|
||||
function M.fg(name)
|
||||
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
|
||||
local fg = hl and hl.fg or hl.foreground
|
||||
return fg and { fg = string.format("#%06x", fg) } or nil
|
||||
end
|
||||
|
||||
function M.maximize()
|
||||
---@type {k:string, v:any}[]?
|
||||
local maximized = nil
|
||||
return Snacks.toggle({
|
||||
name = "Maximize",
|
||||
get = function()
|
||||
return maximized ~= nil
|
||||
end,
|
||||
set = function(state)
|
||||
if state then
|
||||
maximized = {}
|
||||
local function set(k, v)
|
||||
table.insert(maximized, 1, { k = k, v = vim.o[k] })
|
||||
vim.o[k] = v
|
||||
end
|
||||
set("winwidth", 999)
|
||||
set("winheight", 999)
|
||||
set("winminwidth", 10)
|
||||
set("winminheight", 4)
|
||||
vim.cmd("wincmd =")
|
||||
-- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that
|
||||
-- `VimLeavePre` might be another consideration? Not sure about differences between the 2
|
||||
vim.api.nvim_create_autocmd("ExitPre", {
|
||||
once = true,
|
||||
group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }),
|
||||
desc = "Restore width/height when close Neovim while maximized",
|
||||
callback = function()
|
||||
M.maximize.set(false)
|
||||
end,
|
||||
})
|
||||
else
|
||||
for _, opt in ipairs(maximized) do
|
||||
vim.o[opt.k] = opt.v
|
||||
end
|
||||
maximized = nil
|
||||
vim.cmd("wincmd =")
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue