From 6c16b57f3b5914c7cde33811b8bb41a3dee1a036 Mon Sep 17 00:00:00 2001 From: aloslider <53711835+aloslider@users.noreply.github.com> Date: Tue, 21 Apr 2026 03:42:54 +0300 Subject: [PATCH] [nvim] Switch from Mason to Chezmoi --- .chezmoidata/packages.yaml | 2 + .chezmoiexternals/nvim.toml | 10 ++++ .../run_once_before_11-set-zsh.sh.tmpl | 2 +- .../run_once_install-neovim.sh.tmpl | 2 +- ... run_onchange_10_install-packages.sh.tmpl} | 18 ++++--- .../run_onchange_11_install-neovim-tools.tmpl | 18 +++++++ ...n_onchange_before_10-setup-age-key.sh.tmpl | 3 +- .netcoredbg_hist | 2 + dot_config/nvim/benq/init.lua | 27 +++------- dot_config/nvim/benq/lsp/lua_ls.lua | 9 ---- dot_config/nvim/benq/lsp/vtsls.lua | 54 ------------------- .../nvim/benq/lua/config/diagnostics.lua | 18 +++++++ dot_config/nvim/benq/lua/config/lsp.lua | 6 +++ .../language-specific/dotnet/debugging.lua | 3 +- .../nvim/benq/lua/plugins/lsp/mason.lua | 38 ------------- .../benq/lua/plugins/lsp/nvim-lspconfig.lua | 3 ++ .../nvim/benq/lua/plugins/lsp/roslyn.lua | 6 --- .../bin/symlink_lua-language-server.tmpl | 1 + dot_local/bin/symlink_netcoredbg.tmpl | 1 + 19 files changed, 83 insertions(+), 140 deletions(-) create mode 100644 .chezmoiexternals/nvim.toml rename .chezmoiscripts/{run_onchange_install-packages.sh.tmpl => run_onchange_10_install-packages.sh.tmpl} (53%) create mode 100644 .chezmoiscripts/run_onchange_11_install-neovim-tools.tmpl create mode 100644 .netcoredbg_hist delete mode 100644 dot_config/nvim/benq/lsp/lua_ls.lua delete mode 100644 dot_config/nvim/benq/lsp/vtsls.lua create mode 100644 dot_config/nvim/benq/lua/config/diagnostics.lua create mode 100644 dot_config/nvim/benq/lua/config/lsp.lua delete mode 100644 dot_config/nvim/benq/lua/plugins/lsp/mason.lua create mode 100644 dot_config/nvim/benq/lua/plugins/lsp/nvim-lspconfig.lua delete mode 100644 dot_config/nvim/benq/lua/plugins/lsp/roslyn.lua create mode 100644 dot_local/bin/symlink_lua-language-server.tmpl create mode 100644 dot_local/bin/symlink_netcoredbg.tmpl diff --git a/.chezmoidata/packages.yaml b/.chezmoidata/packages.yaml index 55dfe28..ab008f3 100644 --- a/.chezmoidata/packages.yaml +++ b/.chezmoidata/packages.yaml @@ -7,11 +7,13 @@ packages: - btop - bitwarden-cli - curl + - dotnet-sdk - eza - fzf - git - lazygit - paru + - npm - ripgrep - tmux - wget diff --git a/.chezmoiexternals/nvim.toml b/.chezmoiexternals/nvim.toml new file mode 100644 index 0000000..81c1572 --- /dev/null +++ b/.chezmoiexternals/nvim.toml @@ -0,0 +1,10 @@ +[".local/share/lua-language-server"] + type = "archive" + url = "https://github.com/LuaLS/lua-language-server/releases/download/3.18.2/lua-language-server-3.18.2-linux-x64.tar.gz" + exact = true + +[".local/share/netcoredbg"] + type = "archive" + url = "https://github.com/Samsung/netcoredbg/releases/download/3.1.3-1062/netcoredbg-linux-amd64.tar.gz" + exact = true + stripComponents = 1 diff --git a/.chezmoiscripts/run_once_before_11-set-zsh.sh.tmpl b/.chezmoiscripts/run_once_before_11-set-zsh.sh.tmpl index 7026806..8347091 100644 --- a/.chezmoiscripts/run_once_before_11-set-zsh.sh.tmpl +++ b/.chezmoiscripts/run_once_before_11-set-zsh.sh.tmpl @@ -1,5 +1,5 @@ #!/bin/bash -{{ if -eq .chezmoi.osRelease.id "nixos" }} +{{ if eq .chezmoi.osRelease.id "nixos" }} exit 0 {{ end }} diff --git a/.chezmoiscripts/run_once_install-neovim.sh.tmpl b/.chezmoiscripts/run_once_install-neovim.sh.tmpl index e0f4a32..b823bff 100755 --- a/.chezmoiscripts/run_once_install-neovim.sh.tmpl +++ b/.chezmoiscripts/run_once_install-neovim.sh.tmpl @@ -1,5 +1,5 @@ #!/bin/bash -{{ if -eq .chezmoi.osRelease.id "nixos" }} +{{ if eq .chezmoi.osRelease.id "nixos" }} exit 0 {{ end }} diff --git a/.chezmoiscripts/run_onchange_install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_10_install-packages.sh.tmpl similarity index 53% rename from .chezmoiscripts/run_onchange_install-packages.sh.tmpl rename to .chezmoiscripts/run_onchange_10_install-packages.sh.tmpl index b7352fe..3216a5c 100755 --- a/.chezmoiscripts/run_onchange_install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_10_install-packages.sh.tmpl @@ -1,5 +1,5 @@ #!/bin/bash -{{ if -eq .chezmoi.osRelease.id "nixos" }} +{{ if eq .chezmoi.osRelease.id "nixos" }} exit 0 {{ end }} @@ -12,22 +12,26 @@ sudo pacman -Sy --noconfirm pkgs=() {{ range .packages.arch }} -pkgs+=("{{ . }}") +if ! pacman -Q "{{ . }}" &>/dev/null; then + pkgs+=("{{ . }}") +fi {{ end }} if [[ ${#pkgs[@]} -gt 0 ]]; then echo "Installing pacman packages" - sudo pacman -S --noconfirm "${pkgs[@]}" + sudo pacman -S --noconfirm --needed "${pkgs[@]}" fi -pkgs=() +aur_pkgs=() {{ range .packages.aur }} -pkgs+=("{{ . }}") +if ! pacman -Q "{{ . }}" &>/dev/null; then + aur_pkgs+=("{{ . }}") +fi {{ end }} -if [[ ${#pkgs[@]} -gt 0 ]]; then +if [[ ${#aur_pkgs[@]} -gt 0 ]]; then echo "Installing AUR packages" - paru -S --noconfirm "${pkgs[@]}" + paru -S --noconfirm --needed "${aur_pkgs[@]}" fi {{ end }} diff --git a/.chezmoiscripts/run_onchange_11_install-neovim-tools.tmpl b/.chezmoiscripts/run_onchange_11_install-neovim-tools.tmpl new file mode 100644 index 0000000..9c7a02b --- /dev/null +++ b/.chezmoiscripts/run_onchange_11_install-neovim-tools.tmpl @@ -0,0 +1,18 @@ +#!/bin/sh +{{ if eq .chezmoi.osRelease.id "nixos" }} +exit 0 +{{ end }} + +set -euo pipefail + +echo "Installing LSPs for Neovim..." + +npm install -g --prefix ~/.local \ + @vtsls/language-server \ + @vue/language-server \ + vscode-langservers-extracted + +dotnet tool install -g roslyn-language-server --prerelease +dotnet tool install -g csharpier + +echo "Done" diff --git a/.chezmoiscripts/run_onchange_before_10-setup-age-key.sh.tmpl b/.chezmoiscripts/run_onchange_before_10-setup-age-key.sh.tmpl index 8dd69f6..b7caece 100755 --- a/.chezmoiscripts/run_onchange_before_10-setup-age-key.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_10-setup-age-key.sh.tmpl @@ -1,5 +1,6 @@ #!/bin/bash -{{ if -eq .chezmoi.osRelease.id "nixos" }} +exit 0 +{{ if eq .chezmoi.osRelease.id "nixos" }} exit 0 {{ end }} diff --git a/.netcoredbg_hist b/.netcoredbg_hist new file mode 100644 index 0000000..115d36b --- /dev/null +++ b/.netcoredbg_hist @@ -0,0 +1,2 @@ +exit +q diff --git a/dot_config/nvim/benq/init.lua b/dot_config/nvim/benq/init.lua index 17a6a63..64bd603 100644 --- a/dot_config/nvim/benq/init.lua +++ b/dot_config/nvim/benq/init.lua @@ -5,27 +5,12 @@ require("config.keymaps") require("config.lazy") require("config.theme") -- ignored by git -vim.lsp.config("roslyn", require("config.lsp.roslyn")) +require("config.lsp") -vim.lsp.enable({ "nixd" }) -- installed locally - --- Set custom breakpoint style -vim.fn.sign_define('DapBreakpoint', { - text = '⚪', - texthl = 'DapBreakpointSymbol', - linehl = 'DapBreakpoint', - numhl = 'DapBreakpoint' -}) -vim.fn.sign_define('DapStopped', { - text = '🔴', - texthl = 'yellow', - linehl = 'DapBreakpoint', - numhl = 'DapBreakpoint' -}) -vim.fn.sign_define('DapBreakpointRejected', { - text = '⭕', - texthl = 'DapStoppedSymbol', - linehl = 'DapBreakpoint', - numhl = 'DapBreakpoint' +vim.lsp.enable({ + "lua_ls", + "html", + "roslyn_ls", }) +require("config.diagnostics") diff --git a/dot_config/nvim/benq/lsp/lua_ls.lua b/dot_config/nvim/benq/lsp/lua_ls.lua deleted file mode 100644 index 212a952..0000000 --- a/dot_config/nvim/benq/lsp/lua_ls.lua +++ /dev/null @@ -1,9 +0,0 @@ -return { - settings = { - Lua = { - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - }, - }, - }, -} diff --git a/dot_config/nvim/benq/lsp/vtsls.lua b/dot_config/nvim/benq/lsp/vtsls.lua deleted file mode 100644 index b3eadd1..0000000 --- a/dot_config/nvim/benq/lsp/vtsls.lua +++ /dev/null @@ -1,54 +0,0 @@ -local vue_language_server_path = vim.fn.expand "$MASON/packages" .. "/vue-language-server" .. "/node_modules/@vue/language-server" - -return { - cmd = { "vtsls", "--stdio" }, - init_options = { - hostInfo = "neovim", - }, - filetypes = { - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "vue", - }, - root_dir = function(bufnr, on_dir) - -- The project root is where the LSP can be started from - -- As stated in the documentation above, this LSP supports monorepos and simple projects. - -- We select then from the project root, which is identified by the presence of a package - -- manager lock file. - local root_markers = { "package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock" } - -- Give the root markers equal priority by wrapping them in a table - root_markers = vim.fn.has("nvim-0.11.3") == 1 and { root_markers, { ".git" } } - or vim.list_extend(root_markers, { ".git" }) - -- exclude deno - local deno_root = vim.fs.root(bufnr, { "deno.json", "deno.jsonc" }) - local deno_lock_root = vim.fs.root(bufnr, { "deno.lock" }) - local project_root = vim.fs.root(bufnr, root_markers) - if deno_lock_root and (not project_root or #deno_lock_root > #project_root) then - -- deno lock is closer than package manager lock, abort - return - end - if deno_root and (not project_root or #deno_root >= #project_root) then - -- deno config is closer than or equal to package manager lock, abort - return - end - -- project is standard TS, not deno - -- We fallback to the current working directory if no project root is found - on_dir(project_root or vim.fn.getcwd()) - end, - settings = { - vtsls = { - tsserver = { - globalPlugins = { - { - name = "@vue/typescript-plugin", - location = vue_language_server_path, - languages = { "vue" }, - configNamespace = "typescript", - } - } - } - } - }, -} diff --git a/dot_config/nvim/benq/lua/config/diagnostics.lua b/dot_config/nvim/benq/lua/config/diagnostics.lua new file mode 100644 index 0000000..ac45103 --- /dev/null +++ b/dot_config/nvim/benq/lua/config/diagnostics.lua @@ -0,0 +1,18 @@ +vim.fn.sign_define('DapBreakpoint', { + text = '⚪', + texthl = 'DapBreakpointSymbol', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint' +}) +vim.fn.sign_define('DapStopped', { + text = '🔴', + texthl = 'yellow', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint' +}) +vim.fn.sign_define('DapBreakpointRejected', { + text = '⭕', + texthl = 'DapStoppedSymbol', + linehl = 'DapBreakpoint', + numhl = 'DapBreakpoint' +}) diff --git a/dot_config/nvim/benq/lua/config/lsp.lua b/dot_config/nvim/benq/lua/config/lsp.lua new file mode 100644 index 0000000..a9773be --- /dev/null +++ b/dot_config/nvim/benq/lua/config/lsp.lua @@ -0,0 +1,6 @@ + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = true + + vim.lsp.config("html", { + capabilities = capabilities, + }) diff --git a/dot_config/nvim/benq/lua/plugins/language-specific/dotnet/debugging.lua b/dot_config/nvim/benq/lua/plugins/language-specific/dotnet/debugging.lua index 43c6eda..64a35eb 100644 --- a/dot_config/nvim/benq/lua/plugins/language-specific/dotnet/debugging.lua +++ b/dot_config/nvim/benq/lua/plugins/language-specific/dotnet/debugging.lua @@ -4,10 +4,9 @@ return { config = function() local dap = require("dap") local utils = require("dap-dll-autopicker") - local mason_path = vim.fn.stdpath("data") .. "/mason/packages/netcoredbg/netcoredbg" local netcoredbg_adapter = { type = "executable", - command = mason_path, + command = "netcoredbg", args = { "--interpreter=vscode" }, } dap.adapters.netcoredbg = netcoredbg_adapter diff --git a/dot_config/nvim/benq/lua/plugins/lsp/mason.lua b/dot_config/nvim/benq/lua/plugins/lsp/mason.lua deleted file mode 100644 index a5039c3..0000000 --- a/dot_config/nvim/benq/lua/plugins/lsp/mason.lua +++ /dev/null @@ -1,38 +0,0 @@ -return { - { - "mason-org/mason-lspconfig.nvim", - dependencies = { "neovim/nvim-lspconfig", }, - opts = { - ensure_installed = { - "docker_compose_language_service", - "lua_ls", - "html", - -- "roslyn", install with :MasonInstall - "vtsls", - "vue_ls", - }, - }, - }, - { - "jay-babu/mason-nvim-dap.nvim", - dependencies = { "neovim/nvim-lspconfig", }, - opts = { - ensure_installed = { - "coreclr", - } - } - }, - { - "neovim/nvim-lspconfig", - dependencies = { "mason-org/mason.nvim", } - }, - { - "mason-org/mason.nvim", - opts = { - registries = { - "github:mason-org/mason-registry", - "github:Crashdummyy/mason-registry", - }, - } - } -} diff --git a/dot_config/nvim/benq/lua/plugins/lsp/nvim-lspconfig.lua b/dot_config/nvim/benq/lua/plugins/lsp/nvim-lspconfig.lua new file mode 100644 index 0000000..a011add --- /dev/null +++ b/dot_config/nvim/benq/lua/plugins/lsp/nvim-lspconfig.lua @@ -0,0 +1,3 @@ +return { + "neovim/nvim-lspconfig" +} diff --git a/dot_config/nvim/benq/lua/plugins/lsp/roslyn.lua b/dot_config/nvim/benq/lua/plugins/lsp/roslyn.lua deleted file mode 100644 index 2c96bba..0000000 --- a/dot_config/nvim/benq/lua/plugins/lsp/roslyn.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "seblyng/roslyn.nvim", - ---@module 'roslyn.config' - ---@type RoslynNvimConfig - opts = {}, -} diff --git a/dot_local/bin/symlink_lua-language-server.tmpl b/dot_local/bin/symlink_lua-language-server.tmpl new file mode 100644 index 0000000..e210395 --- /dev/null +++ b/dot_local/bin/symlink_lua-language-server.tmpl @@ -0,0 +1 @@ +{{ .chezmoi.homeDir }}/.local/share/lua-language-server/bin/lua-language-server diff --git a/dot_local/bin/symlink_netcoredbg.tmpl b/dot_local/bin/symlink_netcoredbg.tmpl new file mode 100644 index 0000000..36000fc --- /dev/null +++ b/dot_local/bin/symlink_netcoredbg.tmpl @@ -0,0 +1 @@ +{{ .chezmoi.homeDir }}/.local/share/netcoredbg/netcoredbg