Closed quebin31 closed 5 years ago
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 combinecquery
+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.
I'm getting the same problem even though I'm using the default setups provided in the docs
{
"languageserver": {
"ccls": {
"command": "ccls",
"filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"],
"rootPatterns": [".ccls", "compile_commands.json", ".git/", ".hg/"],
"initializationOptions": {
"cache": {
"directory": "/tmp/ccls"
}
}
}
}
}
@AhmadFudl clangd, or coc-clangd is recommended.
This seems like a bug that might be related, but you see the error
Error: invalid params of initialize: expected array for /workspaceFolders
If the root directory is a name like "3DGs.cpp" which is the name of the project in my case.
It's an absurd corner-case (I've never known many projects to call themselves something like A.cpp, and hence result in directory files such as A.cpp
as the root dir.)
Not sure if its worth fixing, but if anyone comes across this issue in the future, its a simple fix: rename the root dir.
Given that ccls
is sensitive to the name of the root directory, I imagine there are other cases possible that result in similar errors, so the fix would be:
Rename your root dir to something reasonable (not dots, no file extensions in the name of the root dir.)
Result from CocInfo
Describe the bug Opening a C++ file located in
$HOME
with the configured server withccls
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 messagesTo Reproduce
Screenshot