Skip to content

Commit 2135d27

Browse files
authored
Merge pull request #291 from mav3ri3k/262
Update 'vim.lsp.get_active_clients()' -> 'vim.lsp.get_clients()'
2 parents 82a2933 + 07c3f9e commit 2135d27

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

docs/Markdown Oxide Docs/README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)