1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:20:05 +08:00

perf(lsp): use notify api to display workspace

This commit is contained in:
wsdjeg 2023-06-20 21:21:43 +08:00
parent 68a3f4e203
commit 634ea0a34f
2 changed files with 24 additions and 1 deletions

View File

@ -145,6 +145,28 @@ function! s:language_specified_mappings() abort
call SpaceVim#mapping#space#langSPC('nmap', ['l','s', 's'],
\ 'call SpaceVim#plugins#repl#send("selection")',
\ 'send selection and keep code buffer focused', 1)
if SpaceVim#layers#lsp#check_filetype('lua')
\ || SpaceVim#layers#lsp#check_server('lua_ls')
\ || SpaceVim#layers#lsp#check_server('sumneko_lua')
nnoremap <silent><buffer> K :call SpaceVim#lsp#show_doc()<CR>
nnoremap <silent><buffer> gD :<C-u>call SpaceVim#lsp#go_to_typedef()<Cr>
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'],
\ 'call SpaceVim#lsp#show_doc()', 'show-document', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'x'],
\ 'call SpaceVim#lsp#references()', 'show-references', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'e'],
\ 'call SpaceVim#lsp#rename()', 'rename-symbol', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'h'],
\ 'call SpaceVim#lsp#show_line_diagnostics()', 'show-line-diagnostics', 1)
let g:_spacevim_mappings_space.l.w = {'name' : '+Workspace'}
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'l'],
\ 'call SpaceVim#lsp#list_workspace_folder()', 'list-workspace-folder', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'a'],
\ 'call SpaceVim#lsp#add_workspace_folder()', 'add-workspace-folder', 1)
call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'w', 'r'],
\ 'call SpaceVim#lsp#remove_workspace_folder()', 'remove-workspace-folder', 1)
endif
endfunction
function! SpaceVim#layers#lang#lua#health() abort

View File

@ -15,6 +15,7 @@ endif
let s:NVIM_VERSION = SpaceVim#api#import('neovim#version')
let s:box = SpaceVim#api#import('unicode#box')
let s:NOTI = SpaceVim#api#import('notify')
if (has('nvim-0.5.0') && s:NVIM_VERSION.is_release_version()) || has('nvim-0.6.0')
" use neovim built-in lsp
@ -56,7 +57,7 @@ if (has('nvim-0.5.0') && s:NVIM_VERSION.is_release_version()) || has('nvim-0.6.0
let workspace = luaeval('vim.lsp.buf.list_workspace_folders()')
let bw = max(map(deepcopy(workspace), 'strwidth(v:val)')) + 5
let box = s:box.drawing_box(workspace, 1, 1, bw, {'align' : 'left'})
echo join(box, "\n")
call s:NOTI.notify(join(box, "\n"))
endfunction
function! SpaceVim#lsp#add_workspace_folder() abort
lua vim.lsp.buf.add_workspace_folder()