Skip to content

Commit

Permalink
Fix clangd command-line toggles cannot be set to false (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
LDAP authored Oct 2, 2023
1 parent 5e68ba1 commit 3f16a74
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 22 deletions.
16 changes: 8 additions & 8 deletions LSP-clangd.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@

// If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point.
// Such completions can insert scope qualifiers
"clangd.all-scopes-completion": false,
"clangd.all-scopes-completion": null,
// Index project code in the background and persist index on disk
"clangd.background-index": false,
"clangd.background-index": null,
// Thread priority for building the background index. The effect of this flag is OS-specific.
// One of "background", "low", "normal"
"clangd.background-index-priority": null,
// Enable clang-tidy diagnostics
"clangd.clang-tidy": false,
"clangd.clang-tidy": null,
// Granularity of code completion suggestions
// detailed: One completion item for each semantically distinct completion, with full type information
// bundled: Similar completion items (e.g. function overloads) are combined. Type information shown where possible
Expand All @@ -65,13 +65,13 @@
"clangd.fallback-style": null,
// When disabled, completions contain only parentheses for function calls.
// When enabled, completions also contain placeholders for method parameters
"clangd.function-arg-placeholders": false,
"clangd.function-arg-placeholders": null,
// Add #include directives when accepting code completions
// iwyu: Include what you use. Insert the owning header for top-level symbols, unless the header is already directly included or the symbol is forward-declared
// never: Never insert #include directives as part of code completion
"clangd.header-insertion": null,
// Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not
"clangd.header-insertion-decorators": false,
"clangd.header-insertion-decorators": null,
// Limit the number of references returned by clangd. 0 means no limit (default=1000)
"clangd.limit-references": null,
// Limit the number of results returned by clangd. 0 means no limit (default=100)
Expand All @@ -86,11 +86,11 @@
// Number of workers used for indexing and language server
"clangd.number-workers": null,
// Set to "true" to release memory periodically via malloc_trim(3)
"clangd.malloc-trim": false,
"clangd.malloc-trim": null,
// One of "disk", "memory". Storing PCHs in memory increases memory usages, but may improve performance
"clangd.pch-storage": null,
// Read user and project configuration from YAML files.
"clangd.enable-config": false,
"clangd.enable-config": null,

// clangd protocol and logging options:

Expand All @@ -100,6 +100,6 @@
// Comma separated list of '<client_path>=<server_path>' pairs, the first entry matching a given path is used. e.g. /home/project/incl=/opt/include,/home/project=/workarea/project
"clangd.path-mappings": null,
// Pretty-print JSON output
"clangd.pretty": false,
"clangd.pretty": null,
},
}
13 changes: 7 additions & 6 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,13 @@ def on_pre_start(
configuration.command = clangd_base_command.copy()

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):
if value is None:
continue # Use clangd default

if isinstance(value, bool):
value = str(value).lower()

if isinstance(value, str) or isinstance(value, int):
configuration.command.append("{key}={value}".format(key=get_argument_for_setting(key), value=value))
else:
raise TypeError("Type {} not supported for setting {}.".format(str(type(value)), key))
Expand Down
50 changes: 42 additions & 8 deletions sublime-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,19 @@
"description": "Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute."
},
"clangd.all-scopes-completion": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "If set to true, code completion will include index symbols that are not defined in the scopes (e.g. namespaces) visible from the code completion point."
},
"clangd.background-index": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Index project code in the background and persist index on disk."
},
"clangd.background-index-priority": {
Expand All @@ -92,7 +100,11 @@
]
},
"clangd.clang-tidy": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Enable clang-tidy diagnostics."
},
"clangd.completion-style": {
Expand Down Expand Up @@ -122,12 +134,18 @@
"description": "clang-format style to apply by default when no .clang-format file is found"
},
"clangd.function-arg-placeholders": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"enum": [
null,
true,
false
],
"enumDescriptions": [
"use clangd default",
"completions also contain placeholders for method parameters",
"completions contain only parentheses for function calls"
]
Expand All @@ -150,7 +168,11 @@
]
},
"clangd.header-insertion-decorators": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not"
},
"clangd.limit-references": {
Expand Down Expand Up @@ -196,7 +218,11 @@
"description": "Number of workers used for indexing and language server"
},
"clangd.malloc-trim": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Release memory periodically via malloc_trim(3)"
},
"clangd.pch-storage": {
Expand All @@ -213,7 +239,11 @@
]
},
"clangd.enable-config": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Read user and project configuration from YAML files."
},
"clangd.log": {
Expand All @@ -239,7 +269,11 @@
"description": "Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk)."
},
"clangd.pretty": {
"type": "boolean",
"type": [
"boolean",
"null"
],
"default": null,
"description": "Pretty-print JSON output"
}
},
Expand Down

0 comments on commit 3f16a74

Please sign in to comment.