lsp.vim
This commit is contained in:
parent
4708dee78a
commit
c487f8d879
2 changed files with 74 additions and 2 deletions
|
|
@ -32,8 +32,8 @@
|
||||||
cmp-nvim-ultisnips
|
cmp-nvim-ultisnips
|
||||||
nvim-cmp
|
nvim-cmp
|
||||||
{
|
{
|
||||||
plugin: nvim-lspconfig;
|
plugin = nvim-lspconfig;
|
||||||
config = builtins.readfile ./lsp.vim
|
config = builtins.readFile ./lsp.vim;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
plugin = fzf-vim;
|
plugin = fzf-vim;
|
||||||
|
|
|
||||||
72
home/nvim/lsp.vim
Normal file
72
home/nvim/lsp.vim
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
lua <<EOF
|
||||||
|
local cmp = require'cmp'
|
||||||
|
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
window = {
|
||||||
|
-- completion = cmp.config.window.bordered(),
|
||||||
|
-- documentation = cmp.config.window.bordered(),
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
||||||
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||||
|
['<C-Space>'] = cmp.mapping.complete(),
|
||||||
|
['<C-e>'] = cmp.mapping.abort(),
|
||||||
|
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||||
|
}),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'ultisnips' }, -- For ultisnips users.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Set configuration for specific filetype.
|
||||||
|
cmp.setup.filetype('gitcommit', {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline({ '/', '?' }, {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
mapping = cmp.mapping.preset.cmdline(),
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'path' }
|
||||||
|
}, {
|
||||||
|
{ name = 'cmdline' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
-- -- Set up lspconfig.
|
||||||
|
-- local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
-- -- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
|
||||||
|
-- require('lspconfig')['typescript'].setup {
|
||||||
|
-- capabilities = capabilities
|
||||||
|
-- }
|
||||||
|
local servers = { "r_language_server", "tsserver" }
|
||||||
|
for _, lsp in ipairs(servers) do
|
||||||
|
nvim_lsp[lsp].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
flags = {
|
||||||
|
debounce_text_changes = 150,
|
||||||
|
},
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
||||||
|
end
|
||||||
|
EOF
|
||||||
Loading…
Add table
Add a link
Reference in a new issue