Languageclient-neovim: Unrendered markdown showing for textDocument_hover()

Created on 1 Dec 2019  路  7Comments  路  Source: autozimu/LanguageClient-neovim

Describe the bug

Not sure if this is a bug with LanguageClient-neovim, or a bug with julia LanguageServer.jl, or not a bug at all and expected behaviour. When I call textDocument_hover(), I'm getting sensible results but with markdown that isn't being rendered:
image

Environment

  • neovim/vim version (nvim --version or vim --version):
    NVIM v0.4.3

  • This plugin version (git rev-parse --short HEAD):

  • This plugin's binary version (bin/languageclient --version):
silent! let g:plugs['LanguageClient-neovim'].commit = 'a7d3456'
silent! let g:plugs['julia-vim'].commit = '995eae2'
  • Minimal vimrc content (A minimal vimrc is the smallest vimrc that could
    reproduce the issue. Refer to an example here):
call plug#begin('~/.local/share/nvim/plugged')

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

call plug#end()

let g:LanguageClient_autoStart = 1
let g:LanguageClient_serverCommands = {
\   'julia': ['julia', '--startup-file=no', '--history-file=no', '-e', '
\       using LanguageServer;
\       using Pkg;
\       import StaticLint;
\       import SymbolServer;
\       env_path = dirname(Pkg.Types.Context().env.project_file);
\       debug = false; 
\       
\       server = LanguageServer.LanguageServerInstance(stdin, stdout, debug, env_path, "", Dict());
\       server.runlinter = true;
\       run(server);
\   '],
\ }

To Reproduce

Steps to reproduce the behavior:
create a file like:

foo(a, b) = 3
foo(a, b, c) = 4

foo(2,3) 

and when over the last foo call :call LanguageClient#textDocument_hover()

Current behavior

get sensible function definitions back, but with markdown backticks

Expected behavior

render the markdown

Most helpful comment

I was wrong. The issue is appears to be with the way vim-markdown updates syntax: it uses several autocmds to trigger the update, but non of those fire while _LanguageClient_ is creating hover.

https://github.com/plasticboy/vim-markdown/blob/da5a7ac96f517e0fd6f886bc3fbe27156ca1f946/ftplugin/markdown.vim#L782-L791

Locally I was able to get back the formatting by adding the following to init.vim:

augroup markdown_language_client_commands
    autocmd!
    autocmd WinLeave __LanguageClient__ ++nested call <SID>fixLanguageClientHover()
augroup END

function! s:fixLanguageClientHover()
    setlocal modifiable
    setlocal conceallevel=2
    normal i
    setlocal nomodifiable
endfunction

All 7 comments

I'm seeing the same with rust.

  • NVIM v0.4.3
  • LanguageClient-neovim bfa0c0c883cc648d92cef4bc3fcafa21775a94eb
  • rls 1.41.0 (8f1c275 2019-12-10)

Same with both python and javascript.

  • NVIM v0.4.3
  • LanguageClient-neovim 0394fba
  • python-language-server 0.29.3
  • typescript-language-server 0.4.0

Same issue with go and rust:
* NVIM v0.5.0
* LanguageClient-neovim 7c741d0
* golang.org/x/tools/gopls v0.3.1
* rust-analyzer 8a4c248

I suspect that one culprit could be the addition of left margin to the hover buffer, which could break some syntax highlighting:

https://github.com/autozimu/LanguageClient-neovim/blob/8a2396d614579f4b17b33ec942037936b3a73625/autoload/LanguageClient.vim#L370-L373

I was wrong. The issue is appears to be with the way vim-markdown updates syntax: it uses several autocmds to trigger the update, but non of those fire while _LanguageClient_ is creating hover.

https://github.com/plasticboy/vim-markdown/blob/da5a7ac96f517e0fd6f886bc3fbe27156ca1f946/ftplugin/markdown.vim#L782-L791

Locally I was able to get back the formatting by adding the following to init.vim:

augroup markdown_language_client_commands
    autocmd!
    autocmd WinLeave __LanguageClient__ ++nested call <SID>fixLanguageClientHover()
augroup END

function! s:fixLanguageClientHover()
    setlocal modifiable
    setlocal conceallevel=2
    normal i
    setlocal nomodifiable
endfunction

@pschuprikov fantastic, that worked! I also had to set setlocal nonu nornu below the normal i since I had BufEnter/Leave triggers. Thank you so much for posting this!

Fixed in #1139. Thanks for sharing your findings @pschuprikov

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MaskRay picture MaskRay  路  4Comments

martskins picture martskins  路  3Comments

Avi-D-coder picture Avi-D-coder  路  5Comments

MaskRay picture MaskRay  路  3Comments

languitar picture languitar  路  7Comments