Lsp_server usage with vim/nvim

Hi @jamesnvc,

Thank you for providing the lsp_server pack, I find it very useful. I use it with neovim. I am getting the following errors with the latest version:

[LC] LanguageClient: failed to register as NCM source: invalid type: boolean `false`, expected str
uct DocumentLinkOptions
[LC] LanguageClient: failed to parse semantic scopes: invalid type: boolean `false`, expected stru
ct DocumentLinkOptions
1 Like

Ah, thanks for the bug report! I will investigate. Which version of neovim & which Language Server plugin are you using?

Thanks!

NVIM v0.4.3
LanguageClient-neovim – 0.1.158 (latest from git as of aug 1 2020)

Released 2.2.5 of lsp_server which seems to fix that issue for neovim.

The problem was I was setting some capabilities to false, when the keys should’ve just been omitted…the spec isn’t particularly consistent on that & Emacs’ lsp-mode is a little too lenient, it seems.

Thanks! Upgraded and works fine now, appreciate it!

1 Like

Ever since the upgrade I am now getting:

[LC] timed out waiting on receive operation

neovim seems not to be receiving any of the diagnostics (such as Singleton Variable, etc).

EDIT: To get the timeout, I need to wait a few minutes and then the error above is shown.

Hm, strange, I guess the server is getting stuck on something. I’ll take a look.

I can’t reproduce this off the bat. Is there any particular file or sequence of commands you need to do to make this happen?

It is happening only with some prolog source files, and not with others. It is also happening with 2.2.4… Is there a way I can enable logging to get more info?

If you load syslog before it starts, then you can use that to see the debug output.

Change LSP command to be:

let g:LanguageClient_serverCommands = {
\ 'prolog': ['swipl',
\            '-g', 'use_module(library(syslog))', '-g', 'openlog(prolog_lsp, [], user)',
\            '-g', 'use_module(library(lsp_server)).',
\            '-g', 'lsp_server:main',
\            '-t', 'halt',
\            '--', 'stdio']
\ }

Then you can follow the debug output of the LSP server via journalctl -t prolog_lsp -f.

Thanks! I just ran the log and this is the error I am getting:

ug 03 15:50:37 light prolog_lsp[458383]: /home/h/qq.pl:59:12: Quasi quotation syntax asm:asm is not defined
Aug 03 15:50:37 light prolog_lsp[458383]: /home/h/qq.pl:81:12: Quasi quotation syntax asm:asm is not defined
Aug 03 15:50:37 light prolog_lsp[458383]: error handling msg error(type_error(text,Quasi quotation syntax ~q:~q is not defined-[asm,asm]),context(system:atomic_list_concat/2,_36782))

So it’s getting stuck because it is not loading the quasi quotation syntax parser ( which works fine outside the lsp_server).

The two errors above are inside a :- begin_tests(...) :- end_tests(...) block which uses the quasi-quotation.

Ah, quasiquotes! Indeed, I haven’t been testing those, thanks for finding that! I’ll look in to fixing that, hopefully tomorrow.

One of the big limitations with how the server is implemented is that it doesn’t actually load the code, just tries to use static analysis. I’ve been considering changing that soon, since it would make this sort of dynamic syntax much more feasible.

1 Like

Thanks for your responsiveness!! If you keep that up you may beat Jan who currently holds the record for the most responsive open source project!! :grin:

1 Like

Hah, I’d like to aspire to that, but I don’t think I can top Jan :laughing:

2 Likes

I’ve released 2.2.6 of lsp_server which should at least not get stuck on quasiquotes. It unfortunately will flag custom quasiquotes as errors, but I will work on fixing that as well.

EDIT: it looks like the presence of an unknown quasiquote is breaking semantic colouring too…

Thanks! I am running it now and it is showing the Singleton warnings again. It shows the quasi-quotes as errors, like you said, but at least we have the other errors back. Appreciate it!

Do you know a way I can get semantic colouring to work on neovim?

As far as I can tell, none of the neovim LSP plugins yet implement the semantic tokens capabilities. The version of the LSP spec that adds semantic tokens still isn’t officially released yet though, so presumably after that, clients will start to support it.

1 Like

Thanks, you’re even ahead of the released specs :slight_smile: