sublimelsp / LSP-clangd

C/C++ support for Sublime's LSP plugin provided through clangd.
MIT License
42 stars 1 forks source link

Incorrect command line options #16

Closed esoterix closed 11 months ago

esoterix commented 1 year ago

clangd defines some command line options with type llvm::opt<bool>. The default value can be either true or false. To specify that such an option should be set to false, you would pass --option-name=false on the command line [1].

The relevant code for this issue is in plugin.py on_pre_start:

        for key, value in configuration.init_options.get("clangd").items():
            if not value:
                # False or None
                continue
            elif value is True:
                configuration.command.append(get_argument_for_setting(key))
            elif isinstance(value, str) or isinstance(value, int):
                configuration.command.append("{key}={value}".format(key=get_argument_for_setting(key), value=value))

Any LSP-clangd option that is set to false or zero is skipped. In clangd, --all-scopes-completion defaults to true [2]. I would expect that configuring the LSP-clangd option using "clangd.all-scopes-completion": false would set the option to false, but since the option is skipped, clangd ends up using the default value of true.

This also applies to other options such as malloc-trim, background-index, enable-config, and function-arg-placeholders.

[1] https://llvm.org/docs/CommandLine.html#boolean-arguments [2] https://github.com/llvm/llvm-project/blob/042dd99484d6f393cc8a365def250e9d74c24d37/clang-tools-extra/clangd/tool/ClangdMain.cpp#L146

kultlv commented 11 months ago

Esotk fix cheat pls

rchl commented 11 months ago

Wouldn't it work to just quote the value: "clangd.all-scopes-completion": "false" ? I suppose the LSP-json will complain until schema is updated but that won't stop it from working.

LDAP commented 11 months ago

I am looking into this next weekend.

LDAP commented 11 months ago

Should be fixed in #19