From 9b450cc22f9d26ece587409f07a80de28b73c779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Wed, 1 Nov 2023 18:03:14 +0100 Subject: [PATCH] nix: vim: Snippets and auto-completion --- .../roles/vim/templates/pluginlist.j2 | 11 ---------- .../roles/vim/templates/plugins/vsnip.j2 | 4 ---- config/nix/hm/vim.nix | 20 +++++++++++++++++++ .../hm/vim/nvim-compe.lua} | 16 ++------------- 4 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 config/automatrop/roles/vim/templates/plugins/vsnip.j2 rename config/{automatrop/roles/vim/templates/plugins/nvim_compe.j2 => nix/hm/vim/nvim-compe.lua} (78%) diff --git a/config/automatrop/roles/vim/templates/pluginlist.j2 b/config/automatrop/roles/vim/templates/pluginlist.j2 index aee12e7..2dff490 100644 --- a/config/automatrop/roles/vim/templates/pluginlist.j2 +++ b/config/automatrop/roles/vim/templates/pluginlist.j2 @@ -16,17 +16,6 @@ " Theme source ~/.config/vim/theme.vim -" Snippets -{{ use_plugin('vsnip') }} - -" Auto-completion -{% if variant == 'nvim' %} -{{ use_plugin('nvim_compe') }} -{% else %} -{{ use_plugin('deoplete') }} -{{ use_plugin('supertab') }} -{% endif %} - " Undo management {{ use_plugin('undotree') }} diff --git a/config/automatrop/roles/vim/templates/plugins/vsnip.j2 b/config/automatrop/roles/vim/templates/plugins/vsnip.j2 deleted file mode 100644 index 2c710ca..0000000 --- a/config/automatrop/roles/vim/templates/plugins/vsnip.j2 +++ /dev/null @@ -1,4 +0,0 @@ -{{ add_source('hrsh7th/vim-vsnip') -}} -{{ add_source('hrsh7th/vim-vsnip-integ') -}} -{{ add_source('rafamadriz/friendly-snippets') -}} -{# TODO Ansible snippets? #} diff --git a/config/nix/hm/vim.nix b/config/nix/hm/vim.nix index 8407289..7c72942 100644 --- a/config/nix/hm/vim.nix +++ b/config/nix/hm/vim.nix @@ -210,6 +210,15 @@ in # Treesitter nvim-ts-rainbow # Randomly color parenthesis pairs # 23.11: Replace with plugins.rainbow-delimiters + + # Snippets + vim-vsnip + vim-vsnip-integ + friendly-snippets + + # Auto-completion + nvim-compe + # TODO Archived. Maybe use nvim-cmp and plugins instead? ]; extraConfigLua = lib.strings.concatMapStringsSep "\n" (f: builtins.readFile f) [ ./vim/feline.lua @@ -220,6 +229,17 @@ in extraConfigVim = '' " vim-gutentags let g:gutentags_cache_dir = expand('~/.cache/nvim/tags') + + " nvim-compe + " Copy-pasted because I couldn't be bothered + set completeopt=menuone,noselect + + inoremap compe#complete() + inoremap compe#confirm('') + inoremap compe#close('') + inoremap compe#scroll({ 'delta': +4 }) + inoremap compe#scroll({ 'delta': -4 }) + ''; autoCmd = [ # vim-easy-align: Align Markdown tables diff --git a/config/automatrop/roles/vim/templates/plugins/nvim_compe.j2 b/config/nix/hm/vim/nvim-compe.lua similarity index 78% rename from config/automatrop/roles/vim/templates/plugins/nvim_compe.j2 rename to config/nix/hm/vim/nvim-compe.lua index 0c89f21..81d2274 100644 --- a/config/automatrop/roles/vim/templates/plugins/nvim_compe.j2 +++ b/config/nix/hm/vim/nvim-compe.lua @@ -1,7 +1,4 @@ -{{ add_source('hrsh7th/nvim-compe') -}} -{# I'm a bit lost with all this, so this is the default recommended config, -using vim-vsnip because the proposed configuration for tab-completion uses it, so… #} -lua << EOF +-- Default recommended config require'compe'.setup { enabled = true; autocomplete = true; @@ -32,17 +29,9 @@ require'compe'.setup { vsnip = true; }; } -EOF -set completeopt=menuone,noselect +-- Vim instructions were here -inoremap compe#complete() -inoremap compe#confirm('') -inoremap compe#close('') -inoremap compe#scroll({ 'delta': +4 }) -inoremap compe#scroll({ 'delta': -4 }) - -lua << EOF local t = function(str) return vim.api.nvim_replace_termcodes(str, true, true, true) end @@ -81,4 +70,3 @@ vim.api.nvim_set_keymap("i", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("i", "", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "", "v:lua.s_tab_complete()", {expr = true}) -EOF