update nvim config

This commit is contained in:
ksyasuda
2022-10-30 12:49:59 -07:00
parent 851ae5a1a2
commit c82203111a
7 changed files with 123 additions and 46 deletions

View File

@@ -185,10 +185,11 @@ lsp_installer.on_server_ready(function(server)
end)
local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'sumneko_lua', 'rust_analyzer', 'clangd', 'ansiblels' }
local servers = { 'jedi_language_server', 'bashls', 'vimls', 'yamlls', 'dockerls', 'rust_analyzer', 'clangd', 'ansiblels' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
handlers = handlers,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,

View File

@@ -8,6 +8,7 @@ capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
-- luasnip setup
local luasnip = require 'luasnip'
local has_words_before = function()
if vim.api.nvim_buf_get_option(0, "buftype") == "prompt" then return false end
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
@@ -36,24 +37,53 @@ cmp.setup({
-- ['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- },
mapping = {
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<C-n>'] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { 'i', 's' }),
['<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 = false,
select = true,
},
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
if has_words_before() then
require('copilot.suggestion').accept()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif not has_words_before() then
cmp.complete()
else
fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
end
-- if cmp.visible() then
-- cmp.select_next_item()
-- elseif has_words_before() then
-- cmp.complete()
-- else
-- fallback() -- The fallback function sends a already mapped key. In this case, it's probably `<Tab>`.
-- end
end, { "i", "s" }),
['<S-Tab>'] = cmp.mapping(function()
if cmp.visible() then
@@ -105,9 +135,9 @@ for _, lsp in ipairs(servers) do
end
cmp.event:on("menu_opened", function()
vim.b.copilot_suggestion_hidden = true
end)
cmp.event:on("menu_closed", function()
vim.b.copilot_suggestion_hidden = false
end)
-- cmp.event:on("menu_opened", function()
-- vim.b.copilot_suggestion_hidden = true
-- end)
-- cmp.event:on("menu_closed", function()
-- vim.b.copilot_suggestion_hidden = false
-- end)