Skip to content

:LanguageClientStop or :call LanguageClient#exit() not killing language server process #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
TylerLeonhardt opened this issue Apr 20, 2018 · 2 comments

Comments

@TylerLeonhardt
Copy link
Contributor

Summary

For the PowerShell language server, "PowerShell Editor Services", it runs a powershell script that starts the language server in a powershell instance. (see below init.vim for details) When :LanguageClientStop or :call LanguageClient#exit() get called, that powershell process hangs around leading to stray processes.

LanguageClient-neovim should kill these processes when calling Stop or Exit.

Reproduction

  • neovim/vim version (nvim --version or vim --version): NVIM v0.2.2
  • This plugin version (git rev-parse --short HEAD): b96f442
  • This plugin's binary version (bin/languageclient --version):
    languageclient 0.1.70 6e901906a6b63e074d043b59fe2d44107d5ad792
  • Minimal vimrc content. A minimal vimrc is the smallest vimrc that could
    reproduce the issue. Refer to an example here. Make sure
    your vimrc contains let g:LanguageClient_loggingLevel = 'DEBUG' to have
    full log:

init.vim

call plug#begin('~/.local/share/nvim/plugged')

Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'autozimu/LanguageClient-neovim', {
        \ 'branch': 'next',
        \ 'do': 'bash install.sh',
        \ }
Plug 'sheerun/vim-polyglot'
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"let g:deoplete#enable_at_startup = 1
Plug 'roxma/nvim-completion-manager'
call plug#end()

"LanguageServerProtocol setup
"required for operations modifying multiple buffers like rename.
set hidden

"note call to powershell (pwsh)
let g:LanguageClient_serverCommands = {
    \ 'ps1': ['pwsh', '~/Desktop/PowerShellEditorServices/module/Start-EditorServices.ps1', '-HostName', 'nvim', '-HostProfileId', '0', '-HostVersion', '1.0.0', '-EditorServicesVersion', '1.6.0', '-LogPath', '~/Desktop/pses.log.txt', '-LogLevel', 'Diagnostic', '-BundledModulesPath', '~/Desktop/PowerShellEditorServices/module', '-Stdio', '-SessionDetailsPath', '~/Desktop/.pses_session']
    \ }
let g:LanguageClient_loggingLevel = 'DEBUG'

autocmd FileType ps1 call VsimEnableLanguageServerKeys()
function! VsimEnableLanguageServerKeys()
        " TODO hover with timer
        nnoremap <silent> <S-K> :call LanguageClient_textDocument_hover()<CR>
        nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR>
        nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
        nnoremap <silent> <F12> :call LanguageClient_textDocument_definition()<CR>
        set formatexpr=LanguageClient_textDocument_rangeFormatting()
        vnoremap = :call LanguageClient_textDocument_rangeFormatting()<CR>
        nnoremap <C-k><C-r> :call LanguageClient_textDocument_references()<CR>
        nnoremap <C-e><C-d> :call LanguageClient_textDocument_formatting()<CR>
        autocmd! CursorHold * call LanguageClient_textDocument_hover()

        autocmd! VimLeave * :LanguageClientStop

endfunction

This will allow PowerShell Editor Services to listen on stdio to be able to work with LanguageClient-neovim

@yatli's fork is here: https://github.com/yatli/PowerShellEditorServices

clone that to ~/Desktop

You'll need to run the build step to get it working:
https://github.com/powershell/powershelleditorservices#development

  • Steps to reproduce the issue from clean state
    1. open a ps1 with neovim
    2. close neovim or do :LanguageClientStop or do :call LanguageClient#exit()
    3. run ps aux | grep pwsh
  • Logs. Paste or attach /tmp/LanguageClient.log and /tmp/LanguageServer.log.
    LanguageClient.log
    LanguageServer.log

Expected Behavior

LanguageClient-neovim would close the running instance of powershell (where the language server is running)

Current Behavior

The process is still running:

tylerleonhardt   19425   0.0  0.7  6606068 118280 s001  S+   11:13PM   0:04.18 pwsh /Users/tylerleonhardt/Desktop/PowerShellEditorServices/module/Start-EditorServices.ps1 -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -EditorServicesVersion 1.6.0 -LogPath /Users/tylerleonhardt/Desktop/pses.log.txt -LogLevel Diagnostic -BundledModulesPath /Users/tylerleonhardt/Desktop/PowerShellEditorServices/module -Stdio -SessionDetailsPath /Users/tylerleonhardt/Desktop/.pses_session

This is bad because I often close and open neovim all the time and every time that happens a new process is left behind. Too many stray processes.

@TylerLeonhardt
Copy link
Contributor Author

Once I address this last issue I promise to submit a PR on how to set PowerShell up with LanguageClient-neovim 😄

@autozimu
Copy link
Owner

According to spec the server should quit itself when receiving exit(), no matter what the mode is (TCP or STDIO). This is at least my understanding. PS server should fix it's own problem correctly handling this exit() notification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants