I broke up with neovim....vim is my best friend now

This commit is contained in:
LinlyBoi
2023-04-30 08:14:07 +03:00
parent 0d185449c5
commit 4a4a6b1e81
5245 changed files with 468325 additions and 25 deletions

View File

@@ -0,0 +1,55 @@
function! vsnip_integ#integration#asyncomplete#attach() abort
call asyncomplete#register_source(
\ s:get_source_option({
\ 'name': 'vsnip',
\ 'whitelist': ['*'],
\ 'completor': function('s:completor'),
\ })
\ )
endfunction
"
" get_source_option
"
function! s:get_source_option(opts) abort
let l:defaults = {
\ 'name': 'vsnip',
\ 'completor': function('s:completor'),
\ 'whitelist': ['*']
\ }
return extend(l:defaults, a:opts)
endfunction
"
" completor
"
function! s:completor(opts, ctx) abort
let l:before_line = getline('.')
let l:idx = min([strlen(l:before_line), col('.') - 2])
let l:idx = max([l:idx, 0])
let l:before_line = l:before_line[0 : l:idx]
if len(matchstr(l:before_line, s:get_keyword_pattern() . '$')) < 1
return
endif
call asyncomplete#complete(
\ a:opts.name,
\ a:ctx,
\ a:ctx.col - strlen(matchstr(a:ctx.typed, '\k*$')),
\ vsnip#get_complete_items(bufnr('%'))
\ )
endfunction
"
" get_keyword_pattern
"
function! s:get_keyword_pattern() abort
let l:keywords = split(&iskeyword, ',')
let l:keywords = filter(l:keywords, { _, k -> match(k, '\d\+-\d\+') == -1 })
let l:keywords = filter(l:keywords, { _, k -> k !=# '@' })
let l:pattern = '\%(' . join(map(l:keywords, { _, v -> '\V' . escape(v, '\') . '\m' }), '\|') . '\|\w\)*'
return l:pattern
endfunction