vim: Better snippets (and split completion file)
This commit is contained in:
parent
d325eb2d27
commit
6e4130fd26
4 changed files with 92 additions and 35 deletions
54
hm/vim/completion.nix
Normal file
54
hm/vim/completion.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
config = {
|
||||
# Completion
|
||||
programs.nixvim = {
|
||||
extraConfigLuaPre = builtins.readFile ./completion_pre.lua;
|
||||
plugins = {
|
||||
# Snippets
|
||||
# UltiSnips should be the better snippet engine, but:
|
||||
# - Not built-in into Nixvim yet (UPST?)
|
||||
# - Couldn't manage to make it work with friendly-snippets, which seems to give better snippets for Python at least
|
||||
# - Tab switching between fields seems hard to configure
|
||||
luasnip = {
|
||||
enable = true;
|
||||
fromVscode = [
|
||||
{ paths = "${pkgs.vimPlugins.friendly-snippets}"; }
|
||||
# { paths = "${pkgs.vimPlugins.vim-snippets}"; } # UPST Needs snipmate support
|
||||
];
|
||||
};
|
||||
|
||||
# Completion
|
||||
nvim-cmp = {
|
||||
enable = true;
|
||||
mapping = {
|
||||
# Proposed example, since there's no default
|
||||
"<C-Space>" = "cmp.mapping.complete()";
|
||||
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
|
||||
"<C-e>" = "cmp.mapping.close()";
|
||||
"<C-f>" = "cmp.mapping.scroll_docs(4)";
|
||||
"<CR>" = "cmp.mapping.confirm({ select = true })";
|
||||
"<S-Tab>" = {
|
||||
action = "nvim_cmp_stab";
|
||||
modes = [ "i" "s" ];
|
||||
};
|
||||
"<Tab>" = {
|
||||
action = "nvim_cmp_tab";
|
||||
modes = [ "i" "s" ];
|
||||
};
|
||||
};
|
||||
sources = [
|
||||
# Respective plugins will get installed automatically
|
||||
{ name = "buffer"; }
|
||||
{ name = "calc"; }
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "path"; }
|
||||
{ name = "luasnip"; }
|
||||
];
|
||||
snippet.expand = "luasnip";
|
||||
};
|
||||
lspkind.enable = true; # Add icons to LSP completions
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue