mirror of
https://github.com/tomru/nvim.git
synced 2026-03-03 14:37:15 +01:00
inline completion config
This commit is contained in:
@@ -1,73 +0,0 @@
|
|||||||
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
|
||||||
vim.opt.shortmess:append 'c'
|
|
||||||
|
|
||||||
local lspkind = require 'lspkind'
|
|
||||||
lspkind.init {
|
|
||||||
symbol_map = {
|
|
||||||
Copilot = '',
|
|
||||||
},
|
|
||||||
mode = 'symbol',
|
|
||||||
}
|
|
||||||
vim.api.nvim_set_hl(0, 'CmpItemKindCopilot', { fg = '#6CC644' })
|
|
||||||
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
|
|
||||||
cmp.setup {
|
|
||||||
sources = {
|
|
||||||
{ name = 'copilot' },
|
|
||||||
{ name = 'luasnip' },
|
|
||||||
{ name = 'nvim_lsp' },
|
|
||||||
{ name = 'path' },
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
mapping = {
|
|
||||||
['<C-n>'] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
|
||||||
['<C-p>'] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
|
||||||
['<C-y>'] = cmp.mapping(
|
|
||||||
cmp.mapping.confirm {
|
|
||||||
behavior = cmp.ConfirmBehavior.Insert,
|
|
||||||
select = true,
|
|
||||||
},
|
|
||||||
{ 'i', 'c' }
|
|
||||||
),
|
|
||||||
},
|
|
||||||
|
|
||||||
-- Enable luasnip to handle snippet expansion for nvim-cmp
|
|
||||||
snippet = {
|
|
||||||
expand = function(args)
|
|
||||||
require('luasnip').lsp_expand(args.body)
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Setup up vim-dadbod
|
|
||||||
cmp.setup.filetype({ 'sql' }, {
|
|
||||||
sources = {
|
|
||||||
{ name = 'vim-dadbod-completion' },
|
|
||||||
{ name = 'buffer' },
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
local ls = require 'luasnip'
|
|
||||||
ls.config.set_config {
|
|
||||||
history = false,
|
|
||||||
updateevents = 'TextChanged,TextChangedI',
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do
|
|
||||||
loadfile(ft_path)()
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.keymap.set({ 'i', 's' }, '<c-k>', function()
|
|
||||||
if ls.expand_or_jumpable() then
|
|
||||||
ls.expand_or_jump()
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
vim.keymap.set({ 'i', 's' }, '<c-j>', function()
|
|
||||||
if ls.jumpable(-1) then
|
|
||||||
ls.jump(-1)
|
|
||||||
end
|
|
||||||
end, { silent = true })
|
|
||||||
|
|
||||||
require('luasnip/loaders/from_vscode').lazy_load()
|
|
||||||
@@ -14,7 +14,79 @@ return {
|
|||||||
'zbirenbaum/copilot-cmp',
|
'zbirenbaum/copilot-cmp',
|
||||||
},
|
},
|
||||||
config = function()
|
config = function()
|
||||||
require 'completion'
|
vim.opt.completeopt = { 'menu', 'menuone', 'noselect' }
|
||||||
|
vim.opt.shortmess:append 'c'
|
||||||
|
|
||||||
|
local lspkind = require 'lspkind'
|
||||||
|
lspkind.init {
|
||||||
|
symbol_map = {
|
||||||
|
Copilot = '',
|
||||||
|
},
|
||||||
|
mode = 'symbol',
|
||||||
|
}
|
||||||
|
vim.api.nvim_set_hl(0, 'CmpItemKindCopilot', { fg = '#6CC644' })
|
||||||
|
|
||||||
|
local cmp = require 'cmp'
|
||||||
|
|
||||||
|
cmp.setup {
|
||||||
|
sources = {
|
||||||
|
{ name = 'copilot' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
},
|
||||||
|
mapping = {
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert },
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert },
|
||||||
|
['<C-y>'] = cmp.mapping(
|
||||||
|
cmp.mapping.confirm {
|
||||||
|
behavior = cmp.ConfirmBehavior.Insert,
|
||||||
|
select = true,
|
||||||
|
},
|
||||||
|
{ 'i', 'c' }
|
||||||
|
),
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Enable luasnip to handle snippet expansion for nvim-cmp
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Setup up vim-dadbod
|
||||||
|
cmp.setup.filetype({ 'sql' }, {
|
||||||
|
sources = {
|
||||||
|
{ name = 'vim-dadbod-completion' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
local ls = require 'luasnip'
|
||||||
|
ls.config.set_config {
|
||||||
|
history = false,
|
||||||
|
updateevents = 'TextChanged,TextChangedI',
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file('lua/custom/snippets/*.lua', true)) do
|
||||||
|
loadfile(ft_path)()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<c-k>', function()
|
||||||
|
if ls.expand_or_jumpable() then
|
||||||
|
ls.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
vim.keymap.set({ 'i', 's' }, '<c-j>', function()
|
||||||
|
if ls.jumpable(-1) then
|
||||||
|
ls.jump(-1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
require('luasnip/loaders/from_vscode').lazy_load()
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user