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

LSP-clangd

by sublimelsp ST4 Trending

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

Details

Installs

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

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).