From c6b9d4f99a51da86a8312097129df5aa5f46d99c Mon Sep 17 00:00:00 2001 From: foxora Date: Sat, 21 Feb 2026 17:03:47 +0000 Subject: [PATCH 1/4] fixed ip changing on reboot and added stuff to make home assistant not hang on setup --- hosts/arcturus/default.nix | 2 ++ snow.nix | 2 +- vms/home-assistant/default.nix | 31 ++++++++++++++++++++++++------- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/hosts/arcturus/default.nix b/hosts/arcturus/default.nix index 0779ae1..6bd53fe 100644 --- a/hosts/arcturus/default.nix +++ b/hosts/arcturus/default.nix @@ -23,6 +23,7 @@ networking = { useNetworkd = false; + networkmanager.enable = false; useDHCP = false; nftables.enable = true; @@ -92,6 +93,7 @@ Gateway = "10.16.1.1"; DNS = ["10.16.1.1"]; LinkLocalAddressing = "no"; + DHCP = "no"; }; linkConfig.RequiredForOnline = "routable"; }; diff --git a/snow.nix b/snow.nix index 0be6e6b..4f03787 100644 --- a/snow.nix +++ b/snow.nix @@ -78,7 +78,7 @@ cerulean.mkNexus ./. (self: { { image = "/var/lib/microvms/home-assistant/data.img"; mountPoint = "/var/lib/hass"; - size = 16384; # 16GB + autoCreate = false; } ]; }; diff --git a/vms/home-assistant/default.nix b/vms/home-assistant/default.nix index 17ad40c..70bcd07 100644 --- a/vms/home-assistant/default.nix +++ b/vms/home-assistant/default.nix @@ -2,7 +2,7 @@ { services.home-assistant = { enable = true; - configDir = "/var/lib/hass"; + configDir = "/var/lib/hass/hass"; # disables config generation, i don't wanna configure home assistant # through nix at the moment @@ -16,15 +16,32 @@ extraPackages = python3Packages: with python3Packages; [ getmac + aiohue + numpy + aiodhcpwatcher + async-upnp-client + gtts + numpy + plexapi + pyipp + paho-mqtt + pyturbojpeg ]; }; - systemd.tmpfiles.rules = [ - # configures the config directory to be mounted - # correclty with the right permissions - "z /var/lib/hass 0755 hass hass -" - "z /var/lib/hass/lost+found 0755 hass hass -" - ]; + # configures the config directory to be mounted + # correctly with the right permissions + systemd.services.hass-permissions = { + wantedBy = [ "multi-user.target" ]; + after = [ "var-lib-hass.mount" ]; + requires = [ "var-lib-hass.mount" ]; + before = [ "home-assistant.service" ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.bash}/bin/bash -c 'mkdir -p /var/lib/hass/hass && chown hass:hass /var/lib/hass/hass'"; + RemainAfterExit = true; + }; + }; networking = { nftables.enable = true; From a8a297d142187c017a6c24fb2d76c4188c12751a Mon Sep 17 00:00:00 2001 From: foxora Date: Sat, 21 Feb 2026 17:20:53 +0000 Subject: [PATCH 2/4] commented out volume for testing --- snow.nix | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/snow.nix b/snow.nix index 4f03787..c927050 100644 --- a/snow.nix +++ b/snow.nix @@ -75,11 +75,11 @@ cerulean.mkNexus ./. (self: { ]; volumes = [ - { - image = "/var/lib/microvms/home-assistant/data.img"; - mountPoint = "/var/lib/hass"; - autoCreate = false; - } + #{ + #image = "/var/lib/microvms/home-assistant/data.img"; + #mountPoint = "/var/lib/hass"; + #autoCreate = false; + #} ]; }; From 35bab88ce9a9971a7d8602ae309bdbd84777f0d7 Mon Sep 17 00:00:00 2001 From: foxora Date: Sat, 21 Feb 2026 19:05:00 +0000 Subject: [PATCH 3/4] added formatter and format on save!!! --- homes/modules/programs/neovim/init.lua | 89 +++++---- .../programs/neovim/lua/lsp/capabilities.lua | 89 +++++---- .../programs/neovim/lua/lsp/completion.lua | 166 ++++++++-------- .../programs/neovim/lua/lsp/indentation.lua | 24 +-- .../modules/programs/neovim/lua/lsp/init.lua | 6 +- homes/modules/programs/neovim/lua/lsp/lsp.lua | 184 +++++++++--------- .../programs/neovim/lua/plugins/dressing.lua | 6 +- .../programs/neovim/lua/plugins/format.lua | 33 ++++ .../programs/neovim/lua/plugins/fyler.lua | 33 ++-- .../programs/neovim/lua/plugins/init.lua | 15 +- .../neovim/lua/plugins/mini-hipatterns.lua | 136 ++++++------- .../programs/neovim/lua/plugins/telescope.lua | 106 +++++++--- .../neovim/lua/plugins/treesitter.lua | 162 +++++++-------- homes/modules/programs/neovim/nixcats.nix | 65 +++++-- 14 files changed, 620 insertions(+), 494 deletions(-) create mode 100644 homes/modules/programs/neovim/lua/plugins/format.lua diff --git a/homes/modules/programs/neovim/init.lua b/homes/modules/programs/neovim/init.lua index b46afbe..7ec6af4 100644 --- a/homes/modules/programs/neovim/init.lua +++ b/homes/modules/programs/neovim/init.lua @@ -14,34 +14,46 @@ local colors = {} -- function to load colors local function load_colors() - local new_colors = {} - for line in io.lines(colorscheme_filepath) do - table.insert(new_colors, line) - end + local new_colors = {} + for line in io.lines(colorscheme_filepath) do + table.insert(new_colors, line) + end - -- ensure the table has enough entries to avoid indexing issues - if #new_colors >= 18 then - colors = new_colors - require('base16-colorscheme').setup({ - base00 = colors[17], base01 = colors[1], base02 = colors[3], base03 = colors[3], - base04 = colors[5], base05 = colors[8], base06 = colors[5], base07 = colors[8], - base08 = colors[18], base09 = colors[4], base0A = colors[11], base0B = colors[5], - base0C = colors[6], base0D = colors[7], base0E = colors[6], base0F = colors[16], - }) + -- ensure the table has enough entries to avoid indexing issues + if #new_colors >= 18 then + colors = new_colors + require("base16-colorscheme").setup({ + base00 = colors[17], + base01 = colors[1], + base02 = colors[3], + base03 = colors[3], + base04 = colors[5], + base05 = colors[8], + base06 = colors[5], + base07 = colors[8], + base08 = colors[18], + base09 = colors[4], + base0A = colors[11], + base0B = colors[5], + base0C = colors[6], + base0D = colors[7], + base0E = colors[6], + base0F = colors[16], + }) - -- set colors for blink.cmp's completion menu - vim.api.nvim_set_hl(0, 'BlinkCmpMenu', { bg = colors[17] }) - vim.api.nvim_set_hl(0, 'BlinkCmpMenuBorder', { bg = colors[17], fg = colors[13] }) - vim.api.nvim_set_hl(0, 'BlinkCmpMenuSelection', { bg = colors[15], fg = colors[17] }) - vim.api.nvim_set_hl(0, 'BlinkCmpScrollBarThumb', { bg = colors[18] }) - vim.api.nvim_set_hl(0, 'BlinkCmpKind', { bg = colors[17], fg = colors[14] }) - vim.api.nvim_set_hl(0, 'BlinkCmpLabel', { bg = colors[17], fg = colors[18] }) - vim.api.nvim_set_hl(0, 'BlinkCmpLabelMatch', { bg = colors[17], fg = colors[18] }) - vim.api.nvim_set_hl(0, 'BlinkCmpLabelDetail', { bg = colors[17], fg = colors[18] }) - vim.api.nvim_set_hl(0, 'BlinkCmpLabelDescription', { bg = colors[17], fg = colors[18] }) - else - print("Error: Not enough colors in file") - end + -- set colors for blink.cmp's completion menu + vim.api.nvim_set_hl(0, "BlinkCmpMenu", { bg = colors[17] }) + vim.api.nvim_set_hl(0, "BlinkCmpMenuBorder", { bg = colors[17], fg = colors[13] }) + vim.api.nvim_set_hl(0, "BlinkCmpMenuSelection", { bg = colors[15], fg = colors[17] }) + vim.api.nvim_set_hl(0, "BlinkCmpScrollBarThumb", { bg = colors[18] }) + vim.api.nvim_set_hl(0, "BlinkCmpKind", { bg = colors[17], fg = colors[14] }) + vim.api.nvim_set_hl(0, "BlinkCmpLabel", { bg = colors[17], fg = colors[18] }) + vim.api.nvim_set_hl(0, "BlinkCmpLabelMatch", { bg = colors[17], fg = colors[18] }) + vim.api.nvim_set_hl(0, "BlinkCmpLabelDetail", { bg = colors[17], fg = colors[18] }) + vim.api.nvim_set_hl(0, "BlinkCmpLabelDescription", { bg = colors[17], fg = colors[18] }) + else + print("Error: Not enough colors in file") + end end -- initial load @@ -51,19 +63,18 @@ load_colors() -- set up a file watcher local function watch_colorscheme() - local handle - handle = uv.new_fs_event() - if handle then - uv.fs_event_start(handle, colorscheme_filepath, {}, function(err, _, _) - if err then - print("Error watching colorscheme file:", err) - return - end - -- debounce by adding a slight delay before reloading - vim.defer_fn(load_colors, 100) - end) - end + local handle + handle = uv.new_fs_event() + if handle then + uv.fs_event_start(handle, colorscheme_filepath, {}, function(err, _, _) + if err then + print("Error watching colorscheme file:", err) + return + end + -- debounce by adding a slight delay before reloading + vim.defer_fn(load_colors, 100) + end) + end end watch_colorscheme() - diff --git a/homes/modules/programs/neovim/lua/lsp/capabilities.lua b/homes/modules/programs/neovim/lua/lsp/capabilities.lua index 9256965..7e9957b 100644 --- a/homes/modules/programs/neovim/lua/lsp/capabilities.lua +++ b/homes/modules/programs/neovim/lua/lsp/capabilities.lua @@ -1,59 +1,66 @@ local M = {} function M.on_attach(_, bufnr) - -- we create a function that lets us more easily define mappings specific - -- for LSP related items. It sets the mode, buffer and description for us each time. + -- we create a function that lets us more easily define mappings specific + -- for LSP related items. It sets the mode, buffer and description for us each time. - local nmap = function(keys, func, desc) - if desc then - desc = 'LSP: ' .. desc - end + local nmap = function(keys, func, desc) + if desc then + desc = "LSP: " .. desc + end - vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc }) - end + vim.keymap.set("n", keys, func, { buffer = bufnr, desc = desc }) + end - nmap('rn', vim.lsp.buf.rename, '[R]e[n]ame') - nmap('ca', vim.lsp.buf.code_action, '[C]ode [A]ction') + nmap("rn", vim.lsp.buf.rename, "[R]e[n]ame") + nmap("ca", vim.lsp.buf.code_action, "[C]ode [A]ction") - nmap('gd', vim.lsp.buf.definition, '[G]oto [D]efinition') + nmap("gd", vim.lsp.buf.definition, "[G]oto [D]efinition") - -- NOTE: why are these functions that call the telescope builtin? - -- because otherwise they would load telescope eagerly when this is defined. - -- due to us using the on_require handler to make sure it is available. - if nixCats('general.telescope') then - nmap('gr', function() require('telescope.builtin').lsp_references() end, '[G]oto [R]eferences') - nmap('gI', function() require('telescope.builtin').lsp_implementations() end, '[G]oto [I]mplementation') - nmap('ds', function() require('telescope.builtin').lsp_document_symbols() end, '[D]ocument [S]ymbols') - nmap('ws', function() require('telescope.builtin').lsp_dynamic_workspace_symbols() end, '[W]orkspace [S]ymbols') - nmap('dd', "Telescope diagnostics bufnr=0", '[D]ocument [D]iagnostics') - nmap('wd', "Telescope diagnostics", '[W]orkspace [D]iagnostics') - end -- TODO: someone who knows the builtin versions of these to do instead help me out please. + -- NOTE: why are these functions that call the telescope builtin? + -- because otherwise they would load telescope eagerly when this is defined. + -- due to us using the on_require handler to make sure it is available. + if nixCats("general.telescope") then + nmap("gr", function() + require("telescope.builtin").lsp_references() + end, "[G]oto [R]eferences") + nmap("gI", function() + require("telescope.builtin").lsp_implementations() + end, "[G]oto [I]mplementation") + nmap("ds", function() + require("telescope.builtin").lsp_document_symbols() + end, "[D]ocument [S]ymbols") + nmap("ws", function() + require("telescope.builtin").lsp_dynamic_workspace_symbols() + end, "[W]orkspace [S]ymbols") + nmap("dd", "Telescope diagnostics bufnr=0", "[D]ocument [D]iagnostics") + nmap("wd", "Telescope diagnostics", "[W]orkspace [D]iagnostics") + end -- TODO: someone who knows the builtin versions of these to do instead help me out please. - nmap('D', vim.lsp.buf.type_definition, 'Type [D]efinition') - nmap('e', vim.diagnostic.open_float, 'Show [E]rror') + nmap("D", vim.lsp.buf.type_definition, "Type [D]efinition") + nmap("e", vim.diagnostic.open_float, "Show [E]rror") - -- See `:help K` for why this keymap - nmap('K', vim.lsp.buf.hover, 'Hover Documentation') - nmap('', vim.lsp.buf.signature_help, 'Signature Documentation') + -- See `:help K` for why this keymap + nmap("K", vim.lsp.buf.hover, "Hover Documentation") + nmap("", vim.lsp.buf.signature_help, "Signature Documentation") - -- Lesser used LSP functionality - nmap('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') - nmap('wa', vim.lsp.buf.add_workspace_folder, '[W]orkspace [A]dd Folder') - nmap('wr', vim.lsp.buf.remove_workspace_folder, '[W]orkspace [R]emove Folder') - nmap('wl', function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, '[W]orkspace [L]ist Folders') - - -- Create a command `:Format` local to the LSP buffer - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, { desc = 'Format current buffer with LSP' }) + -- Lesser used LSP functionality + nmap("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") + nmap("wa", vim.lsp.buf.add_workspace_folder, "[W]orkspace [A]dd Folder") + nmap("wr", vim.lsp.buf.remove_workspace_folder, "[W]orkspace [R]emove Folder") + nmap("wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, "[W]orkspace [L]ist Folders") + -- Create a command `:Format` local to the LSP buffer + vim.api.nvim_buf_create_user_command(bufnr, "Format", function(_) + vim.lsp.buf.format() + end, { desc = "Format current buffer with LSP" }) end function M.get(server_name) - local capabilities = require('blink.cmp').get_lsp_capabilities() + local capabilities = require("blink.cmp").get_lsp_capabilities() - return capabilities + return capabilities end return M diff --git a/homes/modules/programs/neovim/lua/lsp/completion.lua b/homes/modules/programs/neovim/lua/lsp/completion.lua index cdbc9db..2e485d9 100644 --- a/homes/modules/programs/neovim/lua/lsp/completion.lua +++ b/homes/modules/programs/neovim/lua/lsp/completion.lua @@ -1,88 +1,88 @@ return { - { - "friendly-snippets", - dep_of = { "blink.cmp" }, - }, - { - "blink.cmp", - event = { "InsertEnter", "CmdlineEnter" }, - on_require = "blink", - load = function (name) - vim.cmd.packadd(name) - end, - after = function(plugin) - local blink = require('blink.cmp') - - blink.setup({ - keymap = { - preset = 'default', - }, - - appearance = { - nerd_font_variant = 'mono', + { + "friendly-snippets", + dep_of = { "blink.cmp" }, }, + { + "blink.cmp", + event = { "InsertEnter", "CmdlineEnter" }, + on_require = "blink", + load = function(name) + vim.cmd.packadd(name) + end, + after = function(plugin) + local blink = require("blink.cmp") - sources = { - default = { 'lsp', 'path', 'snippets', 'buffer' }, - providers = { - lsp = { - name = 'LSP', - module = 'blink.cmp.sources.lsp', - enabled = true, - }, - path = { - name = 'Path', - module = 'blink.cmp.sources.path', - enabled = true, - }, - snippets = { - name = 'Snippets', - module = 'blink.cmp.sources.snippets', - enabled = true, - }, - buffer = { - name = 'Buffer', - module = 'blink.cmp.sources.buffer', - enabled = true, - }, - }, + blink.setup({ + keymap = { + preset = "default", + }, + + appearance = { + nerd_font_variant = "mono", + }, + + sources = { + default = { "lsp", "path", "snippets", "buffer" }, + providers = { + lsp = { + name = "LSP", + module = "blink.cmp.sources.lsp", + enabled = true, + }, + path = { + name = "Path", + module = "blink.cmp.sources.path", + enabled = true, + }, + snippets = { + name = "Snippets", + module = "blink.cmp.sources.snippets", + enabled = true, + }, + buffer = { + name = "Buffer", + module = "blink.cmp.sources.buffer", + enabled = true, + }, + }, + }, + + completion = { + accept = { + auto_brackets = { + enabled = true, + }, + }, + + menu = { + border = "rounded", + max_height = 12, + scrolloff = 2, + + draw = { + columns = { + { "kind_icon", gap = 1 }, + { "label", "label_description", gap = 1 }, + }, + }, + }, + + documentation = { + auto_show = false, + window = { + border = "rounded", + }, + }, + }, + + signature = { + enabled = true, + window = { + border = "rounded", + }, + }, + }) + end, }, - - completion = { - accept = { - auto_brackets = { - enabled = true, - }, - }, - - menu = { - border = 'rounded', - max_height = 12, - scrolloff = 2, - - draw = { - columns = { - { "kind_icon", gap = 1, }, - { "label", "label_description", gap = 1, }, - }, - }, - }, - - documentation = { - auto_show = false, - window = { - border = 'rounded', - }, - }, - }, - - signature = { - enabled = true, - window = { - border = 'rounded', - }, - }, - }) - end - }, } diff --git a/homes/modules/programs/neovim/lua/lsp/indentation.lua b/homes/modules/programs/neovim/lua/lsp/indentation.lua index df7c2a8..b7b65ac 100644 --- a/homes/modules/programs/neovim/lua/lsp/indentation.lua +++ b/homes/modules/programs/neovim/lua/lsp/indentation.lua @@ -1,17 +1,17 @@ vim.api.nvim_create_autocmd("FileType", { - pattern = "lua", - callback = function() - vim.opt_local.shiftwidth = 2 - vim.opt_local.tabstop = 2 - vim.opt_local.expandtab = true - end, + pattern = "lua", + callback = function() + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, }) vim.api.nvim_create_autocmd("FileType", { - pattern = "nix", - callback = function() - vim.opt_local.shiftwidth = 2 - vim.opt_local.tabstop = 2 - vim.opt_local.expandtab = true - end, + pattern = "nix", + callback = function() + vim.opt_local.shiftwidth = 2 + vim.opt_local.tabstop = 2 + vim.opt_local.expandtab = true + end, }) diff --git a/homes/modules/programs/neovim/lua/lsp/init.lua b/homes/modules/programs/neovim/lua/lsp/init.lua index 647d24f..e2d09ed 100644 --- a/homes/modules/programs/neovim/lua/lsp/init.lua +++ b/homes/modules/programs/neovim/lua/lsp/init.lua @@ -1,6 +1,6 @@ -require("lze").load { - { import = "lsp.completion", }, -} +require("lze").load({ + { import = "lsp.completion" }, +}) require("lsp.indentation") require("lsp.lsp") diff --git a/homes/modules/programs/neovim/lua/lsp/lsp.lua b/homes/modules/programs/neovim/lua/lsp/lsp.lua index 18e3c80..fd8bd1b 100644 --- a/homes/modules/programs/neovim/lua/lsp/lsp.lua +++ b/homes/modules/programs/neovim/lua/lsp/lsp.lua @@ -1,87 +1,87 @@ local servers = {} servers.lua_ls = { - settings = { - Lua = { - formatters = { - ignoreComments = false, - }, - signatureHelp = { enable = true }, - diagnostics = { - globals = { 'nixCats', 'vim' }, - -- disable = { 'missing-fields' }, - }, - workspace = { - -- make the server aware of the neovim runtime files - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - }, - telemetry = { enabled = false }, - }, + settings = { + Lua = { + formatters = { + ignoreComments = false, + }, + signatureHelp = { enable = true }, + diagnostics = { + globals = { "nixCats", "vim" }, + -- disable = { 'missing-fields' }, + }, + workspace = { + -- make the server aware of the neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + }, + telemetry = { enabled = false }, + }, } servers.nil_ls = { - settings = {}, + settings = {}, } local rust_analyzer_cmd = os.getenv("RUST_ANALYZER_CMD") servers.rust_analyzer = { - cmd = { rust_analyzer_cmd }, - settings = { - server = { - -- For debugging rust-analyzer, to see log location do :LspInfo in neovim - -- extraEnv = { {["RA_LOG"]="project_model=debug"} }, - }, - cargo = { - allFeatures = false, - allTargets = false, - buildScripts = { enable = true }, - target = "x86_64-unknown-linux-gnu", - }, - diagnostics = { - enable = true, - }, - }, + cmd = { rust_analyzer_cmd }, + settings = { + server = { + -- For debugging rust-analyzer, to see log location do :LspInfo in neovim + -- extraEnv = { {["RA_LOG"]="project_model=debug"} }, + }, + cargo = { + allFeatures = false, + allTargets = false, + buildScripts = { enable = true }, + target = "x86_64-unknown-linux-gnu", + }, + diagnostics = { + enable = true, + }, + }, } servers.zls = { - settings = {}, + settings = {}, } local elixir_ls_cmd = os.getenv("ELIXIR_LS_CMD") servers.elixirls = { - cmd = { elixir_ls_cmd }, - settings = {}, + cmd = { elixir_ls_cmd }, + settings = {}, } servers.gleam = { - settings = {}, + settings = {}, } servers.hls = { - settings = {}, + settings = {}, } local java_home = os.getenv("JAVA_HOME") servers.jdtls = { - settings = { - java = { - contentProvider = { preferred = 'fernflower' }, - configuration = { - runtimes = { - { - name = "OpenJDK 17", - path = os.getenv("OPENJDK_17"), - }, - { - name = "OpenJDK 21", - path = os.getenv("OPENJDK_21"), - }, - } - } - }, - } + settings = { + java = { + contentProvider = { preferred = "fernflower" }, + configuration = { + runtimes = { + { + name = "OpenJDK 17", + path = os.getenv("OPENJDK_17"), + }, + { + name = "OpenJDK 21", + path = os.getenv("OPENJDK_21"), + }, + }, + }, + }, + }, } -- Taken from nixCats example: @@ -90,41 +90,41 @@ servers.jdtls = { -- nvim-lspconfig, it would do the same thing. -- come to think of it, it might be better because then lspconfig doesnt have to be called before lsp attach? -- but you would still end up triggering on a FileType event anyway, so, it makes little difference. -vim.api.nvim_create_autocmd('LspAttach', { - group = vim.api.nvim_create_augroup('nixCats-lsp-attach', { clear = true }), - callback = function(event) - require('lsp.capabilities').on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf) - end +vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("nixCats-lsp-attach", { clear = true }), + callback = function(event) + require("lsp.capabilities").on_attach(vim.lsp.get_client_by_id(event.data.client_id), event.buf) + end, }) -require("lze").load { - { - "nvim-lspconfig", - event = "FileType", - after = function(plugin) - -- Just register configs, don't enable yet - for server_name, cfg in pairs(servers) do - vim.lsp.config(server_name, { - capabilities = require('lsp.capabilities').get(server_name), - settings = (cfg or {}).settings, - filetypes = (cfg or {}).filetypes, - cmd = (cfg or {}).cmd, - root_pattern = (cfg or {}).root_pattern, - }) - end +require("lze").load({ + { + "nvim-lspconfig", + event = "FileType", + after = function(plugin) + -- Just register configs, don't enable yet + for server_name, cfg in pairs(servers) do + vim.lsp.config(server_name, { + capabilities = require("lsp.capabilities").get(server_name), + settings = (cfg or {}).settings, + filetypes = (cfg or {}).filetypes, + cmd = (cfg or {}).cmd, + root_pattern = (cfg or {}).root_pattern, + }) + end - -- Enable on-demand per filetype - for server_name, cfg in pairs(servers) do - local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes - if filetypes then - vim.api.nvim_create_autocmd('FileType', { - pattern = filetypes, - callback = function() - vim.lsp.enable(server_name) - end, - }) - end - end - end, - }, -} + -- Enable on-demand per filetype + for server_name, cfg in pairs(servers) do + local filetypes = cfg.filetypes or vim.lsp.config[server_name].filetypes + if filetypes then + vim.api.nvim_create_autocmd("FileType", { + pattern = filetypes, + callback = function() + vim.lsp.enable(server_name) + end, + }) + end + end + end, + }, +}) diff --git a/homes/modules/programs/neovim/lua/plugins/dressing.lua b/homes/modules/programs/neovim/lua/plugins/dressing.lua index bca1775..42e7280 100644 --- a/homes/modules/programs/neovim/lua/plugins/dressing.lua +++ b/homes/modules/programs/neovim/lua/plugins/dressing.lua @@ -1,5 +1,5 @@ return { - { - "dressing.nvim" - }, + { + "dressing.nvim", + }, } diff --git a/homes/modules/programs/neovim/lua/plugins/format.lua b/homes/modules/programs/neovim/lua/plugins/format.lua new file mode 100644 index 0000000..2097d75 --- /dev/null +++ b/homes/modules/programs/neovim/lua/plugins/format.lua @@ -0,0 +1,33 @@ +-- docs -> https://github.com/stevearc/conform.nvim +return { + { + "conform.nvim", + enabled = nixCats("format") or false, + keys = { + { "p", desc = "Format File (pretty :3)" }, + }, + after = function(plugin) + local conform = require("conform") + + conform.setup({ + formatters_by_ft = { + lua = nixCats("lang.lua.format") and { "stylua" } or nil, + nix = nixCats("lang.nix.format") and { "nixfmt" } or nil, + rust = nixCats("lang.rust.format") and { "rustfmt", lsp_format = "fallback" } or nil, + haskell = nixCats("lang.haskell.format") and { "ormolu" } or nil, + }, + format_on_save = { + timeout_ms = 500, + }, + }) + + vim.keymap.set({ "n", "v" }, "p", function() + conform.format({ + lsp_fallback = false, + async = false, + timeout_ms = 1000, + }) + end, { desc = "Format File (pretty :3)" }) + end, + }, +} diff --git a/homes/modules/programs/neovim/lua/plugins/fyler.lua b/homes/modules/programs/neovim/lua/plugins/fyler.lua index dd2bdab..2737b78 100644 --- a/homes/modules/programs/neovim/lua/plugins/fyler.lua +++ b/homes/modules/programs/neovim/lua/plugins/fyler.lua @@ -1,15 +1,22 @@ return { - { - "fyler.nvim", - cmd = { "Fyler" }, - keys = { - { "tf", function() return require('fyler').toggle({ kind = "split_right" }) end, mode = {"n"}, desc = 'Open [F]yler' }, - }, - load = function (name) - vim.cmd.packadd(name) - end, - after = function(plugin) - local fyler = require("fyler").setup() - end, - }, + { + "fyler.nvim", + cmd = { "Fyler" }, + keys = { + { + "tf", + function() + return require("fyler").toggle({ kind = "split_right" }) + end, + mode = { "n" }, + desc = "Open [F]yler", + }, + }, + load = function(name) + vim.cmd.packadd(name) + end, + after = function(plugin) + local fyler = require("fyler").setup() + end, + }, } diff --git a/homes/modules/programs/neovim/lua/plugins/init.lua b/homes/modules/programs/neovim/lua/plugins/init.lua index c45bebd..7fa3ecd 100644 --- a/homes/modules/programs/neovim/lua/plugins/init.lua +++ b/homes/modules/programs/neovim/lua/plugins/init.lua @@ -1,7 +1,8 @@ -require("lze").load { - { import = "plugins.dressing", }, - { import = "plugins.telescope", }, - { import = "plugins.treesitter", }, - { import = "plugins.fyler", }, - { import = "plugins.mini-hipatterns", }, -} +require("lze").load({ + { import = "plugins.dressing" }, + { import = "plugins.telescope" }, + { import = "plugins.treesitter" }, + { import = "plugins.fyler" }, + { import = "plugins.mini-hipatterns" }, + { import = "plugins.format" }, +}) diff --git a/homes/modules/programs/neovim/lua/plugins/mini-hipatterns.lua b/homes/modules/programs/neovim/lua/plugins/mini-hipatterns.lua index a7c6c2a..f41688e 100644 --- a/homes/modules/programs/neovim/lua/plugins/mini-hipatterns.lua +++ b/homes/modules/programs/neovim/lua/plugins/mini-hipatterns.lua @@ -1,76 +1,76 @@ return { - { - "mini.hipatterns", - after = function(plugin) - local hipatterns = require("mini.hipatterns") + { + "mini.hipatterns", + after = function(plugin) + local hipatterns = require("mini.hipatterns") - -- Returns hex color group for matching short hex color. - -- - ---@param match string - ---@return string - local hex_color_short = function(_, match) - local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg' - local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4) - local hex = string.format('#%s%s%s%s%s%s', r, r, g, g, b, b) - return hipatterns.compute_hex_color_group(hex, style) - end + -- Returns hex color group for matching short hex color. + -- + ---@param match string + ---@return string + local hex_color_short = function(_, match) + local style = "fg" -- 'fg' or 'bg', for extmark_opts_inline use 'fg' + local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4) + local hex = string.format("#%s%s%s%s%s%s", r, r, g, g, b, b) + return hipatterns.compute_hex_color_group(hex, style) + end - -- Returns hex color group for matching alpha hex color. - -- - ---@param match string - ---@return string - local hex_color_alpha = function(_, match) - local style = 'fg' -- 'fg' or 'bg', for extmark_opts_inline use 'fg' - local r, g, b = match:sub(2, 3), match:sub(4, 5), match:sub(6, 7) - local hex = string.format('#%s%s%s', r, g, b) - return hipatterns.compute_hex_color_group(hex, style) - end + -- Returns hex color group for matching alpha hex color. + -- + ---@param match string + ---@return string + local hex_color_alpha = function(_, match) + local style = "fg" -- 'fg' or 'bg', for extmark_opts_inline use 'fg' + local r, g, b = match:sub(2, 3), match:sub(4, 5), match:sub(6, 7) + local hex = string.format("#%s%s%s", r, g, b) + return hipatterns.compute_hex_color_group(hex, style) + end - -- Returns extmark opts for highlights with virtual inline text. - -- - ---@param data table Includes `hl_group`, `full_match` and more. - ---@return table - local extmark_opts_inline = function(_, _, data) - return { - virt_text = { { '󰧞', data.hl_group } }, - virt_text_pos = 'inline', - right_gravity = false, - } - end + -- Returns extmark opts for highlights with virtual inline text. + -- + ---@param data table Includes `hl_group`, `full_match` and more. + ---@return table + local extmark_opts_inline = function(_, _, data) + return { + virt_text = { { "󰧞", data.hl_group } }, + virt_text_pos = "inline", + right_gravity = false, + } + end - -- Returns extmark opts for highlights with virtual inline text. - -- - ---@param data table Includes `hl_group`, `full_match` and more. - ---@return table - local extmark_opts_inline_alpha = function(_, _, data) - return { - virt_text = { { '󱡓', data.hl_group } }, - virt_text_pos = 'inline', - right_gravity = false, - } - end + -- Returns extmark opts for highlights with virtual inline text. + -- + ---@param data table Includes `hl_group`, `full_match` and more. + ---@return table + local extmark_opts_inline_alpha = function(_, _, data) + return { + virt_text = { { "󱡓", data.hl_group } }, + virt_text_pos = "inline", + right_gravity = false, + } + end - hipatterns.setup({ - highlighters = { - -- #rrggbb - hex_color = hipatterns.gen_highlighter.hex_color({ - style = "inline", - inline_text = '󰧞', - }), - -- #rgb - hex_color_short = { - pattern = "#%x%x%x%f[%X]", - group = hex_color_short, - extmark_opts = extmark_opts_inline, - }, - -- #rrggbbaa - hex_color_alpha = { - pattern = "#%x%x%x%x%x%x%x%x%f[%X]", - group = hex_color_alpha, - extmark_opts = extmark_opts_inline_alpha, - }, + hipatterns.setup({ + highlighters = { + -- #rrggbb + hex_color = hipatterns.gen_highlighter.hex_color({ + style = "inline", + inline_text = "󰧞", + }), + -- #rgb + hex_color_short = { + pattern = "#%x%x%x%f[%X]", + group = hex_color_short, + extmark_opts = extmark_opts_inline, + }, + -- #rrggbbaa + hex_color_alpha = { + pattern = "#%x%x%x%x%x%x%x%x%f[%X]", + group = hex_color_alpha, + extmark_opts = extmark_opts_inline_alpha, + }, + }, + }) + end, }, - }) - end, - }, } diff --git a/homes/modules/programs/neovim/lua/plugins/telescope.lua b/homes/modules/programs/neovim/lua/plugins/telescope.lua index 919f3bd..a61f19c 100644 --- a/homes/modules/programs/neovim/lua/plugins/telescope.lua +++ b/homes/modules/programs/neovim/lua/plugins/telescope.lua @@ -1,36 +1,78 @@ return { - { - "telescope.nvim", - cmd = { "Telescope" }, - keys = { - { "f", function() return require('telescope.builtin').find_files() end, mode = {"n"}, desc = 'Telescope search [F]iles' }, - { "tr", function() return require('telescope.builtin').oldfiles() end, mode = {"n"}, desc = '[T]elescope search [R]ecent files' }, - { "ts", function() return require('telescope.builtin').live_grep() end, mode = {"n"}, desc = '[T]elescope [S]earch cwd with grep' }, - { "tw", function() return require('telescope.builtin').grep_string() end, mode = {"n"}, desc = '[T]elescope search current [W]ord' }, - { "tk", function() return require('telescope.builtin').keymaps() end, mode = {"n"}, desc = '[T]elescope search [K]eymaps' }, - { "tb", function() return require('telescope.builtin').buffers() end, mode = {"n"}, desc = '[T]elescope search [B]uffers' }, - }, - load = function (name) - vim.cmd.packadd(name) - vim.cmd.packadd("telescope-fzf-native.nvim") - end, - after = function(plugin) - local telescope = require("telescope") - local actions = require("telescope.actions") + { + "telescope.nvim", + cmd = { "Telescope" }, + keys = { + { + "f", + function() + return require("telescope.builtin").find_files() + end, + mode = { "n" }, + desc = "Telescope search [F]iles", + }, + { + "tr", + function() + return require("telescope.builtin").oldfiles() + end, + mode = { "n" }, + desc = "[T]elescope search [R]ecent files", + }, + { + "ts", + function() + return require("telescope.builtin").live_grep() + end, + mode = { "n" }, + desc = "[T]elescope [S]earch cwd with grep", + }, + { + "tw", + function() + return require("telescope.builtin").grep_string() + end, + mode = { "n" }, + desc = "[T]elescope search current [W]ord", + }, + { + "tk", + function() + return require("telescope.builtin").keymaps() + end, + mode = { "n" }, + desc = "[T]elescope search [K]eymaps", + }, + { + "tb", + function() + return require("telescope.builtin").buffers() + end, + mode = { "n" }, + desc = "[T]elescope search [B]uffers", + }, + }, + load = function(name) + vim.cmd.packadd(name) + vim.cmd.packadd("telescope-fzf-native.nvim") + end, + after = function(plugin) + local telescope = require("telescope") + local actions = require("telescope.actions") - telescope.setup { - defaults = { - mappings = { - i = { - [""] = actions.move_selection_previous, -- move to prev result - [""] = actions.move_selection_next, -- move to next result - [""] = actions.send_selected_to_qflist + actions.open_qflist - } - } - } - } + telescope.setup({ + defaults = { + mappings = { + i = { + [""] = actions.move_selection_previous, -- move to prev result + [""] = actions.move_selection_next, -- move to next result + [""] = actions.send_selected_to_qflist + actions.open_qflist, + }, + }, + }, + }) - pcall(telescope.load_extension, "fzf") - end, - }, + pcall(telescope.load_extension, "fzf") + end, + }, } diff --git a/homes/modules/programs/neovim/lua/plugins/treesitter.lua b/homes/modules/programs/neovim/lua/plugins/treesitter.lua index 489ecf9..55984c7 100644 --- a/homes/modules/programs/neovim/lua/plugins/treesitter.lua +++ b/homes/modules/programs/neovim/lua/plugins/treesitter.lua @@ -2,94 +2,94 @@ -- https://github.com/BirdeeHub/nixCats-nvim/blob/3c9bc4d7123e1b48d92f25ba505b889af541e897/templates/example/lua/myLuaConf/plugins/treesitter.lua return { - { - "nvim-treesitter", - lazy = false, - after = function (plugin) - --@param buf integer - --@param language string - local function treesitter_try_attach(buf, language) - --check if parser exists and load it - if not vim.treesitter.language.add(language) then - return - end + { + "nvim-treesitter", + lazy = false, + after = function(plugin) + --@param buf integer + --@param language string + local function treesitter_try_attach(buf, language) + --check if parser exists and load it + if not vim.treesitter.language.add(language) then + return + end - -- enables syntax highlight and other treesitter features - vim.treesitter.start(buf, language) + -- enables syntax highlight and other treesitter features + vim.treesitter.start(buf, language) - -- enables treesitter based folds - vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + -- enables treesitter based folds + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" - -- enables treesiter based indentation - vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" - end + -- enables treesiter based indentation + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end - local available_parsers = require("nvim-treesitter").get_available() - vim.api.nvim_create_autocmd("FileType", { - callback = function(args) - local buf, filetype = args.buf, args.match - local language = vim.treesitter.language.get_lang(filetype) - if not language then - return - end + local available_parsers = require("nvim-treesitter").get_available() + vim.api.nvim_create_autocmd("FileType", { + callback = function(args) + local buf, filetype = args.buf, args.match + local language = vim.treesitter.language.get_lang(filetype) + if not language then + return + end - local installed_parsers = require("nvim-treesitter").get_installed("parsers") + local installed_parsers = require("nvim-treesitter").get_installed("parsers") - if vim.tbl_contains(installed_parsers, language) then - -- enable the parser if it is installed - treesitter_try_attach(buf, language) - elseif vim.tbl_contains(available_parsers, language) then - -- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed - require("nvim-treesitter").install(language):await(function() - treesitter_try_attach(buf, language) - end) - else - -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` - treesitter_try_attach(buf, language) - end - end, - }) - end, - }, - { - "nvim-treesitter-textobjects", - lazy = false, - before = function(plugin) - vim.g.no_plugin_maps = true - end, - after = function(plugin) - require("nvim-treesitter-textobjects").setup { - select = { - lookahead = true, - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - }, - include_surrounding_whitespace = false, + if vim.tbl_contains(installed_parsers, language) then + -- enable the parser if it is installed + treesitter_try_attach(buf, language) + elseif vim.tbl_contains(available_parsers, language) then + -- if a parser is available in `nvim-treesitter` enable it after ensuring it is installed + require("nvim-treesitter").install(language):await(function() + treesitter_try_attach(buf, language) + end) + else + -- try to enable treesitter features in case the parser exists but is not available from `nvim-treesitter` + treesitter_try_attach(buf, language) + end + end, + }) + end, }, - } + { + "nvim-treesitter-textobjects", + lazy = false, + before = function(plugin) + vim.g.no_plugin_maps = true + end, + after = function(plugin) + require("nvim-treesitter-textobjects").setup({ + select = { + lookahead = true, + selection_modes = { + ["@parameter.outer"] = "v", -- charwise + ["@function.outer"] = "V", -- linewise + }, + include_surrounding_whitespace = false, + }, + }) - -- keymaps - vim.keymap.set({ "x", "o" }, "am", function() - require "nvim-treesitter-textobjects.select".select_textobject("@function.outer", "textobjects") - end) - vim.keymap.set({ "x", "o" }, "im", function() - require "nvim-treesitter-textobjects.select".select_textobject("@function.inner", "textobjects") - end) - vim.keymap.set({ "x", "o" }, "ac", function() - require "nvim-treesitter-textobjects.select".select_textobject("@class.outer", "textobjects") - end) - vim.keymap.set({ "x", "o" }, "ic", function() - require "nvim-treesitter-textobjects.select".select_textobject("@class.inner", "textobjects") - end) - -- You can also use captures from other query groups like `locals.scm` - vim.keymap.set({ "x", "o" }, "as", function() - require "nvim-treesitter-textobjects.select".select_textobject("@local.scope", "locals") - end) + -- keymaps + vim.keymap.set({ "x", "o" }, "am", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "im", function() + require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ac", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects") + end) + vim.keymap.set({ "x", "o" }, "ic", function() + require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects") + end) + -- You can also use captures from other query groups like `locals.scm` + vim.keymap.set({ "x", "o" }, "as", function() + require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals") + end) - -- NOTE: for more textobjects options, see the following link. - -- This template is using the new `main` branch of the repo. - -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main - end, - }, + -- NOTE: for more textobjects options, see the following link. + -- This template is using the new `main` branch of the repo. + -- https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main + end, + }, } diff --git a/homes/modules/programs/neovim/nixcats.nix b/homes/modules/programs/neovim/nixcats.nix index e9061cf..d1ee226 100644 --- a/homes/modules/programs/neovim/nixcats.nix +++ b/homes/modules/programs/neovim/nixcats.nix @@ -1,3 +1,5 @@ +# TODO: look into changing to this: +# https://github.com/BirdeeHub/nix-wrapper-modules { inputs, spkgs, @@ -56,31 +58,38 @@ in { tree-sitter ]; lang = with pkgs; { - lua = [ - lua-language-server - ]; - nix = [ - nil - nix-doc - ]; - rust = with pkgs; [ - cargo - mpkgs.rust-analyzer - ]; - zig = with pkgs; [ + lua = { + lsp = [ lua-language-server ]; + format = [ stylua ]; + }; + nix = { + lsp = [ + nil + nix-doc # TODO: i forgot what this is for + ]; + format = [ nixfmt ]; + }; + rust = { + lsp = [ + cargo + mpkgs.rust-analyzer + ]; + format = [ rustfmt ]; + }; + zig = [ spkgs.zls # FIX: using spkgs version as zls is broken rn ;-; ]; - elixir = with pkgs; [ + elixir = [ elixir-ls ]; - gleam = with pkgs; [ + gleam = [ gleam ]; - haskell = with pkgs; [ + haskell = [ haskell-language-server ormolu ]; - java = with pkgs; [ + java = [ jdt-language-server javaPackages.compiler.openjdk17 javaPackages.compiler.openjdk21 @@ -138,6 +147,9 @@ in { cmp-cmdline-history lspkind-nvim ]; + format = with pkgs.vimPlugins; [ + conform-nvim + ]; lang = with pkgs.vimPlugins; { java = [ nvim-jdtls @@ -214,16 +226,29 @@ in { fyler = true; lsp = true; completion = true; + format = true; treesitter = true; lang = { - lua = true; - nix = true; - rust = true; + lua = { + lsp = true; + format = true; + }; + nix = { + lsp = true; + format = true; + }; + rust = { + lsp = true; + format = true; + }; zig = true; elixir = true; gleam = true; - haskell = true; + haskell = { + lsp = true; + format = true; + }; java = true; }; }; From bf1706b0faad25ed09fe304ffd7ee826d42c9158 Mon Sep 17 00:00:00 2001 From: foxora Date: Sat, 21 Feb 2026 19:42:57 +0000 Subject: [PATCH 4/4] fixed lsp and formatter stuff!! <3 --- flake.lock | 6 +++--- homes/modules/programs/neovim/nixcats.nix | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index ddf7975..d2b22c3 100644 --- a/flake.lock +++ b/flake.lock @@ -1293,11 +1293,11 @@ }, "nixpkgs-master": { "locked": { - "lastModified": 1771439456, - "narHash": "sha256-HtQgNJrjYvZdpqpPJddF+TxGCazNyxvA8umbDcjrxT8=", + "lastModified": 1771702014, + "narHash": "sha256-/P7uAp8q1xFhaw9Z+OG7lUK3wVz1Q/wreAyeiMyyjLI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f84d6f6cd5f17d594439710f40349ba7d0706f4b", + "rev": "cceb9213362e92c06b60b50c1e2877bc5fb95887", "type": "github" }, "original": { diff --git a/homes/modules/programs/neovim/nixcats.nix b/homes/modules/programs/neovim/nixcats.nix index d1ee226..d0bb93f 100644 --- a/homes/modules/programs/neovim/nixcats.nix +++ b/homes/modules/programs/neovim/nixcats.nix @@ -85,10 +85,10 @@ in { gleam = [ gleam ]; - haskell = [ - haskell-language-server - ormolu - ]; + haskell = { + lsp = [ haskell-language-server ]; + format = [ ormolu ]; + }; java = [ jdt-language-server javaPackages.compiler.openjdk17 @@ -166,15 +166,15 @@ in { }; environmentVariables = { lang = { - rust = { + rust.lsp = { # it literally won't see the rust-analyzer provided to it # if you don't use an envrionment variable to tell it - RUST_ANALYZER_CMD = "${pkgs.rust-analyzer}/bin/rust-analyzer"; + RUST_ANALYZER_CMD = "${mpkgs.rust-analyzer}/bin/rust-analyzer"; }; - elixir = { + elixir.lsp = { ELIXIR_LS_CMD = "${pkgs.elixir-ls}/scripts/language_server.sh"; }; - java = { + java.lsp = { JAVA_HOME = "${pkgs.javaPackages.compiler.openjdk17}"; OPENJDK_17 = "${pkgs.javaPackages.compiler.openjdk17}"; OPENJDK_21 = "${pkgs.javaPackages.compiler.openjdk21}";