nvim: fix startup errors, add language + project-run support
Startup errors:
- catppuccin: the bufferline integration moved to catppuccin.special.bufferline
- lspconfig-extended: drop the removed LazyVim keymaps API for
opts.servers["*"].keys, and move remove-workspace-folder to <leader>clR
so it stops colliding with LspRestart on <leader>clr
- options: lazyvim_cmp = "blink" is not a valid value, it is "blink.cmp"
Language support (python, c/cpp, rust, zephyr, and the common ones) via
lazyvim.json extras: dap.core, clangd, cmake, docker, git, json, rust,
toml, yaml.
- lang/zephyr.lua: gated entirely on ZEPHYR_BASE / ZEPHYR_SDK_INSTALL_DIR /
GNUARMEMB_TOOLCHAIN_PATH, returning {} when none are set, so it is inert
on machines without Zephyr. Nothing is hardcoded: the clangd
--query-driver globs are built from those vars, falling back to resolving
the cross-gcc through exepath()+fs_realpath(). Adds devicetree/kconfig
treesitter and filetypes (*.overlay, Kconfig.*, prj.conf, *_defconfig).
- clangd/config.yaml: strip the GCC-only flags Zephyr emits into
compile_commands.json (-fno-printf-return-value, -mfp16-format=*, ...),
which clang rejects as "Unknown argument". Remove only drops flags that
are present, so it is a no-op for native builds. Takes a built Zephyr app
from 15 diagnostics to 0, with CONFIG_* resolving into the generated
autoconf.h.
- npm-servers.lua: npm is not installed here, so yaml/docker servers failed
to install on every startup and to spawn on every matching file. Sets
both enabled = false and mason = false for servers whose binary is
missing from PATH and from mason/bin.
Project runner under <leader>R (<leader>r is refactoring), dispatching on
the detected project type -- zephyr, rust, python, cmake, make:
Rr run project Rb build Rt test RF build+flash Rf run file
Rk configure Rc clean Rs select target/board Ri info
Zephyr boards are picked with vim.ui.select over `west boards`, cached per
scan and persisted per project root under stdpath("state"), never written
into the project. A build with no board set prompts first, then proceeds.
Detection walks up from the last real file buffer, tracked by an autocmd,
because a terminal opened by one of these verbs would otherwise become the
buffer detection ran from.
Also <leader>b1..b9/b0 jump to buffer N (ordinal, no longer skipping the
current one) and <leader>b<Left>/<Right> cycle.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StGBghPW9Dm7z7uj2VNWHr
This commit is contained in:
60
nvim/lua/plugins/npm-servers.lua
Normal file
60
nvim/lua/plugins/npm-servers.lua
Normal file
@@ -0,0 +1,60 @@
|
||||
-- Some language servers are distributed only as npm packages, and Node on Arch
|
||||
-- ships without npm. Without this guard you get two separate rounds of errors:
|
||||
--
|
||||
-- 1. mason-lspconfig retries the install on every startup and fails, once per
|
||||
-- server ("failed to install yamlls" ...).
|
||||
-- 2. LazyVim still enables the server, so opening any matching file fails with
|
||||
-- "Spawning language server with cmd: { "yaml-language-server", ... } failed".
|
||||
--
|
||||
-- So each server below is disabled unless its binary can actually be found.
|
||||
-- Nothing is hardcoded to this host: the check is a PATH lookup plus Mason's own
|
||||
-- bin directory, so the moment the server exists it enables itself again.
|
||||
--
|
||||
-- To get them: sudo pacman -S npm
|
||||
-- nvim +"MasonInstall yaml-language-server dockerfile-language-server" +qa
|
||||
|
||||
-- LazyVim server name -> the executable Mason/npm installs for it.
|
||||
local npm_servers = {
|
||||
yamlls = "yaml-language-server",
|
||||
dockerls = "docker-langserver",
|
||||
docker_compose_language_service = "docker-compose-langserver",
|
||||
}
|
||||
|
||||
local mason_bin = vim.fs.joinpath(vim.fn.stdpath("data"), "mason", "bin")
|
||||
|
||||
---@param bin string
|
||||
---@return boolean
|
||||
local function available(bin)
|
||||
if vim.fn.executable(bin) == 1 then
|
||||
return true
|
||||
end
|
||||
-- Mason prepends its bin dir to PATH only after setup, so look there directly.
|
||||
return vim.uv.fs_stat(vim.fs.joinpath(mason_bin, bin)) ~= nil
|
||||
end
|
||||
|
||||
local missing = {}
|
||||
for server, bin in pairs(npm_servers) do
|
||||
if not available(bin) then
|
||||
missing[#missing + 1] = server
|
||||
end
|
||||
end
|
||||
|
||||
if #missing == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function(_, opts)
|
||||
opts.servers = opts.servers or {}
|
||||
for _, server in ipairs(missing) do
|
||||
opts.servers[server] = vim.tbl_deep_extend("force", opts.servers[server] or {}, {
|
||||
enabled = false, -- do not try to spawn a binary that is not there
|
||||
mason = false, -- and do not retry the impossible install every startup
|
||||
})
|
||||
end
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user