Skip to content

Commit 3149a10

Browse files
committed
update example
1 parent 231dbe4 commit 3149a10

File tree

1 file changed

+8
-39
lines changed

1 file changed

+8
-39
lines changed

README.md

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ api.nvim_create_autocmd('LspAttach', {
104104
if not client or not client:supports_method(ms.textDocument_completion) then
105105
return
106106
end
107+
local chars = client.server_capabilities.completionProvider.triggerCharacters
108+
if chars then
109+
for i = string.byte('a'), string.byte('z') do
110+
if not vim.list_contains(chars, string.char(i)) then
111+
table.insert(chars, string.char(i))
112+
end
113+
end
114+
end
107115

108116
completion.enable(true, client.id, bufnr, {
109117
autotrigger = true,
@@ -114,45 +122,6 @@ api.nvim_create_autocmd('LspAttach', {
114122
}
115123
end,
116124
})
117-
if #api.nvim_get_autocmds({ buffer = bufnr, event = 'InsertCharPre', group = g }) ~= 0 then
118-
return
119-
end
120-
api.nvim_create_autocmd(InsertCharPre, {
121-
buffer = bufnr,
122-
group = g,
123-
callback = function()
124-
if tonumber(pumvisible()) == 1 then
125-
return
126-
end
127-
local triggerchars = vim.tbl_get(
128-
client,
129-
'server_capabilities',
130-
'completionProvider',
131-
'triggerCharacters'
132-
) or {}
133-
if vim.v.char:match('[%w_]') and not vim.list_contains(triggerchars, vim.v.char) then
134-
vim.schedule(function()
135-
completion.get()
136-
end)
137-
end
138-
end,
139-
desc = 'glepnir: completion on character which not exist in lsp client triggerCharacters',
140-
})
141-
api.nvim_create_autocmd('TextChangedP', {
142-
buffer = bufnr,
143-
group = g,
144-
callback = function()
145-
vim.g._ts_force_sync_parsing = true
146-
end,
147-
})
148-
149-
api.nvim_create_autocmd('CompleteDone', {
150-
buffer = bufnr,
151-
group = g,
152-
callback = function()
153-
vim.g._ts_force_sync_parsing = false
154-
end,
155-
})
156125
end,
157126
})
158127
```

0 commit comments

Comments
 (0)