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.

Labels lsp, c++

Details

Installs

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

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