# clangd_extensions.nvim: the clangd extension commands Neovim does not expose

> clangd_extensions.nvim is a Lua plugin that surfaces clangd's non-standard extension commands in Neovim, covering AST dumps, symbol info, type hierarchy, memory usage, source and header switching and completion scores. It suits a C or C++ developer who already runs clangd and wants the extra views, and the GitHub copy is no longer where the work happens.

**dchinmay2/clangd_extensions.nvim** — Clangd's off-spec features for neovim's LSP client. Use https://sr.ht/~chinmay/clangd_extensions.nvim instead

- Repository: https://github.com/dchinmay2/clangd_extensions.nvim
- Stars: 589 · Forks: 18
- Language: Lua
- License: MIT
- Published: 2026-10-22 · Updated: 2026-10-22 · Language: en
- Canonical page: https://hysenlabs.com/projects/dchinmay2-clangd-extensions-nvim

## The GitHub copy is a redirect, not where the work happens

The project description is unusually direct about this. It says the plugin provides clangd's off-spec features for Neovim's LSP client, and then it tells you to use a sourcehut URL instead. The build badge in the readme also points at builds.sr.ht under a chinmay user rather than at a GitHub Actions workflow, and the repository has a.build.yml file at the top level, which is the configuration sourcehut's build service expects. The tree itself is small and tells you what kind of project this is. There is a lua directory for the plugin code, a plugin directory for the file Neovim loads automatically, a stylua.toml for formatting, a flake.nix and flake.lock for a Nix development environment, an.emmyrc.json for the EmmyLua language server, and a.envrc for direnv. The licence is MIT. The last push to this repository was on 2026-04-13, and there are no GitHub releases attached.

## Neovim 0.10 is the floor, and the setup call is optional

The requirement line is short and precise: Neovim 0.10 or newer. Installation goes through any plugin or package manager you like, or you can read the packages help topic that Neovim ships, which the readme links directly. Configuration follows the usual clangd path, so you set up clangd through nvim-lspconfig or vim.lsp.config as normal and this plugin sits on top of that rather than replacing it. The one piece of configuration you might expect to be mandatory is not. The readme says you do not need to call the setup function at all if you like the defaults, which is a design choice that keeps the plugin usable with zero configuration and leaves the setup call for the handful of things worth changing, which are the AST icons, the highlight of detail nodes, and the borders on the memory usage and symbol info windows.

```lua
require("clangd_extensions").setup({
    memory_usage = {
        border = "none",
    },
    symbol_info = {
        border = "none",
    },
})
```

The defaults for the AST window set icons for the roles a node can play and the kinds a node can have, and a commented out block in the same configuration shows an alternative set that requires the codicons font instead, which is a detail worth knowing if you are using a patched Nerd Font or the Microsoft codicons set.

## The AST window and the memory usage report are two float windows

Two of the commands open scrollable windows with their own folding setup, and the readme is specific about it. The AST window has shiftwidth of 2 and foldmethod set to indent, so you can fold nodes with the zc family of commands, and the memory usage window has the same two settings. The AST command is :ClangdAST, which views the AST for the current line as the range, and with a visual selection, :'<,'>ClangdAST uses the selected lines as the range. The readme points at the clangd extensions documentation for how ranges are handled, which is a fair division of labour since the range semantics belong to clangd. The memory usage command is :ClangdMemoryUsage, and it has one quirk worth knowing: the preamble can be large, so it is collapsed by default, and to expand it you pass the argument expand_preamble, giving :ClangdMemoryUsage expand_preamble. A window that opens with a wall of preprocessor output is not a useful default, so collapsing it is the sensible choice.

## Symbol info and type hierarchy cover the two questions the LSP leaves open

The other two window commands are smaller and quicker. Symbol info is :ClangdSymbolInfo with the cursor at the symbol you want described, and it is a request against clangd's symbol info extension, which answers questions about a symbol that the standard LSP does not carry. Type hierarchy is :ClangdTypeHierarchy with the cursor over the type or over a symbol of that type, and the readme adds a second detail that is easy to miss: gd with the cursor over a type in the window goes to its definition, so the hierarchy window is not just a display, it is a navigation surface. The fifth command is the simplest of the set, :ClangdSwitchSourceHeader, which toggles between a source file and its header, and the linked clangd documentation describes it as a switch between source and header. Together these five commands are the whole feature list, and each one maps to a named extension in the clangd documentation rather than to a general purpose wrapper.

