From 9c946f8f786137aeabfe005f2865043183838876 Mon Sep 17 00:00:00 2001 From: Oxbian Date: Mon, 19 Jun 2023 08:59:16 +0200 Subject: Adding snippets engine --- .vim/keymaps.vim | 20 ++++++++++++++++++++ .vim/plugins.vim | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/.vim/keymaps.vim b/.vim/keymaps.vim index 794f84b..993ef87 100644 --- a/.vim/keymaps.vim +++ b/.vim/keymaps.vim @@ -24,4 +24,24 @@ nnoremap hs :GitGutterStageHunk nnoremap hu :GitGutterUndoHunk nnoremap hp :GitGutterPreviewHunk +" Vsnip +" Expand +imap vsnip#expandable() ? '(vsnip-expand)' : '' +smap vsnip#expandable() ? '(vsnip-expand)' : '' +" Expand or jump +imap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' +smap vsnip#available(1) ? '(vsnip-expand-or-jump)' : '' + +" Jump forward or backward +imap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +smap vsnip#jumpable(1) ? '(vsnip-jump-next)' : '' +imap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' +smap vsnip#jumpable(-1) ? '(vsnip-jump-prev)' : '' + +" Select or cut text to use as $TM_SELECTED_TEXT in the next snippet. +" See https://github.com/hrsh7th/vim-vsnip/pull/50 +nmap s (vsnip-select-text) +xmap s (vsnip-select-text) +nmap S (vsnip-cut-text) +xmap S (vsnip-cut-text) diff --git a/.vim/plugins.vim b/.vim/plugins.vim index b873d58..d881f6a 100644 --- a/.vim/plugins.vim +++ b/.vim/plugins.vim @@ -27,6 +27,10 @@ Plug 'airblade/vim-gitgutter' " Git diff " Autocompletion, linter, syntax Plug 'dense-analysis/ale' " Swiss-knife for all this +" Snippets +Plug 'hrsh7th/vim-vsnip' +Plug 'rafamadriz/friendly-snippets' + call plug#end() filetype plugin indent on " Allow filetype detection, plugins, indentation @@ -106,3 +110,5 @@ autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_ autocmd BufEnter * if bufname('#') =~# "^NERD_tree_" && winnr('$') > 1 | b# | endif let g:plug_window = 'noautocmd vertical topleft new' " Stop crash if vimplug command called on the nerdtree window +" VIM snip +let g:vsnip_filetypes = {} -- cgit v1.2.3