David JULIEN
19af34b75d
!!! BREAKING: packer.nvim is not used anymore to get telescope-fzf-native.nvim working, run `:Lazy build telescope-fzf-native.nvim`
152 lines
5.6 KiB
Lua
152 lines
5.6 KiB
Lua
-- Author : swytch
|
|
-- Created : Sunday Jan. 29, 00:03:53 CET
|
|
-- License : GPLv3
|
|
-- Description : completion plugin config file
|
|
|
|
return {
|
|
{
|
|
"L3MON4D3/LuaSnip",
|
|
opts = function()
|
|
local types = require("luasnip.util.types")
|
|
return {
|
|
history = true,
|
|
-- Update more often, :h events for more info.
|
|
updateevents = "TextChanged,TextChangedI",
|
|
ext_opts = {
|
|
[types.choiceNode] = {
|
|
active = {
|
|
virt_text = { { "●", "LuaSnipChoice" } },
|
|
},
|
|
inactive = {
|
|
virt_text = { { "●", "LuaSnipInactive" } },
|
|
},
|
|
},
|
|
[types.functionNode] = {
|
|
active = {
|
|
virt_text = { { "●", "LuaSnipFunction" } },
|
|
},
|
|
inactive = {
|
|
virt_text = { { "●", "LuaSnipInactive" } },
|
|
},
|
|
},
|
|
[types.insertNode] = {
|
|
active = {
|
|
virt_text = { { "●", "LuaSnipInsert" } },
|
|
},
|
|
inactive = {
|
|
virt_text = { { "●", "LuaSnipInactive" } },
|
|
},
|
|
},
|
|
},
|
|
-- treesitter-hl has 100, use something higher (default is 200).
|
|
ext_base_prio = 200,
|
|
-- minimal increase in priority.
|
|
ext_prio_increase = 1,
|
|
enable_autosnippets = true,
|
|
}
|
|
end,
|
|
},
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
dependencies = {
|
|
"saadparwaiz1/cmp_luasnip",
|
|
"hrsh7th/cmp-nvim-lsp",
|
|
"hrsh7th/cmp-nvim-lua",
|
|
"hrsh7th/cmp-buffer",
|
|
"hrsh7th/cmp-path",
|
|
"hrsh7th/cmp-calc",
|
|
"ray-x/cmp-treesitter",
|
|
"f3fora/cmp-spell",
|
|
},
|
|
opts = function()
|
|
local cmp = require("cmp")
|
|
local luasnip = require("luasnip")
|
|
|
|
local has_words_before = function()
|
|
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
return col ~= 0 and
|
|
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
|
|
sub(col, col):match('%s') == nil
|
|
end
|
|
|
|
return {
|
|
completion = {
|
|
autocomplete = true
|
|
},
|
|
sources = {
|
|
{ name = "path" },
|
|
{ name = "luasnip" },
|
|
{ name = "nvim_lsp" },
|
|
{ name = "buffer" },
|
|
{ name = "nvim_lua" },
|
|
{ name = "calc" },
|
|
{ name = "spell" },
|
|
{ name = "treesitter" },
|
|
},
|
|
formatting = {
|
|
format = function(entry, vim_item)
|
|
vim_item.menu = ({
|
|
nvim_lsp = "[lsp]",
|
|
nvim_lua = "[nvim]",
|
|
luasnip = "[snip]",
|
|
path = "[path]",
|
|
buffer = "[buff]",
|
|
calc = "[calc]",
|
|
spell = "[spel]",
|
|
treesitter = "[tree]",
|
|
})[entry.source.name]
|
|
return vim_item
|
|
end,
|
|
},
|
|
snippet = {
|
|
expand = function(args)
|
|
luasnip.lsp_expand(args.body)
|
|
end,
|
|
},
|
|
mapping = {
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
["<C-e>"] = cmp.mapping.close(),
|
|
["<CR>"] = cmp.mapping.confirm({
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
select = true,
|
|
}),
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
if luasnip.expand_or_locally_jumpable() then
|
|
luasnip.expand_or_jump()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
if luasnip.jumpable(-1) then
|
|
luasnip.jump(-1)
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<C-n>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_next_item()
|
|
elseif has_words_before() then
|
|
cmp.complete()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
["<C-p>"] = cmp.mapping(function(fallback)
|
|
if cmp.visible() then
|
|
cmp.select_prev_item()
|
|
else
|
|
fallback()
|
|
end
|
|
end, { "i", "s" }),
|
|
},
|
|
view = {
|
|
entries = { name = 'custom', selection_order = 'near_cursor' }
|
|
},
|
|
}
|
|
end,
|
|
}
|
|
}
|