Skip to content

Commit

Permalink
Update suggested neovim config
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Jul 2, 2024
1 parent 8f855c3 commit e2ec551
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,25 @@ Markdown Oxide's features are implemented in the form of a language server aimin
Modify your lsp `on_attach` function.
```lua
local function check_codelens_support()
local clients = vim.lsp.get_active_clients({ bufnr = 0 })
for _, c in ipairs(clients) do
if c.server_capabilities.codeLensProvider then
return true
end
end
return false
end
-- refresh codelens on TextChanged and InsertLeave as well
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave', 'CursorHold', 'LspAttach' }, {
buffer = bufnr,
callback = function ()
if vim.lsp.codelens.get(bufnr) then -- refresh only if there are servers supporting codelens
vim.lsp.codelens.refresh()
end
end
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave', 'CursorHold', 'LspAttach', 'BufEnter' }, {
buffer = bufnr,
callback = function ()
if check_codelens_support() then
vim.lsp.codelens.refresh({bufnr = 0})
end
end
})
-- trigger codelens refresh
vim.api.nvim_exec_autocmds('User', { pattern = 'LspAttached' })
```
Expand Down

0 comments on commit e2ec551

Please sign in to comment.