p00f / clangd_extensions.nvim

Clangd's off-spec features for neovim's LSP client. Use https://sr.ht/~p00f/clangd_extensions.nvim instead
MIT License
448 stars 16 forks source link

Not clear how to set up after new update #49

Closed ismasou closed 10 months ago

ismasou commented 10 months ago

After the new update, my older setup using nvim-lspconfig is not working. I use lazy.nvim and add a lsp to nvim-lspconfig named clangd:

        setup = {
                clangd = function(_, opts)
                    opts.capabilities.documentFormattingProvider = false
                    require("clangd_extensions").setup({
                        server = {
                            cmd = { "clangd",
                                "--background-index",
                                "--completion-style=detailed",
                                "--header-insertion=iwyu",
                                "--suggest-missing-includes",
                                "--cross-file-rename",
                                "--offset-encoding=utf-16",
                            },
                            init_options = {
                                clangdFileStatus = true,
                                usePlaceholders = true,
                                completeUnimported = true,
                                semanticHighlighting = true,
                            },
                        },
                        extensions = {
                            autoSetHints = true,
                            ast = {
                                --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 = "",
                                },
                            },
                        },
                    })

                    vim.keymap.set("n", "gh", "<cmd>ClangdSwitchSourceHeader<CR>",
                        { silent = true, desc = "Switch between header and source" })
                    return opts
                end
                }

Can you please clarify how one should do the setup now?

p00f commented 10 months ago

https://github.com/p00f/clangd_extensions.nvim#configuration

Just use lspconfig or vim.lsp.start like your other servers, instead of the server key in clang-extensions setup