asyncomplete_neovim_lsp's People
asyncomplete_neovim_lsp's Issues
Snippet support
It would be nice if we have snippet support. i.e. that LSP snippets would expand using UltiSnips
I found some code already but I didn't nail every part down yet. Do you think it makes sense to implement that in this plugin?
https://github.com/thomasfaingnaert/vim-lsp-ultisnips/blob/master/autoload/lsp_ultisnips.vim#L7-L9
Applying the snippet: https://github.com/prabirshrestha/vim-lsp/blob/2de8f4d479229eedcb9bf41a878b94fb7e2662ed/autoload/lsp/ui/vim/completion.vim#L57-L117
Clearing the text: https://github.com/prabirshrestha/vim-lsp/blob/2de8f4d479229eedcb9bf41a878b94fb7e2662ed/autoload/lsp/ui/vim/completion.vim#L173-L224
Applying the text edits: https://github.com/prabirshrestha/vim-lsp/blob/2de8f4d479229eedcb9bf41a878b94fb7e2662ed/autoload/lsp/utils/text_edit.vim#L1-L21
This leads to this code already but the s:clear_inserted_text
still needs to be fixed + have a way to actually clear the line as it's using vim-lsp code under the hood.
function! s:escape_string(str) abort
let l:ret = substitute(a:str, '\%x00', '\\n', 'g')
let l:ret = substitute(l:ret, '"', '\\"', 'g')
return l:ret
endfunction
function! s:clear_inserted_text(line, done_position, complete_position, completed_item, completion_item) abort
" Remove commit characters.
call setline('.', a:line)
" Create range to remove v:completed_item.
let l:range = {
\ 'start': {
\ 'line': a:done_position[1] - 1,
\ 'character': lsp#utils#to_char('%', a:done_position[1], a:done_position[2] + a:done_position[3]) - strchars(a:completed_item['word'])
\ },
\ 'end': {
\ 'line': a:done_position[1] - 1,
\ 'character': lsp#utils#to_char('%', a:done_position[1], a:done_position[2] + a:done_position[3])
\ }
\ }
" Expand remove range to textEdit.
if has_key(a:completion_item, 'textEdit')
let l:range = {
\ 'start': {
\ 'line': a:completion_item['textEdit']['range']['start']['line'],
\ 'character': a:completion_item['textEdit']['range']['start']['character'],
\ },
\ 'end': {
\ 'line': a:completion_item['textEdit']['range']['end']['line'],
\ 'character': a:completion_item['textEdit']['range']['end']['character'] + strchars(a:completed_item['word']) - (a:complete_position['character'] - l:range['start']['character'])
\ }
\ }
endif
" Remove v:completed_item.word (and textEdit range if need).
call lsp#utils#text_edit#apply_text_edits(lsp#utils#get_buffer_uri(bufnr('%')), [{
\ 'range': l:range,
\ 'newText': ''
\ }])
" Move to complete start position.
call cursor(lsp#utils#position#lsp_to_vim('%', l:range['start']))
endfunction
function! s:get_expand_text(completed_item, completion_item) abort
let l:text = a:completed_item['word']
if has_key(a:completion_item, 'textEdit') && type(a:completion_item['textEdit']) == v:t_dict
let l:text = a:completion_item['textEdit']['newText']
elseif has_key(a:completion_item, 'insertText')
let l:text = a:completion_item['insertText']
endif
return l:text
endfunction
function! s:handle_completion() abort
if empty(v:completed_item)
return
endif
let l:completion_item = v:completed_item.user_data.nvim.lsp.completion_item
let l:new_text = s:get_expand_text(v:completed_item, l:completion_item)
if strlen(l:new_text) > 0
" call s:clear_inserted_text(
" \ l:line,
" \ l:done_position,
" \ l:complete_position,
" \ l:completed_item,
" \ l:completion_item,
" \ )
call feedkeys("i\<C-r>=UltiSnips#Anon(\"" . s:escape_string(l:new_text) . "\", \"\")\<CR>", 'i')
endif
endfunction
autocmd CompleteDonePre * call s:handle_completion()
Not working with lastest neovim
E714: List Required
When I try this plugin, I'm getting the following error:
Error executing vim.schedule lua callback: Vim(for):E714: List required
I'm using mac os x, neovim v0.5.0-1bfccf028
Any ideas?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.