mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 09:18:51 +02:00
feat(lsp): added native codelens support. Enable in lsp settings. (disabled by default). Fixes #2656
This commit is contained in:
parent
b2a0ae6d0d
commit
780b9bb337
2 changed files with 26 additions and 0 deletions
|
@ -41,6 +41,12 @@ return {
|
||||||
inlay_hints = {
|
inlay_hints = {
|
||||||
enabled = false,
|
enabled = false,
|
||||||
},
|
},
|
||||||
|
-- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0
|
||||||
|
-- Be aware that you also will need to properly configure your LSP server to
|
||||||
|
-- provide the code lenses.
|
||||||
|
codelens = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
-- add any global capabilities here
|
-- add any global capabilities here
|
||||||
capabilities = {},
|
capabilities = {},
|
||||||
-- options for vim.lsp.buf.format
|
-- options for vim.lsp.buf.format
|
||||||
|
@ -64,6 +70,9 @@ return {
|
||||||
workspace = {
|
workspace = {
|
||||||
checkThirdParty = false,
|
checkThirdParty = false,
|
||||||
},
|
},
|
||||||
|
codeLens = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
completion = {
|
completion = {
|
||||||
callSnippet = "Replace",
|
callSnippet = "Replace",
|
||||||
},
|
},
|
||||||
|
@ -123,6 +132,7 @@ return {
|
||||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- inlay hints
|
||||||
if opts.inlay_hints.enabled then
|
if opts.inlay_hints.enabled then
|
||||||
Util.lsp.on_attach(function(client, buffer)
|
Util.lsp.on_attach(function(client, buffer)
|
||||||
if client.supports_method("textDocument/inlayHint") then
|
if client.supports_method("textDocument/inlayHint") then
|
||||||
|
@ -131,6 +141,20 @@ return {
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- code lens
|
||||||
|
if opts.codelens.enabled and vim.lsp.codelens then
|
||||||
|
Util.lsp.on_attach(function(client, buffer)
|
||||||
|
if client.supports_method("textDocument/codeLens") then
|
||||||
|
vim.lsp.codelens.refresh()
|
||||||
|
--- autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh()
|
||||||
|
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
|
||||||
|
buffer = buffer,
|
||||||
|
callback = vim.lsp.codelens.refresh,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
||||||
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
||||||
or function(diagnostic)
|
or function(diagnostic)
|
||||||
|
|
|
@ -23,6 +23,8 @@ function M.get()
|
||||||
{ "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" },
|
{ "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" },
|
||||||
{ "<c-k>", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" },
|
{ "<c-k>", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" },
|
||||||
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
|
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
|
||||||
|
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
|
||||||
|
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
|
||||||
{
|
{
|
||||||
"<leader>cA",
|
"<leader>cA",
|
||||||
function()
|
function()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue