Closed max397574 closed 2 years ago
was a problem with my config
I got the same problem, the config.options.server.on_attach
never gets called. And thed cmd
field load correctly.
Any suggestions?
This is my config:
function M.setup(opts)
opts.cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--fallback-style=llvm",
"--all-scopes-completion",
"--completion-style=detailed",
"--header-insertion=iwyu",
"--header-insertion-decorators",
"--pch-storage=memory",
"--inlay-hints",
}
require('clangd_extensions').setup({
server = opts,
})
end
are you calling M.setup with an actual table
are you calling M.setup with an actual table
Yes, I did that. The clangd_extensions.setup
function got be called, but the new on_attach
function does not be called.
what is inside opts
? what happens when you add print(vim.inspect(opts))
just before require('clangd_extensions').setup({...})
? Is the output the same as what you expected?
what is inside
opts
? what happens when you addprint(vim.inspect(opts))
just beforerequire('clangd_extensions').setup({...})
? Is the output the same as what you expected?
The opts
does not have any problem. Finlly, I did it with the next config:
-- clangd
--
local cmds = {
"clangd",
"--background-index",
"--clang-tidy",
"--fallback-style=llvm",
"--all-scopes-completion",
"--completion-style=detailed",
"--header-insertion=iwyu",
"--header-insertion-decorators",
"--pch-storage=memory",
"--inlay-hints",
}
local function on_attach(client, bufnr)
require('../plugins/lspconfig').on_attach(client, bufnr)
require('clangd_extensions').setup({
server = {
cmd = cmds
}
})
end
local config = {
on_attach = on_attach,
cmd = cmds,
}
return {
config = function(_) return config end,
}
Firstly, I called require('lspconfig').clangd.setup(opts)
.
Then, I got on_attach
called above.
Finlly, I setup clangd_extensions
.
That works!!!
But I setup clangd_extensions
directly still NOT work.
It's strange. And I have no idea about that.
I have a custom on_attach function I use it like this:
but the on_attach function never gets called
EDIT: after debugging this a little bit I found the problem for me
config.options.server
is a table inside a table. But it should only be a table I don't know if this is an error in the code or just a problem with my config.