Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
prabirshrestha authored Sep 9, 2023
2 parents ddadaeb + aa93b2a commit f5b0bf8
Show file tree
Hide file tree
Showing 12 changed files with 126 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linux_neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: |
# https://github.com/Zettlr/Zettlr/issues/3517
sudo apt-get install libfuse2
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download neovim
shell: bash
run: |
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
env:
GO111MODULE: 'on'
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux_vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
run: |
# https://github.com/Zettlr/Zettlr/issues/3517
sudo apt-get install libfuse2
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download vim
shell: bash
run: |
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
env:
GO111MODULE: 'on'
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mac_neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runs-on: ${{matrix.os}}
continue-on-error: ${{matrix.allow_failure}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download neovim
shell: bash
run: curl -L https://github.com/neovim/neovim/releases/download/${{matrix.neovim_version}}/nvim-macos.tar.gz -o ~/nvim.tar.gz
Expand All @@ -46,7 +46,7 @@ jobs:
run: tar xzf ~/nvim.tar.gz -C ~/
continue-on-error: ${{matrix.allow_failure}}
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/mac_vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install MacVim
shell: bash
run: brew install macvim
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reviewdog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: runner / vint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: vint
uses: reviewdog/action-vint@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows_neovim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
runs-on: ${{matrix.os}}
continue-on-error: ${{matrix.allow_failure}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download neovim
shell: PowerShell
run: Invoke-WebRequest -Uri https://github.com/neovim/neovim/releases/download/${{matrix.neovim_version}}/nvim-${{matrix.neovim_arch}}.zip -OutFile neovim.zip
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
env:
GO111MODULE: 'on'
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows_vim.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
vim_ver_path: vim80
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Download vim
shell: PowerShell
run: Invoke-WebRequest -Uri https://github.com/vim/vim-win32-installer/releases/download/v${{matrix.vim_version}}/gvim_${{matrix.vim_version}}_${{matrix.vim_arch}}.zip -OutFile vim.zip
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
env:
GO111MODULE: 'on'
- name: Download test runner
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: thinca/vim-themis
path: ./vim-themis
Expand Down
24 changes: 24 additions & 0 deletions autoload/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ function! lsp#get_server_names() abort
return keys(s:servers)
endfunction

function! lsp#is_valid_server_name(name) abort
return has_key(s:servers, a:name)
endfunction

function! lsp#get_server_info(server_name) abort
return get(get(s:servers, a:server_name, {}), 'server_info', {})
endfunction
Expand Down Expand Up @@ -128,6 +132,19 @@ function! s:server_status(server_name) abort
return 'not running'
endfunction

function! lsp#is_server_running(name) abort
if !has_key(s:servers, a:name)
return 0
endif

let l:server = s:servers[a:name]

return has_key(l:server, 'init_result')
\ && !has_key(l:server, 'exited')
\ && !has_key(l:server, 'init_callbacks')
\ && !has_key(l:server, 'failed')
endfunction

" Returns the current status of all servers (if called with no arguments) or
" the given server (if given an argument). Can be one of "unknown server",
" "exited", "starting", "failed", "running", "not running"
Expand Down Expand Up @@ -1329,6 +1346,13 @@ function! lsp#server_complete(lead, line, pos) abort
return filter(sort(keys(s:servers)), 'stridx(v:val, a:lead)==0 && has_key(s:servers[v:val], "init_result")')
endfunction

function! lsp#server_complete_running(lead, line, pos) abort
let l:all_servers = sort(keys(s:servers))
return filter(l:all_servers, {idx, name ->
\ stridx(name, a:lead) == 0 && lsp#is_server_running(name)
\ })
endfunction

function! lsp#_new_command() abort
let s:last_command_id += 1
call lsp#stream(1, { 'command': 1 })
Expand Down
69 changes: 65 additions & 4 deletions autoload/lsp/ui/vim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,78 @@ function! lsp#ui#vim#rename() abort
call s:rename(l:server, input('new name: ', expand('<cword>')), lsp#get_position())
endfunction

function! lsp#ui#vim#stop_server(...) abort
let l:name = get(a:000, 0, '')
for l:server in lsp#get_allowed_servers()
if !empty(l:name) && l:server != l:name
function! s:stop_all_servers() abort
for l:server in lsp#get_server_names()
if !lsp#is_server_running(l:server)
continue
endif

echo 'Stopping' l:server 'server ...'
call lsp#stop_server(l:server)
endfor
endfunction

function! s:stop_named_server(name) abort
if !lsp#is_valid_server_name(a:name)
call lsp#utils#warning('No LSP servers named "' . a:name . '"')
return
endif

if lsp#is_server_running(a:name)
echo 'Stopping "' . a:name . '" server...'
call lsp#stop_server(a:name)
else
call lsp#utils#warning(
\ 'Server "' . a:name . '" is not running: '
\ . lsp#get_server_status(a:name)
\ )
endif
endfunction

function! s:stop_buffer_servers() abort
let l:servers = lsp#get_allowed_servers()
let l:servers =
\ filter(l:servers, {idx, name -> lsp#is_server_running(name)})

if empty(l:servers)
call lsp#utils#warning('No active LSP servers for the current buffer')
return
endif

for l:server in l:servers
echo 'Stopping "' . l:server . '" server ...'
call lsp#stop_server(l:server)
endfor
endfunction

function! lsp#ui#vim#stop_server(stop_all, ...) abort
if a:0 != 0 && a:0 != 1
call lsp#utils#error(
\ 'lsp#ui#vim#stop_server(): expected 1 optional "name" argument.'
\ . ' Got: "' . join(a:000, '", "') . '".')
return
endif
let l:stop_all = a:stop_all ==# '!'
let l:name = get(a:000, 0, '')

if l:stop_all
if !empty(l:name)
call lsp#utils#error(
\ '"!" stops all servers: name is ignored: "' . l:name . '"')
endif

call s:stop_all_servers()
return
endif

if !empty(l:name)
call s:stop_named_server(l:name)
return
endif

call s:stop_buffer_servers()
endfunction

function! lsp#ui#vim#workspace_symbol(query) abort
let l:servers = filter(lsp#get_allowed_servers(), 'lsp#capabilities#has_workspace_symbol_provider(v:val)')
let l:command_id = lsp#_new_command()
Expand Down
4 changes: 2 additions & 2 deletions autoload/lsp/ui/vim/utils.vim
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function! lsp#ui#vim#utils#symbols_to_loc_list(server, result) abort
\ 'filename': l:path,
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name'],
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . (g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name']),
\ })
endif
else
Expand All @@ -84,7 +84,7 @@ function! lsp#ui#vim#utils#symbols_to_loc_list(server, result) abort
\ 'filename': l:path,
\ 'lnum': l:line,
\ 'col': l:col,
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name'],
\ 'text': lsp#ui#vim#utils#_get_symbol_text_from_kind(a:server, l:symbol['kind']) . ' : ' . (g:lsp_document_symbol_detail ? l:symbol['detail'] : l:symbol['name']),
\ })
if has_key(l:symbol, 'children') && !empty(l:symbol['children'])
call s:symbols_to_loc_list_children(a:server, l:path, l:list, l:symbol['children'], 1)
Expand Down
23 changes: 21 additions & 2 deletions doc/vim-lsp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1917,9 +1917,28 @@ Prints the status of all registered servers. Use `:verbose LspStatus` to
additionally show each server's workspace_config.
See also |vim-lsp-healthcheck|.

