nix: vim: Snippets and auto-completion

This commit is contained in:
Geoffrey Frogeye 2023-11-01 18:03:14 +01:00
parent b42cc85dec
commit 9b450cc22f
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
4 changed files with 22 additions and 29 deletions

View file

@ -16,17 +16,6 @@
" Theme " Theme
source ~/.config/vim/theme.vim 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 " Undo management
{{ use_plugin('undotree') }} {{ use_plugin('undotree') }}

View file

@ -1,4 +0,0 @@
{{ add_source('hrsh7th/vim-vsnip') -}}
{{ add_source('hrsh7th/vim-vsnip-integ') -}}
{{ add_source('rafamadriz/friendly-snippets') -}}
{# TODO Ansible snippets? #}

View file

@ -210,6 +210,15 @@ in
# Treesitter # Treesitter
nvim-ts-rainbow # Randomly color parenthesis pairs nvim-ts-rainbow # Randomly color parenthesis pairs
# 23.11: Replace with plugins.rainbow-delimiters # 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) [ extraConfigLua = lib.strings.concatMapStringsSep "\n" (f: builtins.readFile f) [
./vim/feline.lua ./vim/feline.lua
@ -220,6 +229,17 @@ in
extraConfigVim = '' extraConfigVim = ''
" vim-gutentags " vim-gutentags
let g:gutentags_cache_dir = expand('~/.cache/nvim/tags') let g:gutentags_cache_dir = expand('~/.cache/nvim/tags')
" nvim-compe
" Copy-pasted because I couldn't be bothered
set completeopt=menuone,noselect
inoremap <silent><expr> <C-Space> compe#complete()
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <C-e> compe#close('<C-e>')
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
''; '';
autoCmd = [ autoCmd = [
# vim-easy-align: Align Markdown tables # vim-easy-align: Align Markdown tables

View file

@ -1,7 +1,4 @@
{{ add_source('hrsh7th/nvim-compe') -}} -- Default recommended config
{# 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
require'compe'.setup { require'compe'.setup {
enabled = true; enabled = true;
autocomplete = true; autocomplete = true;
@ -32,17 +29,9 @@ require'compe'.setup {
vsnip = true; vsnip = true;
}; };
} }
EOF
set completeopt=menuone,noselect
-- Vim instructions were here
inoremap <silent><expr> <C-Space> compe#complete()
inoremap <silent><expr> <CR> compe#confirm('<CR>')
inoremap <silent><expr> <C-e> compe#close('<C-e>')
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
lua << EOF
local t = function(str) local t = function(str)
return vim.api.nvim_replace_termcodes(str, true, true, true) return vim.api.nvim_replace_termcodes(str, true, true, true)
end end
@ -81,4 +70,3 @@ vim.api.nvim_set_keymap("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) vim.api.nvim_set_keymap("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
EOF