ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

LSP-clangd

by sublimelsp ST4

C/C++ support for Sublime's LSP plugin provided through clangd.

Details

Installs

  • Total 6K
  • Win 3K
  • Mac 1K
  • Linux 2K
Sep 28 Sep 27 Sep 26 Sep 25 Sep 24 Sep 23 Sep 22 Sep 21 Sep 20 Sep 19 Sep 18 Sep 17 Sep 16 Sep 15 Sep 14 Sep 13 Sep 12 Sep 11 Sep 10 Sep 9 Sep 8 Sep 7 Sep 6 Sep 5 Sep 4 Sep 3 Sep 2 Sep 1 Aug 31 Aug 30 Aug 29 Aug 28 Aug 27 Aug 26 Aug 25 Aug 24 Aug 23 Aug 22 Aug 21 Aug 20 Aug 19 Aug 18 Aug 17 Aug 16 Aug 15 Aug 14
Windows 7 7 11 15 7 12 11 16 8 14 7 13 6 11 8 10 7 14 9 15 11 12 10 7 11 6 16 10 6 10 10 6 8 11 7 11 5 9 5 8 8 6 9 11 7 17
Mac 7 6 5 6 1 8 3 2 5 2 1 3 3 2 3 3 1 4 3 2 2 4 3 2 5 5 0 1 5 5 0 3 2 1 0 5 5 3 4 2 9 5 3 1 3 4
Linux 2 7 10 9 3 7 8 14 8 9 10 12 16 7 8 10 8 14 5 8 10 10 8 9 12 9 5 10 8 8 13 8 7 8 9 14 7 4 5 8 10 9 11 8 10 7

Readme

Source
raw.​githubusercontent.​com

LSP-clangd

C/C++ and Objective-C/C++ support for Sublime's LSP plugin provided through clangd.

Installation

  • Install LSP and LSP-clangd from Package Control
  • (Optional) Install clangd using your package manager or let this package install clangd for you

Usage

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.

For complex projects, clangd needs to know your build flags. This can be done using a compile_commands.json or compile_flags.txt file.

For CMake-based projects a compile_commands.json file can be generated using the -DCMAKE_EXPORT_COMPILE_COMMANDS=1 flag.

cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
# compile_commands.json will be written to your build directory.

If your build directory is equivalent to the root of the project or <project_root>/build then clangd will find it. Otherwise, symlink or copy it to the root of your project.

See clangd Project Setup for more information on using compile_commands.json, compile_flags.txt and other build systems.

Configuration

Here are some ways to configure the package and the language server.

  • From Preferences > Package Settings > LSP > Servers > LSP-clangd
  • From the command palette: Preferences: LSP-clangd Settings
  • Project-specific configuration. From the command palette run Project: Edit Project and add your settings in:
{
     "settings": {
        "LSP": {
           "clangd": {
              "initializationOptions": {
                // Put your settings here eg.
                // "clangd.header-insertion": "iwyu",
              }
           }
        }
     }
  }

Sublime Commands

Sublime Command Description
lsp_clangd_switch_source_header Switch between the main source file (.cpp) and header (.h).