Question: .vscode/settings.json not over-riding clangd settings
Did you check docs and existing issues?
- [X] I have read all the neoconf.nvim docs
- [X] I have searched the existing issues of neoconf.nvim
- [X] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
0.9.1
Operating system/version
Ubuntu 20.04
Describe the bug
I'm trying to use neoconf to pick up the custom clangd settings from our company provided .vscode/settings.json file at the root of our project directory.
I see that Neoconf show does show the custom clangd settings. I see something like this:
clangd = {
arguments = { "--malloc-trim", "--pretty", "--pch-storage=disk", "--background-index", "--compile-commands-dir=${workspaceFolder}", "-j=8", "-log=verbose" },
detectExtensionConflicts = true,
onConfigChanged = "restart",
path = "/path/to/company/provided/clangd",
restartAfterCrash = true
},
However Neoconf lsp just shows an empty directory:
* /path/to/root/.vscode/settings.json
```lua
vim.empty_dict()
I verified that neoconf is sourced before lspconfig by putting print statements.
Steps To Reproduce
-
Create a directory (say
/tmp/repro) -
Create a file
/tmp/repro/init.luawith contents as shown in the minimal repro box below -
Create a file
.vscode/settings.jsonwith contents below:
{
"clangd.detectExtensionConflicts": true,
"clangd.arguments": [
"--malloc-trim",
"--pretty",
"--pch-storage=disk",
"--background-index",
"--compile-commands-dir=${workspaceFolder}",
"-j=8",
"-log=verbose"
],
"clangd.restartAfterCrash": true,
"clangd.onConfigChanged": "restart",
"clangd.path": "/tmp/repro/tools/clangd",
}
-
You'll need to manually copy over a working
clangdinto thetoolssubdirectory. -
Now open neovim by doing
nvim -u init.lua foo.cpp
Expected Behavior
When the C++ file is opened, LspInfo should show the path to the clangd in the tools subdirectory. However, it will probably error out.
Repro
-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
-- allows for project specific settings for clangd etc.
-- Automatically picks up .vscode/settings.json etc.
"folke/neoconf.nvim",
config = function()
require('neoconf').setup()
end,
},
{
"neovim/nvim-lspconfig", -- enable LSP
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"folke/neoconf.nvim", -- neoconf needs to be setup before lspconfig
},
config = function()
local lspconfig = require('lspconfig')
-- lspconfig.clangd.setup({
-- cmd = { "/tmp/repro_neconf/proj/tools/clangd" }
-- })
lspconfig.clangd.setup({})
end
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
The problem is that for .neoconf.json the settings are specified as lspconfig[servername][key] = value, whereas in .vscode/settings.json they are in a form of [namespace][key] (not always, but most of the time).
The namespace can be the same as the server name (e.g. eslint, clangd), but not always (typescript. for tsserver).
The config options with namespaces are defined in language servers schemas (listed at the bottom of neoconf readme).
Vscode passes these these directly to settings field of the nameserver. (E.g. settings.clangd.restartAfterCrash).
If you define them in .neoconf.json, they will be passed as settings.restartAfterCrash because neoconf will treat clangd as server name and not part of the config option name.
For servers where the server name is the same as the namespace name, you can change this line in neoconf
- options.import.vscode and Settings.get_local(root_dir):get("vscode") or {},
+ options.import.vscode and Settings.get_local(root_dir):get("vscode." .. config.name) or {},
The problem arises for the stuff like tsserver. For some reason, neither tsserver, nor eslint ls want to accept settings options in a form of { settings = { eslint = { nodePath = "foo" } } }, even though this is what schema says.
@folke , do you know why this is happening? Apparently, the same servers accept it in vscode, but not in neovim via lspconfig. I am not sure where the problem lies exactly. I thought it was neoconf, but it may be lspconfig or neovim, or the servers themselves.
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.