## Completion scores reorder nvim-cmp by what clangd thinks

The one feature that touches your editing rather than a floating window is completion scores, and it integrates with nvim-cmp rather than replacing it. The comparator is added to the sorting list of your existing nvim-cmp setup, and the readme shows the position it occupies, between the recently used comparator and the kind comparator.

```lua
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,
        },
    },
}
```

The mechanism is that clangd scores its completions, and this comparator uses that score to reorder the list, so the item clangd considered most likely appears above ones that merely share a prefix. The placement in the chain matters, because the comparators are tried in order, so putting the score comparator after the exact match comparator means a prefix match can still win over a scored item, which is usually what you want when you have typed a complete identifier.

## The implementation status list is honest about what is missing

The readme ends with a checklist against the clangd extensions documentation, and it is worth reading because it tells you the ceiling of the plugin. Memory usage, AST, symbol info request, type hierarchy and switch between source and header are all marked as done, and so are file status and compilation commands. File status is noted as visible through a separate plugin, lsp-status.nvim, and compilation commands can be specified either in vim.lsp.config or in nvim-lspconfig through init_options and settings respectively, which is a useful detail for anyone who has been trying to work out where that setting lives. Code completion scores are also marked done. The one entry that is not is force diagnostics generation, with the note not sure. So the plugin covers most of the extension surface, and the gap is a single item, but it is the one you might reach for when a diagnostic does not appear and you want to force it.

## Conclusion

clangd_extensions.nvim fits a C or C++ developer who already has clangd wired into Neovim and wants the off-specification views, since the AST window, the memory usage report and the type hierarchy are the kind of information that is otherwise awkward to get. It does not fit a Lua developer on a Neovim older than 0.10, and it does not suit anyone who intends to follow the project on GitHub, because the project description points at a sourcehut repository as the place to use instead. Before you install it, read the project description and switch to the sourcehut repository, keep your clangd configuration through nvim-lspconfig or vim.lsp.config as usual, and check the implementation status list, where forcing diagnostic generation is still marked as not done.

## FAQ

### What is clangd_extensions.nvim and what does it add to Neovim?

It is a Lua plugin that surfaces clangd's off-specification extension commands in Neovim's LSP client, covering AST viewing, symbol info, type hierarchy, memory usage, switching between source and header, and completion scores.

### What are the requirements for clangd_extensions.nvim?

Neovim 0.10 or newer. You install it with any plugin or package manager, and you set up clangd through nvim-lspconfig or vim.lsp.config as usual. You do not need to call the setup function if you are happy with the defaults.

### Which commands does clangd_extensions.nvim provide?

ClangdSwitchSourceHeader, ClangdAST, ClangdSymbolInfo, ClangdTypeHierarchy and ClangdMemoryUsage. The AST and memory usage windows can be folded with the zc commands, and the memory usage preamble is collapsed by default unless you pass expand_preamble.

### How does clangd_extensions.nvim integrate with nvim-cmp?

It ships a comparator, require("clangd_extensions.cmp_scores"), that you add to the sorting comparators in your nvim-cmp setup, positioned between the recently used comparator and the kind comparator, so completions are ordered using the score clangd assigned them.

### Where should I get clangd_extensions.nvim from?

The project description points at a sourcehut repository, https://sr.ht/~chinmay/clangd_extensions.nvim, as the place to use instead of this GitHub copy, and the build badge also points at builds.sr.ht.

## Sources

- [dchinmay2/clangd_extensions.nvim on GitHub](https://github.com/dchinmay2/clangd_extensions.nvim)
- [Issues](https://github.com/dchinmay2/clangd_extensions.nvim/issues)
- [License: MIT](https://github.com/dchinmay2/clangd_extensions.nvim/blob/main/LICENSE)
- [README](https://github.com/dchinmay2/clangd_extensions.nvim/blob/main/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/dchinmay2-clangd-extensions-nvim
