From 066769e6f9486934d7ed072c84a0981fb84d37d2 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Mon, 17 Feb 2025 02:24:02 -0300 Subject: [PATCH 1/5] fix(hyprland): finally remove fixme on blur subcategory --- modules/home-manager/programs/hyprland/default.nix | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/home-manager/programs/hyprland/default.nix b/modules/home-manager/programs/hyprland/default.nix index c41a26b..6f82512 100644 --- a/modules/home-manager/programs/hyprland/default.nix +++ b/modules/home-manager/programs/hyprland/default.nix @@ -233,11 +233,13 @@ in # See https://wiki.hyprland.org/Configuring/Variables/ for more rounding = 8 - # FIXME: Check these deprecations. - #blur = yes - #blur_size = 3 - #blur_passes = 1 - #blur_new_optimizations = on + + blur { + enabled = true + size = 8 + passes = 1 + new_optimizations = true + } shadow { enabled = true From ef337e45c0a407431e3200bb845b466d3c35684c Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Mon, 17 Feb 2025 02:28:30 -0300 Subject: [PATCH 2/5] chore(desktop): enable rocm ollama support for neovim again --- specific/desktop/home-manager.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/specific/desktop/home-manager.nix b/specific/desktop/home-manager.nix index 2f7fbae..0b20301 100644 --- a/specific/desktop/home-manager.nix +++ b/specific/desktop/home-manager.nix @@ -126,7 +126,6 @@ # Enable ollama support ollama.enable = true; - ollama.type = "cpu"; }; modules.hyprland = { From a2ff5d1b6a1bc83c0f0b8f98df725406b6c20210 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Mon, 17 Feb 2025 19:00:25 -0300 Subject: [PATCH 3/5] fix(neovim): use getnixpath util for nvim-dap and lsp, move polish This moves polish.lua to `lua/`, creates a util.lua file to be loaded before lazy.nvim so we can use the `getnixpath` util everywhere, and replaces in polish.lua and lsp.lua the template strings for substitution with a `getnixpath` equivalent --- .../home-manager/programs/neovim/default.nix | 10 +- modules/home-manager/programs/neovim/init.lua | 12 +- modules/home-manager/programs/neovim/lsp.lua | 3 +- .../programs/neovim/lua/plugins/nvim-dap.lua | 84 +++++++++ .../neovim/lua/plugins/roslyn-nvim.lua | 10 +- .../programs/neovim/lua/polish.lua | 16 ++ .../home-manager/programs/neovim/lua/util.lua | 65 +++++++ .../home-manager/programs/neovim/polish.lua | 162 ------------------ 8 files changed, 180 insertions(+), 182 deletions(-) create mode 100644 modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua create mode 100644 modules/home-manager/programs/neovim/lua/polish.lua create mode 100644 modules/home-manager/programs/neovim/lua/util.lua delete mode 100644 modules/home-manager/programs/neovim/polish.lua diff --git a/modules/home-manager/programs/neovim/default.nix b/modules/home-manager/programs/neovim/default.nix index 79db868..fb23827 100644 --- a/modules/home-manager/programs/neovim/default.nix +++ b/modules/home-manager/programs/neovim/default.nix @@ -153,15 +153,7 @@ in substituteInPlace $out \ --replace-fail "{hostname}" "${config.programs.neovim.nixd.hostname}" \ - --replace-fail "{location}" "${config.programs.neovim.nixd.location}" \ - --replace-fail "{pkgs.vue-language-server}" "${pkgs.vue-language-server}" - ''; - - xdg.configFile."nvim/lua/polish.lua".source = pkgs.runCommand "polish.lua" { } '' - cp ${./polish.lua} $out - - substituteInPlace $out \ - --replace-fail "{pkgs.vscode-extensions.ms-vscode.cpptools}" "${pkgs.vscode-extensions.ms-vscode.cpptools}" \ + --replace-fail "{location}" "${config.programs.neovim.nixd.location}" ''; }; } diff --git a/modules/home-manager/programs/neovim/init.lua b/modules/home-manager/programs/neovim/init.lua index f05f9e8..d59bf57 100644 --- a/modules/home-manager/programs/neovim/init.lua +++ b/modules/home-manager/programs/neovim/init.lua @@ -3,17 +3,21 @@ local lazypath = vim.env.LAZY or vim.fn.stdpath "data" .. "/lazy/lazy.nvim" if not (vim.env.LAZY or (vim.uv or vim.loop).fs_stat(lazypath)) then -- stylua: ignore - vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath }) + vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", + lazypath }) end vim.opt.rtp:prepend(lazypath) -- validate that lazy is available if not pcall(require, "lazy") then -- stylua: ignore - vim.api.nvim_echo({ { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, true, {}) - vim.fn.getchar() - vim.cmd.quit() + vim.api.nvim_echo( + { { ("Unable to load lazy from: %s\n"):format(lazypath), "ErrorMsg" }, { "Press any key to exit...", "MoreMsg" } }, + true, {}) + vim.fn.getchar() + vim.cmd.quit() end +require "util" require "lazy_setup" require "polish" diff --git a/modules/home-manager/programs/neovim/lsp.lua b/modules/home-manager/programs/neovim/lsp.lua index 413048d..97f204a 100644 --- a/modules/home-manager/programs/neovim/lsp.lua +++ b/modules/home-manager/programs/neovim/lsp.lua @@ -104,7 +104,8 @@ return { globalPlugins = { { name = "@vue/typescript-plugin", - location = "{pkgs.vue-language-server}/lib/node_modules/@vue/language-server", + location = vim.fn.getnixpath "vue-language-server" + .. "/lib/node_modules/@vue/language-server", languages = { "vue" }, configNamespace = "typescript", enableForWorkspaceTypeScriptVersions = true, diff --git a/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua b/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua new file mode 100644 index 0000000..1e8ce17 --- /dev/null +++ b/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua @@ -0,0 +1,84 @@ +---@type LazySpec +return { + "mfussenegger/nvim-dap", + config = function() + local dap = require "dap" + + ---@type dap.Adapter + dap.adapters.codelldb = { + port = "${port}", + type = "server", + executable = { + command = "codelldb", + args = { "--port", "${port}" }, + }, + } + + ---@type dap.Configuration[] + dap.configurations.rust = { + { + name = "Launch file", + type = "codelldb", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopOnEntry = false, + }, + } + + ---@type dap.Adapter + dap.adapters.cppdbg = { + id = "cppdbg", + type = "executable", + command = vim.fn.getnixpath "vscode-extensions.ms-vscode.cpptools" + .. "/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7", + } + + ---@type dap.Configuration[] + dap.configurations.cpp = { + { + name = "Launch file", + type = "cppdbg", + request = "launch", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + stopAtEntry = true, + }, + { + name = "Attach to gdbserver :1234", + type = "cppdbg", + request = "launch", + MIMode = "gdb", + miDebuggerServerAddress = "localhost:1234", + miDebuggerPath = "/usr/bin/gdb", + cwd = "${workspaceFolder}", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + }, + } + dap.configurations.c = dap.configurations.cpp + + ---@type dap.Adapter + dap.adapters.godot = { + type = "server", + host = "127.0.0.1", + port = 6006, + } + + ---@type dap.Configuration[] + dap.configurations.gdscript = { + { + name = "Launch scene", + type = "godot", + request = "launch", + project = "${workspaceFolder}", + scene = "current", + }, + } + end, +} diff --git a/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua b/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua index 98653f7..8554cf9 100644 --- a/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua +++ b/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua @@ -7,12 +7,10 @@ return { dependencies = { { "tris203/rzls.nvim", - config = function() - ---@diagnostic disable-next-line: missing-fields - require("rzls").setup { - path = vim.fn.getnixpath "rzls" .. "/bin/rzls", - } - end, + opts = { + capabilities = vim.lsp.protocol.make_client_capabilities(), + path = vim.fn.getnixpath "rzls" .. "/bin/rzls", + }, }, }, opts = function(_, opts) diff --git a/modules/home-manager/programs/neovim/lua/polish.lua b/modules/home-manager/programs/neovim/lua/polish.lua new file mode 100644 index 0000000..f7c2205 --- /dev/null +++ b/modules/home-manager/programs/neovim/lua/polish.lua @@ -0,0 +1,16 @@ +-- This will run last in the setup process and is a good place to configure +-- things like custom filetypes. This just pure lua so anything that doesn't +-- fit in the normal config locations above can go here + +-- Set up custom filetypes +vim.filetype.add { + extension = { + foo = "fooscript", + }, + filename = { + ["Foofile"] = "fooscript", + }, + pattern = { + ["~/%.config/foo/.*"] = "fooscript", + }, +} diff --git a/modules/home-manager/programs/neovim/lua/util.lua b/modules/home-manager/programs/neovim/lua/util.lua new file mode 100644 index 0000000..345871b --- /dev/null +++ b/modules/home-manager/programs/neovim/lua/util.lua @@ -0,0 +1,65 @@ +--- Define PackageOutput +--- @enum PackageOutput +local PACKAGEOUTPUT = { + out = 0, + lib = 1, +} + +--- Get the store path of a package +--- @param packagename NixSearchExceptions | string +--- @param packageoutput PackageOutput? +--- @return string | nil +vim.fn.getnixpath = function(packagename, packageoutput) + ---@enum (key) NixSearchExceptions + local exceptions = {} + + return vim.split( + vim.api.nvim_cmd( + vim.api.nvim_parse_cmd( + string.format( + "silent !NIXPKGS_ALLOW_UNFREE=1 nix eval --raw --expr 'with import { }; (%s).%s' --impure", + exceptions[packagename] or packagename, + (packageoutput == PACKAGEOUTPUT.out or packageoutput == nil) and "outPath" + or string.format("lib.getLib %s", packagename) + ), + {} + ) --[[@as vim.api.keyset.cmd]], + { + output = true, + } + ), + "\n" + )[3] +end + +--- Helper function to allow me to run commands grabbed +--- by the current selection. +--- @param isLua boolean +--- @return string +vim.fn.runcmdonmark = function(isLua) + local beginRow, beginCol = unpack(vim.api.nvim_buf_get_mark(0, "<")) + local endRow, endCol = unpack(vim.api.nvim_buf_get_mark(0, ">")) + + if beginRow == nil or beginCol == nil or endRow == nil or endCol == nil then + return "" + end + + local text = table.concat( + vim.tbl_map(function(incoming) + return vim.trim(incoming) + end, vim.api.nvim_buf_get_text(0, beginRow - 1, beginCol, endRow - 1, endCol + 1, {})), + " " + ) + + vim.notify("Running expression: " .. text, vim.log.levels.INFO) + + return vim.api.nvim_cmd( + vim.api.nvim_parse_cmd((isLua == true and ":lua " or "") .. text, {}) --[[@as vim.api.keyset.cmd]], + {} + ) +end + +--- Register the function as a command as well, to facilitate things. +vim.api.nvim_create_user_command("RunCmdOnMark", function(opts) + vim.fn.runcmdonmark((opts.args == "v:false" or opts.args == "false") and false or true) +end, { range = true, nargs = "?" }) diff --git a/modules/home-manager/programs/neovim/polish.lua b/modules/home-manager/programs/neovim/polish.lua deleted file mode 100644 index 7f2c3d1..0000000 --- a/modules/home-manager/programs/neovim/polish.lua +++ /dev/null @@ -1,162 +0,0 @@ --- This will run last in the setup process and is a good place to configure --- things like custom filetypes. This just pure lua so anything that doesn't --- fit in the normal config locations above can go here - --- Set up custom filetypes -vim.filetype.add { - extension = { - foo = "fooscript", - }, - filename = { - ["Foofile"] = "fooscript", - }, - pattern = { - ["~/%.config/foo/.*"] = "fooscript", - }, -} - ---- Define PackageOutput ---- @enum PackageOutput -local PACKAGEOUTPUT = { - out = 0, - lib = 1, -} - ---- Get the store path of a package ---- @param packagename NixSearchExceptions | string ---- @param packageoutput PackageOutput? ---- @return string | nil -vim.fn.getnixpath = function(packagename, packageoutput) - ---@enum (key) NixSearchExceptions - local exceptions = {} - - return vim.split( - vim.api.nvim_cmd( - vim.api.nvim_parse_cmd( - string.format( - "silent !nix eval --raw --expr 'with import { }; (%s).%s' --impure", - exceptions[packagename] or packagename, - (packageoutput == PACKAGEOUTPUT.out or packageoutput == nil) and "outPath" - or string.format("lib.getLib %s", packagename) - ), - {} - ) --[[@as vim.api.keyset.cmd]], - { - output = true, - } - ), - "\n" - )[3] -end - ---- Helper function to allow me to run commands grabbed ---- by the current selection. ---- @param isLua boolean ---- @return string -vim.fn.runcmdonmark = function(isLua) - local beginRow, beginCol = unpack(vim.api.nvim_buf_get_mark(0, "<")) - local endRow, endCol = unpack(vim.api.nvim_buf_get_mark(0, ">")) - - if beginRow == nil or beginCol == nil or endRow == nil or endCol == nil then - return "" - end - - local text = table.concat( - vim.tbl_map(function(incoming) - return vim.trim(incoming) - end, vim.api.nvim_buf_get_text(0, beginRow - 1, beginCol, endRow - 1, endCol + 1, {})), - " " - ) - - vim.notify("Running expression: " .. text, vim.log.levels.INFO) - - return vim.api.nvim_cmd( - vim.api.nvim_parse_cmd((isLua == true and ":lua " or "") .. text, {}) --[[@as vim.api.keyset.cmd]], - {} - ) -end - ---- Register the function as a command as well, to facilitate things. -vim.api.nvim_create_user_command("RunCmdOnMark", function(opts) - vim.fn.runcmdonmark((opts.args == "v:false" or opts.args == "false") and false or true) -end, { range = true, nargs = "?" }) - -local dap = require "dap" - ----@type dap.Adapter -dap.adapters.codelldb = { - port = "${port}", - type = "server", - executable = { - command = "codelldb", - args = { "--port", "${port}" }, - }, -} - ----@type dap.Adapter -dap.adapters.cppdbg = { - id = "cppdbg", - type = "executable", - command = - "{pkgs.vscode-extensions.ms-vscode.cpptools}/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7", -} - ----@type dap.Adapter -dap.adapters.godot = { - type = "server", - host = "127.0.0.1", - port = 6006, -} - ----@type dap.Configuration[] -dap.configurations.rust = { - { - name = "Launch file", - type = "codelldb", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - }, -} - ----@type dap.Configuration[] -dap.configurations.cpp = { - { - name = "Launch file", - type = "cppdbg", - request = "launch", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - cwd = "${workspaceFolder}", - stopAtEntry = true, - }, - { - name = "Attach to gdbserver :1234", - type = "cppdbg", - request = "launch", - MIMode = "gdb", - miDebuggerServerAddress = "localhost:1234", - miDebuggerPath = "/usr/bin/gdb", - cwd = "${workspaceFolder}", - program = function() - return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") - end, - }, -} - -dap.configurations.c = dap.configurations.cpp - ----@type dap.Configuration[] -dap.configurations.gdscript = { - { - name = "Launch scene", - type = "godot", - request = "launch", - project = "${workspaceFolder}", - scene = "current", - }, -} From 34ad9056ca44b498e58cdca9b35db9fa11f549f2 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Mon, 17 Feb 2025 19:00:59 -0300 Subject: [PATCH 4/5] fix(neovim): remove prettierd extension of razor files --- modules/home-manager/programs/neovim/lua/plugins/none-ls.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/home-manager/programs/neovim/lua/plugins/none-ls.lua b/modules/home-manager/programs/neovim/lua/plugins/none-ls.lua index 304876d..6877139 100644 --- a/modules/home-manager/programs/neovim/lua/plugins/none-ls.lua +++ b/modules/home-manager/programs/neovim/lua/plugins/none-ls.lua @@ -53,9 +53,7 @@ return { null_ls.builtins.formatting.nixfmt, null_ls.builtins.formatting.stylua, --deno_fmt, - null_ls.builtins.formatting.prettierd.with { - extra_filetypes = { "razor" }, - }, + null_ls.builtins.formatting.prettierd, null_ls.builtins.code_actions.statix, From 39e987678cea737a72ded2f2e6708f5b6b2ed934 Mon Sep 17 00:00:00 2001 From: "Alexandre Cavalheiro S. Tiago da Silva" Date: Tue, 18 Feb 2025 04:32:35 -0300 Subject: [PATCH 5/5] feat(neovim): add nix-store.nvim and change old calls --- .../programs/neovim/ftplugin/cs.lua | 2 +- modules/home-manager/programs/neovim/lsp.lua | 364 +++++++++--------- .../programs/neovim/lua/plugins/nix-store.lua | 9 + .../programs/neovim/lua/plugins/nvim-dap.lua | 2 +- .../neovim/lua/plugins/roslyn-nvim.lua | 14 +- .../home-manager/programs/neovim/lua/util.lua | 34 -- 6 files changed, 206 insertions(+), 219 deletions(-) create mode 100644 modules/home-manager/programs/neovim/lua/plugins/nix-store.lua diff --git a/modules/home-manager/programs/neovim/ftplugin/cs.lua b/modules/home-manager/programs/neovim/ftplugin/cs.lua index c129918..1b6eb4a 100644 --- a/modules/home-manager/programs/neovim/ftplugin/cs.lua +++ b/modules/home-manager/programs/neovim/ftplugin/cs.lua @@ -122,7 +122,7 @@ function M:start() vim.fn.setenv("DOTNET_ENVIRONMENT", "Development") - local debugger_path = vim.fn.getnixpath "netcoredbg" .. "/bin/netcoredbg" + local debugger_path = vim.fn.get_nix_store "netcoredbg" .. "/bin/netcoredbg" local dap = require "dap" diff --git a/modules/home-manager/programs/neovim/lsp.lua b/modules/home-manager/programs/neovim/lsp.lua index 97f204a..f621f41 100644 --- a/modules/home-manager/programs/neovim/lsp.lua +++ b/modules/home-manager/programs/neovim/lsp.lua @@ -6,197 +6,205 @@ ---@type LazySpec return { "AstroNvim/astrolsp", - ---@type AstroLSPOpts - opts = { - -- Configuration table of features provided by AstroLSP - features = { - autoformat = true, -- enable or disable auto formatting on start - codelens = true, -- enable/disable codelens refresh on start - inlay_hints = false, -- enable/disable inlay hints on start - semantic_tokens = true, -- enable/disable semantic token highlighting - }, - -- customize lsp formatting options - formatting = { - -- control auto formatting on save - format_on_save = { - enabled = true, -- enable or disable format on save globally - allow_filetypes = { -- enable format on save for specified filetypes only - -- "go", - "c", - "cpp", - "cs", - "gdscript", - "h", - "javascript", - "jsx", - "lua", - "nix", - "rust", - "svelte", - "tsx", - "typescript", - "vue", - }, - ignore_filetypes = { -- disable format on save for specified filetypes - -- "python", - }, + ---@param opts AstroLSPOpts + ---@return AstroLSPOpts + opts = function(_, opts) + ---@type AstroLSPOpts + local lsp_options = { + -- Configuration table of features provided by AstroLSP + features = { + autoformat = true, -- enable or disable auto formatting on start + codelens = true, -- enable/disable codelens refresh on start + inlay_hints = false, -- enable/disable inlay hints on start + semantic_tokens = true, -- enable/disable semantic token highlighting }, - disabled = { -- disable formatting capabilities for the listed language servers - -- disable lua_ls formatting capability if you want to use StyLua to format your lua code - -- "lua_ls", - }, - timeout_ms = 1000, -- default format timeout - -- filter = function(client) -- fully override the default formatting function - -- return true - -- end - }, - -- enable servers that you already have installed without mason - servers = { - "basedpyright", - "clangd", - "cmake", - --"csharp_ls", Testing roslyn.nvim - "cssls", - "denols", - "eslint", - "gdscript", - "html", - "jsonls", - "lua_ls", - "marksman", - "nixd", - "rust_analyzer", - "svelte", - "taplo", - "volar", - "vtsls", - "yamlls", - }, - -- customize language server configuration options passed to `lspconfig` - ---@diagnostic disable: missing-fields - config = { - -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, - ---@type lspconfig.Config - nixd = { - settings = { - nixd = { - nixpkgs = { - expr = "import (builtins.getFlake ({location})).inputs.nixpkgs { }", - }, - options = { - nixos = { - expr = '(builtins.getFlake ("{location}")).nixosConfigurations.{hostname}.options', - }, - home_manager = { - expr = - '(builtins.getFlake ("{location}")).nixosConfigurations.{hostname}.options.home-manager.users.type.getSubOptions []', - }, - }, + -- customize lsp formatting options + formatting = { + -- control auto formatting on save + format_on_save = { + enabled = true, -- enable or disable format on save globally + allow_filetypes = { -- enable format on save for specified filetypes only + -- "go", + "c", + "cpp", + "cs", + "gdscript", + "h", + "javascript", + "jsx", + "lua", + "nix", + "rust", + "svelte", + "tsx", + "typescript", + "vue", + }, + ignore_filetypes = { -- disable format on save for specified filetypes + -- "python", }, }, + disabled = { -- disable formatting capabilities for the listed language servers + -- disable lua_ls formatting capability if you want to use StyLua to format your lua code + -- "lua_ls", + }, + timeout_ms = 1000, -- default format timeout + -- filter = function(client) -- fully override the default formatting function + -- return true + -- end }, - ---@type lspconfig.Config - vtsls = { - filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" }, - settings = { - vtsls = { - tsserver = { - globalPlugins = { - { - name = "@vue/typescript-plugin", - location = vim.fn.getnixpath "vue-language-server" - .. "/lib/node_modules/@vue/language-server", - languages = { "vue" }, - configNamespace = "typescript", - enableForWorkspaceTypeScriptVersions = true, + -- enable servers that you already have installed without mason + servers = { + "basedpyright", + "clangd", + "cmake", + --"csharp_ls", Testing roslyn.nvim + "cssls", + "denols", + "eslint", + "gdscript", + "html", + "jsonls", + "lua_ls", + "marksman", + "nixd", + "rust_analyzer", + "svelte", + "taplo", + "volar", + "vtsls", + "yamlls", + }, + -- customize language server configuration options passed to `lspconfig` + ---@diagnostic disable: missing-fields + config = { + -- clangd = { capabilities = { offsetEncoding = "utf-8" } }, + ---@type lspconfig.Config + nixd = { + settings = { + nixd = { + nixpkgs = { + expr = "import (builtins.getFlake ({location})).inputs.nixpkgs { }", + }, + options = { + nixos = { + expr = '(builtins.getFlake ("{location}")).nixosConfigurations.{hostname}.options', + }, + home_manager = { + expr = + '(builtins.getFlake ("{location}")).nixosConfigurations.{hostname}.options.home-manager.users.type.getSubOptions []', }, }, }, }, }, - }, - ---@type lspconfig.Config - rust_analyzer = { - settings = { - ["rust-analyzer"] = { - cargo = { - extraEnv = { CARGO_PROFILE_RUST_ANALYZER_INHERITS = "dev" }, - extraArgs = { "--profile", "rust-analyzer" }, + ---@type lspconfig.Config + vtsls = { + filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue" }, + settings = { + vtsls = { + tsserver = { + globalPlugins = { + { + name = "@vue/typescript-plugin", + location = vim.fn.get_nix_store "vue-language-server" + .. "/lib/node_modules/@vue/language-server", + languages = { "vue" }, + configNamespace = "typescript", + enableForWorkspaceTypeScriptVersions = true, + }, + }, + }, }, - check = { command = "check", extraArgs = {} }, + }, + }, + ---@type lspconfig.Config + rust_analyzer = { + settings = { + ["rust-analyzer"] = { + cargo = { + extraEnv = { CARGO_PROFILE_RUST_ANALYZER_INHERITS = "dev" }, + extraArgs = { "--profile", "rust-analyzer" }, + }, + check = { command = "check", extraArgs = {} }, + }, + }, + }, + ---@type lspconfig.Config + html = { + filetypes = { "html", "templ", "razor" }, + }, + }, + -- customize how language servers are attached + handlers = { + -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server + -- function(server, opts) require("lspconfig")[server].setup(opts) end + + -- the key is the server that is being setup with `lspconfig` + -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server + -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed + }, + -- Configure buffer local auto commands to add when attaching a language server + autocmds = { + -- first key is the `augroup` to add the auto commands to (:h augroup) + lsp_document_highlight = { + -- Optional condition to create/delete auto command group + -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` + -- condition will be resolved for each client on each execution and if it ever fails for all clients, + -- the auto commands will be deleted for that buffer + cond = "textDocument/documentHighlight", + -- cond = function(client, bufnr) return client.name == "lua_ls" end, + -- list of auto commands to set + { + -- events to trigger + event = { "CursorHold", "CursorHoldI" }, + -- the rest of the autocmd options (:h nvim_create_autocmd) + desc = "Document Highlighting", + callback = function() + vim.lsp.buf.document_highlight() + end, + }, + { + event = { "CursorMoved", "CursorMovedI", "BufLeave" }, + desc = "Document Highlighting Clear", + callback = function() + vim.lsp.buf.clear_references() + end, }, }, }, - ---@type lspconfig.Config - html = { - filetypes = { "html", "templ", "razor" }, + -- mappings to be set up on attaching of a language server + mappings = { + n = { + gl = { + function() + vim.diagnostic.open_float() + end, + desc = "Hover diagnostics", + }, + -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean + -- gD = { + -- function() vim.lsp.buf.declaration() end, + -- desc = "Declaration of current symbol", + -- cond = "textDocument/declaration", + -- }, + -- ["uY"] = { + -- function() require("astrolsp.toggles").buffer_semantic_tokens() end, + -- desc = "Toggle LSP semantic highlight (buffer)", + -- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end, + -- }, + }, }, - }, - -- customize how language servers are attached - handlers = { - -- a function without a key is simply the default handler, functions take two parameters, the server name and the configured options table for that server - -- function(server, opts) require("lspconfig")[server].setup(opts) end + -- A custom `on_attach` function to be run after the default `on_attach` function + -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) + on_attach = function(client, bufnr) + -- this would disable semanticTokensProvider for all clients + -- client.server_capabilities.semanticTokensProvider = nil + end, + } - -- the key is the server that is being setup with `lspconfig` - -- rust_analyzer = false, -- setting a handler to false will disable the set up of that language server - -- pyright = function(_, opts) require("lspconfig").pyright.setup(opts) end -- or a custom handler function can be passed - }, - -- Configure buffer local auto commands to add when attaching a language server - autocmds = { - -- first key is the `augroup` to add the auto commands to (:h augroup) - lsp_document_highlight = { - -- Optional condition to create/delete auto command group - -- can either be a string of a client capability or a function of `fun(client, bufnr): boolean` - -- condition will be resolved for each client on each execution and if it ever fails for all clients, - -- the auto commands will be deleted for that buffer - cond = "textDocument/documentHighlight", - -- cond = function(client, bufnr) return client.name == "lua_ls" end, - -- list of auto commands to set - { - -- events to trigger - event = { "CursorHold", "CursorHoldI" }, - -- the rest of the autocmd options (:h nvim_create_autocmd) - desc = "Document Highlighting", - callback = function() - vim.lsp.buf.document_highlight() - end, - }, - { - event = { "CursorMoved", "CursorMovedI", "BufLeave" }, - desc = "Document Highlighting Clear", - callback = function() - vim.lsp.buf.clear_references() - end, - }, - }, - }, - -- mappings to be set up on attaching of a language server - mappings = { - n = { - gl = { - function() - vim.diagnostic.open_float() - end, - desc = "Hover diagnostics", - }, - -- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean - -- gD = { - -- function() vim.lsp.buf.declaration() end, - -- desc = "Declaration of current symbol", - -- cond = "textDocument/declaration", - -- }, - -- ["uY"] = { - -- function() require("astrolsp.toggles").buffer_semantic_tokens() end, - -- desc = "Toggle LSP semantic highlight (buffer)", - -- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end, - -- }, - }, - }, - -- A custom `on_attach` function to be run after the default `on_attach` function - -- takes two parameters `client` and `bufnr` (`:h lspconfig-setup`) - on_attach = function(client, bufnr) - -- this would disable semanticTokensProvider for all clients - -- client.server_capabilities.semanticTokensProvider = nil - end, - }, + opts = vim.tbl_deep_extend("force", opts, lsp_options) + + return opts + end, } diff --git a/modules/home-manager/programs/neovim/lua/plugins/nix-store.lua b/modules/home-manager/programs/neovim/lua/plugins/nix-store.lua new file mode 100644 index 0000000..7607b47 --- /dev/null +++ b/modules/home-manager/programs/neovim/lua/plugins/nix-store.lua @@ -0,0 +1,9 @@ +---@type LazySpec +return { + "wizardlink/nix-store.nvim", + priority = 999999, + lazy = false, + opts = { + allow_unfree = true, + }, +} diff --git a/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua b/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua index 1e8ce17..7798b02 100644 --- a/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua +++ b/modules/home-manager/programs/neovim/lua/plugins/nvim-dap.lua @@ -32,7 +32,7 @@ return { dap.adapters.cppdbg = { id = "cppdbg", type = "executable", - command = vim.fn.getnixpath "vscode-extensions.ms-vscode.cpptools" + command = vim.fn.get_nix_store "vscode-extensions.ms-vscode.cpptools" .. "/share/vscode/extensions/ms-vscode.cpptools/debugAdapters/bin/OpenDebugAD7", } diff --git a/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua b/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua index 8554cf9..f926f22 100644 --- a/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua +++ b/modules/home-manager/programs/neovim/lua/plugins/roslyn-nvim.lua @@ -7,14 +7,18 @@ return { dependencies = { { "tris203/rzls.nvim", - opts = { - capabilities = vim.lsp.protocol.make_client_capabilities(), - path = vim.fn.getnixpath "rzls" .. "/bin/rzls", - }, + opts = function(_, opts) + opts = { + capabilities = vim.lsp.protocol.make_client_capabilities(), + path = vim.fn.get_nix_store "rzls" .. "/bin/rzls", + } + + return opts + end, }, }, opts = function(_, opts) - local rzlspath = vim.fn.getnixpath "rzls" + local rzlspath = vim.fn.get_nix_store "rzls" require("roslyn.config").get() opts = { diff --git a/modules/home-manager/programs/neovim/lua/util.lua b/modules/home-manager/programs/neovim/lua/util.lua index 345871b..8dc9ea4 100644 --- a/modules/home-manager/programs/neovim/lua/util.lua +++ b/modules/home-manager/programs/neovim/lua/util.lua @@ -1,37 +1,3 @@ ---- Define PackageOutput ---- @enum PackageOutput -local PACKAGEOUTPUT = { - out = 0, - lib = 1, -} - ---- Get the store path of a package ---- @param packagename NixSearchExceptions | string ---- @param packageoutput PackageOutput? ---- @return string | nil -vim.fn.getnixpath = function(packagename, packageoutput) - ---@enum (key) NixSearchExceptions - local exceptions = {} - - return vim.split( - vim.api.nvim_cmd( - vim.api.nvim_parse_cmd( - string.format( - "silent !NIXPKGS_ALLOW_UNFREE=1 nix eval --raw --expr 'with import { }; (%s).%s' --impure", - exceptions[packagename] or packagename, - (packageoutput == PACKAGEOUTPUT.out or packageoutput == nil) and "outPath" - or string.format("lib.getLib %s", packagename) - ), - {} - ) --[[@as vim.api.keyset.cmd]], - { - output = true, - } - ), - "\n" - )[3] -end - --- Helper function to allow me to run commands grabbed --- by the current selection. --- @param isLua boolean