@@ -126,32 +126,36 @@ Set up the PKM for your text editor...
126126 Modify your lsp ` on_attach` function.
127127
128128 ` ` ` lua
129- local function check_codelens_support( )
130- local clients = vim.lsp.get_active_clients ({ bufnr = 0 })
131- for _, c in ipairs(clients) do
132- if c.server_capabilities.codeLensProvider then
133- return true
129+ local function codelens_supported(bufnr )
130+ for _, c in ipairs( vim.lsp.get_clients ({ bufnr = bufnr })) do
131+ if c.server_capabilities and c.server_capabilities.codeLensProvider then
132+ return true
133+ end
134134 end
135- end
136- return false
135+ return false
137136 end
138137
139- vim.api.nvim_create_autocmd({ ' TextChanged' , ' InsertLeave' , ' CursorHold' , ' LspAttach' , ' BufEnter' }, {
140- buffer = bufnr,
141- callback = function ()
142- if check_codelens_support () then
143- vim.lsp.codelens.refresh({bufnr = 0})
144- end
138+ vim.api.nvim_create_autocmd(
139+ { ' TextChanged' , ' InsertLeave' , ' CursorHold' , ' BufEnter' },
140+ {
141+ buffer = bufnr,
142+ callback = function ()
143+ if codelens_supported(bufnr) then
144+ vim.lsp.codelens.refresh({ bufnr = bufnr })
145+ end
146+ end,
147+ }
148+ )
149+
150+ if codelens_supported(bufnr) then
151+ vim.lsp.codelens.refresh({ bufnr = bufnr })
145152 end
146- })
147- -- trigger codelens refresh
148- vim.api.nvim_exec_autocmds(' User' , { pattern = ' LspAttached' })
149153 ` ` `
150154
151155 < /details>
152156
153157 - < details>
154- < summary>( optional) Enable opening daily notes with natural langauge < /summary>
158+ < summary>( optional) Enable opening daily notes with natural language < /summary>
155159
156160 Modify your lsp ` on_attach` function to support opening daily notes with, for example, ` :Daily two days ago` or ` :Daily next monday` .
157161
0 commit comments