Skip to content

Commit

Permalink
Added support to yeagappan lsp (#472)
Browse files Browse the repository at this point in the history
* Added support to yeagappan lsp

* Update README and docs.
  • Loading branch information
j0ng4b authored Jun 11, 2024
1 parent 04fa99a commit c07585b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ In addition to being a tags viewer, vista.vim can also be a symbol navigator sim
- [x] [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovim)
- [x] [vim-lsc](https://github.com/natebosch/vim-lsc)
- [x] [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
- [x] [yegappan lsp](https://github.com/yegappan/lsp)
- [x] Finder for tags and LSP symbols.
- [x] [fzf](https://github.com/junegunn/fzf)
- [x] [skim](https://github.com/lotabout/skim)
Expand Down
90 changes: 90 additions & 0 deletions autoload/vista/executive/yegappan_lsp.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
" Copyright (c) 2019 Liu-Cheng Xu
" MIT License
" vim: ts=2 sw=2 sts=2 et

let s:provider = fnamemodify(expand('<sfile>'), ':t:r')

let s:reload_only = v:false
let s:should_display = v:false

let s:fetching = v:true

function! s:HandleLSPResponse(server, results) abort
let s:fetching = v:false
if empty(a:results)
return []
endif

let s:data = vista#renderer#LSPPreprocess(a:results)

if !empty(s:data)
let [s:reload_only, s:should_display] = vista#renderer#LSPProcess(s:data, s:reload_only, s:should_display)

" Update cache when new data comes.
let s:cache = get(s:, 'cache', {})
let s:cache[s:fpath] = s:data
let s:cache.ftime = getftime(s:fpath)
let s:cache.bufnr = bufnr('')
endif

call vista#cursor#TryInitialRun()
endfunction

function! s:AutoUpdate(fpath) abort
let s:reload_only = v:true
let s:fpath = a:fpath
call s:RunAsync()
endfunction

function! s:Run() abort
call s:RunAsync()
while s:fetching
sleep 100m
endwhile
return get(s:, 'data', {})
endfunction

function! s:RunAsync() abort
call vista#SetProvider(s:provider)

let bufnum = bufnr('%')
let params = #{textDocument: #{uri: lsp#util#LspFileToUri(bufname(bufnum))}}
let servers = lsp#buffer#BufLspServersGet(bufnum)

for server in servers
if !server.isDocumentSymbolProvider
continue
endif

silent call server.rpc_a('textDocument/documentSymbol', params, function('s:HandleLSPResponse'))
endfor
endfunction

function! vista#executive#yegappan_lsp#Run(fpath) abort
let s:fpath = a:fpath
return s:Run()
endfunction

function! vista#executive#yegappan_lsp#RunAsync() abort
call s:RunAsync()
endfunction

function! vista#executive#yegappan_lsp#Execute(bang, should_display, ...) abort
call vista#source#Update(bufnr('%'), winnr(), expand('%'), expand('%:p'))
let s:fpath = expand('%:p')

call vista#OnExecute(s:provider, function('s:AutoUpdate'))

let g:vista.silent = v:false
let s:should_display = a:should_display

if a:bang
return s:Run()
else
call s:RunAsync()
endif
endfunction

function! vista#executive#yegappan_lsp#Cache() abort
return get(s:, 'cache', {})
endfunction
3 changes: 3 additions & 0 deletions doc/vista.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ FEATURES *vista-feature
[x] LanguageClient-neovim (https://github.com/autozimu/LanguageClient-neovim)
[x] vim-lsc (https://github.com/natebosch/vim-lsc)
[x] nvim-lsp (https://github.com/neovim/neovim)
[x] yegappan lsp (https://github.com/yegappan/lsp)
[x] Finder for tags and LSP symbols.
[x] fzf (https://github.com/junegunn/fzf)
[x] Display decent detailed symbol info in cmdline.
Expand Down Expand Up @@ -124,6 +125,8 @@ Vista *Vist

`:Vista nvim_lsp` open vista window based on nvim-lsp.

`:Vista yegappan_lsp` open vista window based on yeagappan lsp.

*vista-finder*

`:Vista finder` same with `:Vista finder fzf:ctags` .
Expand Down

0 comments on commit c07585b

Please sign in to comment.