LspStopServer *:LspStopServer*
LspStopServer[!] [name] *:LspStopServer*

Stop all active servers.
:LspStopServer

Stops all active servers that handle files matching the current buffer type
are stopped. This is often what you want. For example, if you have multiple
files of different types open, `LspStopServer` will only stop the server for
the current buffer. Shows an error if there are no active LSP servers for the
current buffer.

:LspStopServer!

Stops all active servers, regardless of the current buffer. Shows a message
for every stopped server.

:LspStopServer name

Stops a server named 'name', comparing the provided ID with the value of the
the 'name' property in the |lsp#register_server()| call. Shows an error if
'name' does not match a defined and currently running server.

Completion should list only currently running servers for the 'name' argument.

==============================================================================
Autocommands *vim-lsp-autocommands*
Expand Down
2 changes: 1 addition & 1 deletion plugin/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ command! LspPeekImplementation call lsp#ui#vim#implementation(1)
command! -nargs=0 LspStatus call lsp#print_server_status()
command! LspNextReference call lsp#internal#document_highlight#jump(+1)
command! LspPreviousReference call lsp#internal#document_highlight#jump(-1)
command! -nargs=? -complete=customlist,lsp#server_complete LspStopServer call lsp#ui#vim#stop_server(<f-args>)
command! -nargs=? -bang -complete=customlist,lsp#server_complete_running LspStopServer call lsp#ui#vim#stop_server("<bang>", <f-args>)
command! -nargs=? -complete=customlist,lsp#utils#empty_complete LspSignatureHelp call lsp#ui#vim#signature_help#get_signature_help_under_cursor()
command! LspDocumentFold call lsp#ui#vim#folding#fold(0)
command! LspDocumentFoldSync call lsp#ui#vim#folding#fold(1)
Expand Down

0 comments on commit f5b0bf8

Please sign in to comment.