julia-vscode / LanguageServer.jl

An implementation of the Microsoft Language Server Protocol for the Julia language.
Other
371 stars 81 forks source link

Various errors when running LanguageServer.jl with neovim nightly #735

Closed kdheepak closed 4 years ago

kdheepak commented 4 years ago

This is my .vimrc file:

set nocompatible              " be iMproved, required
filetype off                  " required

if empty(glob('~/.local/share/nvim/site/autoload/plug.vim'))
  silent !curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
"
" Specify a directory for plugins
" - For Neovim:
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.local/share/nvim/plugged')

Plug 'JuliaEditorSupport/julia-vim'                               | " julia support for vim
Plug 'neovim/nvim-lsp'                                            | " collection of common configurations for the Nvim LSP client.

" Initialize plugin system
call plug#end()

let mapleader = " "

" use built in neovim lsp for autocomplete
autocmd Filetype julia setlocal omnifunc=v:lua.vim.lsp.omnifunc

lua << EOF
    require'nvim_lsp'.julials.setup{}
EOF

nnoremap 1gD           :lua vim.lsp.buf.type_definition()<CR>
nnoremap gr            :lua vim.lsp.buf.references()<CR>
nnoremap g0            :lua vim.lsp.buf.document_symbol()<CR>
nnoremap gD            :lua vim.lsp.buf.implementation()<CR>
nnoremap gd            :lua vim.lsp.buf.declaration()<CR>
nnoremap <c-]>         :lua vim.lsp.buf.definition()<CR>
nnoremap <leader>lk    :lua vim.lsp.buf.hover()<CR>
nnoremap <leader>ld    :lua vim.lsp.util.show_line_diagnostics()<CR>
nnoremap <leader>ls    :lua vim.lsp.buf.signature_help()<CR>

with neovim version:

$ nvim --version

NVIM v0.5.0-539-g91e41c857
Build type: Release
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode-10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/travis/build/neovim/bot-ci/build/neovim/build/config -I/Users/travis/build/neovim/bot-ci/build/neovim/src -I/Users/travis/build/neovim/bot-ci/build/neovim/.deps/usr/include -I/usr/include -I/usr/local/opt/gettext/include -I/Users/travis/build/neovim/bot-ci/build/neovim/build/src/nvim/auto -I/Users/travis/build/neovim/bot-ci/build/neovim/build/include
Compiled by travis@Traviss-Mac-6.local

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

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

Run :checkhealth for more info

This is what I'm using to start the LanguageServer:

        "julia", "--startup-file=no", "--history-file=no", "-e", [[
        using LanguageServer;
        using Pkg;
        env_path = dirname(Pkg.Types.Context().env.project_file)
        server = LanguageServer.LanguageServerInstance(stdin, stdout, env_path);
        server.runlinter = true;
        run(server);

The following are the various errors:

This is always the first thing that is being printed in the log file. Julia appears to be

ERROR
signal (15): Terminated: 15
in expression starting at none:0
getindex at ./compiler/ssair/ir.jl:297
iterate at ./compiler/ssair/ir.jl:391

The language server does appear to start up after that because I'm getting other errors after this message.


SymbolServer not defined. This is a fresh installation of Julia and these are the only two packages I have in my global environment:

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.0 (2020-03-21)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(@v1.4) pkg> st
Status `~/.julia/environments/v1.4/Project.toml`
  [2b0e0bc5] LanguageServer v3.0.0
  [cf896787] SymbolServer v4.4.0

(@v1.4) pkg>
ERROR: UndefVarError: SymbolServer not defined
Stacktrace:
 [1] deserialize_module(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:915
 [2] handle_deserialize(::Serialization.Serializer{IOStream}, ::Int32) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:812
 [3] deserialize(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:735
 [4] deserialize_datatype(::Serialization.Serializer{IOStream}, ::Bool) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:1210
 [5] handle_deserialize(::Serialization.Serializer{IOStream}, ::Int32) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:788
 [6] deserialize(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:735
 [7] handle_deserialize(::Serialization.Serializer{IOStream}, ::Int32) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:795
 [8] deserialize(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:735
 [9] handle_deserialize(::Serialization.Serializer{IOStream}, ::Int32) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:838
 [10] deserialize(::Serialization.Serializer{IOStream}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:735
 [11] deserialize at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.4/Serialization/src/Serialization.jl:722 [inlined]
 [12] #25 at /Users/USER/.julia/packages/SymbolServer/vTGsB/src/SymbolServer.jl:171 [inlined]
 [13] open(::SymbolServer.var"#25#26", ::String; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at ./io.jl:298
 [14] open at ./io.jl:296 [inlined]
 [15] load_package_from_cache_into_store!(::SymbolServer.SymbolServerInstance, ::Base.UUID, ::Dict{Base.UUID,Pkg.Types.PackageEntry}, ::Dict{Symbol,SymbolServer.ModuleStore}) at /Users/USER/.julia/packages/SymbolServer/vTGsB/src/SymbolServer.jl:170
 [16] load_project_packages_into_store!(::SymbolServer.SymbolServerInstance, ::String, ::Dict{Symbol,SymbolServer.ModuleStore}) at /Users/USER/.julia/packages/SymbolServer/vTGsB/src/SymbolServer.jl:142
 [17] getstore(::SymbolServer.SymbolServerInstance, ::String, ::LanguageServer.var"#2#4"{LanguageServerInstance}, ::Nothing) at /Users/USER/.julia/packages/SymbolServer/vTGsB/src/SymbolServer.jl:100
 [18] macro expansion at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/languageserverinstance.jl:157 [inlined]
 [19] (::LanguageServer.var"#1#3"{LanguageServerInstance})() at ./task.jl:358
┌ Warning: Tried to load LanguageServer but failed to load from disc, re-caching.
└ @ SymbolServer ~/.julia/packages/SymbolServer/vTGsB/src/SymbolServer.jl:179
[ Info: Received new data from Julia Symbol Server.

The following are other errors I've received but I'm not able to reproduce consistently:

ERROR: KeyError: key "params" not found
Stacktrace:
 [1] getindex at ./dict.jl:477 [inlined]
 [2] parse(::Type{LanguageServer.JSONRPC.Request}, ::Dict{String,Any}) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/jsonrpc.jl:44
 [3] run(::LanguageServerInstance) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/languageserverinstance.jl:246
 [4] top-level scope at none:6
ERROR: MethodError: no method matching parse_params(::Type{Val{Symbol("textDocument/declaration")}}, ::Dict{String,Any})
Closest candidates are:
  parse_params(!Matched::Type{Val{:initialize}}, ::Any) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/requests/init.jl:123
  parse_params(!Matched::Type{Val{:initialized}}, ::Any) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/requests/init.jl:155
  parse_params(!Matched::Type{Val{:shutdown}}, ::Any) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/requests/init.jl:180
  ...
Stacktrace:
 [1] parse(::Type{LanguageServer.JSONRPC.Request}, ::Dict{String,Any}) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/jsonrpc.jl:46
 [2] run(::LanguageServerInstance) at /Users/USER/.julia/packages/LanguageServer/mpNvN/src/languageserverinstance.jl:246
 [3] top-level scope at none:6
kdheepak commented 4 years ago

Would it be productive to post all the errors I'm getting here? Just as a record on what is going on. I know what vscode allows you to get feedback/log files from vscode users. Maybe similar log files from neovim users would be handy?

non-Jedi commented 4 years ago

The second error is a result of https://github.com/julia-vscode/SymbolServer.jl/issues/54 and can be fixed by changing using LanguageServer to using LanguageServer, SymbolServer. It might be the cause of the segfault as well; not sure.

non-Jedi commented 4 years ago

In general, both the output from stderr and the logs of messages sent received by the client are highly helpful in debugging.

kdheepak commented 4 years ago

Thanks for the quick reply! I will try that change.

Even without that change, it seems like it works sometimes? Here is a screencast I captured when it was working:

julialanguageserver

kdheepak commented 4 years ago

Adding using LanguageServer, SymbolServer resolves the segfaults! Thanks for that!

kdheepak commented 4 years ago

both the output from stderr and the logs of messages sent received by the client

I'm sharing everything that is in the nvim lsp.log file, which appears to be just the stderr from LanguageServer.jl. I'll look into how to get logs from the client as well.

non-Jedi commented 4 years ago

If you see crashes or other problems with the new script, please open a new issue. :)