feat: add clangd LSP
This commit is contained in:
parent
967a9c5c01
commit
cfe9c2f31e
2 changed files with 41 additions and 0 deletions
|
@ -20,3 +20,43 @@ require('neo-tree').setup({
|
|||
}
|
||||
}
|
||||
})
|
||||
|
||||
vim.lsp.enable('clangd')
|
||||
|
||||
-- set autocomplete behavior.
|
||||
-- fuzzy = fuzzy search in results
|
||||
-- menuone = show menu, even if there is only 1 item
|
||||
-- popup = show extra info in popup
|
||||
-- noselect = don't insert the text until an item is selected
|
||||
vim.cmd('set completeopt=fuzzy,menuone,popup,noselect')
|
||||
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
||||
callback = function(args)
|
||||
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
|
||||
if client:supports_method('textDocument/implementation') then
|
||||
-- Create a keymap for vim.lsp.buf.implementation ...
|
||||
end
|
||||
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
|
||||
if client:supports_method('textDocument/completion') then
|
||||
-- Optional: trigger autocompletion on EVERY keypress. May be slow!
|
||||
local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
|
||||
client.server_capabilities.completionProvider.triggerCharacters = chars
|
||||
vim.lsp.completion.enable(true, client.id, args.buf, {autotrigger = true})
|
||||
end
|
||||
-- Auto-format ("lint") on save.
|
||||
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
|
||||
if not client:supports_method('textDocument/willSaveWaitUntil')
|
||||
and client:supports_method('textDocument/formatting') then
|
||||
vim.api.nvim_create_autocmd('BufWritePre', {
|
||||
group = vim.api.nvim_create_augroup('my.lsp', {clear=false}),
|
||||
buffer = args.buf,
|
||||
callback = function()
|
||||
vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
|
||||
end,
|
||||
})
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
|
|
1
.config/nvim/pack/nvim/start/nvim-lspconfig
Submodule
1
.config/nvim/pack/nvim/start/nvim-lspconfig
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit ac98db2f9f06a56498ec890a96928774eae412c3
|
Loading…
Add table
Add a link
Reference in a new issue