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

ccls: remove inaccurate vscode client initialization options from docgen #70

Closed
cdelledonne opened this issue Dec 12, 2019 · 13 comments · Fixed by #546
Closed

ccls: remove inaccurate vscode client initialization options from docgen #70

cdelledonne opened this issue Dec 12, 2019 · 13 comments · Fixed by #546

Comments

@cdelledonne
Copy link

I'm having trouble figuring out how to specify initialization options for ccls (the only LSP server I've tested so far) using the settings key. Say I want ccls.cache.directory to be /tmp/ccls-cache, using a command switch I can achieve it like the following

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls',
        '--init={"cache": {"directory": "/tmp/ccls-cache"}}'
    };
}

That works. I'd like to be able to do the same using the settings key, but I can't. For instance, neither

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls'
    };
    settings = {
        ccls = {
            cache = {
                directory = "/tmp/ccls-cache";
            };
        };
    };
}

nor

local nvim_lsp = require 'nvim_lsp'
nvim_lsp.ccls.setup{
    cmd = {
        'ccls'
    };
    settings = {
        cache = {
            directory = "/tmp/ccls-cache";
        };
    };
}

work. Looking into ccls's log, the cache option is not even being sent to the server when initializing it.

Am I doing something wrong?

Environment

  • NVIM v0.5.0-233-g76d1e9360
@norcalli
Copy link

norcalli commented Dec 12, 2019

That would depend on whether it's "initialization options" or "workspace configuration." This is one of my least favorite parts of the LSP protocol, which is that there are many different ways to send initial configurations to the client:

  • Initialization options (initializationOptions sent via initialize) correspond to init_options in our system.
  • Workspace configuration (workspace/configuration and workspace/didChangeConfiguration) corresponds to settings in our system.

Without looking into it further, I'd double check which one ccls is expecting.

EDIT: Nvm I looked at our README and it does state that ccls.cache.directory should be a valid "setting". I'll look into it later.

@cdelledonne
Copy link
Author

Indeed using init_options works. I guess the same holds for other options listed under ccls which have to be sent via initialize.

A side question: there are three options under ccls.misc.<suboption>. Why is misc there? I believe ccls only expects <suboption>, rather than misc.<suboption> (e.g, compilationDatabaseDirectory).

@norcalli
Copy link

Those values are scraped directly from the package.json in the vscode extension. I guess that it's impossible to know if they are init_options or settings, but they are things that the ccls-project.ccls extension defines, so they are definitely real. I can't really say more than that.

@cdelledonne
Copy link
Author

Got it, thanks. Feel free to close the issue, but I feel the README is a little confusing.

@norcalli
Copy link

I'm going to leave it open as a reminder to improve the README :P

@wheelsandmetal
Copy link

I also found this confusing

This is what I thought the docs were telling me to do

nvim_lsp.ccls.setup{
  settings = {
    ccls = {
      misc = {     
	compilationDatabaseDirectory = "build"
      }
    }
  }
}

And this is what I actually needed

nvim_lsp.ccls.setup{
  init_options = {
	compilationDatabaseDirectory = "build"
  }
}

@mjlbach
Copy link
Contributor

mjlbach commented Jan 4, 2021

@cdelledonne Can you look at #528, I tried to make it clear the customization for ccls is all set via on_init. Many servers are inconsistent with whether configuration is done via settings/init options, so I think the best thing we can do is just have good documentation for each one.

@cdelledonne
Copy link
Author

@mjlbach the improved documentation with the example is a nice additions, thanks!

However, I can still see the following in CONFIG.md, is that outdated or am I missing something?

This server accepts configuration via the `settings` key.

@mjlbach
Copy link
Contributor

mjlbach commented Jan 5, 2021

Ah, you are correct. Docgen automatically adds that

'This server accepts configuration via the `settings` key.';

Not sure the best thing to do about that, it should probably be removed and manually added to each server.

Other than removing that, is there anything you would improve?

@mjlbach mjlbach changed the title Initialization options for ccls ignored ccls: remove mention of configuration via settings from docgen Jan 5, 2021
@cdelledonne
Copy link
Author

cdelledonne commented Jan 5, 2021

I do have one more question: the example shows how to set the compilationDatabaseDirectory

init_options = { 
    compilationDatabaseDirectory = "build";
    ...
}

but the list of options presents it as ccls.misc.compilationDatabaseDirectory. Why isn't the option set as follows?

init_options = { 
    misc = {
        compilationDatabaseDirectory = "build";
    };
    ...
}

Do all misc options fall directly under init_options?

@mjlbach
Copy link
Contributor

mjlbach commented Jan 5, 2021

Does that work for you? I might just remove the package.json for ccls.

I was going by the entry here which isn't nested under misc:
https://github.com/MaskRay/ccls/wiki/Customization#compilationdatabasedirectory

@mjlbach
Copy link
Contributor

mjlbach commented Jan 5, 2021

Oh, they remap misc.compilationDatabaseDirectory to compilationDatabaseDirectory when it's sent from the client (vscode-ccls) to the server (ccls) here: https://github.com/MaskRay/vscode-ccls/blob/456f21ebf3013abbc553442dd81610f1595310f5/src/serverContext.ts#L148-L155.

The documentation would be accurate if we were using the vscode client (which of course, we aren't), but we're scraping the settings from the vscode client which explains why the remapped settings are showing up in the documentation. I'm just going to remove them, because it seems like a common source of confusion.

@mjlbach mjlbach changed the title ccls: remove mention of configuration via settings from docgen ccls: remove mention of inaccurate vscode client initialization options from docgen Jan 5, 2021
@mjlbach mjlbach changed the title ccls: remove mention of inaccurate vscode client initialization options from docgen ccls: remove inaccurate vscode client initialization options from docgen Jan 5, 2021
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

Successfully merging a pull request may close this issue.

4 participants