~p00f/clangd_extensions.nvim

Clangd's off-spec features for neovim's LSP client
remove inlay hints (neovim 0.10 is old enough)
8f7b7210 — Victor Bogado da Silva Lins 4 months ago
Fix issue with inlay_hints when text is a `table` (#67)
385a44f1 — Kenneth Jefferson 5 months ago
Format with stylua, drop deprecated functions entirely, fix `vim.highlight.range()` args, etc. (#64)

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~p00f/clangd_extensions.nvim
read/write
git@git.sr.ht:~p00f/clangd_extensions.nvim

You can also use your local clone with git send-email.

clangd

Requires Neovim 0.7+

#Installation

Install this plugin using any plugin/package manager or see :h packages

#Configuration:

Set up clangd via lspconfig/vim.lsp.start, 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

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

#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: For nvim-cmp

local cmp = require "cmp"
cmp.setup {
    -- ... rest of your 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

image

#Usage

:ClangdSymbolInfo with the cursor at the desired symbol.

#Type hierarchy

image

#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. image

#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 vim.lsp.start()/lspconfig init_options and settings)

☑️ Code completion scores

⬜ Force diagnostics generation (not sure)

Do not follow this link