mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
moar nvim: snippets and other things
This commit is contained in:
parent
bcb84e54eb
commit
0fb3cfeef9
14 changed files with 426 additions and 138 deletions
|
|
@ -1,61 +1,73 @@
|
|||
return function()
|
||||
local cmp = require('cmp')
|
||||
local lspkind = require('utils.lspkind')
|
||||
local icons = require('config.icons')
|
||||
local cmp = require("cmp")
|
||||
local utils = require("utils.cmd")
|
||||
local luasnip = require("luasnip")
|
||||
local lspkind = require("utils.lspkind")
|
||||
local icons = require("config.icons")
|
||||
|
||||
local selectPrev = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert })
|
||||
local selectPrev = utils.selectPrev({ behavior = cmp.SelectBehavior.Insert })
|
||||
local selectNext = utils.selectNext({ behavior = cmp.SelectBehavior.Insert })
|
||||
|
||||
local windowstyle = {
|
||||
border = vim.g.float_border or 'none',
|
||||
winhighlight = 'Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None',
|
||||
}
|
||||
local windowstyle = {
|
||||
border = vim.g.float_border or "none",
|
||||
winhighlight = "Normal:Pmenu,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None",
|
||||
}
|
||||
|
||||
return {
|
||||
preselect = false,
|
||||
completion = {
|
||||
completeopt = "menuone,longest,noinsert,preview"
|
||||
},
|
||||
view = {
|
||||
entries = { name = 'custom', selection_order = 'near_cursor' },
|
||||
},
|
||||
window = {
|
||||
documentation = windowstyle,
|
||||
completion = windowstyle
|
||||
},
|
||||
mapping = {
|
||||
["<Up>"] = selectPrev,
|
||||
["<S-Tab>"] = selectPrev,
|
||||
["<Down>"] = selectNext,
|
||||
["<Tab>"] = selectNext,
|
||||
["<C-c>"] = cmp.mapping.abort(),
|
||||
['<CR>'] = cmp.mapping.confirm({ select = true }),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
formatting = {
|
||||
fields = { "abbr", "kind", "menu" },
|
||||
format = lspkind.format({
|
||||
mode = 'symbol',
|
||||
preset = 'codicons',
|
||||
symbol_map = icons.symbols,
|
||||
maxwidth = 40,
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
{ name = 'luasnip' }
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
hl_group = "NonText",
|
||||
},
|
||||
},
|
||||
}
|
||||
return {
|
||||
preselect = false,
|
||||
completion = {
|
||||
completeopt = "menuone,longest,noinsert,preview",
|
||||
},
|
||||
view = {
|
||||
entries = { name = "custom", selection_order = "near_cursor" },
|
||||
},
|
||||
window = {
|
||||
documentation = windowstyle,
|
||||
completion = windowstyle,
|
||||
},
|
||||
mapping = {
|
||||
["<Up>"] = selectPrev,
|
||||
["<S-Tab>"] = selectPrev,
|
||||
["<Down>"] = selectNext,
|
||||
["<Tab>"] = selectNext,
|
||||
["<C-c>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = utils.confirm({ select = true }),
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
formatting = {
|
||||
fields = { "abbr", "kind", "menu" },
|
||||
format = lspkind.format({
|
||||
mode = "symbol",
|
||||
preset = "codicons",
|
||||
symbol_map = icons.symbols,
|
||||
maxwidth = 40,
|
||||
ellipsis_char = "...",
|
||||
}),
|
||||
},
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
{
|
||||
name = "spell",
|
||||
option = {
|
||||
keep_all_entries = false,
|
||||
enable_in_context = function()
|
||||
return true
|
||||
end,
|
||||
preselect_correct_word = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = {
|
||||
hl_group = "NonText",
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue