Files
nixos/home-modules/explicit-configs/nvim/lua/completion/init.lua
T

53 lines
1.4 KiB
Lua
Raw Normal View History

local cmp = require('cmp')
2025-05-03 23:42:03 -07:00
local snippy = require('snippy')
2026-11-20 12:31:01 -08:00
-- Neovim shifts wide floating menus back onto the screen. nvim-cmp otherwise
-- anchors docs to the requested column, which can overlap the shifted menu.
local entries_view = require('cmp.view.custom_entries_view')
entries_view.info = function(self)
local info = self.entries_win:info()
info.col = math.max(0, math.min(info.col, vim.o.columns - info.width))
return info
end
vim.opt.completeopt = { 'menuone', 'noselect' }
vim.opt.shortmess:append('c')
2025-05-03 23:42:03 -07:00
cmp.setup({
window = {
2026-11-20 12:31:01 -08:00
completion = cmp.config.window.bordered({ border = 'rounded' }),
documentation = cmp.config.window.bordered({
border = 'rounded',
-- Leave a column between the menu and docs, on either side.
col_offset = 1,
}),
2025-05-03 23:42:03 -07:00
},
snippet = {
expand = function(args)
snippy.expand_snippet(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-n>'] = cmp.mapping.select_next_item(),
['<C-p>'] = cmp.mapping.select_prev_item(),
['<C-Space>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.abort(),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'path' },
2025-05-03 23:42:03 -07:00
{ name = 'snippy' },
}, {
{ name = 'buffer' },
}),
2025-05-03 23:42:03 -07:00
})
snippy.setup({
mappings = {
is = {
['<Tab>'] = 'expand_or_advance',
['<S-Tab>'] = 'previous',
2025-05-03 23:42:03 -07:00
},
},
2025-05-03 23:42:03 -07:00
})