autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 273 forks source link

Loading vim / nvim sessions from command line breaks LanguageClient #533

Open mwgkgk opened 6 years ago

mwgkgk commented 6 years ago

Summary

When launching either vim or nvim with -c "source ~/.vim/sessions/session-name" (doesn't occur when loading a session manually in a running editor), LanguageClient breaks into error spam (see below).

Doesn't occur when the editor has a file argument when starting: vim ~/some-file-not-necessarily-existing -c "source ~/.vim/sessions/session-name".

Reproduction

vim 8.1

VIM - Vi IMproved 8.1 (2018 May 17, compiled May 25 2018 00:50:25) Included patches: 1-22 Compiled by Arch Linux Huge version with GTK3 GUI. Features included (+) or not (-): +acl +farsi +mouse_sgr -tag_any_white +arabic +file_in_path -mouse_sysmouse +tcl/dyn +autocmd +find_in_path +mouse_urxvt +termguicolors -autoservername +float +mouse_xterm +terminal +balloon_eval +folding +multi_byte +terminfo +balloon_eval_term -footer +multi_lang +termresponse +browse +fork() -mzscheme +textobjects ++builtin_terms +gettext +netbeans_intg +timers +byte_offset -hangul_input +num64 +title +channel +iconv +packages +toolbar +cindent +insert_expand +path_extra +user_commands +clientserver +job +perl/dyn +vertsplit +clipboard +jumplist +persistent_undo +virtualedit +cmdline_compl +keymap +postscript +visual +cmdline_hist +lambda +printer +visualextra +cmdline_info +langmap +profile +viminfo +comments +libcall +python/dyn +vreplace +conceal +linebreak +python3/dyn +wildignore +cryptv +lispindent +quickfix +wildmenu +cscope +listcmds +reltime +windows +cursorbind +localmap +rightleft +writebackup +cursorshape +lua/dyn +ruby/dyn +X11 +dialog_con_gui +menu +scrollbind -xfontset +diff +mksession +signs +xim +digraphs +modify_fname +smartindent -xpm +dnd +mouse +startuptime +xsmp_interact -ebcdic +mouseshape +statusline +xterm_clipboard +emacs_tags +mouse_dec -sun_workshop -xterm_save +eval +mouse_gpm +syntax +ex_extra -mouse_jsbterm +tag_binary +extra_search +mouse_netterm +tag_old_static

Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/libdrm -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lfribidi -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lelf -lnsl -lacl -lattr -lgpm -ldl -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.26/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib -L/usr/lib/perl5/5.26/core_perl/CORE -lperl -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

nvim 0.3.1

NVIM v0.3.1 Build type: Release LuaJIT 2.0.5 Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.3.1/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include

Features: +acl +iconv +jemalloc +tui

LanguageClient-neovim

~/.vim/bundle/LanguageClient-neovim git rev-parse --short HEAD f90b90b

~/.vim/bundle/LanguageClient-neovim bin/languageclient --version languageclient 0.1.105

Vimrc

reproducible with https://github.com/autozimu/LanguageClient-neovim/blob/next/min-init.vim

Rust Language Server

~/.vim/bundle/LanguageClient-neovim rls --version rls-preview 0.129.0-nightly (2b57851 2018-07-14)

Steps to reproduce:

Logs

LanguageClient.log

Current Behavior

Error spam on startup and every cursormove:

Error detected while processing BufDelete Auto commands for "*":
E117: Unknown function: LanguageClient#handleBufDelete
"src/main.rs" 13L, 167C
Error detected while processing BufRead Auto commands for "*":
E117: Unknown function: LanguageClient#handleBufReadPost
Error detected while processing CursorMoved Auto commands for "*":
E117: Unknown function: LanguageClient#handleCursorMoved
ngortheone commented 5 years ago

@autozimu I was unable to reproduce this on current versions. OS

[~/.nvim]$ uname -s -r -v -m -o
Linux 5.0.13-arch1-1-ARCH #1 SMP PREEMPT Sun May 5 18:05:41 UTC 2019 x86_64 GNU/Linux

nvim

[~/.nvim]$ nvim --version
NVIM v0.3.5
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -Wconversion -O2 -DNDEBUG -DMIN_LOG_LEVEL=3 -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -I/build/neovim/src/build/config -I/build/neovim/src/neovim-0.3.5/src -I/usr/include -I/build/neovim/src/build/src/nvim/auto -I/build/neovim/src/build/include
Compiled by builduser

Features: +acl +iconv +jemalloc +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

LanguageClient-neovim

[~/.nvim/plugged/LanguageClient-neovim]$  git rev-parse --short HEAD                                                                                   [next]
41c948e

rls

[~/.nvim/plugged/LanguageClient-neovim]$ rls --version                                                                                                 [next]
rls 1.35.0 (49efc06 2019-04-06)

@mwgkgk can you re-test with new versions of everything?

mwgkgk commented 5 years ago

Further debugging uncovered following: the above crash only occurs when set sessionoptions+=globals is present before :mksession. So the steps to reproduce the problem should include that line in the vimrc. Here's mine, for quick reference:

set nocompatible

call plug#begin('~/.vim/bundle')

set sessionoptions+=globals

Plug 'autozimu/LanguageClient-neovim', {
    \ 'branch': 'next',
    \ 'do': 'bash install.sh',
    \ }

augroup filetype_rust
    autocmd!
    autocmd BufReadPost *.rs setlocal filetype=rust
augroup END

" Always draw sign column. Prevent buffer moving when adding/deleting sign.
set signcolumn=yes

let g:LanguageClient_serverCommands = {
    \ 'rust': ['rls'],
    \ }
let $RUST_BACKTRACE = 1
let g:LanguageClient_loggingLevel = 'INFO'
let g:LanguageClient_loggingFile =  expand('~/.local/share/nvim/LanguageClient.log')
let g:LanguageClient_serverStderr = expand('~/.local/share/nvim/LanguageServer.log')

call plug#end()

Reason I'm adding globals to sessionoptions is to preserve gcmt/taboo.vim tab names in session.

Please accept my apology for not realizing this before: I've probably tested the clean vimrc with contaminated session saves? Seems like an odd way to go and not what I've described in steps, but there's no one else to blame.