redo autocompletion setup
This commit is contained in:
parent
185add40d1
commit
b47f21ba1b
1 changed files with 35 additions and 46 deletions
|
@ -10,8 +10,8 @@ cmp.setup({
|
||||||
mapping = {
|
mapping = {
|
||||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||||
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i','c'}),
|
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), { 'i', 'c' }),
|
||||||
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i','c'}),
|
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), { 'i', 'c' }),
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||||
['<C-e>'] = cmp.mapping({
|
['<C-e>'] = cmp.mapping({
|
||||||
|
@ -26,42 +26,14 @@ cmp.setup({
|
||||||
{ name = 'nvim_lsp',
|
{ name = 'nvim_lsp',
|
||||||
entry_filter = function(entry, ctx)
|
entry_filter = function(entry, ctx)
|
||||||
return require('cmp.types').lsp.CompletionItemKind[entry:get_kind()] ~= 'Text'
|
return require('cmp.types').lsp.CompletionItemKind[entry:get_kind()] ~= 'Text'
|
||||||
end
|
end,
|
||||||
},
|
},
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer', keyword_length = 5 },
|
||||||
})
|
}),
|
||||||
})
|
experimental = {
|
||||||
|
native_menu = false,
|
||||||
-- Use buffer source for `vimwiki`
|
ghost_text = true,
|
||||||
cmp.setup.cmdline('vimwiki', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup.cmdline('md', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
cmp.setup.cmdline('tex', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Use buffer source for `/`
|
|
||||||
cmp.setup.cmdline('/', {
|
|
||||||
sources = {
|
|
||||||
{ name = 'buffer' }
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -82,8 +54,7 @@ local on_attach = function(client, bufnr)
|
||||||
local opts = { noremap = true, silent = true }
|
local opts = { noremap = true, silent = true }
|
||||||
buf_set_keymap("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
buf_set_keymap("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts)
|
||||||
buf_set_keymap("n", "gD", "<cmd>Telescope lsp_implementations<CR>", opts)
|
buf_set_keymap("n", "gD", "<cmd>Telescope lsp_implementations<CR>", opts)
|
||||||
-- buf_set_keymap("n", "gr", "<cmd>Telescope lsp_references<CR>", opts)
|
vim.keymap.set("n", "gf", vim.lsp.buf.format)
|
||||||
vim.keymap.set("n", "gf",vim.lsp.buf.format)
|
|
||||||
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
|
vim.keymap.set("n", "gh", vim.lsp.buf.hover)
|
||||||
vim.keymap.set("n", "ge", vim.diagnostic.open_float)
|
vim.keymap.set("n", "ge", vim.diagnostic.open_float)
|
||||||
vim.keymap.set("n", "gs", vim.lsp.buf.signature_help)
|
vim.keymap.set("n", "gs", vim.lsp.buf.signature_help)
|
||||||
|
@ -91,16 +62,34 @@ local on_attach = function(client, bufnr)
|
||||||
vim.keymap.set("n", "gH", vim.lsp.buf.code_action)
|
vim.keymap.set("n", "gH", vim.lsp.buf.code_action)
|
||||||
end
|
end
|
||||||
|
|
||||||
local lsp_installer = require 'nvim-lsp-installer'
|
-- LSP INSTALLER
|
||||||
lsp_installer.on_server_ready(function(server)
|
local lsp_installer = require "nvim-lsp-installer"
|
||||||
local opts = {}
|
lsp_installer.setup {
|
||||||
opts.on_attach = on_attach
|
automatic_installation = false,
|
||||||
opts.capabilities = require('cmp_nvim_lsp').update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
}
|
||||||
|
|
||||||
server:setup(opts)
|
local lspconfig = require "lspconfig"
|
||||||
vim.cmd [[ do User LspAttachBuffers ]]
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
for _, server in ipairs(lsp_installer.get_installed_servers()) do
|
||||||
|
lspconfig[server.name].setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = require("cmp_nvim_lsp").update_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
-- EXTRA SETUP
|
||||||
|
lspconfig.sumneko_lua.setup {
|
||||||
|
settings = {
|
||||||
|
Lua = {
|
||||||
|
diagnostics = {
|
||||||
|
-- Get the language server to recognize the `vim` global
|
||||||
|
globals = { 'vim' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- LSP SIGNATURE
|
||||||
require "lsp_signature".setup {
|
require "lsp_signature".setup {
|
||||||
handler_opts = {
|
handler_opts = {
|
||||||
border = "rounded"
|
border = "rounded"
|
||||||
|
|
Loading…
Add table
Reference in a new issue