autozimu / LanguageClient-neovim

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

String interpolation of rootPath in serverCommands #650

Open languitar opened 6 years ago

languitar commented 6 years ago

Looking again at an issue I had with the java language server (https://github.com/eclipse/eclipse.jdt.ls/issues/622#issuecomment-382719309) it seems that I need a way to expand the project root path used for starting a server into it's command line to specify it workspace (a kind of working directory that should be unique to the project I am working on).

Describe the solution you'd like

I would need something like the following:

let g:LanguageClient_serverCommands={
    \ 'java': ['jdtls', '-data', '/home/languitar/.local/share/nvim/ls/java/%r'],

where %r is something that uniquely identifies the discovered root path in way that it can be used as a stable folder name.

Describe alternatives you've considered

Without this option, I will have to override the serverCommand manually for each java project using something like an .exrc file, which is a lot of work and can easily be forgotten.

martskins commented 4 years ago

I know this is terribly late but doesn't this solve your issue?

let g:LanguageClient_serverCommands = {
    \ 'java' : ['jdtls', '-data', '/home/languitar/.local/share/nvim/ls/java' . expand('%r')],
    \ }

That may not be exactly the same project root that LCN ends up using, but I feel like that should be unique enough?