Compare commits
31 Commits
Author | SHA1 | Date | |
---|---|---|---|
3f67ac3c73 | |||
33c677a55e | |||
e11a3cbe80 | |||
639a6e7545 | |||
80e6696343 | |||
eebdceca17 | |||
c9bbb922e5 | |||
6e3fb589d5 | |||
4e0a05808c | |||
6b837e9165 | |||
21ee35f710 | |||
25f3587f3f | |||
0cdc23a51d | |||
89d0805fb8 | |||
1bc78272da | |||
af9e452854 | |||
9372d78e7e | |||
30d573502a | |||
3c92fa4eb0 | |||
8c20e0b588 | |||
862e140a7a | |||
1935486ff1 | |||
237be9e3a7 | |||
75a26e8509 | |||
0fcdbe20da | |||
fb110e76d8 | |||
8bcc241b72 | |||
d8f4382dd3 | |||
11c9084ec5 | |||
54df3e26ac | |||
e1f5484c82 |
79
CHANGELOG.md
79
CHANGELOG.md
@ -1,5 +1,84 @@
|
||||
# Changelog
|
||||
|
||||
## [9.6.0](https://github.com/LazyVim/LazyVim/compare/v9.5.0...v9.6.0) (2023-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **extra:** add extra `util.dot` that configures multiple ft and treesitter langs when needed ([639a6e7](https://github.com/LazyVim/LazyVim/commit/639a6e7545830602c09711b3757a28537baf8e75))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **config:** trigger LazyFile additionally on BufWritePre for saving unnamed files ([e11a3cb](https://github.com/LazyVim/LazyVim/commit/e11a3cbe800a1216062f7cefd25827f6fdad9daa))
|
||||
* **yaml:** yaml schemas are a dict, not a list, so merge properly. Fixes [#1636](https://github.com/LazyVim/LazyVim/issues/1636) ([33c677a](https://github.com/LazyVim/LazyVim/commit/33c677a55e97ee115ad7050856856df7cd96b3e1))
|
||||
|
||||
## [9.5.0](https://github.com/LazyVim/LazyVim/compare/v9.4.1...v9.5.0) (2023-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **treesitter:** add diff, jsonc and yaml by default ([c9bbb92](https://github.com/LazyVim/LazyVim/commit/c9bbb922e58b223d49785cddbed2feeea536237e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **util:** fixup typo vim.lsp.get_active_clients ([eebdcec](https://github.com/LazyVim/LazyVim/commit/eebdceca1723801e1889d2a65bd676d17139fc6c))
|
||||
|
||||
## [9.4.1](https://github.com/LazyVim/LazyVim/compare/v9.4.0...v9.4.1) (2023-10-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **config:** dont append LazyVim early to the rtp when bootstrapping ([4e0a058](https://github.com/LazyVim/LazyVim/commit/4e0a05808cb0997e0ac7d939421f68e9dfa5d74d))
|
||||
* **util:** fixed lsp willRenameFiles support check ([21ee35f](https://github.com/LazyVim/LazyVim/commit/21ee35f7108f4eefbce84d88a002572b168fc357))
|
||||
|
||||
## [9.4.0](https://github.com/LazyVim/LazyVim/compare/v9.3.1...v9.4.0) (2023-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **codeium:** add codeium extra ([#1619](https://github.com/LazyVim/LazyVim/issues/1619)) ([af9e452](https://github.com/LazyVim/LazyVim/commit/af9e4528543d98bccce333d39eccc34e433ef6dc))
|
||||
* **keymaps:** added support for lazy's per-mode keymap disabling ([1bc7827](https://github.com/LazyVim/LazyVim/commit/1bc78272da28821479e98df528d399214a8cdbee))
|
||||
* **nlua:** make lua dap keybindings buffer-local ([9372d78](https://github.com/LazyVim/LazyVim/commit/9372d78e7e4ed46612de9818868373da81b6f4f1))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **alpha:** reset laststatus when alpha unloads. Fixes [#1623](https://github.com/LazyVim/LazyVim/issues/1623) ([30d5735](https://github.com/LazyVim/LazyVim/commit/30d573502a2f9264273a14143e6bddb0b876a391))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **navic:** enable lazy_update_context option to update context on "CursorHold" instead of of using default "CursorMove" ([#1620](https://github.com/LazyVim/LazyVim/issues/1620)) ([3c92fa4](https://github.com/LazyVim/LazyVim/commit/3c92fa4eb04f827c79c095905ca9391d540fea79))
|
||||
|
||||
## [9.3.1](https://github.com/LazyVim/LazyVim/compare/v9.3.0...v9.3.1) (2023-10-07)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **config:** trigger all buf filetype events on LazyFile ([862e140](https://github.com/LazyVim/LazyVim/commit/862e140a7ad8452cd5a103982687fca63a2f44da))
|
||||
* **rust:** explicitly enable nvim-cmp source registration for crates ([#1609](https://github.com/LazyVim/LazyVim/issues/1609)) ([237be9e](https://github.com/LazyVim/LazyVim/commit/237be9e3a7f5ca8165d4242d47df34d8d407f4cc))
|
||||
* **treesitter-textobjects:** use normal ]c,]C,[c,[C when in diff-mode instead of goto class. Fixes [#1610](https://github.com/LazyVim/LazyVim/issues/1610) ([1935486](https://github.com/LazyVim/LazyVim/commit/1935486ff143dd5cf100b8c89204dc01d8e06021))
|
||||
* **ui:** properly handly signs without name. Fixes [#1612](https://github.com/LazyVim/LazyVim/issues/1612) ([0fcdbe2](https://github.com/LazyVim/LazyVim/commit/0fcdbe20daf44f00252668b3866b19ac18b339df))
|
||||
|
||||
## [9.3.0](https://github.com/LazyVim/LazyVim/compare/v9.2.0...v9.3.0) (2023-10-06)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **bufremove:** ask to save changes before trying to remove a buffer ([54df3e2](https://github.com/LazyVim/LazyVim/commit/54df3e26aca5c5c4da746f210e6f7e7de30673bb))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **tailwind:** nil check for filetypes_include. Fixes [#1607](https://github.com/LazyVim/LazyVim/issues/1607) ([d8f4382](https://github.com/LazyVim/LazyVim/commit/d8f4382dd3850550076b33d64a5f455daf7e6450))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **config:** only enable LazyFile when opening a file from the cmdline ([11c9084](https://github.com/LazyVim/LazyVim/commit/11c9084ec576c8735a87550f7975640eb75e6ff7))
|
||||
|
||||
## [9.2.0](https://github.com/LazyVim/LazyVim/compare/v9.1.1...v9.2.0) (2023-10-06)
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 06
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 08
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *LazyVim-table-of-contents*
|
||||
|
@ -1,8 +1,9 @@
|
||||
---@class LazyVimConfig: LazyVimOptions
|
||||
local M = {}
|
||||
|
||||
M.lazy_version = ">=9.1.0"
|
||||
M.lazy_version = ">=10.8.0"
|
||||
M.use_lazy_file = true
|
||||
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
|
||||
|
||||
---@class LazyVimOptions
|
||||
local defaults = {
|
||||
@ -45,6 +46,7 @@ local defaults = {
|
||||
Array = " ",
|
||||
Boolean = " ",
|
||||
Class = " ",
|
||||
Codeium = " ",
|
||||
Color = " ",
|
||||
Constant = " ",
|
||||
Constructor = " ",
|
||||
@ -90,33 +92,50 @@ M.renames = {
|
||||
---@type LazyVimOptions
|
||||
local options
|
||||
|
||||
---@param lines {[1]:string, [2]:string}[]
|
||||
function M.msg(lines)
|
||||
vim.cmd([[clear]])
|
||||
vim.api.nvim_echo(lines, true, {})
|
||||
vim.fn.getchar()
|
||||
end
|
||||
|
||||
---@param opts? LazyVimOptions
|
||||
function M.setup(opts)
|
||||
options = vim.tbl_deep_extend("force", defaults, opts or {}) or {}
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 0 then
|
||||
vim.api.nvim_echo({
|
||||
M.msg({
|
||||
{
|
||||
"LazyVim requires Neovim >= 0.9.0\n",
|
||||
"ErrorMsg",
|
||||
},
|
||||
{ "Press any key to exit", "MoreMsg" },
|
||||
}, true, {})
|
||||
|
||||
vim.fn.getchar()
|
||||
})
|
||||
vim.cmd([[quit]])
|
||||
return
|
||||
end
|
||||
|
||||
if not M.has() then
|
||||
require("lazy.core.util").error(
|
||||
"**LazyVim** needs **lazy.nvim** version "
|
||||
.. M.lazy_version
|
||||
.. " to work properly.\n"
|
||||
.. "Please upgrade **lazy.nvim**",
|
||||
{ title = "LazyVim" }
|
||||
)
|
||||
error("Exiting")
|
||||
M.msg({
|
||||
{
|
||||
"LazyVim requires lazy.nvim " .. M.lazy_version .. "\n",
|
||||
"WarningMsg",
|
||||
},
|
||||
{ "Press any key to attempt an upgrade", "MoreMsg" },
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyVimStarted",
|
||||
callback = function()
|
||||
require("lazy").update({ plugins = { "lazy.nvim" }, wait = true })
|
||||
M.msg({
|
||||
{
|
||||
"**lazy.nvim** has been upgraded.\nPlease restart **Neovim**",
|
||||
"WarningMsg",
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- autocmds can be loaded lazily when not opening a file
|
||||
@ -137,7 +156,6 @@ function M.setup(opts)
|
||||
end,
|
||||
})
|
||||
|
||||
M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil
|
||||
if M.use_lazy_file then
|
||||
M.lazy_file()
|
||||
end
|
||||
@ -169,10 +187,10 @@ function M.lazy_file()
|
||||
local Util = require("lazy.core.util")
|
||||
vim.api.nvim_del_augroup_by_name("lazy_file")
|
||||
|
||||
Util.track({ event = "LazyFile" })
|
||||
Util.track({ event = "LazyVim.lazy_file" })
|
||||
|
||||
---@type table<string,string[]>
|
||||
local skips = { FileType = Event.get_augroups("FileType") }
|
||||
local skips = {}
|
||||
for _, event in ipairs(events) do
|
||||
skips[event.event] = skips[event.event] or Event.get_augroups(event.event)
|
||||
end
|
||||
@ -188,7 +206,6 @@ function M.lazy_file()
|
||||
if vim.bo[event.buf].filetype then
|
||||
Event.trigger({
|
||||
event = "FileType",
|
||||
exclude = skips.FileType,
|
||||
buf = event.buf,
|
||||
})
|
||||
end
|
||||
@ -202,7 +219,7 @@ function M.lazy_file()
|
||||
-- and the UI can continue rendering without blocking
|
||||
load = vim.schedule_wrap(load)
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
|
||||
vim.api.nvim_create_autocmd(M.lazy_file_events, {
|
||||
group = vim.api.nvim_create_augroup("lazy_file", { clear = true }),
|
||||
callback = function(event)
|
||||
table.insert(events, event)
|
||||
@ -251,7 +268,15 @@ M.did_init = false
|
||||
function M.init()
|
||||
if not M.did_init then
|
||||
M.did_init = true
|
||||
vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir)
|
||||
local plugin = require("lazy.core.config").spec.plugins.LazyVim
|
||||
if plugin then
|
||||
vim.opt.rtp:append(plugin.dir)
|
||||
end
|
||||
|
||||
M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
M.use_lazy_file = M.use_lazy_file and require("lazy.core.handler.event").trigger_events == nil
|
||||
|
||||
-- delay notifications till vim.notify was replaced or after 500ms
|
||||
require("lazyvim.util").lazy_notify()
|
||||
|
||||
@ -263,19 +288,32 @@ function M.init()
|
||||
local add = Plugin.Spec.add
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
Plugin.Spec.add = function(self, plugin, ...)
|
||||
if type(plugin) == "table" and M.renames[plugin[1]] then
|
||||
require("lazy.core.util").warn(
|
||||
("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format(
|
||||
plugin[1],
|
||||
M.renames[plugin[1]],
|
||||
self.importing or "LazyVim"
|
||||
),
|
||||
{ title = "LazyVim" }
|
||||
)
|
||||
plugin[1] = M.renames[plugin[1]]
|
||||
end
|
||||
if not M.use_lazy_file and type(plugin) == "table" and plugin.event == "LazyFile" then
|
||||
plugin.event = { "BufReadPost", "BufNewFile" }
|
||||
if type(plugin) == "table" then
|
||||
if M.renames[plugin[1]] then
|
||||
require("lazy.core.util").warn(
|
||||
("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format(
|
||||
plugin[1],
|
||||
M.renames[plugin[1]],
|
||||
self.importing or "LazyVim"
|
||||
),
|
||||
{ title = "LazyVim" }
|
||||
)
|
||||
plugin[1] = M.renames[plugin[1]]
|
||||
end
|
||||
if not M.use_lazy_file and plugin.event then
|
||||
if plugin.event == "LazyFile" then
|
||||
plugin.event = M.lazy_file_events
|
||||
elseif type(plugin.event) == "table" then
|
||||
local events = {} ---@type string[]
|
||||
for _, event in ipairs(plugin.event) do
|
||||
if event == "LazyFile" then
|
||||
vim.list_extend(events, M.lazy_file_events)
|
||||
else
|
||||
events[#events + 1] = event
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return add(self, plugin, ...)
|
||||
end
|
||||
|
@ -1,19 +1,9 @@
|
||||
-- This file is automatically loaded by lazyvim.config.init
|
||||
local Util = require("lazyvim.util")
|
||||
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
local keys = require("lazy.core.handler").handlers.keys
|
||||
---@cast keys LazyKeysHandler
|
||||
-- do not create the keymap if a lazy keys handler exists
|
||||
if not keys.active[keys.parse({ lhs, mode = mode }).id] then
|
||||
opts = opts or {}
|
||||
opts.silent = opts.silent ~= false
|
||||
if opts.remap and not vim.g.vscode then
|
||||
opts.remap = nil
|
||||
end
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
-- DO NOT USE THIS IN YOU OWN CONFIG!!
|
||||
-- use `vim.keymap.set` instead
|
||||
local map = Util.safe_keymap_set
|
||||
|
||||
-- better up/down
|
||||
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
|
@ -387,9 +387,27 @@ return {
|
||||
-- buffer remove
|
||||
{
|
||||
"echasnovski/mini.bufremove",
|
||||
-- stylua: ignore
|
||||
|
||||
keys = {
|
||||
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" },
|
||||
{
|
||||
"<leader>bd",
|
||||
function()
|
||||
local bd = require("mini.bufremove").delete
|
||||
if vim.bo.modified then
|
||||
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
|
||||
if choice == 1 then -- Yes
|
||||
vim.cmd.write()
|
||||
bd(0)
|
||||
elseif choice == 2 then -- No
|
||||
bd(0, true)
|
||||
end
|
||||
else
|
||||
bd(0)
|
||||
end
|
||||
end,
|
||||
desc = "Delete Buffer",
|
||||
},
|
||||
-- stylua: ignore
|
||||
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
|
||||
},
|
||||
},
|
||||
|
25
lua/lazyvim/plugins/extras/coding/codeium.lua
Normal file
25
lua/lazyvim/plugins/extras/coding/codeium.lua
Normal file
@ -0,0 +1,25 @@
|
||||
return {
|
||||
|
||||
-- codeium
|
||||
{
|
||||
"Exafunction/codeium.nvim",
|
||||
cmd = "Codeium",
|
||||
build = ":Codeium Auth",
|
||||
opts = {},
|
||||
},
|
||||
-- codeium cmp source
|
||||
{
|
||||
"nvim-cmp",
|
||||
dependencies = {
|
||||
{
|
||||
"Exafunction/codeium.nvim",
|
||||
},
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, { name = "codeium", group_index = 2 })
|
||||
opts.sorting = opts.sorting or require("cmp.config.default")().sorting
|
||||
end,
|
||||
},
|
||||
|
||||
}
|
@ -6,8 +6,8 @@ return {
|
||||
"jbyuki/one-small-step-for-vimkind",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server" },
|
||||
{ "<leader>dal", function() require("osv").run_this() end, desc = "Adapter Lua" },
|
||||
{ "<leader>daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server", ft = "lua" },
|
||||
{ "<leader>dal", function() require("osv").run_this() end, desc = "Adapter Lua", ft = "lua" },
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
|
@ -36,7 +36,7 @@ return {
|
||||
injected = { options = { ignore_errors = true } },
|
||||
-- -- Example of using dprint only when a dprint.json file is present
|
||||
-- dprint = {
|
||||
-- condition = function(self, ctx)
|
||||
-- condition = function(ctx)
|
||||
-- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1]
|
||||
-- end,
|
||||
-- },
|
||||
|
@ -7,7 +7,11 @@ return {
|
||||
{
|
||||
"Saecki/crates.nvim",
|
||||
event = { "BufRead Cargo.toml" },
|
||||
config = true,
|
||||
opts = {
|
||||
src = {
|
||||
cmp = { enabled = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
|
@ -27,7 +27,7 @@ return {
|
||||
end, opts.filetypes)
|
||||
|
||||
-- Add additional filetypes
|
||||
vim.list_extend(opts.filetypes, opts.filetypes_include)
|
||||
vim.list_extend(opts.filetypes, opts.filetypes_include or {})
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
@ -35,8 +35,11 @@ return {
|
||||
},
|
||||
-- lazy-load schemastore when needed
|
||||
on_new_config = function(new_config)
|
||||
new_config.settings.yaml.schemas = new_config.settings.yaml.schemas or {}
|
||||
vim.list_extend(new_config.settings.yaml.schemas, require("schemastore").yaml.schemas())
|
||||
new_config.settings.yaml.schemas = vim.tbl_deep_extend(
|
||||
"force",
|
||||
new_config.settings.yaml.schemas or {},
|
||||
require("schemastore").yaml.schemas()
|
||||
)
|
||||
end,
|
||||
settings = {
|
||||
redhat = { telemetry = { enabled = false } },
|
||||
|
62
lua/lazyvim/plugins/extras/util/dot.lua
Normal file
62
lua/lazyvim/plugins/extras/util/dot.lua
Normal file
@ -0,0 +1,62 @@
|
||||
---@type string
|
||||
local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config"
|
||||
|
||||
---@param path string
|
||||
local function have(path)
|
||||
return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
-- Add Hyprland Parser
|
||||
{
|
||||
"luckasRanarison/tree-sitter-hypr",
|
||||
enabled = have("hypr"),
|
||||
event = "BufRead */hypr/*.conf",
|
||||
config = function()
|
||||
-- Fix ft detection for hyprland
|
||||
vim.filetype.add({
|
||||
pattern = { [".*/hypr/.*%.conf"] = "hypr" },
|
||||
})
|
||||
require("nvim-treesitter.parsers").get_parser_configs().hypr = {
|
||||
install_info = {
|
||||
url = "https://github.com/luckasRanarison/tree-sitter-hypr",
|
||||
files = { "src/parser.c" },
|
||||
branch = "master",
|
||||
},
|
||||
filetype = "hypr",
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- add some stuff to treesitter
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
local function add(lang)
|
||||
if type(opts.ensure_installed) ~= "table" then
|
||||
table.insert(opts.ensure_installed, lang)
|
||||
end
|
||||
end
|
||||
|
||||
vim.filetype.add({
|
||||
extension = { rasi = "rasi" },
|
||||
pattern = {
|
||||
[".*/waybar/config"] = "jsonc",
|
||||
[".*/mako/config"] = "dosini",
|
||||
[".*/kitty/*.conf"] = "bash",
|
||||
},
|
||||
})
|
||||
|
||||
add("git_config")
|
||||
|
||||
if have("fish") then
|
||||
add("fish")
|
||||
end
|
||||
|
||||
if have("rofi") or have("wofi") then
|
||||
add("rasi")
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
@ -82,7 +82,7 @@ function M.get_formatters(bufnr)
|
||||
}
|
||||
|
||||
---@type lsp.Client[]
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
local clients = require("lazyvim.util").get_clients({ bufnr = bufnr })
|
||||
for _, client in ipairs(clients) do
|
||||
if M.supports_format(client) then
|
||||
if (#null_ls > 0 and client.name == "null-ls") or #null_ls == 0 then
|
||||
|
@ -55,7 +55,7 @@ return {
|
||||
-- mason = false, -- set to false if you don't want this server to be installed with mason
|
||||
-- Use this to add any additional keymaps
|
||||
-- for specific lsp servers
|
||||
---@type LazyKeys[]
|
||||
---@type LazyKeysSpec[]
|
||||
-- keys = {},
|
||||
settings = {
|
||||
Lua = {
|
||||
|
@ -1,12 +1,16 @@
|
||||
local M = {}
|
||||
|
||||
---@type PluginLspKeys
|
||||
---@type LazyKeysLspSpec[]|nil
|
||||
M._keys = nil
|
||||
|
||||
---@return (LazyKeys|{has?:string})[]
|
||||
---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string}
|
||||
---@alias LazyKeysLsp LazyKeys|{has?:string}
|
||||
|
||||
---@return LazyKeysLspSpec[]
|
||||
function M.get()
|
||||
if not M._keys then
|
||||
---@class PluginLspKeys
|
||||
if M._keys then
|
||||
return M._keys
|
||||
end
|
||||
-- stylua: ignore
|
||||
M._keys = {
|
||||
{ "<leader>cd", vim.diagnostic.open_float, desc = "Line Diagnostics" },
|
||||
@ -42,20 +46,19 @@ function M.get()
|
||||
has = "codeAction",
|
||||
}
|
||||
}
|
||||
if require("lazyvim.util").has("inc-rename.nvim") then
|
||||
M._keys[#M._keys + 1] = {
|
||||
"<leader>cr",
|
||||
function()
|
||||
local inc_rename = require("inc_rename")
|
||||
return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("<cword>")
|
||||
end,
|
||||
expr = true,
|
||||
desc = "Rename",
|
||||
has = "rename",
|
||||
}
|
||||
else
|
||||
M._keys[#M._keys + 1] = { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }
|
||||
end
|
||||
if require("lazyvim.util").has("inc-rename.nvim") then
|
||||
M._keys[#M._keys + 1] = {
|
||||
"<leader>cr",
|
||||
function()
|
||||
local inc_rename = require("inc_rename")
|
||||
return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("<cword>")
|
||||
end,
|
||||
expr = true,
|
||||
desc = "Rename",
|
||||
has = "rename",
|
||||
}
|
||||
else
|
||||
M._keys[#M._keys + 1] = { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }
|
||||
end
|
||||
return M._keys
|
||||
end
|
||||
@ -63,7 +66,7 @@ end
|
||||
---@param method string
|
||||
function M.has(buffer, method)
|
||||
method = method:find("/") and method or "textDocument/" .. method
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
if client.supports_method(method) then
|
||||
return true
|
||||
@ -72,45 +75,33 @@ function M.has(buffer, method)
|
||||
return false
|
||||
end
|
||||
|
||||
---@return (LazyKeys|{has?:string})[]
|
||||
function M.resolve(buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = {} ---@type table<string,LazyKeys|{has?:string}>
|
||||
|
||||
local function add(keymap)
|
||||
local keys = Keys.parse(keymap)
|
||||
if keys[2] == false then
|
||||
keymaps[keys.id] = nil
|
||||
else
|
||||
keymaps[keys.id] = keys
|
||||
end
|
||||
if not Keys.resolve then
|
||||
return {}
|
||||
end
|
||||
for _, keymap in ipairs(M.get()) do
|
||||
add(keymap)
|
||||
end
|
||||
|
||||
local spec = M.get()
|
||||
local opts = require("lazyvim.util").opts("nvim-lspconfig")
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
|
||||
for _, keymap in ipairs(maps) do
|
||||
add(keymap)
|
||||
end
|
||||
vim.list_extend(spec, maps)
|
||||
end
|
||||
return keymaps
|
||||
return Keys.resolve(spec)
|
||||
end
|
||||
|
||||
function M.on_attach(client, buffer)
|
||||
function M.on_attach(_, buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = M.resolve(buffer)
|
||||
|
||||
for _, keys in pairs(keymaps) do
|
||||
if not keys.has or M.has(buffer, keys.has) then
|
||||
local opts = Keys.opts(keys)
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
opts.has = nil
|
||||
opts.silent = opts.silent ~= false
|
||||
opts.buffer = buffer
|
||||
vim.keymap.set(keys.mode or "n", keys[1], keys[2], opts)
|
||||
vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -11,16 +11,26 @@ return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
config = function()
|
||||
-- Disable class keymaps in diff mode
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
callback = function(event)
|
||||
if vim.wo.diff then
|
||||
for _, key in ipairs({ "[c", "]c", "[C", "]C" }) do
|
||||
pcall(vim.keymap.del, "n", key, { buffer = event.buf })
|
||||
-- When in diff mode, we want to use the default
|
||||
-- vim text objects c & C instead of the treesitter ones.
|
||||
local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
|
||||
local configs = require("nvim-treesitter.configs")
|
||||
for name, fn in pairs(move) do
|
||||
if name:find("goto") == 1 then
|
||||
move[name] = function(q, ...)
|
||||
if vim.wo.diff then
|
||||
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
|
||||
for key, query in pairs(config or {}) do
|
||||
if q == query and key:find("[%]%[][cC]") then
|
||||
vim.cmd("normal! " .. key)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
return fn(q, ...)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
@ -30,16 +40,19 @@ return {
|
||||
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||
},
|
||||
---@type TSConfig
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
opts = {
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"diff",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
@ -48,6 +61,7 @@ return {
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
|
@ -316,11 +316,13 @@ return {
|
||||
return dashboard
|
||||
end,
|
||||
config = function(_, dashboard)
|
||||
local laststatus = vim.o.laststatus
|
||||
vim.o.laststatus = 0
|
||||
-- close Lazy and re-open when the dashboard is ready
|
||||
if vim.o.filetype == "lazy" then
|
||||
vim.cmd.close()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
once = true,
|
||||
pattern = "AlphaReady",
|
||||
callback = function()
|
||||
require("lazy").show()
|
||||
@ -328,9 +330,18 @@ return {
|
||||
})
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("BufUnload", {
|
||||
once = true,
|
||||
buffer = vim.api.nvim_get_current_buf(),
|
||||
callback = function()
|
||||
vim.opt.laststatus = laststatus
|
||||
end,
|
||||
})
|
||||
|
||||
require("alpha").setup(dashboard.opts)
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
once = true,
|
||||
pattern = "LazyVimStarted",
|
||||
callback = function()
|
||||
local stats = require("lazy").stats()
|
||||
@ -362,6 +373,7 @@ return {
|
||||
highlight = true,
|
||||
depth_limit = 5,
|
||||
icons = require("lazyvim.config").icons.kinds,
|
||||
lazy_update_context = true,
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
@ -8,7 +8,7 @@ M.root_patterns = { ".git", "lua" }
|
||||
function M.on_attach(on_attach)
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local buffer = args.buf
|
||||
local buffer = args.buf ---@type number
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
on_attach(client, buffer)
|
||||
end,
|
||||
@ -22,9 +22,11 @@ end
|
||||
|
||||
function M.fg(name)
|
||||
---@type {foreground?:number}?
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
|
||||
local fg = hl and hl.fg or hl.foreground
|
||||
return fg and { fg = string.format("#%06x", fg) }
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local fg = hl and (hl.fg or hl.foreground)
|
||||
return fg and { fg = string.format("#%06x", fg) } or nil
|
||||
end
|
||||
|
||||
---@param fn fun()
|
||||
@ -47,6 +49,8 @@ function M.opts(name)
|
||||
return Plugin.values(plugin, "opts", false)
|
||||
end
|
||||
|
||||
M.get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||
|
||||
-- returns the root directory based on:
|
||||
-- * lsp workspace folders
|
||||
-- * lsp root_dir
|
||||
@ -60,7 +64,7 @@ function M.get_root()
|
||||
---@type string[]
|
||||
local roots = {}
|
||||
if path then
|
||||
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||
for _, client in pairs(M.get_clients({ bufnr = 0 })) do
|
||||
local workspace = client.config.workspace_folders
|
||||
local paths = workspace and vim.tbl_map(function(ws)
|
||||
return vim.uri_to_fname(ws.uri)
|
||||
@ -227,7 +231,7 @@ function M.lazy_notify()
|
||||
vim.notify = temp
|
||||
|
||||
local timer = vim.loop.new_timer()
|
||||
local check = vim.loop.new_check()
|
||||
local check = assert(vim.loop.new_check())
|
||||
|
||||
local replay = function()
|
||||
timer:stop()
|
||||
@ -253,6 +257,7 @@ function M.lazy_notify()
|
||||
timer:start(500, 0, replay)
|
||||
end
|
||||
|
||||
---@return _.lspconfig.options
|
||||
function M.lsp_get_config(server)
|
||||
local configs = require("lspconfig.configs")
|
||||
return rawget(configs, server)
|
||||
@ -263,6 +268,7 @@ end
|
||||
function M.lsp_disable(server, cond)
|
||||
local util = require("lspconfig.util")
|
||||
local def = M.lsp_get_config(server)
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
|
||||
if cond(root_dir, config) then
|
||||
config.enabled = false
|
||||
@ -302,9 +308,10 @@ end
|
||||
---@param from string
|
||||
---@param to string
|
||||
function M.on_rename(from, to)
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
local clients = M.get_clients()
|
||||
for _, client in ipairs(clients) do
|
||||
if client:supports_method("workspace/willRenameFiles") then
|
||||
if client.supports_method("workspace/willRenameFiles") then
|
||||
---@diagnostic disable-next-line: invisible
|
||||
local resp = client.request_sync("workspace/willRenameFiles", {
|
||||
files = {
|
||||
{
|
||||
@ -312,7 +319,7 @@ function M.on_rename(from, to)
|
||||
newUri = vim.uri_from_fname(to),
|
||||
},
|
||||
},
|
||||
}, 1000)
|
||||
}, 1000, 0)
|
||||
if resp and resp.result ~= nil then
|
||||
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
|
||||
end
|
||||
@ -320,4 +327,28 @@ function M.on_rename(from, to)
|
||||
end
|
||||
end
|
||||
|
||||
-- Wrapper around vim.keymap.set that will
|
||||
-- not create a keymap if a lazy key handler exists.
|
||||
-- It will also set `silent` to true by default.
|
||||
function M.safe_keymap_set(mode, lhs, rhs, opts)
|
||||
local keys = require("lazy.core.handler").handlers.keys
|
||||
---@cast keys LazyKeysHandler
|
||||
local modes = type(mode) == "string" and { mode } or mode
|
||||
|
||||
---@param m string
|
||||
modes = vim.tbl_filter(function(m)
|
||||
return not (keys.have and keys:have(lhs, m))
|
||||
end, modes)
|
||||
|
||||
-- do not create the keymap if a lazy keys handler exists
|
||||
if #modes > 0 then
|
||||
opts = opts or {}
|
||||
opts.silent = opts.silent ~= false
|
||||
if opts.remap and not vim.g.vscode then
|
||||
opts.remap = nil
|
||||
end
|
||||
vim.keymap.set(modes, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -26,7 +26,7 @@ function M.get_signs(buf, lnum)
|
||||
)
|
||||
for _, extmark in pairs(extmarks) do
|
||||
signs[#signs + 1] = {
|
||||
name = extmark[4].sign_hl_group,
|
||||
name = extmark[4].sign_hl_group or "",
|
||||
text = extmark[4].sign_text,
|
||||
texthl = extmark[4].sign_hl_group,
|
||||
priority = extmark[4].priority,
|
||||
@ -93,7 +93,7 @@ function M.statuscolumn()
|
||||
---@type Sign?,Sign?,Sign?
|
||||
local left, right, fold
|
||||
for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do
|
||||
if s.name:find("GitSign") then
|
||||
if s.name and s.name:find("GitSign") then
|
||||
right = s
|
||||
else
|
||||
left = s
|
||||
|
Reference in New Issue
Block a user