You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
718 B
Lua
27 lines
718 B
Lua
function enable_autocomplete(client, buf)
|
|
if client.supports_method('textDocument/completion') then
|
|
vim.lsp.completion.enable(true, client.id, buf, {autotrigger = true})
|
|
end
|
|
end
|
|
|
|
function enable_autoformat(client, buf)
|
|
if client.supports_method('textDocument/formatting') then
|
|
vim.api.nvim_create_autocmd('BufWritePre', {
|
|
buffer = buf,
|
|
callback = function()
|
|
vim.lsp.buf.format({bufnr = buf, id = client.id})
|
|
end,
|
|
})
|
|
end
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
callback = function(args)
|
|
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
|
local buf = args.buf
|
|
|
|
-- enable_autocomplete(client, buf)
|
|
enable_autoformat(client, buf)
|
|
end,
|
|
})
|