From 6fea0a1f4e10affd9f1a3fbdec86a1a82564570b Mon Sep 17 00:00:00 2001 From: Natalie Date: Wed, 21 May 2025 10:44:59 -0700 Subject: [PATCH] nearly at parity with lua-based config --- flake.nix | 1 - lib/mkSystem.nix | 2 +- modules/macos/homebrew.nix | 16 +-- modules/neovim/default.nix | 3 - users/natalie/desktop/configuration.nix | 1 + users/natalie/home.nix | 4 +- users/natalie/laptop/configuration.nix | 18 ++-- users/natalie/vim.nix | 21 +++- users/natalie/vim/keybinds.nix | 8 +- users/natalie/vim/languages.nix | 137 ++++++++++++++++-------- 10 files changed, 132 insertions(+), 79 deletions(-) diff --git a/flake.nix b/flake.nix index 1269413..8877e2f 100644 --- a/flake.nix +++ b/flake.nix @@ -49,7 +49,6 @@ }@inputs: let lib = nixpkgs.lib; - # TODO: apply these overlays sooner and remove uses of legacyPackages elsewhere. overlays = [ inputs.zig.overlays.default diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 0b9baa7..40387ac 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -7,7 +7,7 @@ mkNeovim, }: name: { user, # ./users/{name} - host, # ./users/{name}/{host} (optional) + host, # ./users/{name}/{host} system, # arch-os extraModules ? [], }: let diff --git a/modules/macos/homebrew.nix b/modules/macos/homebrew.nix index f149ae8..275844e 100644 --- a/modules/macos/homebrew.nix +++ b/modules/macos/homebrew.nix @@ -4,27 +4,15 @@ _: { enable = true; onActivation = { - autoUpdate = true; + autoUpdate = false; cleanup = "none"; - upgrade = true; + upgrade = false; }; brews = [ - "imagemagick" - "opam" ]; casks = [ - "battle-net" - "stremio" - "alt-tab" - "legcord" - "zulip" - "zen-browser" - "supertuxkart" - "sf-symbols" - - "mediosz/tap/swipeaerospace" ]; masApps = { diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 461f6d1..355a395 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -87,9 +87,6 @@ ripgrep.enable = true; }; friendly-snippets.enable = true; - setupOpts = { - keymap.preset = "super-tab"; - }; }; }; statusline = { diff --git a/users/natalie/desktop/configuration.nix b/users/natalie/desktop/configuration.nix index d5caecf..abc5094 100644 --- a/users/natalie/desktop/configuration.nix +++ b/users/natalie/desktop/configuration.nix @@ -9,6 +9,7 @@ # Include the results of the hardware scan. ./hardware-configuration.nix ]; + documentation.man.generateCaches = false; programs = { gamemode.enable = true; diff --git a/users/natalie/home.nix b/users/natalie/home.nix index ee30ddf..230fe96 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -2,8 +2,7 @@ pkgs, lib, ... -}@args: -{ +} @ args: { programs = { # sort-lines:start atuin.enable = true; @@ -11,6 +10,7 @@ hyfetch.enable = true; direnv.enable = true; fish.enable = true; + man.generateCaches = false; # sort-lines:end }; diff --git a/users/natalie/laptop/configuration.nix b/users/natalie/laptop/configuration.nix index f7d8c3e..484ad78 100644 --- a/users/natalie/laptop/configuration.nix +++ b/users/natalie/laptop/configuration.nix @@ -1,5 +1,4 @@ -{ pkgs, ... }: -{ +{pkgs, ...}: { environment.systemPackages = with pkgs; [ pinentry_mac signal-desktop-bin @@ -8,7 +7,7 @@ # Custom configuration modules in "modules" are shared between users, # and can be configured in this "shared" namespace shared.darwin = { - macAppStoreApps = [ "wireguard" ]; + macAppStoreApps = ["wireguard"]; }; # Create /etc/zshrc that loads the nix-darwin environment. @@ -30,14 +29,6 @@ # Use homebrew to install casks homebrew = { - enable = true; - - onActivation = { - autoUpdate = true; - cleanup = "none"; - upgrade = true; - }; - brews = [ "imagemagick" "opam" @@ -49,8 +40,11 @@ "alt-tab" "legcord" "zulip" - "zen-browser" + "zen" "supertuxkart" + "sf-symbols" + + "mediosz/tap/swipeaerospace" ]; }; } diff --git a/users/natalie/vim.nix b/users/natalie/vim.nix index ae57a12..b3b342d 100644 --- a/users/natalie/vim.nix +++ b/users/natalie/vim.nix @@ -1,8 +1,27 @@ -{...}: { +{pkgs, ...}: { imports = [ ./vim/default.nix ]; vim = { + options = { + tabstop = 2; + softtabstop = 2; + shiftwidth = 2; + undofile = true; + swapfile = false; + showmode = false; + foldmethod = "expr"; + foldexpr = "v:lua.vim.treesitter.foldexpr()"; + }; + + autocmds = [ + { + event = ["LspAttach"]; + pattern = ["*"]; + desc = "User: Set LSP folding if client supports it"; + callback = pkgs.lib.generators.mkLuaInline ''function(ctx) local client = assert(vim.lsp.get_client_by_id(ctx.data.client_id)) if client:supports_method("textDocument/foldingRange") then local win = vim.api.nvim_get_current_win() vim.wo[win][0].foldexpr = "v:lua.vim.lsp.foldexpr()" end end''; + } + ]; theme = { name = "catppuccin"; style = "mocha"; diff --git a/users/natalie/vim/keybinds.nix b/users/natalie/vim/keybinds.nix index b077e50..619dec4 100644 --- a/users/natalie/vim/keybinds.nix +++ b/users/natalie/vim/keybinds.nix @@ -1,4 +1,5 @@ -{...}: let +{ ... }: +let mkKeymap = mode: key: action: desc: { inherit mode @@ -7,7 +8,8 @@ desc ; }; -in { +in +{ vim = { keymaps = [ (mkKeymap "n" "e" ":lua require('snacks').explorer()" "File Explorer") @@ -17,7 +19,7 @@ in { (mkKeymap "n" "ff" ":lua require('snacks').picker.files()" "Find File") (mkKeymap "n" "fg" ":lua require('snacks').picker.grep()" "Grep Files") # Lsp - (mkKeymap "n" "K" ":lua vim.lsp.buf.hover()" "Hover docs") + (mkKeymap "n" "K" ":Lspsaga hover_doc" "Hover docs") (mkKeymap "n" "lr" ":lua vim.lsp.buf.rename()" "Rename") # (mkKeymap "n" "th" ":lua function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end" "Toggle Inlay Hints") ]; diff --git a/users/natalie/vim/languages.nix b/users/natalie/vim/languages.nix index 94bc705..6f51b4d 100644 --- a/users/natalie/vim/languages.nix +++ b/users/natalie/vim/languages.nix @@ -1,63 +1,95 @@ { flake, - userConfig, + user, + host, pkgs, ... -}: { +}: let + darwin = + if host.darwin + then "darwin" + else "nixos"; + flakePath = "/${ + if host.darwin + then "Users" + else "home" + }/${user.username}/.dotfiles"; + + # BIG HACK DO NOT DO PLS + + hostname = + if host.darwin + then "Natalies-MacBook-Air" + else "nixos"; +in { vim = { extraPackages = with pkgs; [ python312Packages.pylatexenc ]; lsp = { + lightbulb.enable = false; + lspsaga = { + enable = true; + setupOpts = { + lightbulb = { + virtual_text = false; + }; + }; + }; nvim-docs-view.enable = true; inlayHints.enable = true; - servers.nixd.settings = { - nixd.nixpkgs.expr = ''import "${flake.inputs.nixpkgs}" { }''; - options = { - nixos = { - expr = '' - (let pkgs = import "${flake.inputs.nixpkgs}" {}; inherit (pkgs) lib; in (lib.evalModules { modules = (import "${flake.inputs.nixpkgs}/nixos/modules/module-list.nix"); check = false;})).options''; + servers.nixd.settings.nixd = { + nixpkgs.expr = ''import "" { }''; + options = + { + home-manager = { + expr = ''(builtins.getFlake "${flakePath}").${darwin}Configurations.${hostname}.options.home-manager.users.type.getSubOptions [ ]''; + }; + } + // pkgs.lib.optionalAttrs host.darwin { + nix-darwin = { + expr = ''(builtins.getFlake "${flakePath}").darwinConfigurations.${hostname}.options''; + }; + } + // pkgs.lib.optionalAttrs host.linux { + nixos = { + expr = ''(builtins.getFlake "${flakePath}").nixosConfigurations.${hostname}.options''; + }; }; - nix_darwin = { - expr = '' - (let pkgs = import "${flake.inputs.nixpkgs}" {}; inherit (pkgs) lib; in (lib.evalModules { modules = import ("${flake.inputs.darwin}/modules/module-list.nix"); check = false;})).options''; - }; - home_manager = { - expr = '' - (let pkgs = import "${flake.inputs.nixpkgs}" {}; lib = import "${flake.inputs.home-manager}/modules/lib/stdlib-extended.nix" pkgs.lib; in (lib.evalModules { modules = (import "${flake.inputs.home-manager}/modules/modules.nix") { inherit lib pkgs; check = false; };})).options''; - }; - }; - mappings = { - codeAction = "ca"; - goToDeclaration = "gD"; - goToDefinition = "gd"; - listReferences = "gr"; - goToType = "gy"; - hover = "K"; - nextDiagnostic = "d"; - openDiagnosticFloat = "df"; - renameSymbol = "rn"; - documentHighlight = null; - listDocumentSymbols = null; - listImplementations = null; - listWorkspaceFolders = null; - previousDiagnostic = null; - removeWorkspaceFolder = null; - signatureHelp = null; - toggleFormatOnSave = null; - }; + }; + mappings = { + codeAction = "ca"; + goToDeclaration = "gD"; + goToDefinition = "gd"; + listReferences = "gr"; + goToType = "gy"; + hover = null; + nextDiagnostic = "d"; + openDiagnosticFloat = "df"; + renameSymbol = "rn"; + documentHighlight = null; + listDocumentSymbols = null; + listImplementations = null; + listWorkspaceFolders = null; + previousDiagnostic = null; + removeWorkspaceFolder = null; + signatureHelp = null; + toggleFormatOnSave = null; }; }; languages = { enableDAP = true; - # haskell.enable = true; lua.enable = true; python.enable = true; python.format.type = "ruff"; - markdown.extensions.render-markdown-nvim = { + markdown = { enable = true; + extensions.render-markdown-nvim = { + enable = true; + }; }; }; + formatter.conform-nvim = { enable = true; setupOpts = { @@ -84,9 +116,13 @@ additionalVimRegexHighlighting = true; }; - context.enable = true; + grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ + markdown_inline + markdown + ]; + highlight.enable = true; - indent.enable = true; + indent.enable = false; }; visuals = { @@ -98,13 +134,30 @@ }; autocomplete.blink-cmp = { enable = true; - # mappings = { - # }; + mappings = { + close = null; + complete = null; + confirm = null; + next = null; + previous = null; + scrollDocsDown = null; + scrollDocsUp = null; + }; setupOpts = { + keymap = { + preset = "super-tab"; + }; completion = { ghost_text.enabled = false; list.selection.preselect = true; + trigger = { + show_in_snippet = true; + }; + accept.auto_brackets.enabled = true; + }; + signature = { + enabled = true; }; }; };