mirror of
https://github.com/akr2002/nv.git
synced 2024-11-12 20:19:45 +00:00
add completion
This commit is contained in:
parent
bb4a0871a3
commit
466b79672c
2 changed files with 169 additions and 0 deletions
167
config/completion/cmp.nix
Normal file
167
config/completion/cmp.nix
Normal file
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
plugins = {
|
||||
nvim-cmp = {
|
||||
enable = true;
|
||||
autoEnableSources = true;
|
||||
experimental = {
|
||||
ghost_text = true;
|
||||
};
|
||||
performance = {
|
||||
debounce = 60;
|
||||
fetchingTimeout = 200;
|
||||
maxViewEntries = 30;
|
||||
};
|
||||
snippet = {
|
||||
expand = "luasnip";
|
||||
};
|
||||
formatting = {
|
||||
fields = ["kind" "abbr" "menu"];
|
||||
expandableIndicator = true;
|
||||
};
|
||||
window = {
|
||||
completion = {
|
||||
border = "rounded";
|
||||
winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None";
|
||||
};
|
||||
documentation = {
|
||||
border = "rounded";
|
||||
};
|
||||
};
|
||||
sources = [
|
||||
{
|
||||
name = "nvim_lsp"; # lsp
|
||||
}
|
||||
{
|
||||
name = "buffer"; # text within current buffer
|
||||
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
|
||||
keywordLength = 3;
|
||||
}
|
||||
{
|
||||
name = "path"; # file system paths
|
||||
keywordLength = 3;
|
||||
}
|
||||
{
|
||||
name = "luasnip"; # snippets
|
||||
keywordLength = 3;
|
||||
}
|
||||
];
|
||||
|
||||
mapping = {
|
||||
"<Tab>" = {
|
||||
modes = ["i" "s"];
|
||||
action = ''
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
"<S-Tab>" = {
|
||||
modes = ["i" "s"];
|
||||
action = ''
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
"<C-j>" = {
|
||||
action = "cmp.mapping.select_next_item()";
|
||||
};
|
||||
"<C-k>" = {
|
||||
action = "cmp.mapping.select_prev_item()";
|
||||
};
|
||||
"<C-e>" = {
|
||||
action = "cmp.mapping.abort()";
|
||||
};
|
||||
"<C-b>" = {
|
||||
action = "cmp.mapping.scroll_docs(-4)";
|
||||
};
|
||||
"<C-f>" = {
|
||||
action = "cmp.mapping.scroll_docs(4)";
|
||||
};
|
||||
"<C-Space>" = {
|
||||
action = "cmp.mapping.complete()";
|
||||
};
|
||||
"<CR>" = {
|
||||
action = "cmp.mapping.confirm({ select = true })";
|
||||
};
|
||||
"<S-CR>" = {
|
||||
action = "cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true })";
|
||||
};
|
||||
};
|
||||
};
|
||||
cmp-nvim-lsp = {enable = true;}; # lsp
|
||||
cmp-buffer = {enable = true;};
|
||||
cmp-path = {enable = true;}; # file system paths
|
||||
cmp_luasnip = {enable = true;}; # snippets
|
||||
cmp-cmdline = {enable = false;}; # autocomplete for cmdline
|
||||
};
|
||||
extraConfigLua = ''
|
||||
luasnip = require("luasnip")
|
||||
kind_icons = {
|
||||
Text = "",
|
||||
Method = "",
|
||||
Function = "",
|
||||
Constructor = "",
|
||||
Field = "",
|
||||
Variable = "",
|
||||
Class = "",
|
||||
Interface = "",
|
||||
Module = "",
|
||||
Property = "",
|
||||
Unit = "",
|
||||
Value = "",
|
||||
Enum = "",
|
||||
Keyword = "",
|
||||
Snippet = "",
|
||||
Color = "",
|
||||
File = "",
|
||||
Reference = "",
|
||||
Folder = "",
|
||||
EnumMember = "",
|
||||
Constant = "",
|
||||
Struct = "",
|
||||
Event = "",
|
||||
Operator = "",
|
||||
TypeParameter = "",
|
||||
}
|
||||
|
||||
local cmp = require'cmp'
|
||||
|
||||
-- Use buffer source for `/` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({'/', "?" }, {
|
||||
sources = {
|
||||
{ name = 'buffer' }
|
||||
}
|
||||
})
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
})
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' }
|
||||
}, {
|
||||
{ name = 'cmdline' }
|
||||
}),
|
||||
}) '';
|
||||
}
|
||||
|
|
@ -6,6 +6,8 @@
|
|||
./colorschemes/catppuccin.nix
|
||||
./colorschemes/rose-pine.nix
|
||||
|
||||
./completion/cmp.nix
|
||||
|
||||
./sets.nix
|
||||
./dap/dap.nix
|
||||
./keymaps.nix
|
||||
|
|
Loading…
Reference in a new issue