Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass configuration when running vls from command line? #13

Open
przepompownia opened this issue Oct 19, 2019 · 15 comments
Open

How to pass configuration when running vls from command line? #13

przepompownia opened this issue Oct 19, 2019 · 15 comments

Comments

@przepompownia
Copy link
Contributor

Hello,

I would like to use vim-language-server with https://github.com/autozimu/LanguageClient-neovim
but I (as not Node developer) have no idea how to pass the configuration presented for --stdio.

With

let g:LanguageClient_serverCommands['vim'] = [exepath('vim-language-server'), '--stdio']

seems to work, but I would like to configure fromRuntimepath and not only.

Seriously: I even not know how to list possible options... Running vim-language-server without parameters throws the error with suggestion to use only the basic

'--node-ipc', '--stdio' or '--socket={number}'

but not how to display help message and how to inject any configuration.

Please complete documentation.

@iamcco
Copy link
Owner

iamcco commented Oct 20, 2019

It not support to pass initializationOptions in command line by now, you should config the LSP client to send initializationOptions config in the initialize request to the LSP.

@przepompownia
Copy link
Contributor Author

I am still unfamiliar also with many basics of the LSP protocol. Having the request name, I grepped it within LanguageClient-neovim sources and found the answer:

2.12 g:LanguageClient_settingsPath              *g:LanguageClient_settingsPath*

Path for language server settings. If not an absolute path this is relative
to the workspace directory.

Example settings file content: >
    {
        "rust.clippy_preference": "on"
    }

Default: ".vim/settings.json"

Maybe it is worth mentioning explicitly in the documentation (as well as hints for some other popular clients).

Thanks for the answer containing the crucial request name.

@iamcco
Copy link
Owner

iamcco commented Oct 21, 2019

The option initializationOptions is already mention in the readme.

PS. I don't use the other LSP client so i don't know how they config. PR is welcome.

@przepompownia
Copy link
Contributor Author

Yes, this examples are helpful, but only partially in my case. Probably it contains the part that is sent with the initial request and some of contents outside this part that are specific to, maybe, coc.nvim.

Using logs from the client I see that the full long runtimepath appears in logs

{
    "jsonrpc": "2.0",
    "method": "initialize",
    "params": {
        "capabilities": {
            "textDocument": {
                "colorProvider": null,
                "completion": {
                    "completionItem": {
                        "snippetSupport": false
                    }
                },
                "declaration": {
                    "linkSupport": true
                },
                "definition": {
                    "linkSupport": true
                },
                "implementation": {
                    "linkSupport": true
                },
                "publishDiagnostics": {
                    "relatedInformation": true
                },
                "signatureHelp": {
                    "signatureInformation": {
                        "parameterInformation": {
                            "labelOffsetSupport": true
                        }
                    }
                },
                "typeDefinition": {
                    "linkSupport": true
                }
            },
            "workspace": {
                "applyEdit": true,
                "didChangeWatchedFiles": {
                    "dynamicRegistration": true
                }
            }
        },
        "initializationOptions": {
            "diagnostic": {
                "enable": true
            },
            "indexes": {
                "count": 3,
                "gap": 100,
                "runtimepath": true
            },
            "iskeyword": "@,48-57,_,192-255,#",
            "runtimepath": "/home/______/.config/nvim,/home/______/.config/nvim/bundle/LanguageClient-neovim,/home/______/.config/nvim/bundle/PHP-Indenting-for-VIm,/home/______/.config/nvim/bundle/ale,/home/______/.config/nvim/bundle/______,/home/______/.config/nvim/bundle/auto-pairs,/home/______/.config/nvim/bundle/bufexplorer,/home/______/.config/nvim/bundle/ctrlp.vim,/home/______/.config/nvim/bundle/deoplete-phpactor,/home/______/.config/nvim/bundle/deoplete.nvim,/home/______/.config/nvim/bundle/fugitive,/home/______/.config/nvim/bundle/fzf.vim,/home/______/.config/nvim/bundle/luciusColorscheme,/home/______/.config/nvim/bundle/neopairs.vim,/home/______/.config/nvim/bundle/nerdtree,/home/______/.config/nvim/bundle/nginx.vim,/home/______/.config/nvim/bundle/phpactor,/home/______/.config/nvim/bundle/snippets,/home/______/.config/nvim/bundle/surround,/home/______/.config/nvim/bundle/tabname,/home/______/.config/nvim/bundle/tail-bundle,/home/______/.config/nvim/bundle/tmux.vim,/home/______/.config/nvim/bundle/ultisnips,/home/______/.config/nvim/bundle/vdebug,/home/______/.config/nvim/bundle/vim-airline,/home/______/.config/nvim/bundle/vim-airline-themes,/home/______/.config/nvim/bundle/vim-commentary,/home/______/.config/nvim/bundle/vim-dispatch,/home/______/.config/nvim/bundle/vim-gitgutter,/home/______/.config/nvim/bundle/vim-javascript,/home/______/.config/nvim/bundle/vim-markdown,/home/______/.config/nvim/bundle/vim-markdown-folding,/home/______/.config/nvim/bundle/vim-move,/home/______/.config/nvim/bundle/vim-pasta,/home/______/.config/nvim/bundle/vim-pathogen,/home/______/.config/nvim/bundle/vim-repeat,/home/______/.config/nvim/bundle/vim-rhubarb,/home/______/.config/nvim/bundle/vim-spacejam,/home/______/.config/nvim/bundle/vim-test,/home/______/.config/nvim/bundle/vim-tmux-focus-events,/home/______/.config/nvim/bundle/vim-toml,/home/______/.config/nvim/bundle/vim-twig,/home/______/.config/nvim/bundle/vim-unimpaired,/etc/xdg/nvim,/home/______/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/runtime,/usr/share/nvim/runtime/pack/dist/opt/matchit,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,/home/______/.local/share/nvim/site/after,/etc/xdg/nvim/after,/home/______/.config/nvim/bundle/vim-markdown-folding/after,/home/______/.config/nvim/bundle/vim-javascript/after,/home/______/.config/nvim/bundle/ultisnips/after,/home/______/.config/nvim/bundle/______/after,/home/______/.config/nvim/after,/usr/share/doc/fzf/examples",
            "suggest": {
                "fromRuntimepath": true,
                "fromVimruntime": true
            },
            "vimruntime": "/usr/share/nvim/runtime"
        },
        "processId": 14056,
        "rootPath": "/home/______/.vim",
        "rootUri": "file:///home/______/.vim",
        "trace": "verbose"
    },
    "id": 1
}

only if I put to the request the contents under vimls only:

{
  "command": "vim-language-server",
  "args": ["--stdio"],
  "initializationOptions": {
    "iskeyword": "@,48-57,_,192-255,#",
    "vimruntime": "/usr/share/nvim/runtime",
    "runtimepath": "/home/______/.config/nvim,/home/______/.config/nvim/bundle/LanguageClient-neovim,/home/______/.config/nvim/bundle/PHP-Indenting-for-VIm,/home/______/.config/nvim/bundle/ale,/home/______/.config/nvim/bundle/______,/home/______/.config/nvim/bundle/auto-pairs,/home/______/.config/nvim/bundle/bufexplorer,/home/______/.config/nvim/bundle/ctrlp.vim,/home/______/.config/nvim/bundle/deoplete-phpactor,/home/______/.config/nvim/bundle/deoplete.nvim,/home/______/.config/nvim/bundle/fugitive,/home/______/.config/nvim/bundle/fzf.vim,/home/______/.config/nvim/bundle/luciusColorscheme,/home/______/.config/nvim/bundle/neopairs.vim,/home/______/.config/nvim/bundle/nerdtree,/home/______/.config/nvim/bundle/nginx.vim,/home/______/.config/nvim/bundle/phpactor,/home/______/.config/nvim/bundle/snippets,/home/______/.config/nvim/bundle/surround,/home/______/.config/nvim/bundle/tabname,/home/______/.config/nvim/bundle/tail-bundle,/home/______/.config/nvim/bundle/tmux.vim,/home/______/.config/nvim/bundle/ultisnips,/home/______/.config/nvim/bundle/vdebug,/home/______/.config/nvim/bundle/vim-airline,/home/______/.config/nvim/bundle/vim-airline-themes,/home/______/.config/nvim/bundle/vim-commentary,/home/______/.config/nvim/bundle/vim-dispatch,/home/______/.config/nvim/bundle/vim-gitgutter,/home/______/.config/nvim/bundle/vim-javascript,/home/______/.config/nvim/bundle/vim-markdown,/home/______/.config/nvim/bundle/vim-markdown-folding,/home/______/.config/nvim/bundle/vim-move,/home/______/.config/nvim/bundle/vim-pasta,/home/______/.config/nvim/bundle/vim-pathogen,/home/______/.config/nvim/bundle/vim-repeat,/home/______/.config/nvim/bundle/vim-rhubarb,/home/______/.config/nvim/bundle/vim-spacejam,/home/______/.config/nvim/bundle/vim-test,/home/______/.config/nvim/bundle/vim-tmux-focus-events,/home/______/.config/nvim/bundle/vim-toml,/home/______/.config/nvim/bundle/vim-twig,/home/______/.config/nvim/bundle/vim-unimpaired,/etc/xdg/nvim,/home/______/.local/share/nvim/site,/usr/local/share/nvim/site,/usr/share/nvim/site,/usr/share/nvim/runtime,/usr/share/nvim/runtime/pack/dist/opt/matchit,/usr/share/nvim/site/after,/usr/local/share/nvim/site/after,/home/______/.local/share/nvim/site/after,/etc/xdg/nvim/after,/home/______/.config/nvim/bundle/vim-markdown-folding/after,/home/______/.config/nvim/bundle/vim-javascript/after,/home/______/.config/nvim/bundle/ultisnips/after,/home/______/.config/nvim/bundle/______/after,/home/______/.config/nvim/after,/usr/share/doc/fzf/examples",
    "diagnostic": {
      "enable": true
    },
    "indexes": {
      "runtimepath": true,
      "gap": 100,
      "count": 3
    },
    "suggest": {
      "fromVimruntime": true,
      "fromRuntimepath": true
    }
  },
  "filetypes": [ "vim" ]
}

With this configuration I expected to see globals and functions available by autoloading from plugins in completion menu but none of them are present. I then suspect that the configuration is still incorrect.

@iamcco
Copy link
Owner

iamcco commented Oct 21, 2019

The log seems right. It need some time to index all your vim files in runtimepath.

@przepompownia
Copy link
Contributor Author

Long indexing is probably not the case. For elimination of such potential situation I restricted runtimepath to /home/______/.config/nvim/bundle/LanguageClient-neovim and still don't see any public function from its autoload. For example,

call LanguageClient#

with the cursor at the end of line, I expect debugInfo and other functions.
I added the following line at the end of the scan() body in parser.js:

log.info(vscode_uri_1.default.file(path_1.join(p, 'f')).toString());

and I get

"parser: file:///home/______/.config/nvim/bundle/LanguageClient-neovim/f"

among other scanned directories. This at least seems to confirm that "runtimepath" is passed correctly in the initial request ;).

Where the index is stored? Is it an in-memory instance only or has it persisted form to read at the next start of the server?

@przepompownia
Copy link
Contributor Author

From some hours I have one client-server connection. Indeed, most of autoloaded function are present in the suggestions list. The most of public functions defined in plugins is also visible. Some of plugins are still not invisible, although they are in runtimepath (and callable from the command line).

First, I would like to get detailed log about when each file is indexed and when indexing is complete. Next, why some function and variable names are still not suggested (it seems that whole plugin directories are ignored, e.g. vdebug). Both problems exceed the topic of this issue.

P.S. After reopening connection I noticed absence of many expected suggestions indexed previously. It suggests that there is no cached form of the index to initial use before slow reindexing.

@iamcco
Copy link
Owner

iamcco commented Oct 22, 2019

It must be something wrong, it can't take hours to index all plugins. It only take 1x-2x seconds to index 3x plugins with my macbook pro.

If it parser the plugin's file fail, it will not get the items from that plugin's file, and it does not have cache by now.

@iamcco
Copy link
Owner

iamcco commented Oct 22, 2019

@przepompownia
Copy link
Contributor Author

Thanks for info about VDebug before I worked out this.

I found (using "print debugging" as a typescript beginner) two bugs. The first is the cause of absence of my local plugin. The second is related to logging. I can sent separate pull requests to propose the fixes.

@masaeedu
Copy link

masaeedu commented Feb 3, 2020

@iamcco Does the plugin automatically use &rtp if no "runtimepath" option is provided? Is there a way to configure it to use this variable (so that I don't have to go adjust my coc-settings.json every time I install a new plugin)?

@iamcco
Copy link
Owner

iamcco commented Feb 3, 2020

@masaeedu The plugin will not use the &rtp if you don't set the runtimepath. There is no way use variable if you use coc-setting.json to config, but you can use vim to config read the coc wiki or docs. Or you can use https://github.com/iamcco/coc-vimlsp it will set those option automatically.

@masaeedu
Copy link

masaeedu commented Feb 3, 2020

@iamcco That's another thing; I am actually using that extension, but until I explicitly added that configuration block in coc-settings.json, the extension didn't work. I was under the impression that maybe this extension needs the language server to be explicitly configured.

@iamcco
Copy link
Owner

iamcco commented Feb 3, 2020

@masaeedu The extension do not need configured in coc-settings.json

@iddinev
Copy link

iddinev commented Oct 29, 2020

Anybody had any luck configuring the server under LanguageClient-neovim ? I've been trying to get it working under vim 8.2 for the past couple of days, but alas - I am still new to the whole LSP thing.
I can't seem to get the signature help working at all (I suspect the echodoc plugin that has to actually do it, but still..)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants