Last active
June 20, 2024 12:29
-
-
Save Chattille/adbd1f296b03bc3f85bb7f8d6f648c6f to your computer and use it in GitHub Desktop.
Refresh Codelens on LSP attachment in Neovim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- trigger upon LSP attachment | |
vim.api.nvim_create_autocmd('User', { | |
pattern = 'LspAttached', | |
once = true, | |
callback = vim.lsp.codelens.refresh, | |
}) | |
-- ... servers and enhanced_opts ... | |
for _, lsp in ipairs(servers) do | |
local opts = { | |
on_attach = function(_, bufnr) | |
-- refresh codelens on TextChanged and InsertLeave as well | |
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave' }, { | |
buffer = bufnr, | |
callback = vim.lsp.codelens.refresh, | |
}) | |
-- trigger codelens refresh | |
vim.api.nvim_exec_autocmds('User', { pattern = 'LspAttached' }) | |
end, | |
} | |
if enhanced_opts[lsp] then | |
enhanced_opts[lsp](opts) | |
end | |
require('lspconfig').setup(opts) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment