60 lines
2.2 KiB
Lua
60 lines
2.2 KiB
Lua
|
local lspconfig = require 'lspconfig'
|
||
|
|
||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||
|
capabilities.textDocument.completion.completionItem.documentationFormat = { 'markdown', 'plaintext' }
|
||
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.preselectSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.insertReplaceSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.labelDetailsSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.deprecatedSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.commitCharactersSupport = true
|
||
|
capabilities.textDocument.completion.completionItem.tagSupport = { valueSet = { 1 } }
|
||
|
capabilities.textDocument.completion.completionItem.resolveSupport = {
|
||
|
properties = {
|
||
|
'documentation',
|
||
|
'detail',
|
||
|
'additionalTextEdits',
|
||
|
},
|
||
|
}
|
||
|
|
||
|
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||
|
local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver', 'svelte' }
|
||
|
for _, lsp in ipairs(servers) do
|
||
|
lspconfig[lsp].setup {
|
||
|
-- on_attach = my_custom_on_attach,
|
||
|
capabilities = capabilities,
|
||
|
}
|
||
|
end
|
||
|
|
||
|
-- luasnip setup
|
||
|
local luasnip = require 'luasnip'
|
||
|
|
||
|
-- nvim-cmp setup
|
||
|
local cmp = require 'cmp'
|
||
|
cmp.setup {
|
||
|
snippet = {
|
||
|
expand = function(args)
|
||
|
require('luasnip').lsp_expand(args.body)
|
||
|
end,
|
||
|
},
|
||
|
mapping = {
|
||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||
|
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||
|
['<C-e>'] = cmp.mapping.close(),
|
||
|
['<CR>'] = cmp.mapping.confirm {
|
||
|
behavior = cmp.ConfirmBehavior.Replace,
|
||
|
select = true,
|
||
|
},
|
||
|
['<Tab>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 's' }),
|
||
|
['<S-Tab>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 's' }),
|
||
|
},
|
||
|
sources = {
|
||
|
{ name = 'nvim_lsp' },
|
||
|
{ name = 'nvim_lua' },
|
||
|
{ name = 'luasnip' },
|
||
|
},
|
||
|
}
|