nvim: fix tmux completion

This commit is contained in:
Daniel Lundin 2022-01-09 21:38:00 +01:00
parent c1445e28dc
commit e7f78f287a

View file

@ -34,68 +34,80 @@ return require('packer').startup(function()
local cmp = require'cmp' local cmp = require'cmp'
-- local cmp = require('hrsh7th/nvim-cmp') -- local cmp = require('hrsh7th/nvim-cmp')
cmp.setup({ cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine formatting = {
expand = function(args) format = require('lspkind').cmp_format({
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. with_text = true,
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users. menu = {
-- require('snippy').expand_snippet(args.body) -- For `snippy` users. buffer = "[Buffer]",
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users. tmux = "[Tmux]",
end, luasnip = "[LuaSnip]",
}, nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
path = "[Path]",
},
}),
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = { mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4), ["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-u>"] = cmp.mapping.scroll_docs(4), ["<C-u>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.close(), ["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({ ["<CR>"] = cmp.mapping.confirm({
select = false, select = false,
}), }),
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), ['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item() cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
elseif has_words_before() then elseif has_words_before() then
cmp.complete() cmp.complete()
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item() cmp.select_prev_item()
elseif luasnip.jumpable(-1) then elseif luasnip.jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()
end end
end, { "i", "s" }), end, { "i", "s" }),
}, },
sources = cmp.config.sources({ sources = cmp.config.sources({
{ {
name = 'buffer', name = 'buffer',
priority = 1, priority = 1,
}, },
{ name = 'luasnip' }, { name = 'luasnip' },
{ {
name = 'tmux', name = 'tmux',
priority = 2, priority = 2,
option = { option = {
trigger_characters = {}, all_panes = true,
} trigger_characters = {},
}, }
{ },
name = 'nvim_lsp', {
priority = 3, name = 'nvim_lsp',
}, priority = 3,
}) },
}) })
})
end end
} }