├── .python-version ├── .gitignore ├── messages.json ├── .gitattributes ├── pyrightconfig.json ├── modules ├── version.py └── github_utils.py ├── LSP-clangd.sublime-commands ├── messages └── install.txt ├── Main.sublime-menu ├── LICENSE ├── README.md ├── LSP-clangd.sublime-settings ├── plugin.py └── sublime-package.json /.python-version: -------------------------------------------------------------------------------- 1 | 3.8 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/__pycache__ -------------------------------------------------------------------------------- /messages.json: -------------------------------------------------------------------------------- 1 | { 2 | "install": "messages/install.txt" 3 | } -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | .github/ export-ignore 2 | renovate.json export-ignore 3 | scripts/ export-ignore 4 | -------------------------------------------------------------------------------- /pyrightconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "pythonVersion": "3.11", 3 | "reportMissingModuleSource": "none", 4 | } 5 | -------------------------------------------------------------------------------- /modules/version.py: -------------------------------------------------------------------------------- 1 | # This file is auto-generated by ./scripts/update_version.py 2 | 3 | CLANGD_VERSION = (21, 1, 0) 4 | -------------------------------------------------------------------------------- /LSP-clangd.sublime-commands: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "caption": "Preferences: LSP-clangd Settings", 4 | "command": "edit_settings", 5 | "args": { 6 | "base_file": "${packages}/LSP-clangd/LSP-clangd.sublime-settings", 7 | "default": "// Settings in here override those in \"LSP-clangd/LSP-clangd.sublime-settings\"\n{\n\t$0\n}\n" 8 | } 9 | }, 10 | { 11 | "caption": "LSP-clangd: Switch to Source/Header", 12 | "command": "lsp_clangd_switch_source_header", 13 | }, 14 | ] -------------------------------------------------------------------------------- /messages/install.txt: -------------------------------------------------------------------------------- 1 | ## Installation 2 | - Install LSP and LSP-clangd from Package Control 3 | - Install clangd using your package manager or let this plugin install clangd for you 4 | 5 | ## Usage 6 | 7 | By default, clangd will assume your code is built as clang some_file.cc, and you’ll probably get errors about missing #included files, etc. 8 | 9 | For complex projects clangd needs to know your build flags. This can be done using a `compile_commands.json` or `compile_flags.txt` file. 10 | 11 | See https://clangd.llvm.org/installation#project-setup 12 | -------------------------------------------------------------------------------- /modules/github_utils.py: -------------------------------------------------------------------------------- 1 | import json 2 | import re 3 | import urllib.request 4 | from typing import Tuple 5 | 6 | GITHUB_RELEASE_API_URL = "https://api.github.com/repos/{repository}/releases/latest" 7 | 8 | 9 | def get_latest_release_tag(github_repo: str) -> str: 10 | """Returns the latest release tag for a Github repository 'username/reponame'. 11 | """ 12 | api_url = GITHUB_RELEASE_API_URL.format(repository=github_repo) 13 | with urllib.request.urlopen(api_url) as f: 14 | str_data = f.read().decode("utf-8") 15 | json_data = json.loads(str_data) 16 | return json_data["tag_name"] 17 | 18 | 19 | def get_latest_release_version(github_repo) -> Tuple[int, ...]: 20 | latest_tag = get_latest_release_tag(github_repo) 21 | return tuple(int(x) for x in re.findall(r"\d+", latest_tag)) 22 | -------------------------------------------------------------------------------- /Main.sublime-menu: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "id": "preferences", 4 | "children": [ 5 | { 6 | "caption": "Package Settings", 7 | "mnemonic": "P", 8 | "id": "package-settings", 9 | "children": [ 10 | { 11 | "caption": "LSP", 12 | "id": "lsp-settings", 13 | "children": [ 14 | { 15 | "caption": "Servers", 16 | "id": "lsp-servers", 17 | "children": [ 18 | { 19 | "caption": "LSP-clangd", 20 | "command": "edit_settings", 21 | "args": { 22 | "base_file": "${packages}/LSP-clangd/LSP-clangd.sublime-settings", 23 | "default": "// Settings in here override those in \"LSP-clangd/LSP-clangd.sublime-settings\"\n\n{\n\t$0\n}\n", 24 | } 25 | } 26 | ] 27 | } 28 | ] 29 | } 30 | ] 31 | } 32 | ] 33 | } 34 | ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 SublimeLSP 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LSP-clangd 2 | 3 | C/C++ and Objective-C/C++ support for Sublime's LSP plugin provided through clangd. 4 | 5 | ## Installation 6 | 7 | - Install [LSP](https://packagecontrol.io/packages/LSP) and `LSP-clangd` from Package Control 8 | - (Optional) Install clangd using your package manager or let this package install clangd for you 9 | 10 | ## Usage 11 | 12 | By default, clangd will assume your code is built as `clang some_file.cc`, and you’ll probably get errors about missing `#include`d files, etc. 13 | 14 | For complex projects, clangd needs to know your build flags. This can be done using a `compile_commands.json` or `compile_flags.txt` file. 15 | 16 | For CMake-based projects a `compile_commands.json` file can be generated using the `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` flag. 17 | 18 | ```bash 19 | cd build 20 | cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. 21 | # compile_commands.json will be written to your build directory. 22 | ``` 23 | 24 | If your build directory is equivalent to the root of the project or `/build` then clangd will find it. Otherwise, symlink or copy it to the root of your project. 25 | 26 | > See [clangd Project Setup](https://clangd.llvm.org/installation#project-setup) for more information on using `compile_commands.json`, `compile_flags.txt` and other build systems. 27 | 28 | ## Configuration 29 | 30 | Here are some ways to configure the package and the language server. 31 | 32 | - From `Preferences > Package Settings > LSP > Servers > LSP-clangd` 33 | - From the command palette: `Preferences: LSP-clangd Settings` 34 | - Project-specific configuration. 35 | From the command palette run `Project: Edit Project` and add your settings in: 36 | 37 | ```js 38 | { 39 | "settings": { 40 | "LSP": { 41 | "clangd": { 42 | "initializationOptions": { 43 | // Put your settings here eg. 44 | // "clangd.header-insertion": "iwyu", 45 | } 46 | } 47 | } 48 | } 49 | } 50 | ``` 51 | 52 | ## Sublime Commands 53 | 54 | | Sublime Command | Description | 55 | | ------------------------------- | ----------------------------------------------------------- | 56 | | `lsp_clangd_switch_source_header` | Switch between the main source file (.cpp) and header (.h). | 57 | -------------------------------------------------------------------------------- /LSP-clangd.sublime-settings: -------------------------------------------------------------------------------- 1 | { 2 | ///////////////////////// 3 | // LSP-clangd Settings // 4 | ///////////////////////// 5 | 6 | // The clangd binary to use. 7 | // "system": Prefers the system binary below 8 | // "auto": Prefers the system binary but falls back to GitHub without user intervention 9 | // "github": Prefers the latest tested release from GitHub 10 | // "custom": Use the custom command in the initializationOptions below 11 | "binary": "system", 12 | // The binary to use when `binary` is set to `system`. 13 | "system_binary": "clangd", 14 | // Generated internally because clangd is configured via command line arguments. 15 | // DO NOT CHANGE THIS, use `system_binary` or `custom_command` instead. 16 | "command": [], 17 | // Enable clangd for C/C++ and Objective-C/C++ 18 | "selector": "source.c | source.c++ | source.objc | source.objc++ | source.cuda-c++", 19 | // Makes the auto-complete not trigger twice when writing a -> or when writing :: 20 | "auto_complete_selector": "punctuation.accessor | (meta.preprocessor.include string - punctuation.definition.string.end)", 21 | "initializationOptions": { 22 | // A custom command to start clangd. Set `binary` to `custom` to use this command. 23 | // The command-line arguments which are generated from the `clang.*` settings are appended to this command. 24 | // This can be used for MSYS2's clangd for example. 25 | "custom_command": [], 26 | 27 | // @see https://clangd.llvm.org/extensions#file-status 28 | // Enables receiving textDocument/clangd.fileStatus notifications. 29 | // -- unsupported -- 30 | "clangdFileStatus": false, 31 | // @see https://clangd.llvm.org/extensions#compilation-commands 32 | // Controls the flags used when no specific compile command is found. 33 | // The compile command will be approximately clang $FILE $fallbackFlags in this case. 34 | "fallbackFlags": [], 35 | 36 | // clangd options. Set to null to keep the clangd default. 37 | // These options are converted to commandline options when clangd is startet. 38 | 39 | // clangd compilation flags options: 40 | 41 | // Specify a path to look for compile_commands.json. 42 | // If path is invalid, clangd will look in the current directory and parent paths of each source file 43 | "clangd.compile-commands-dir": null, 44 | // Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute. 45 | // Drivers matching any of these globs will be used to extract system includes. e.g. /usr/bin/**/clang-*,/path/to/repo/**/g++-* 46 | "clangd.query-driver": null, 47 | 48 | // clangd feature options: 49 | 50 | // 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. 51 | // Such completions can insert scope qualifiers 52 | "clangd.all-scopes-completion": null, 53 | // Index project code in the background and persist index on disk 54 | "clangd.background-index": null, 55 | // Thread priority for building the background index. The effect of this flag is OS-specific. 56 | // One of "background", "low", "normal" 57 | "clangd.background-index-priority": null, 58 | // Enable clang-tidy diagnostics 59 | "clangd.clang-tidy": null, 60 | // Granularity of code completion suggestions 61 | // detailed: One completion item for each semantically distinct completion, with full type information 62 | // bundled: Similar completion items (e.g. function overloads) are combined. Type information shown where possible 63 | "clangd.completion-style": null, 64 | // clang-format style to apply by default when no .clang-format file is found 65 | "clangd.fallback-style": null, 66 | // When disabled, completions contain only parentheses for function calls. 67 | // When enabled, completions also contain placeholders for method parameters 68 | "clangd.function-arg-placeholders": null, 69 | // Add #include directives when accepting code completions 70 | // 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 71 | // never: Never insert #include directives as part of code completion 72 | "clangd.header-insertion": null, 73 | // Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not 74 | "clangd.header-insertion-decorators": null, 75 | // Limit the number of references returned by clangd. 0 means no limit (default=1000) 76 | "clangd.limit-references": null, 77 | // Limit the number of results returned by clangd. 0 means no limit (default=100) 78 | "clangd.limit-results": null, 79 | // Path to the project root. Requires remote-index-address to be set 80 | "clangd.project-root": null, 81 | // Address of the remote index server 82 | "clangd.remote-index-address": null, 83 | 84 | // clangd miscellaneous options: 85 | 86 | // Number of workers used for indexing and language server 87 | "clangd.number-workers": null, 88 | // Set to "true" to release memory periodically via malloc_trim(3) 89 | "clangd.malloc-trim": null, 90 | // One of "disk", "memory". Storing PCHs in memory increases memory usages, but may improve performance 91 | "clangd.pch-storage": null, 92 | // Read user and project configuration from YAML files. 93 | "clangd.enable-config": null, 94 | 95 | // clangd protocol and logging options: 96 | 97 | // One of "error", "info", "verbose" 98 | "clangd.log": null, 99 | // Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk). 100 | // Comma separated list of '=' pairs, the first entry matching a given path is used. e.g. /home/project/incl=/opt/include,/home/project=/workarea/project 101 | "clangd.path-mappings": null, 102 | // Pretty-print JSON output 103 | "clangd.pretty": null, 104 | }, 105 | "experimental_capabilities": { 106 | "textDocument": { 107 | "completion": { 108 | "editsNearCursor": true 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /plugin.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import stat 4 | import sys 5 | import tempfile 6 | import zipfile 7 | from urllib.request import urlopen 8 | 9 | import sublime 10 | from LSP.plugin import ( 11 | AbstractPlugin, 12 | ClientConfig, 13 | LspTextCommand, 14 | Request, 15 | WorkspaceFolder, 16 | parse_uri, 17 | register_plugin, 18 | unregister_plugin, 19 | ) 20 | from LSP.plugin.core.typing import List, Optional 21 | from LSP.plugin.core.views import text_document_identifier 22 | 23 | # Fix reloading for submodules 24 | for m in list(sys.modules.keys()): 25 | if m.startswith(__package__ + ".") and m != __name__: 26 | del sys.modules[m] 27 | 28 | from .modules.version import CLANGD_VERSION # noqa: E402 29 | 30 | SESSION_NAME = "clangd" 31 | STORAGE_DIR = "LSP-clangd" 32 | SETTINGS_FILENAME = "LSP-clangd.sublime-settings" 33 | GITHUB_DL_URL = 'https://github.com/clangd/clangd/releases/download/'\ 34 | + '{release_tag}/clangd-{platform}-{release_tag}.zip' 35 | # Options under `initializationOptions` that are prefixed with this prefix 36 | # aren't really `initializationOptions` but get converted to command line arguments 37 | # when this plugin starts the server. 38 | CLANGD_SETTING_PREFIX = "clangd." 39 | CLANGD_SETTING_TO_ARGUMENT = { 40 | "number-workers": "-j" 41 | } 42 | VERSION_STRING = ".".join(str(s) for s in CLANGD_VERSION) 43 | 44 | 45 | def get_argument_for_setting(key: str) -> str: 46 | """ 47 | Returns the command argument for a `clangd.*` key. 48 | """ 49 | return CLANGD_SETTING_TO_ARGUMENT.get(key, "--" + key) 50 | 51 | 52 | def get_settings() -> sublime.Settings: 53 | return sublime.load_settings(SETTINGS_FILENAME) 54 | 55 | 56 | def save_settings() -> None: 57 | return sublime.save_settings(SETTINGS_FILENAME) 58 | 59 | 60 | def clangd_download_url(): 61 | platform = sublime.platform() 62 | if platform == "osx": 63 | platform = "mac" 64 | return GITHUB_DL_URL.format(release_tag=VERSION_STRING, platform=platform) 65 | 66 | 67 | def download_file(url: str, file: str) -> None: 68 | with urlopen(url) as response, open(file, "wb") as out_file: 69 | shutil.copyfileobj(response, out_file) 70 | 71 | 72 | def download_server(path: str): 73 | with tempfile.TemporaryDirectory() as tempdir: 74 | zip_path = os.path.join(tempdir, "server.zip") 75 | 76 | sublime.status_message("{}: Downloading server...".format(SESSION_NAME)) 77 | download_file(clangd_download_url(), zip_path) 78 | 79 | sublime.status_message("{}: Extracting server...".format(SESSION_NAME)) 80 | with zipfile.ZipFile(zip_path, "r") as zip_file: 81 | zip_file.extractall(tempdir) 82 | 83 | shutil.move(os.path.join(tempdir, "clangd_{version}".format(version=VERSION_STRING)), path) 84 | 85 | 86 | class Clangd(AbstractPlugin): 87 | @classmethod 88 | def name(cls) -> str: 89 | return SESSION_NAME 90 | 91 | @classmethod 92 | def storage_subpath(cls) -> str: 93 | return os.path.join(cls.storage_path(), STORAGE_DIR) 94 | 95 | @classmethod 96 | def managed_clangd_path(cls) -> Optional[str]: 97 | binary_name = "clangd.exe" if sublime.platform() == "windows" else "clangd" 98 | path = os.path.join(cls.storage_subpath(), "clangd_{version}/bin/{binary_name}".format(version=VERSION_STRING, binary_name=binary_name)) 99 | if os.path.exists(path): 100 | return path 101 | return None 102 | 103 | @classmethod 104 | def system_clangd_path(cls) -> Optional[str]: 105 | system_binary = get_settings().get("system_binary") 106 | # Detect if clangd is installed or the command points to a valid binary. 107 | # Fallback, shutil.which has issues on Windows. 108 | system_binary_path = shutil.which(system_binary) or system_binary 109 | if not os.path.isfile(system_binary_path): 110 | return None 111 | return system_binary_path 112 | 113 | @classmethod 114 | def clangd_path(cls) -> Optional[str]: 115 | """The command to start clangd without any configuration arguments""" 116 | binary_setting = get_settings().get("binary") 117 | if binary_setting == "system": 118 | return cls.system_clangd_path() 119 | elif binary_setting == "github": 120 | return cls.managed_clangd_path() 121 | else: 122 | # binary_setting == "auto": 123 | return cls.system_clangd_path() or cls.managed_clangd_path() 124 | 125 | @classmethod 126 | def needs_update_or_installation(cls) -> bool: 127 | if get_settings().get("binary") == "custom": 128 | return False 129 | return cls.clangd_path() is None 130 | 131 | @classmethod 132 | def install_or_update(cls) -> None: 133 | # Binary cannot be set to custom because needs_update_or_installation 134 | # returns False in this case 135 | if get_settings().get("binary") == "system": 136 | ans = sublime.yes_no_cancel_dialog("clangd was not found in your path. Would you like to auto-install clangd from GitHub?") 137 | if ans == sublime.DIALOG_YES: 138 | get_settings().set("binary", "auto") 139 | save_settings() 140 | else: # sublime.DIALOG_NO or sublime.DIALOG_CANCEL 141 | # dont raise explicitly here 142 | # server start fails in on_pre_start 143 | return 144 | 145 | # At this point clangd is not installed and 146 | # binary setting is "github" or "auto" -> perform installation 147 | 148 | if os.path.isdir(cls.storage_subpath()): 149 | shutil.rmtree(cls.storage_subpath()) 150 | os.makedirs(cls.storage_subpath()) 151 | download_server(cls.storage_subpath()) 152 | 153 | # zip does not preserve file mode 154 | path = cls.managed_clangd_path() 155 | if not path: 156 | # this should never happen 157 | raise ValueError("installation failed silently") 158 | st = os.stat(path) 159 | os.chmod(path, st.st_mode | stat.S_IEXEC) 160 | 161 | @classmethod 162 | def on_pre_start( 163 | cls, 164 | window: sublime.Window, 165 | initiating_view: sublime.View, 166 | workspace_folders: List[WorkspaceFolder], 167 | configuration: ClientConfig, 168 | ) -> Optional[str]: 169 | 170 | if get_settings().get("binary") == "custom": 171 | clangd_base_command = configuration.init_options.get("custom_command") # type: List[str] 172 | else: 173 | clangd_path = cls.clangd_path() 174 | if not clangd_path: 175 | raise ValueError("clangd is currently not installed.") 176 | clangd_base_command = [clangd_path] 177 | 178 | # The configuration is persisted 179 | # reset the command to prevent adding an argument multiple times 180 | configuration.command = clangd_base_command.copy() 181 | 182 | for key, value in configuration.init_options.get("clangd").items(): 183 | if value is None: 184 | continue # Use clangd default 185 | 186 | if isinstance(value, bool): 187 | value = str(value).lower() 188 | 189 | if isinstance(value, str) or isinstance(value, int): 190 | configuration.command.append("{key}={value}".format(key=get_argument_for_setting(key), value=value)) 191 | else: 192 | raise TypeError("Type {} not supported for setting {}.".format(str(type(value)), key)) 193 | return None 194 | 195 | 196 | class LspClangdSwitchSourceHeader(LspTextCommand): 197 | 198 | session_name = SESSION_NAME 199 | 200 | def run(self, edit): 201 | session = self.session_by_name(SESSION_NAME) 202 | if not session: 203 | return 204 | session.send_request( 205 | Request("textDocument/switchSourceHeader", text_document_identifier(self.view)), 206 | self.on_response_async, 207 | self.on_error_async, 208 | ) 209 | 210 | def on_response_async(self, response): 211 | if not response: 212 | sublime.status_message("{}: could not determine source/header".format(self.session_name)) 213 | return 214 | # session.open_uri_async(response) does currently not focus the view 215 | _, file_path = parse_uri(response) 216 | window = self.view.window() 217 | if not window: 218 | return 219 | window.open_file(file_path) 220 | 221 | def on_error_async(self, error): 222 | sublime.status_message("{}: could not switch to source/header: {}".format(self.session_name, error)) 223 | 224 | 225 | def plugin_loaded() -> None: 226 | register_plugin(Clangd) 227 | 228 | 229 | def plugin_unloaded() -> None: 230 | unregister_plugin(Clangd) 231 | -------------------------------------------------------------------------------- /sublime-package.json: -------------------------------------------------------------------------------- 1 | { 2 | "contributions": { 3 | "settings": [ 4 | { 5 | "file_patterns": [ 6 | "/LSP-clangd.sublime-settings" 7 | ], 8 | "schema": { 9 | "$id": "sublime://settings/LSP-clangd", 10 | "definitions": { 11 | "PluginConfig": { 12 | "properties": { 13 | "binary": { 14 | "type": "string", 15 | "default": "system", 16 | "description": "The clangd binary to use.", 17 | "enum": [ 18 | "system", 19 | "auto", 20 | "github", 21 | "custom" 22 | ], 23 | "enumDescriptions": [ 24 | "Prefers the system binary found in path", 25 | "Prefers the system binary but falls back to GitHub without user intervention", 26 | "Prefers the latest tested release from GitHub", 27 | "Use the custom command in the initializationOptions below", 28 | ], 29 | }, 30 | "system_binary": { 31 | "type": "string", 32 | "default": "clangd", 33 | "markdownDescription": "The binary to use when `binary` is set to `system`." 34 | }, 35 | "initializationOptions": { 36 | "additionalProperties": false, 37 | "properties": { 38 | "custom_command": { 39 | "type": "array", 40 | "default": [], 41 | "markdownDescription": "A custom command to start clangd. Set `binary` to `custom` to use this command. The command-line arguments which are generated from the `clang.*` settings are appended to this command." 42 | }, 43 | "clangdFileStatus": { 44 | "type": "boolean", 45 | "description": "Enables receiving textDocument/clangd.fileStatus notifications.", 46 | "enum": [ 47 | false 48 | ], 49 | "default": false, 50 | }, 51 | "fallbackFlags": { 52 | "type": "array", 53 | "default": [], 54 | "description": "Controls the flags used when no specific compile command is found. The compile command will be approximately clang $FILE $fallbackFlags in this case." 55 | }, 56 | "clangd.compile-commands-dir": { 57 | "type": [ 58 | "null", 59 | "string" 60 | ], 61 | "default": null, 62 | "description": "Specify a path to look for compile_commands.json. If path is invalid, clangd will look in the current directory and parent paths of each source file." 63 | }, 64 | "clangd.query-driver": { 65 | "type": [ 66 | "null", 67 | "string" 68 | ], 69 | "default": null, 70 | "description": "Comma separated list of globs for white-listing gcc-compatible drivers that are safe to execute." 71 | }, 72 | "clangd.all-scopes-completion": { 73 | "type": [ 74 | "boolean", 75 | "null" 76 | ], 77 | "default": null, 78 | "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." 79 | }, 80 | "clangd.background-index": { 81 | "type": [ 82 | "boolean", 83 | "null" 84 | ], 85 | "default": null, 86 | "description": "Index project code in the background and persist index on disk." 87 | }, 88 | "clangd.background-index-priority": { 89 | "type": [ 90 | "null", 91 | "string" 92 | ], 93 | "default": null, 94 | "description": "Thread priority for building the background index. The effect of this flag is OS-specific.", 95 | "enum": [ 96 | null, 97 | "background", 98 | "low", 99 | "normal" 100 | ] 101 | }, 102 | "clangd.clang-tidy": { 103 | "type": [ 104 | "boolean", 105 | "null" 106 | ], 107 | "default": null, 108 | "description": "Enable clang-tidy diagnostics." 109 | }, 110 | "clangd.completion-style": { 111 | "type": [ 112 | "null", 113 | "string" 114 | ], 115 | "default": null, 116 | "description": "Granularity of code completion suggestions", 117 | "enum": [ 118 | null, 119 | "detailed", 120 | "bundled" 121 | ], 122 | "enumDescriptions": [ 123 | "Use the clangd default", 124 | "One completion item for each semantically distinct completion, with full type information", 125 | "Similar completion items (e.g. function overloads) are combined. Type information shown where possible" 126 | ] 127 | }, 128 | "clangd.fallback-style": { 129 | "type": [ 130 | "null", 131 | "string" 132 | ], 133 | "default": null, 134 | "description": "clang-format style to apply by default when no .clang-format file is found" 135 | }, 136 | "clangd.function-arg-placeholders": { 137 | "type": [ 138 | "boolean", 139 | "null" 140 | ], 141 | "default": null, 142 | "enum": [ 143 | null, 144 | true, 145 | false 146 | ], 147 | "enumDescriptions": [ 148 | "use clangd default", 149 | "completions also contain placeholders for method parameters", 150 | "completions contain only parentheses for function calls" 151 | ] 152 | }, 153 | "clangd.header-insertion": { 154 | "type": [ 155 | "null", 156 | "string" 157 | ], 158 | "default": null, 159 | "enum": [ 160 | null, 161 | "iwyu", 162 | "never" 163 | ], 164 | "enumDescriptions": [ 165 | "Use the clangd default", 166 | "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", 167 | "Never insert #include directives as part of code completion" 168 | ] 169 | }, 170 | "clangd.header-insertion-decorators": { 171 | "type": [ 172 | "boolean", 173 | "null" 174 | ], 175 | "default": null, 176 | "description": "Prepend a circular dot or space before the completion label, depending on whether an include line will be inserted or not" 177 | }, 178 | "clangd.limit-references": { 179 | "type": [ 180 | "null", 181 | "integer" 182 | ], 183 | "default": null, 184 | "description": "Limit the number of references returned by clangd. 0 means no limit (clangd default=1000)", 185 | "minimum": 0 186 | }, 187 | "clangd.limit-results": { 188 | "type": [ 189 | "null", 190 | "integer" 191 | ], 192 | "default": null, 193 | "description": "Limit the number of results returned by clangd. 0 means no limit (clangd default=100)", 194 | "minimum": 0 195 | }, 196 | "clangd.project-root": { 197 | "type": [ 198 | "null", 199 | "string" 200 | ], 201 | "default": null, 202 | "description": "Path to the project root. Requires remote-index-address to be set" 203 | }, 204 | "clangd.remote-index-address": { 205 | "type": [ 206 | "null", 207 | "string" 208 | ], 209 | "default": null, 210 | "description": "Address of the remote index server" 211 | }, 212 | "clangd.number-workers": { 213 | "type": [ 214 | "null", 215 | "string" 216 | ], 217 | "default": null, 218 | "description": "Number of workers used for indexing and language server" 219 | }, 220 | "clangd.malloc-trim": { 221 | "type": [ 222 | "boolean", 223 | "null" 224 | ], 225 | "default": null, 226 | "description": "Release memory periodically via malloc_trim(3)" 227 | }, 228 | "clangd.pch-storage": { 229 | "type": [ 230 | "null", 231 | "string" 232 | ], 233 | "default": null, 234 | "description": "Sets the PCH storage. Storing PCHs in memory increases memory usages, but may improve performance", 235 | "enum": [ 236 | null, 237 | "disk", 238 | "memory" 239 | ] 240 | }, 241 | "clangd.enable-config": { 242 | "type": [ 243 | "boolean", 244 | "null" 245 | ], 246 | "default": null, 247 | "description": "Read user and project configuration from YAML files." 248 | }, 249 | "clangd.log": { 250 | "type": [ 251 | "null", 252 | "string" 253 | ], 254 | "default": null, 255 | "description": "Sets the clangd log level", 256 | "enum": [ 257 | null, 258 | "error", 259 | "info", 260 | "verbose" 261 | ] 262 | }, 263 | "clangd.path-mappings": { 264 | "type": [ 265 | "null", 266 | "string" 267 | ], 268 | "default": null, 269 | "description": "Translates between client paths (as seen by a remote editor) and server paths (where clangd sees files on disk)." 270 | }, 271 | "clangd.pretty": { 272 | "type": [ 273 | "boolean", 274 | "null" 275 | ], 276 | "default": null, 277 | "description": "Pretty-print JSON output" 278 | } 279 | }, 280 | } 281 | }, 282 | } 283 | }, 284 | "allOf": [ 285 | { 286 | "$ref": "sublime://settings/LSP-plugin-base" 287 | }, 288 | { 289 | "$ref": "sublime://settings/LSP-clangd#/definitions/PluginConfig" 290 | } 291 | ] 292 | } 293 | }, 294 | { 295 | "file_patterns": [ 296 | "/*.sublime-project" 297 | ], 298 | "schema": { 299 | "properties": { 300 | "settings": { 301 | "properties": { 302 | "LSP": { 303 | "properties": { 304 | "clangd": { 305 | "$ref": "sublime://settings/LSP-clangd#/definitions/PluginConfig" 306 | } 307 | } 308 | } 309 | } 310 | } 311 | } 312 | } 313 | } 314 | ] 315 | } 316 | } 317 | --------------------------------------------------------------------------------