mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-03 22:14:39 +02:00
refactor: LazyVim.lsp.on_attach
This commit is contained in:
parent
6098a36d92
commit
8f7ee56dab
6 changed files with 32 additions and 42 deletions
|
@ -66,10 +66,8 @@ return {
|
||||||
-- attach cmp source whenever copilot attaches
|
-- attach cmp source whenever copilot attaches
|
||||||
-- fixes lazy-loading issues with the copilot cmp source
|
-- fixes lazy-loading issues with the copilot cmp source
|
||||||
LazyVim.lsp.on_attach(function(client)
|
LazyVim.lsp.on_attach(function(client)
|
||||||
if client.name == "copilot" then
|
copilot_cmp._on_insert_enter({})
|
||||||
copilot_cmp._on_insert_enter({})
|
end, "copilot")
|
||||||
end
|
|
||||||
end)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -36,11 +36,9 @@ return {
|
||||||
setup = {
|
setup = {
|
||||||
angularls = function()
|
angularls = function()
|
||||||
LazyVim.lsp.on_attach(function(client)
|
LazyVim.lsp.on_attach(function(client)
|
||||||
if client.name == "angularls" then
|
--HACK: disable angular renaming capability due to duplicate rename popping up
|
||||||
--HACK: disable angular renaming capability due to duplicate rename popping up
|
client.server_capabilities.renameProvider = false
|
||||||
client.server_capabilities.renameProvider = false
|
end, "angularls")
|
||||||
end
|
|
||||||
end)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,20 +61,18 @@ return {
|
||||||
-- workaround for gopls not supporting semanticTokensProvider
|
-- workaround for gopls not supporting semanticTokensProvider
|
||||||
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
|
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
|
||||||
LazyVim.lsp.on_attach(function(client, _)
|
LazyVim.lsp.on_attach(function(client, _)
|
||||||
if client.name == "gopls" then
|
if not client.server_capabilities.semanticTokensProvider then
|
||||||
if not client.server_capabilities.semanticTokensProvider then
|
local semantic = client.config.capabilities.textDocument.semanticTokens
|
||||||
local semantic = client.config.capabilities.textDocument.semanticTokens
|
client.server_capabilities.semanticTokensProvider = {
|
||||||
client.server_capabilities.semanticTokensProvider = {
|
full = true,
|
||||||
full = true,
|
legend = {
|
||||||
legend = {
|
tokenTypes = semantic.tokenTypes,
|
||||||
tokenTypes = semantic.tokenTypes,
|
tokenModifiers = semantic.tokenModifiers,
|
||||||
tokenModifiers = semantic.tokenModifiers,
|
},
|
||||||
},
|
range = true,
|
||||||
range = true,
|
}
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end)
|
end, "gopls")
|
||||||
-- end workaround
|
-- end workaround
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,13 +1,3 @@
|
||||||
LazyVim.lsp.on_attach(function(client, buffer)
|
|
||||||
if client.name == "yamlls" then
|
|
||||||
if vim.api.nvim_get_option_value("filetype", { buf = buffer }) == "helm" then
|
|
||||||
vim.schedule(function()
|
|
||||||
vim.cmd("LspStop ++force yamlls")
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
recommended = function()
|
recommended = function()
|
||||||
return LazyVim.extras.wants({
|
return LazyVim.extras.wants({
|
||||||
|
@ -25,9 +15,19 @@ return {
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
opts = {
|
opts = {
|
||||||
servers = {
|
servers = {
|
||||||
yamlls = {},
|
|
||||||
helm_ls = {},
|
helm_ls = {},
|
||||||
},
|
},
|
||||||
|
setup = {
|
||||||
|
yamlls = function()
|
||||||
|
LazyVim.lsp.on_attach(function(client, buffer)
|
||||||
|
if vim.bo[buffer].filetype == "helm" then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.cmd("LspStop ++force yamlls")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end, "yamlls")
|
||||||
|
end,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,11 +58,9 @@ return {
|
||||||
setup = {
|
setup = {
|
||||||
[ruff] = function()
|
[ruff] = function()
|
||||||
LazyVim.lsp.on_attach(function(client, _)
|
LazyVim.lsp.on_attach(function(client, _)
|
||||||
if client.name == ruff then
|
-- Disable hover in favor of Pyright
|
||||||
-- Disable hover in favor of Pyright
|
client.server_capabilities.hoverProvider = false
|
||||||
client.server_capabilities.hoverProvider = false
|
end, ruff)
|
||||||
end
|
|
||||||
end)
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -60,10 +60,8 @@ return {
|
||||||
-- Neovim < 0.10 does not have dynamic registration for formatting
|
-- Neovim < 0.10 does not have dynamic registration for formatting
|
||||||
if vim.fn.has("nvim-0.10") == 0 then
|
if vim.fn.has("nvim-0.10") == 0 then
|
||||||
LazyVim.lsp.on_attach(function(client, _)
|
LazyVim.lsp.on_attach(function(client, _)
|
||||||
if client.name == "yamlls" then
|
client.server_capabilities.documentFormattingProvider = true
|
||||||
client.server_capabilities.documentFormattingProvider = true
|
end, "yamlls")
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue