Coc.nvim: Server ccls failed to start: invalid params of initialize: array

Created on 9 Dec 2018  路  11Comments  路  Source: neoclide/coc.nvim

Result from CocInfo

## versions

vim version: NVIM v0.3.1
node version: v8.9.0
coc.nvim version: 0.0.38
term: xterm-256color
platform: linux

## Error messages

## Output channel: languageserver.ccls

## Output channel: languageserver.ccls-359ca090-fb76-11e8-aac2-83f76a79a3f3
[Trace - 00:49:35] Sending request 'shutdown - (1)'.
[Trace - 00:49:35] Received response 'shutdown - (1)' in 1ms.
No result returned.


[Trace - 00:49:35] Sending notification 'exit'.
No parameters provided.

Describe the bug
Opening a C++ file located in $HOME with the configured server with ccls results in initialization fail, opening a C++ file located somewhere else doesn't result in fail.
Note: An empty vertical split is opened when the error ocurs, and :CocInfo shows no error messages

To Reproduce

cd $HOME
nvim test.cpp

Screenshot
screenshot

Can't reproduce question

All 11 comments

You can't use ccls in home directory, there could be too many files to index.

You can't use ccls in home directory, there could be too many files to index.

That's interesting. I thought that for a moment, but I remember that I used to open files inside home directory with cquery + LanguageClient-neovim. If I combine cquery + coc.nvim, will it fail too?

You can't use ccls in home directory, there could be too many files to index.

That's interesting. I thought that for a moment, but I remember that I used to open files inside home directory with cquery + LanguageClient-neovim. If I combine cquery + coc.nvim, will it fail too?

I don't know, ccls could work for me in home directory, consider paste full output from ccls by add "trace.server": "verbose" to your configuration https://github.com/neoclide/coc.nvim/wiki/Debug-language-server#using-output-channel

It seems for some initialization option, the server expects an array but you passed it something different. ccls HEAD will report a better error message if you have a type error, e.g. "initializationOptions": { "cacheDirectory": 3 }

{"jsonrpc":"2.0","id":0,"error":{"code":-32602,"message":"invalid params of initialize: /initializationOptions/cacheDirectory is expected to be string"}}

Don't start ccls/cquery in the home directory, they will recursively list files and index all of them, you may get unwanted ~/.ccls-cache/**

This is coc-settings.json:

{
    "languageserver": {
        "ccls": {
            "command": "ccls",
            "trace.server": "verbose",
            "initializationOptions": {
                "cacheDirectory": "/tmp/ccls"
            },
            "filetypes": ["c", "cpp", "objc", "objcpp"]
        }
    }
}

As @MaskRay, the expected type should be string for cacheDirectory, with this config I can't still open ccls in home directory (aside from having an unwanted ~/.ccls-cache/**)

You should set rootPatterns for ccls.

I think wiki should be updated with that :)

@lans98 I've updated the wiki https://github.com/neoclide/coc.nvim/wiki/Language-servers#ccobjective-c, you need at least one of those in the tree for root resolve.

Documentation for project setup with ccls: https://github.com/MaskRay/ccls/wiki/Getting-started#project-setup.

If I recall correctly, in the past, I also got problems when a file/directory for root resolve wasn't present, one of the side-effects being the creation of <cwd>/.ccls-cache/**, but ccls states to give support even without any root file/dir. I simply use them all the time now.

FWIW, in Emacs lsp-mode + emacs-ccls, the approach I use is: there should be an explicit project root indicator (e.g. .git .ccls-root). Unless you did git init in your HOME, the language client will not start ccls at ~. Since .git is scanned bottom-up, (projectile-project-root) may think files in the subproject belong to the child workspace, which is not desired. In that case I touch .ccls-root. The reason I don't use .ccls is because .ccls can be hierarchical and is not a reliable bottom-up scanner.

Now "ignoredRootPaths": ["~"] can be used to ignore home as rootPath for specified language server, this could help to prevent server start in specified roots.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lanox picture lanox  路  3Comments

andys8 picture andys8  路  3Comments

aareman picture aareman  路  3Comments

cvlmtg picture cvlmtg  路  3Comments

svenstaro picture svenstaro  路  4Comments