julia-vscode / LanguageServer.jl

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

Omni completion broken with LanguageClient-neovim #261

Open IngoMeyer441 opened 6 years ago

IngoMeyer441 commented 6 years ago

Hey, thanks for this project. I am new to Julia and Lanuage Servers and I am searching for a good autocompletion for Julia. So I tried this Language Server with LanguageClient-neovim but I don't get it running.

My testing setup:

When I open an empty Julia file, type prin and invoke Omni completion by typing C-x C-o neovim freezes completely. After quiting the editor I can find the following log files in /tmp:

IngoMeyer441 commented 6 years ago

I have written a small Dockerfile to reproduce my testing container:

FROM debian:unstable
LABEL maintainer="Ingo Heimbach <i.heimbach@fz-juelich.de>"

RUN apt-get update && \
    apt-get install --no-install-recommends -y automake \
                                               build-essential \
                                               ca-certificates \
                                               cmake \
                                               curl \
                                               gettext \
                                               git \
                                               libtool-bin \
                                               pkg-config \
                                               unzip && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /tmp

RUN curl -O -L https://julialang-s3.julialang.org/bin/linux/x64/0.6/julia-0.6.2-linux-x86_64.tar.gz && \
    tar -xvf julia-0.6.2-linux-x86_64.tar.gz && \
    rm -f julia-0.6.2-linux-x86_64.tar.gz && \
    cd julia-*/ && \
    cp -r bin etc include lib share /usr/local/ && \
    cd .. && \
    rm -rf julia-*

RUN git clone https://github.com/neovim/neovim.git && \
    cd neovim && \
    make CMAKE_BUILD_TYPE=Release && \
    make install && \
    cd .. && \
    rm -rf neovim

RUN julia -e 'Pkg.clone("https://github.com/JuliaEditorSupport/LanguageServer.jl")'

RUN curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh && \
    bash installer.sh ~/.vim/dein && \
    rm -f installer.sh

RUN mkdir -p "${HOME}/.config/nvim" && \
    echo 'set runtimepath^=~/.vim runtimepath+=~/.vim/after\n\
let &packpath = &runtimepath\n\
source ~/.vimrc' \
> "${HOME}/.config/nvim/init.vim" && \
    echo "set nocompatible\n\
\n\
set runtimepath+=/root/.vim/dein/repos/github.com/Shougo/dein.vim\n\
if dein#load_state('/root/.vim/dein')\n\
  call dein#begin('/root/.vim/dein')\n\
  call dein#add('Shougo/dein.vim')\n\
  call dein#add('JuliaEditorSupport/julia-vim')\n\
  call dein#add('autozimu/LanguageClient-neovim', {\n\
                          \ 'rev': 'next',\n\
                          \ 'build': 'bash install.sh'\n\
                          \ })\n\
  call dein#end()\n\
  call dein#save_state()\n\
endif\n\
\n\
filetype plugin indent on\n\
syntax enable\n\
set background=dark\n\
\n\
let g:default_julia_version = '0.6'\n\
\n\
\" language server\n\
let g:LanguageClient_autoStart = 1\n\
let g:LanguageClient_serverCommands = {\n\
\   'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', '\n\
\       using LanguageServer;\n\
\       server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false);\n\
\       server.runlinter = true;\n\
\       run(server);\n\
\   '],\n\
\ }\n" \
> /root/.vimrc

RUN echo ":call dein#install()\n" > ./vim_install_plugins && \
    echo '#!/bin/bash\nnvim -s /tmp/vim_install_plugins\nexec "$@"' > /tmp/entrypoint.sh && \
    chmod +x /tmp/entrypoint.sh

WORKDIR /root

RUN echo "prin" > test.jl

ENTRYPOINT ["/tmp/entrypoint.sh"]
CMD ["/bin/bash"]

After saving the file to Dockerfile you can run

docker build -t language-server-issue:latest -f Dockerfile .
docker run -it language-server-issue:latest

Neovim is opened automatically and installs julia-vim and LanguageClient-neovim. When the installation is complete, you can close Neovim and open my test file with:

nvim test.jl

I hope that makes finding the problem a bit easier :smiley:.

davidanthoff commented 6 years ago

I don’t remember who worked on the neovim options, I’m afraid I can’t help with this one because I’m not a neovim user...

IngoMeyer441 commented 6 years ago

I have also tested LanguageClient-neovim with vim8 and Omni completion hangs for original vim as well...

IngoMeyer441 commented 6 years ago

Here is the Dockerfile replacing Neovim with Vim 8:

FROM debian:unstable
LABEL maintainer="Ingo Heimbach <i.heimbach@fz-juelich.de>"

RUN apt-get update && \
    apt-get install --no-install-recommends -y ca-certificates \
                                               curl \
                                               git \
                                               vim-athena && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /tmp

RUN curl -O -L https://julialang-s3.julialang.org/bin/linux/x64/0.6/julia-0.6.2-linux-x86_64.tar.gz && \
    tar -xvf julia-0.6.2-linux-x86_64.tar.gz && \
    rm -f julia-0.6.2-linux-x86_64.tar.gz && \
    cd julia-*/ && \
    cp -r bin etc include lib share /usr/local/ && \
    cd .. && \
    rm -rf julia-*

RUN julia -e 'Pkg.clone("https://github.com/JuliaEditorSupport/LanguageServer.jl")'

RUN curl https://raw.githubusercontent.com/Shougo/dein.vim/master/bin/installer.sh > installer.sh && \
    bash installer.sh ~/.vim/dein && \
    rm -f installer.sh

RUN echo "set nocompatible\n\
\n\
set runtimepath+=/root/.vim/dein/repos/github.com/Shougo/dein.vim\n\
if dein#load_state('/root/.vim/dein')\n\
  call dein#begin('/root/.vim/dein')\n\
  call dein#add('Shougo/dein.vim')\n\
  call dein#add('JuliaEditorSupport/julia-vim')\n\
  call dein#add('autozimu/LanguageClient-neovim', {\n\
                          \ 'rev': 'next',\n\
                          \ 'build': 'bash install.sh'\n\
                          \ })\n\
  call dein#end()\n\
  call dein#save_state()\n\
endif\n\
\n\
filetype plugin indent on\n\
syntax enable\n\
set background=dark\n\
\n\
let g:default_julia_version = '0.6'\n\
\n\
\" language server\n\
let g:LanguageClient_autoStart = 1\n\
let g:LanguageClient_serverCommands = {\n\
\   'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', '\n\
\       using LanguageServer;\n\
\       server = LanguageServer.LanguageServerInstance(STDIN, STDOUT, false);\n\
\       server.runlinter = true;\n\
\       run(server);\n\
\   '],\n\
\ }\n" \
> /root/.vimrc

RUN echo ":call dein#install()\n" > ./vim_install_plugins && \
    echo '#!/bin/bash\nvim -s /tmp/vim_install_plugins\nexec "$@"' > /tmp/entrypoint.sh && \
    chmod +x /tmp/entrypoint.sh

WORKDIR /root

RUN echo "prin" > test.jl

ENTRYPOINT ["/tmp/entrypoint.sh"]
CMD ["/bin/bash"]
davidanthoff commented 6 years ago

So I'm putting this on the backlog for now because I'm just not familiar with vim or neovim. I think the best hope here is that we can entice the person that sorted out the neovim support in the first place to take a look.

joshbode commented 5 years ago

Hmm - well, that looks like my config :)

This is my current config using ncm2 and vim-plug:

" plugins
call g:plug#begin()
  Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': './install.sh'}
  Plug 'ncm2/ncm2' | Plug 'roxma/nvim-yarp'
  Plug 'sheerun/vim-polyglot'
call g:plug#end()

" language server
let g:LanguageClient_serverCommands = {
\   'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', '
\       import LanguageServer;
\       server = LanguageServer.LanguageServerInstance(stdin, stdout, false);
\       server.runlinter = true;
\       run(server);
\   '],
\ }

nnoremap <silent> K :call LanguageClient_textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR>

Note: To get it working on master I needed to make a few changes (see #274). I still don't have omnicomplete working for modules other than Base and Core but it is a start :)

joshbode commented 5 years ago

274 is merged now :)

rebelot commented 5 years ago

@joshbode does this work with Julia 1.0? I am using the same configuration but I can't make it to work.

I get this error message: data did not match any variant of untagged enum CompletionResponse

joshbode commented 5 years ago

Yes to Julia 1.0.

Hmm - try adding (edited above!):

  Plug 'sheerun/vim-polyglot'

I didn't get the same error as you, but it was required to get the minimal config working when I just tested it now.

Without it, Julia files were being interpreted as Lisp

rebelot commented 5 years ago

@joshbode I do not use vim-polyglot, but I have JuliaEditorSupport/julia-vim in my Plug list, which is basically what vim-polyglot is providing. I am using the latest updates of ncm2 and language-client, the Julia language server is installed via pkg mode cloning this repo. I am confused!

davidanthoff commented 5 years ago

Is this still an issue, or can we close this?