commit f692191456da007094fbcf47192c2de25205d9b1
parent 3f4553bdf3dbfe48558e6153fae304a1d8b4e663
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Mon, 13 Apr 2020 22:35:37 +0200
vim: ultisnips completion
Former-commit-id: d3f37922d517f6d4fbdae946f92cf001a9cd56f9
Diffstat:
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/vim/autoload/ultisnips_complete.vim b/vim/autoload/ultisnips_complete.vim
@@ -0,0 +1,29 @@
+function! ultisnips_complete#ListSnippets(findstart, base) abort
+ if empty(UltiSnips#SnippetsInCurrentScope(1))
+ return ''
+ endif
+
+ if a:findstart
+ " locate the start of the word
+ let line = getline('.')
+ let start = col('.') - 1
+ while start > 0 && (line[start - 1] =~ '\a')
+ let start -= 1
+ endwhile
+ return start
+ else
+ " find classes matching "a:base"
+ let res = []
+ for m in keys(g:current_ulti_dict_info)
+ if m =~ "^" . a:base
+ let n = {
+ \ 'word': m,
+ \ 'menu': '[snip] '. g:current_ulti_dict_info[m]['description']
+ \ }
+ call add(res, n)
+ endif
+ endfor
+ return res
+ endif
+endfunction
+
diff --git a/vim/vimrc b/vim/vimrc
@@ -255,6 +255,9 @@ let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:UltiSnipsSnippetDirectories = [$DOTFILES.'/vim/ultisnips']
let g:UltiSnipsEditSplit = "vertical"
cabbrev USE UltiSnipsEdit
+" Complete ultisnips with <C-x><C-u>, which is coincidentally the same mapping as user completion
+" (custom function btw)
+set completefunc=ultisnips_complete#ListSnippets
" Dokumentary {{{3
" Improve what K does
let g:dokumentary_docprgs = {'ruby': 'ri {0} | col -b'}