README.md

April 13, 2026 ยท View on GitHub

clangd

builds.sr.ht status

Requires Neovim 0.10+


Installation

Install this plugin using any plugin/package manager of your liking or see :h packages.


Configuration

Set up clangd via nvim-lspconfig / vim.lsp.config(), as usual.

You don't need to call require("clangd_extensions").setup() if you like the defaults:

require("clangd_extensions").setup({
    ast = {
        -- These are unicode, should be available in any font
        role_icons = {
            type = "๐Ÿ„ฃ",
            declaration = "๐Ÿ„“",
            expression = "๐Ÿ„”",
            statement = ";",
            specifier = "๐Ÿ„ข",
            ["template argument"] = "๐Ÿ†ƒ",
        },
        kind_icons = {
            Compound = "๐Ÿ„ฒ",
            Recovery = "๐Ÿ…",
            TranslationUnit = "๐Ÿ…„",
            PackExpansion = "๐Ÿ„ฟ",
            TemplateTypeParm = "๐Ÿ…ƒ",
            TemplateTemplateParm = "๐Ÿ…ƒ",
            TemplateParamObject = "๐Ÿ…ƒ",
        },
        --[[ These require codicons (https://github.com/microsoft/vscode-codicons)
            role_icons = {
                type = "๎ญฃ",
                declaration = "๎ชŒ",
                expression = "๎ฉฑ",
                specifier = "๎ฎ†",
                statement = "๎ช†",
                ["template argument"] = "๎ช’",
            },

            kind_icons = {
                Compound = "๎ช‹",
                Recovery = "๎ช‡",
                TranslationUnit = "๎ซฉ",
                PackExpansion = "๎ฉผ",
                TemplateTypeParm = "๎ช’",
                TemplateTemplateParm = "๎ช’",
                TemplateParamObject = "๎ช’",
            }, ]]

        highlights = {
            detail = "Comment",
        },
    },
    memory_usage = {
        border = "none",
    },
    symbol_info = {
        border = "none",
    },
})

Features

Switch Between Source / Header

Usage

:ClangdSwitchSourceHeader

View AST

You can fold nodes using zc and friends - the AST window has shiftwidth=2 and foldmethod=indent.

AST

Usage

:ClangdAST to view the ast with the current line as the range, :'<,'>ClangdAST with a visual selection to view the ast with the selected lines as range. See how ranges are handled at https://clangd.llvm.org/extensions#ast

Completion Scores

Usage with nvim-cmp:

local cmp = require "cmp"
cmp.setup {
    -- ... rest of your `nvim-cmp` setup ...
    sorting = {
        comparators = {
            cmp.config.compare.offset,
            cmp.config.compare.exact,
            cmp.config.compare.recently_used,
            require("clangd_extensions.cmp_scores"),
            cmp.config.compare.kind,
            cmp.config.compare.sort_text,
            cmp.config.compare.length,
            cmp.config.compare.order,
        },
    },
}

Symbol Info

Symbol_Info

Usage

:ClangdSymbolInfo with the cursor at the desired symbol.

Type Hierarchy

Type_Hierarchy

Usage

:ClangdTypeHierarchy with the cursor over the desired type or a symbol of that type. gd with the cursor over a type in a window to go to its definition.

Memory Usage

You can fold items using zc and friends - the memory usage window has shiftwidth=2 and foldmethod=indent.

Memory_Usage

Usage

:ClangdMemoryUsage. Preamble can be large so it is collapsed by default, to expand it use :ClangdMemoryUsage expand_preamble


Implementation status of extensions

  • Memory usage
  • AST
  • Symbol info request
  • Type hierarchy
  • Switch between source/header
  • File status (see lsp-status.nvim)
  • Compilation commands (can be specified in either vim.lsp.config() or nvim-lspconfig through init_options and settings respectively)
  • Code completion scores
  • Force diagnostics generation (not sure)