diff --git a/.gitignore b/.gitignore index b12e90ad5ad4ae77215e74cdf66de71da19ef3cc..fd9d1ca548f88694b09655ec42567e08161475b9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -flake.lock .DS_STORE +.hostname +flake.lock result result-* diff --git a/flake.lock b/flake.lock index 8c35bf3a02d8f914e4d32e9fa7f28ef8afb5667c..f0dbb9d1b89b326a865764b2c31c27cf9f18ecfb 100644 --- a/flake.lock +++ b/flake.lock @@ -9,11 +9,11 @@ ] }, "locked": { - "lastModified": 1754511800, - "narHash": "sha256-/gYkj4dbzcAV1EWJYy+2ryHGtC57jhIrRwSGQKCT8Gk=", + "lastModified": 1755807717, + "narHash": "sha256-x/IcOa+p9VFYlwXmuNhbZ8ce9As24rqy6uABv+tKacU=", "owner": "tadfisher", "repo": "android-nixpkgs", - "rev": "5bb0f6e7b112c7be7895c6058925c29db360b205", + "rev": "4316f29f7f3b34c41f2639ae190022fbed60b850", "type": "github" }, "original": { @@ -58,11 +58,11 @@ ] }, "locked": { - "lastModified": 1751313918, - "narHash": "sha256-HsJM3XLa43WpG+665aGEh8iS8AfEwOIQWk3Mke3e7nk=", + "lastModified": 1755825449, + "narHash": "sha256-XkiN4NM9Xdy59h69Pc+Vg4PxkSm9EWl6u7k6D5FZ5cM=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "e04a388232d9a6ba56967ce5b53a8a6f713cdfcf", + "rev": "8df64f819698c1fee0c2969696f54a843b2231e8", "type": "github" }, "original": { @@ -314,11 +314,11 @@ ] }, "locked": { - "lastModified": 1753943136, - "narHash": "sha256-eiEE5SabVcIlGSTRcRyBjmJMaYAV95SJnjy8YSsVeW4=", + "lastModified": 1755810213, + "narHash": "sha256-QdenO8f0PTg+tC6HuSvngKcbRZA5oZKmjUT+MXKOLQg=", "owner": "nix-community", "repo": "home-manager", - "rev": "bd82507edd860c453471c46957cbbe3c9fd01b5c", + "rev": "6911d3e7f475f7b3558b4f5a6aba90fa86099baa", "type": "github" }, "original": { @@ -363,11 +363,11 @@ ] }, "locked": { - "lastModified": 1753293216, - "narHash": "sha256-4hAm9PYNHAsR3MxH8MhSZt7mTiR8MlhyQilLJEPdaZs=", + "lastModified": 1754439168, + "narHash": "sha256-NcwRidwb/ask65LE86os4RkhyoPQo5sLu0sJs/NboK4=", "owner": "moonlight-mod", "repo": "moonlight", - "rev": "297a1b57c14ff18890382b2fe89f493ba349a730", + "rev": "66b81b113afd6654a88c9adb7edb7fe92839fe84", "type": "github" }, "original": { @@ -383,11 +383,11 @@ ] }, "locked": { - "lastModified": 1753589988, - "narHash": "sha256-y1JlcMB2dKFkrr6g+Ucmj8L//IY09BtSKTH/A7OU7mU=", + "lastModified": 1755404379, + "narHash": "sha256-Q6ZxZDBmD/B988Jjbx7/NchxOKIpOKBBrx9Yb0zMzpQ=", "owner": "nix-community", "repo": "nix-index-database", - "rev": "f0736b09c43028fd726fb70c3eb3d1f0795454cf", + "rev": "ebbc1c05f786ae39bb5e04e57bf2c10c44a649e3", "type": "github" }, "original": { @@ -434,11 +434,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1753694789, - "narHash": "sha256-cKgvtz6fKuK1Xr5LQW/zOUiAC0oSQoA9nOISB0pJZqM=", + "lastModified": 1755615617, + "narHash": "sha256-HMwfAJBdrr8wXAkbGhtcby1zGFvs+StOp19xNsbqdOg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dc9637876d0dcc8c9e5e22986b857632effeb727", + "rev": "20075955deac2583bb12f07151c2df830ef346b4", "type": "github" }, "original": { @@ -540,11 +540,11 @@ ] }, "locked": { - "lastModified": 1753930086, - "narHash": "sha256-Os6Ta5zamfAllmQNlvkbGZLHn06zJy3hVXRk+Dy2yMo=", + "lastModified": 1755830208, + "narHash": "sha256-fMa/Hcg+4O2h+kl3gNPjtGSWPI8NtCl3LYMsejK6qGA=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "17b672c10c1798696a516cb879edbc2ebd0f58a4", + "rev": "802a7b97f8ff672ba2dec70c9e354f51f844e796", "type": "github" }, "original": { @@ -749,11 +749,11 @@ ] }, "locked": { - "lastModified": 1753676490, - "narHash": "sha256-XeifEftxYGP/gzp6O1yO1S1W+MEx4Xvrgeu84ryRPNQ=", + "lastModified": 1754886070, + "narHash": "sha256-MZDmxOkVKL1HY72bliN8Gxh0SYkHUa3W/1fTU2ke36I=", "owner": "youwen5", "repo": "zen-browser-flake", - "rev": "77024f4557204bb4d526893d42db2e6f50727fab", + "rev": "e37d2b326311320c8571111b3ef89b29d26d4b64", "type": "github" }, "original": { @@ -769,11 +769,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1753963984, - "narHash": "sha256-JPiCLZHuNk11XYYCqoLoKYIgdUu2WpNccTzl4ljycTQ=", + "lastModified": 1755605615, + "narHash": "sha256-J0Cxren2QLeI0ZvRZw4XGcMm4q3uPIZHM+eJnaZfXX8=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "45772b76cdb103bd300abac4a85a34518dee65a0", + "rev": "714fae26049a263ff2e4641ce7c973f371f4b005", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 72d7e578f967a98211741e1bb0bdb35eab8fef16..cebe693a0da4cbaf4b7f067231349b803ff3d5b3 100644 --- a/flake.nix +++ b/flake.nix @@ -91,7 +91,6 @@ mkSystem = import ./lib/mkSystem.nix { inherit inputs mkNeovim overlays; }; in rec { - inherit self; # "nix fmt" formatter = forAllSystems (inputs: inputs.pkgs.autofmt); packages = forAllSystems ( @@ -134,6 +133,12 @@ host = "paperback"; system = "aarch64-darwin"; }; + # clover's work macbook pro + darwinConfigurations.clover-work-mac = mkSystem "clover-work-mac" { + user = "clover"; + host = "work"; + system = "aarch64-darwin"; + }; # fish's cattop nixosConfigurations.cattop = mkSystem "cattop" { diff --git a/lib/mkNeovim.nix b/lib/mkNeovim.nix index c0e0c70e832de6bd998898eb5db7a71f3b2a495c..d638598ee58e0b5d0d50fb7bed98c8a54181ff43 100644 --- a/lib/mkNeovim.nix +++ b/lib/mkNeovim.nix @@ -10,16 +10,18 @@ let userDir = ../users + "/${user}"; userConfig = import (userDir + "/user.nix"); + + config = inputs.nvf.lib.neovimConfiguration { + inherit pkgs; + modules = builtins.filter (f: f != null) [ + (../users + ("/" + user + "/vim.nix")) + ../modules/neovim + ]; + extraSpecialArgs = { + inherit host; + flake = self; + user = userConfig; + }; + }; in -(inputs.nvf.lib.neovimConfiguration { - inherit pkgs; - modules = builtins.filter (f: f != null) [ - (../users + ("/" + user + "/vim.nix")) - ../modules/neovim - ]; - extraSpecialArgs = { - inherit host; - flake = self; - user = userConfig; - }; -}).neovim +config.neovim // { input = config; } diff --git a/modules/home/default.nix b/modules/home/default.nix index 997ad2406a696cae358364b543c027167279e82d..0ac5223e3ee64e211c6ef563ae76a5f01abd048b 100644 --- a/modules/home/default.nix +++ b/modules/home/default.nix @@ -77,6 +77,7 @@ in # ViM and Neovim ".*.swp" ".nvimlog" + ".jj" ]; }; @@ -120,16 +121,47 @@ in inherit (pkgs.fishPlugins.bang-bang) src; } ]; - shellAliases = { - } - // lib.optionalAttrs (!host.darwin) { - reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; - }; shellInit = '' - batman --export-env | source - test -r '/Users/${user.username}/.opam/opam-init/init.fish' && source '/Users/${user.username}/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true + if type -q batman + batman --export-env | source + end + test -r "$HOME"'/.opam/opam-init/init.fish' && source "$HOME"'/.opam/opam-init/init.fish' > /dev/null 2> /dev/null; or true ''; }; + zsh = { + enableCompletion = true; + autosuggestion.enable = true; + syntaxHighlighting.enable = true; + autocd = true; + history.size = 10000; + }; + jujutsu = { + settings = { + user = { + email = config.programs.git.userEmail; + name = config.programs.git.userName; + }; + signing = { + behavior = "own"; + backend = "ssh"; + key = "~/.ssh/id_ed25519.pub"; + }; + git = { + sign-on-push = true; + push-new-bookmarks = true; + }; + ui = { + default-command = "log"; + diff-formatter = [ + "${pkgs.difftastic}/bin/difft" + "--color=always" + "$left" + "$right" + ]; + pager = "${pkgs.bat}/bin/bat --style=plain"; + }; + }; + }; ghostty.settings.custom-shader = lib.mkIf ( cfg.ghostty.shader != null diff --git a/modules/neovim/blink-cmp.nix b/modules/neovim/blink-cmp.nix new file mode 100644 index 0000000000000000000000000000000000000000..6a3d3fa5a026978eace2dc92bb576d2067f2849e --- /dev/null +++ b/modules/neovim/blink-cmp.nix @@ -0,0 +1,33 @@ +{ lib, ... }: +{ + vim.autocomplete.blink-cmp = { + enable = true; + mappings = { + close = null; + complete = null; + confirm = null; + next = null; + previous = null; + scrollDocsDown = null; + scrollDocsUp = null; + }; + setupOpts = { + keymap = { + preset = "super-tab"; + "" = [ "show" ]; + }; + completion = { + ghost_text.enabled = false; + list.selection.preselect = true; + trigger = { + show_in_snippet = true; + }; + }; + signature.enabled = true; + }; + sourcePlugins = { + ripgrep.enable = true; + }; + friendly-snippets.enable = true; + }; +} diff --git a/modules/neovim/commands/FullscreenTerm.lua b/modules/neovim/commands/FullscreenTerm.lua new file mode 100644 index 0000000000000000000000000000000000000000..4daeb6b24689ba466bca4a2f7e56ecf314c1a9f9 --- /dev/null +++ b/modules/neovim/commands/FullscreenTerm.lua @@ -0,0 +1,27 @@ +-- Ported from https://www.reddit.com/r/neovim/comments/vemydn +vim.api.nvim_create_user_command("FullscreenTerm", function(opts) + vim.cmd("tab terminal " .. opts.args) + local laststatus = vim.o.laststatus + local showtabline = vim.o.showtabline + local cmdheight = vim.o.cmdheight + vim.o.laststatus = 0 + vim.o.cmdheight = 0 + vim.o.showtabline = 0 + vim.wo.signcolumn = "no" + vim.wo.relativenumber = false + vim.wo.number = false + vim.cmd( + "autocmd! TermClose " + .. "if !v:event.status" + .. " | exec 'bd! '..expand('')" + .. " | endif" + .. " | checktime" + .. " | set laststatus=" + .. laststatus + .. " | set cmdheight=" + .. cmdheight + .. " | set showtabline=" + .. showtabline + ) + vim.cmd("startinsert") +end, { nargs = "*" }) diff --git a/modules/neovim/commands/SmartQuit.lua b/modules/neovim/commands/SmartQuit.lua new file mode 100644 index 0000000000000000000000000000000000000000..9bd9ccdfc7673eec8a9bebbc61e3f1c32fc96bf7 --- /dev/null +++ b/modules/neovim/commands/SmartQuit.lua @@ -0,0 +1,96 @@ +vim.api.nvim_create_user_command("SmartQuit", function(opts) + -- scan all buffers for unsaved buffers + local unsaved = {} + local saved = {} + for _, buf in ipairs(vim.api.nvim_list_bufs()) do + if vim.api.nvim_buf_is_loaded(buf) and vim.api.nvim_buf_get_option(buf, "buflisted") then + if vim.api.nvim_buf_get_option(buf, "modified") then + table.insert(unsaved, buf) + else + table.insert(saved, buf) + end + end + end + + if #unsaved == 0 then + vim.cmd("qa") + return + end + + -- gui for resolving unsaved files + local lines = {} + for _, buf in ipairs(unsaved) do + local full_path = vim.api.nvim_buf_get_name(buf) + local name = full_path == "" and ("[No Name] #" .. buf) or vim.fn.fnamemodify(full_path, ":~:.") + table.insert(lines, " • " .. name) + end + table.insert(lines, "") + table.insert(lines, " s - Save all and quit") + table.insert(lines, " c - Close saved; leave unsaved open") + table.insert(lines, " d - DISCARD ALL") + + local buf = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines) + vim.api.nvim_buf_set_option(buf, "readonly", true) + local width = math.max(unpack(vim.tbl_map(function(l) return #l end, lines))) + local height = #lines + local win = vim.api.nvim_open_win(buf, true, { + relative = "editor", + width = width + 1, + height = height, + row = (vim.o.lines - height) / 2 - 1, + col = (vim.o.columns - width) / 2, + style = "minimal", + border = "rounded", + title = { + { #unsaved .. " Unsaved Buffer" .. (#unsaved ~= 1 and "s" or "") .. "!", "ErrorMsg" }, + }, + title_pos = "center", + }) + + vim.wo[win].winhighlight = "Normal:Normal,FloatBorder:ErrorMsg" + vim.api.nvim_win_set_option(win, "cursorline", false) + + local hl = vim.api.nvim_get_hl_by_name('Cursor', true) + hl.blend = 100 + vim.api.nvim_set_hl(0, 'Cursor', hl) + vim.opt.guicursor:append('a:Cursor/lCursor') + + function close() + local hl = vim.api.nvim_get_hl_by_name('Cursor', true) + hl.blend = 0 + vim.api.nvim_set_hl(0, 'Cursor', hl) + vim.opt.guicursor:remove('a:Cursor/lCursor') + vim.api.nvim_win_close(win, true) + end + + -- keyboard event handlers + vim.keymap.set("n", "s", function() + for _, buf in ipairs(unsaved) do + vim.api.nvim_buf_call(buf, function() + vim.cmd("write") + end) + end + close() + vim.cmd("qa") + end, { buffer = buf }) + vim.keymap.set("n", "c", function() + for _, buf in ipairs(saved) do + vim.api.nvim_buf_delete(buf, {}) + end + close() + end, { buffer = buf }) + vim.keymap.set("n", "d", function() + vim.cmd("qa!") + end, { buffer = buf }) + vim.keymap.set("n", "", function() + close() + end, { buffer = buf }) + + vim.api.nvim_create_autocmd({ 'WinLeave' }, { + buffer = buf, + callback = close, + }) +end, { nargs = 0 }) + +vim.api.nvim_set_hl(0, "QuitPopUpBorder", { fg = "red" }) diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix index 446fe23840991d9e30473eb9ce2c347102b9b247..6a31c91a848672da9814e0b6bd9e5c5ad48a29f8 100644 --- a/modules/neovim/default.nix +++ b/modules/neovim/default.nix @@ -9,6 +9,7 @@ ./formatter.nix ./keybind.nix ./options.nix + ./blink-cmp.nix ]; # based on default options from upstream: # https://github.com/NotAShelf/nvf/blob/main/configuration.nix @@ -20,13 +21,12 @@ # which allows user configurations to disable/override anything here. config.vim = lib.mkOverride 999 { extraLuaFiles = [ - ./lib.lua + ./commands/FullscreenTerm.lua + ./commands/SmartQuit.lua + + ./extra.lua ]; - - theme = { - enable = true; - }; - + theme.enable = true; visuals = { # notification system # https://github.com/j-hui/fidget.nvim @@ -57,17 +57,19 @@ lspkind.enable = config.vim.autocomplete.blink-cmp.enable; # Enables inlay hints (types info in rust and shit) inlayHints.enable = true; - #Nice mappings that i use :3 + # Nice mappings that I use :3 mappings = { - codeAction = "ca"; + codeAction = null; # in keymaps goToDeclaration = "gD"; goToDefinition = "gd"; - listReferences = "gr"; - goToType = "gy"; + # TODO: changing these works but there is something else defining stuff + # like grn, grr, grt, etc + listReferences = "grr"; + goToType = "grt"; hover = "K"; nextDiagnostic = null; # ]d openDiagnosticFloat = "d"; - renameSymbol = "rn"; + renameSymbol = "grn"; documentHighlight = null; listDocumentSymbols = null; listImplementations = null; @@ -82,6 +84,14 @@ treesitter = { enable = true; addDefaultGrammars = true; + # this is buggy and keybind.nix overwrites its keymaps anyways + incrementalSelection.enable = false; + mappings.incrementalSelection = { + decrementByNode = null; + incrementByNode = null; + incrementByScope = null; + init = null; + }; }; debugger.nvim-dap = { enable = true; @@ -99,8 +109,6 @@ clang.enable = true; css.enable = true; html.enable = true; - lua.enable = true; - markdown.enable = true; nix.enable = true; python.enable = true; rust.crates.enable = true; @@ -108,12 +116,30 @@ ts.enable = true; zig.enable = true; # sort-lines: off + + nix.lsp.servers = "nixd"; }; filetree.neo-tree = { enable = true; setupOpts = { enable_cursor_hijack = true; git_status_async = true; + close_if_last_window = true; + window.width = 30; + filesystem.filtered_items = { + # dotfiles are often used for project configuration + hide_dotfiles = false; + never_show = [ + ".git" + ".jj" + ".DS_Store" # macOS + "thumbs.db" # Windows + ]; + never_show_by_pattern = [ + ".*.swp" + "._*" # macOS + ]; + }; }; }; fzf-lua = { @@ -125,36 +151,6 @@ }; }; }; - autocomplete.blink-cmp = { - enable = true; - 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; - }; - sourcePlugins = { - ripgrep.enable = true; - }; - friendly-snippets.enable = true; - }; statusline = { lualine = { enable = true; @@ -188,6 +184,7 @@ gitsigns.enable = true; gitsigns.codeActions.enable = false; # throws an annoying debug message }; + utility.undotree.enable = true; # Better help docs lazy.plugins."helpview.nvim" = { enabled = true; diff --git a/modules/neovim/extra.lua b/modules/neovim/extra.lua new file mode 100644 index 0000000000000000000000000000000000000000..8c91ba429eee35837cccebeb6c2537d479f34e1d --- /dev/null +++ b/modules/neovim/extra.lua @@ -0,0 +1,2 @@ +-- not sure how to add this in nix +require("fzf-lua").register_ui_select() diff --git a/modules/neovim/keybind.nix b/modules/neovim/keybind.nix index 42732a67b0f9f0d2280f4c549d81b4a33ad10eee..a57c35d5f235e7ea0539815b5e399c5d97e1372a 100644 --- a/modules/neovim/keybind.nix +++ b/modules/neovim/keybind.nix @@ -21,6 +21,7 @@ in toggle-explorer = keyCmd "n" "e" "Neotree toggle"; reveal-active-file = keyCmd "n" "E" "Neotree reveal:Neotree focus"; lazygit = keyCmd "n" "gg" "FullscreenTerm ${pkgs.lazygit}/bin/lazygit"; + smart-quit = keyCmd "n" "q" "SmartQuit"; # pickers pick-file = keyCmd "n" "" "FzfLua files"; @@ -34,11 +35,12 @@ in # lsp code-action = keyCmd "n" "ca" - "FzfLua lsp_code_actions winopts.height=15 winopts.backdrop=100 winopts.title=false winopts.preview.title=false winopts.row=1"; + "FzfLua lsp_code_actions winopts.height=8 winopts.width=50 winopts.backdrop=100 winopts.title=false winopts.preview.title=false winopts.row=1 winopts.preview.hidden=true silent=true"; # subtle nice features visual-dedent = keyRemap "v" "<" "" ">gv"; # keep selection + visual-overwrite = keyRemap "v" "p" "pgvygv"; # re-yank text clear-search-highlights = keyRemap "n" "" ":noh"; }; diff --git a/modules/neovim/lib.lua b/modules/neovim/lib.lua deleted file mode 100644 index 4daeb6b24689ba466bca4a2f7e56ecf314c1a9f9..0000000000000000000000000000000000000000 --- a/modules/neovim/lib.lua +++ /dev/null @@ -1,27 +0,0 @@ --- Ported from https://www.reddit.com/r/neovim/comments/vemydn -vim.api.nvim_create_user_command("FullscreenTerm", function(opts) - vim.cmd("tab terminal " .. opts.args) - local laststatus = vim.o.laststatus - local showtabline = vim.o.showtabline - local cmdheight = vim.o.cmdheight - vim.o.laststatus = 0 - vim.o.cmdheight = 0 - vim.o.showtabline = 0 - vim.wo.signcolumn = "no" - vim.wo.relativenumber = false - vim.wo.number = false - vim.cmd( - "autocmd! TermClose " - .. "if !v:event.status" - .. " | exec 'bd! '..expand('')" - .. " | endif" - .. " | checktime" - .. " | set laststatus=" - .. laststatus - .. " | set cmdheight=" - .. cmdheight - .. " | set showtabline=" - .. showtabline - ) - vim.cmd("startinsert") -end, { nargs = "*" }) diff --git a/packages/autofmt/autofmt.js b/packages/autofmt/autofmt.js index dc8481d663f42c7849af589caaf249260b63e4b6..ef74cbf9a340d1f69c3809cddfafd0a3e95d180e 100755 --- a/packages/autofmt/autofmt.js +++ b/packages/autofmt/autofmt.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -// autofmt v1 by paper clover +// autofmt v2 by paper clover // https://paperclover.dev/nix/config/src/branch/main/packages/autofmt/autofmt.js // // Different codebases use different formatters. Autofmt looks for project @@ -25,6 +25,10 @@ // } // }, // +// CHANGELOG +// v2: added 'prettierd' as a supported formatter option. +// v1: initial release +// // @ts-nocheck // -- definitions -- @@ -72,6 +76,15 @@ const formatters = { cmd: ["deno", "fmt", "--", "$files"], stdin: (file) => ["deno", "fmt", "--ext", path.extname(file).slice(1), "-"], }, + prettierd: { + // keep in mind that pretterd never exits. + // https://github.com/fsouza/prettierd/issues/645 + languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"], + mustMatchFile: true, + files: { "node_modules/.bin/prettier": () => which("prettierd") }, + cmd: null, + stdin: (file) => ["prettierd", file], + }, prettier: { languages: ["javascript", "markdown", "json", "yaml", "mdx", "html", "css"], files: ["node_modules/.bin/prettier"], @@ -91,7 +104,7 @@ const formatters = { "nixfmt-rfc-style": { languages: ["nix"], files: { - "flake.nix": (contents) => contents.includes("nixfmt"), + "flake.nix": ({ text }) => text.includes("nixfmt"), }, cmd: ["nixfmt", "--", "$files"], stdin: (file) => ["nixfmt", `--filename=${file}`], @@ -99,7 +112,7 @@ const formatters = { alejandra: { languages: ["nix"], files: { - "flake.nix": (contents) => contents.includes("alejandra"), + "flake.nix": ({ text }) => text.includes("alejandra"), }, cmd: ["alejandra", "--", "$files"], stdin: () => ["alejandra"], @@ -498,24 +511,31 @@ function pickFormatter(file) { return walkUp(dir, (x) => { const children = readDir(x); for (const fmt of order) { + if (formatters[fmt][stdio ? "stdin" : "cmd"] == null) continue; + let matches = false; if (formatters[fmt].files === true) { matches = true; } if (!matches) { const filesToCheck = Array.isArray(formatters[fmt].files) - ? formatters[fmt].files.map((base) => ({ base, contents: true })) + ? formatters[fmt].files.map((base) => ({ base, check: true })) : Object.entries(formatters[fmt].files) - .map(([base, contents]) => ({ base, contents })); - for (const { base, contents } of filesToCheck) { + .map(([base, check]) => ({ base, check })); + for (const { base, check } of filesToCheck) { if (base.includes("/")) { matches = readDir(path.join(x, path.dirname(base))) // .includes(path.basename(base)); } else { matches = children.includes(base); } - if (matches && typeof contents === "function") { - matches = !!contents(fs.readFileSync(path.join(x, base), "utf-8")); + if (matches && typeof check === "function") { + let text; + matches = !!check({ + get text() { + return text ??= fs.readFileSync(path.join(x, base), "utf-8"); + }, + }); } } } @@ -526,7 +546,7 @@ function pickFormatter(file) { return formatterId; } } - }) ?? possible[0]; + }) ?? possible.find((fmt) => !formatters[fmt].mustMatchFile); } /** @param dir {string} @param find {(x: string) => any} */ @@ -581,6 +601,29 @@ function readGitIgnore(dir) { } } +/** @param {string} name @returns {string | null} */ +export function which(name) { + const paths = + process.env.PATH?.split(process.platform === "win32" ? ";" : ":") ?? []; + const exts = process.platform === "win32" + ? (process.env.PATHEXT?.split(";") ?? [".exe", ".cmd", ".bat", ".com"]) + : [""]; + + for (const dir of paths) { + if (!dir) continue; + try { + const entries = readDir(dir); + for (const ext of exts) { + const target = name + ext; + if (entries.includes(target)) { + return dir + sep + target; + } + } + } catch {} + } + return null; +} + function escapeGlob(str) { return str.replace(/[\\*,{}]/g, "\\$&"); } diff --git a/packages/autofmt/default.nix b/packages/autofmt/default.nix index 54893c07aca0b08fc951b8dfee853e6df317f616..fa006e3e7dc0b83bcc7ebb686daafe54b4925e08 100644 --- a/packages/autofmt/default.nix +++ b/packages/autofmt/default.nix @@ -3,12 +3,13 @@ pkgs.writeShellApplication { name = "autofmt"; runtimeInputs = with pkgs; [ # include only a couple of formatters by default + clang-tools deno - nixfmt-rfc-style dprint + nixfmt-rfc-style + prettierd # autofmt only runs on a local build of prettier rustfmt zig - clang-tools ]; - text = ''exec deno run -A ${./autofmt.js} "$@"''; + text = ''exec ${pkgs.nodejs}/bin/node ${./autofmt.js} "$@"''; } diff --git a/switch b/switch index 3c267596a89ce1a79011f5431c6d73cc4e2a25ec..bf5697d655d9362730c9db9854db34b7950154fc 100755 --- a/switch +++ b/switch @@ -1,12 +1,23 @@ #!/bin/sh nh_subcommand="os" fallback_command="nixos-rebuild" -if [ "$(uname -o)" = "darwin" ]; then - nh_subcommand="darwin" - fallback_command="nix run .#darwin-rebuild" +hostname_file="$(dirname "$0")/.hostname" +if [ -n "$1" ]; then + hostname="$1" +elif [ -f "$hostname_file" ]; then + hostname=$(cat "$hostname_file") +fi +if [ -z "$hostname" ]; then + hostname="$(hostname)" +fi +printf "%s" "$hostname" >"$hostname_file" +if [ "$(uname -o)" = "Darwin" ]; then + nh_subcommand="darwin" + fallback_command="nix run .#darwin-rebuild" + hostname="darwinConfigurations.$hostname" fi if command -v nh >/dev/null; then - nh $nh_subcommand switch . + nh $nh_subcommand switch '.#'"$hostname" else - $fallback_command -- switch --flake . + $fallback_command -- switch --flake '.#'"$hostname" fi diff --git a/users/clover/home.nix b/users/clover/home.nix index 3fddc2063a6495e1d9f47399a919fab8a7d40728..4f799cb1e39b41021b6abfc173356266bfab50b0 100644 --- a/users/clover/home.nix +++ b/users/clover/home.nix @@ -10,9 +10,7 @@ in let # packages to always install all = [ - (ffmpeg.override { - withSvtav1 = true; - }) + ffmpeg-full ripgrep uv nh @@ -22,6 +20,7 @@ in desktop = [ git-town lazygit + jjui ]; # packages to install on all servers server = [ ]; @@ -49,10 +48,9 @@ in shader = "cursor-smear-black.glsl"; package = null; settings = { - theme = "light:catppuccin-latte,dark:catppuccin-macchiato"; + theme = "light:Farmhouse Light,dark:Challenger Deep"; font-family = "AT Name Mono"; adjust-cursor-thickness = 1; - minimum-contrast = 1.1; background-opacity = 0.9; background-blur = true; }; @@ -61,14 +59,12 @@ in # zsh is the shell i use zsh = { enable = true; - enableCompletion = true; - autosuggestion.enable = true; - syntaxHighlighting.enable = true; - - history.size = 10000; - shellAliases = { - switch = "nh darwin switch ~/config"; + switch = "~/config/switch"; + gg = "lazygit"; + ga = "git add"; + g = "git status"; + gp = "git pull --rebase && git push"; }; profileExtra = '' function python() { @@ -84,6 +80,193 @@ in # use a git-specific email git.userEmail = "git@paperclover.net"; + jujutsu = { + enable = true; + # my workflow is based on creating changes and editing them. while they + # are in progress the description starts with "WIP: " + settings = rec { + colors = { + bookmark = "green"; + bookmarks = colors.bookmark; + local_bookmarks = colors.bookmarks; + remote_bookmarks = colors.bookmark; + "working_copy bookmark" = "bright green"; + "working_copy bookmarks" = colors."working_copy bookmark"; + "working_copy local_bookmarks" = colors."working_copy bookmark"; + "working_copy remote_bookmarks" = colors."working_copy bookmark"; + + "author" = { + fg = "white"; + bold = false; + italic = true; + }; + "working_copy author" = colors.author; + + desc = { + bold = false; + fg = "bright white"; + }; + description = colors.desc; + cc_wip = { + fg = "bright yellow"; + bold = true; + reverse = true; + }; + cc_header = { + bold = true; + fg = "bright white"; + }; + cc_feat = "green"; + cc_fix = "red"; + cc_hotfix = "red"; + cc_chore = "yellow"; + cc_test = "blue"; + cc_other = "blue"; + cc_scope = { + fg = "cyan"; + bold = false; + italic = true; + }; + + active_marker = { + fg = "bright magenta"; + bold = true; + reverse = true; + }; + conflict_marker = { + fg = "bright red"; + bold = true; + reverse = true; + }; + + timestamp = "bright black"; + commit_id = { + fg = "bright black"; + bold = false; + }; + muted = "bright black"; + }; + # ui.graph.style = "square"; + revsets = { + log = "ancestors(description(regex:\"^(WIP:|\\\\s*$)\"), 3) | ancestors(immutable_heads(), 2) | ancestors(visible_heads(), 2)"; + short-prefixes = "(trunk()..@)::"; + }; + templates.log = "hl_wip(self)"; + + template-aliases = { + # log template, highlighting the WIP commits by making everything else faded out + "hl_wip(commit)" = '' + if(commit.root(), format_root_commit(commit), + label("__commit__", + format_short_commit_header(commit) ++ "\n" ++ + format_commit_description(commit) + ) + ) + ''; + + "format_commit_description(commit)" = '' + label("desc", format_commit_firstline(commit.description().first_line())) ++ + "\n" ++ if( + commit.description().starts_with("WIP:") || commit.current_working_copy(), + commit.description().remove_prefix(commit.description().first_line()).remove_prefix("\n").trim_end() ++ "\n ", + if(commit.description().remove_prefix(commit.description().first_line()).trim().len() > 0, + label("muted", lines_collapsed(commit.description().lines().filter(|x| x.trim().len() > 0).len() - 1)), + " " + ) + ) + ''; + "lines_collapsed(count)" = + ''("[" ++ stringify(count ++ " line" ++ if(count == 1, "", "s")) ++ " collapsed]\n")''; + "format_commit_firstline(line)" = '' + if(line.starts_with("WIP:"), + label("cc_wip", " WIP ") ++ " " ++ format_commit_firstline_a_wip(line.remove_prefix("WIP:").trim()), + format_commit_firstline_a_wip(line) + ) + ''; + "format_commit_firstline_a_wip(line)" = '' + if(line.starts_with("feat:") || line.starts_with("feat("), + label("cc_feat", "feat") ++ format_commit_firstline_a_cc_type(line.remove_prefix("feat")), + if(line.starts_with("fix:") || line.starts_with("fix("), + label("cc_fix", "fix") ++ format_commit_firstline_a_cc_type(line.remove_prefix("fix")), + if(line.starts_with("hotfix:") || line.starts_with("hotfix("), + label("cc_hotfix", "hotfix") ++ format_commit_firstline_a_cc_type(line.remove_prefix("hotfix")), + if(line.starts_with("chore:") || line.starts_with("chore("), + label("cc_chore", "chore") ++ format_commit_firstline_a_cc_type(line.remove_prefix("chore")), + if(line.starts_with("test:") || line.starts_with("test("), + label("cc_other", "test") ++ format_commit_firstline_a_cc_type(line.remove_prefix("test")), + if(line.starts_with("refactor:") || line.starts_with("refactor("), + label("cc_other", "refactor") ++ format_commit_firstline_a_cc_type(line.remove_prefix("refactor")), + if(line.starts_with("perf:") || line.starts_with("perf("), + label("cc_other", "perf") ++ format_commit_firstline_a_cc_type(line.remove_prefix("perf")), + if(line.starts_with("lib:") || line.starts_with("lib("), + label("cc_other", "lib") ++ format_commit_firstline_a_cc_type(line.remove_prefix("lib")), + label("cc_header", line) + )))))))) + ''; + "format_commit_firstline_a_cc_type(rest)" = '' + if(rest.starts_with("(") && rest.contains(")"), + format_firstline_cc_scope(rest, index_of_close_paren(rest)), + format_firstline_a_cc(rest)) + ''; + "format_firstline_cc_scope(rest, index)" = '' + label("cc_scope", rest.substr(0, index)) ++ format_firstline_a_cc(rest.substr(index, rest.len())) + ''; + "format_firstline_a_cc(rest)" = '' + if(rest.starts_with(":"), + label("muted", ":") ++ label("cc_header", rest.remove_prefix(":")), + label("cc_header", rest) + ) + ''; + # sorry! + "index_of_close_paren(line)" = '' + stringify(if(line.substr(1, 2) == ")", "A", + if(line.substr(2, 3) == ")", "AA", + if(line.substr(3, 4) == ")", "AAA", + if(line.substr(4, 5) == ")", "AAAA", + if(line.substr(5, 6) == ")", "AAAAA", + if(line.substr(6, 7) == ")", "AAAAAA", + if(line.substr(7, 8) == ")", "AAAAAAA", + if(line.substr(8, 9) == ")", "AAAAAAAA", + if(line.substr(9, 10) == ")","AAAAAAAAA", + if(line.substr(10, 11) == ")", "AAAAAAAAAA", + if(line.substr(11, 12) == ")", "AAAAAAAAAAA", + if(line.substr(12, 13) == ")", "AAAAAAAAAAAA", + if(line.substr(13, 14) == ")", "AAAAAAAAAAAAA", + if(line.substr(14, 15) == ")", "AAAAAAAAAAAAAA", + if(line.substr(15, 16) == ")", "AAAAAAAAAAAAAAA", + if(line.substr(16, 17) == ")", "AAAAAAAAAAAAAAAA", + if(line.substr(17, 18) == ")", "AAAAAAAAAAAAAAAAA", + if(line.substr(18, 19) == ")", "AAAAAAAAAAAAAAAAAA", + if(line.substr(19, 20) == ")", "AAAAAAAAAAAAAAAAAAA", + if(line.substr(20, 21) == ")", "AAAAAAAAAAAAAAAAAAAA", + "AAAAAAAAAAAAAAAAAAAAA" + ))))))))))))))))))))).len() + 1 + ''; + + "format_short_signature(signature)" = "signature.name()"; + "format_timestamp(timestamp)" = "timestamp.ago()"; + "format_short_commit_header(commit)" = '' + separate(" ", + if(commit.current_working_copy(), label("active_marker", " ACTIVE ")), + if(commit.conflict(), label("conflict_marker", " CONFLICT ")), + format_short_change_id_with_hidden_and_divergent_info(commit), + format_short_signature(commit.author()), + label("muted", "|"), + if(commit.description().trim().len() > 0, label("muted", format_timestamp(commit_timestamp(commit)))), + commit.bookmarks(), + commit.tags(), + commit.working_copies(), + label("muted", "(") ++ + format_short_commit_id(commit.commit_id()) ++ + label("muted", ")"), + if(config("ui.show-cryptographic-signatures").as_boolean(), + format_short_cryptographic_signature(commit.signature())), + ) + ''; + }; + }; + }; + ssh = { enable = true; matchBlocks = rec { @@ -94,12 +277,5 @@ in "nas.paperclover.net" = zenith; }; }; - neovide = { - enable = !hostServer; - settings = { - font.normal = "AT Name Mono"; - font.size = 13; - }; - }; }; } diff --git a/users/clover/paperback/configuration.nix b/users/clover/paperback/configuration.nix index 3d94126693f8ab3136a138d8b013d6491e67fee4..33d6590bbae174414152184a49ac07e49f4204a8 100644 --- a/users/clover/paperback/configuration.nix +++ b/users/clover/paperback/configuration.nix @@ -2,7 +2,6 @@ _: { homebrew = { enable = true; casks = [ - "eloston-chromium" "db-browser-for-sqlite" ]; }; diff --git a/users/clover/paperback/home.nix b/users/clover/paperback/home.nix index 711130f295df837f03f7c41ca2efc7cc64491798..47d88a2034872f1efc7c06355eef2e3b004436b3 100644 --- a/users/clover/paperback/home.nix +++ b/users/clover/paperback/home.nix @@ -3,7 +3,6 @@ # these programs are not globally installed to reduce distractions. # most of these are needed for my work environment. programs = { - bun.enable = true; zsh.profileExtra = '' _bun() { local context state line @@ -12,7 +11,6 @@ ''; }; home.packages = with pkgs; [ - doppler deno nodejs_22 rustup @@ -22,7 +20,5 @@ yt-dlp spotdl zig - ssm-session-manager-plugin - awscli ]; } diff --git a/users/clover/vim.nix b/users/clover/vim.nix index 84bac23ce713af41bcc8bce973f866f8a403b8be..ec63c29156845ebab16ed99f6e77db903a5fa83d 100644 --- a/users/clover/vim.nix +++ b/users/clover/vim.nix @@ -1,20 +1,23 @@ -_: { +{ lib, ... }: +{ vim = { - options = { - linebreak = true; - }; - git = { - gitsigns.setupOpts = { - current_line_blame = false; - current_line_blame_opts = { - virt_text = true; - virt_text_pos = "right_align"; - delay = 25; - ignore_whitespace = true; - virt_text_priority = 100; - use_focus = true; - }; + languages.lua.enable = lib.mkForce true; + options.linebreak = true; + git.gitsigns.setupOpts = { + current_line_blame = false; + current_line_blame_opts = { + virt_text = true; + virt_text_pos = "right_align"; + delay = 25; + ignore_whitespace = true; + virt_text_priority = 100; + use_focus = true; }; }; + # filetree.neo-tree.setupOpts.default_component_configs.indent = { + # padding = 0; + # indent_marker = "|"; + # last_indent_marker = "+"; + # }; }; } diff --git a/users/clover/work/home.nix b/users/clover/work/home.nix new file mode 100644 index 0000000000000000000000000000000000000000..a5fb595349707f6b857c0e40e4208e08ccdeb756 --- /dev/null +++ b/users/clover/work/home.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + programs = { + zsh.profileExtra = '' + _bun() { + local context state line + _arguments -C '*:file:_files' + } + ''; + }; + home.packages = with pkgs; [ + (bun.overrideAttrs (_: rec { + version = "1.1.17"; + src = fetchurl { + url = "https://github.com/oven-sh/bun/releases/download/bun-v${version}/bun-darwin-aarch64.zip"; + hash = "sha256-aULgRZ9evcGUhKJ6slLJOg3IEzUeNfIkJF8RDP3YUlo="; + }; + })) + doppler + deno + nodejs_24 + rustup + typescript + ssm-session-manager-plugin + awscli + ]; +} diff --git a/users/fish/cattop/configuration.nix b/users/fish/cattop/configuration.nix index 8784eed1e591c1813bc90abd2bd63ae4cb2a2a24..510ebab44d3118f2dfbec63a6d960b799c4f099e 100644 --- a/users/fish/cattop/configuration.nix +++ b/users/fish/cattop/configuration.nix @@ -1,115 +1,116 @@ # Edit this configuration file to define what should be installed on # your system. Help is available in the configuration.nix(5) man page, on # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). - { - config, - lib, pkgs, ... }: - { imports = [ - # Include the results of the hardware scan. ./hardware-configuration.nix ]; - # Use the systemd-boot EFI boot loader. boot.loader.efi.canTouchEfiVariables = true; - # networking.hostName = "nixos"; # Define your hostname. - # Pick only one of the below networking options. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + networking.hostName = "cattop"; # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. - # Set your time zone. - # time.timeZone = "Europe/Amsterdam"; - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Select internationalisation properties. - # i18n.defaultLocale = "en_US.UTF-8"; - # console = { - # font = "Lat2-Terminus16"; - # keyMap = "us"; - # useXkbConfig = true; # use xkb.options in tty. - # }; - - # Enable the X11 windowing system. services.xserver.enable = true; - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; + services.displayManager.gdm.enable = true; + services.desktopManager.gnome.enable = true; environment.gnome.excludePackages = ( with pkgs; [ - atomix - cheese + adwaita-fonts + adwaita-icon-theme + baobab + decibels epiphany + evince + file-roller geary - gedit + gnome-backgrounds + gnome-calculator + gnome-calendar gnome-characters + gnome-clocks + gnome-connections + gnome-console + gnome-contacts + gnome-disk-utility + gnome-font-viewer + gnome-logs + gnome-maps gnome-music - gnome-photos - gnome-terminal + gnome-shell-extensions + gnome-system-monitor + gnome-screenshot + gnome-text-editor + gnome-themes-extra gnome-tour - hitori - iagno + gnome-user-docs + gnome-weather + loupe + nautilus + orca + seahorse + simple-scan + snapshot + sushi totem - + yelp ] ); - # Configure keymap in X11 - # services.xserver.xkb.layout = "us"; - # services.xserver.xkb.options = "eurosign:e,caps:escape"; - - # Enable CUPS to print documents. - # services.printing.enable = true; + services.printing.enable = true; # Enable sound. - # services.pulseaudio.enable = true; - # OR - # services.pipewire = { - # enable = true; - # pulse.enable = true; - # }; + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; # Enable touchpad support (enabled default in most desktopManager). # services.libinput.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. users.users.fish = { isNormalUser = true; extraGroups = [ - "wheel" # Enable ‘sudo’ for the user. - "dialout" # Enable serial access for the user. + "wheel" + "dialout" + "audio" ]; packages = with pkgs; [ tree git nh vim - fish ]; }; + programs.git = { + enable = true; + # extraConfig = { + # push = { + # autoSetupRemote = true; + # }; + # }; + }; programs.firefox.enable = true; - programs.neovim.defaultEditor.enable = true; + programs.neovim.enable = true; + #programs.neovim.defaultEditor.enable = true; # List packages installed in system profile. - # You can use https://search.nixos.org/ to find more packages (and options). environment.systemPackages = with pkgs; [ - vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + vim wget ]; - # Some programs need SUID wrappers, can be configured further or are - # started in user sessions. programs.mtr.enable = true; programs.gnupg.agent = { enable = true; @@ -121,12 +122,6 @@ # Enable the OpenSSH daemon. # services.openssh.enable = true; - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; - # Copy the NixOS configuration file and link it from the resulting system # (/run/current-system/configuration.nix). This is useful in case you # accidentally delete configuration.nix. diff --git a/users/fish/cattop/hardware-configuration.nix b/users/fish/cattop/hardware-configuration.nix index 7e98eeb8a81bcaa008732b48c6b2c13496ca1599..b16ddcb14f7da7960d16b1feb84affeece222af5 100644 --- a/users/fish/cattop/hardware-configuration.nix +++ b/users/fish/cattop/hardware-configuration.nix @@ -1,46 +1,32 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ - config, - lib, - pkgs, - modulesPath, - ... -}: +{ config, lib, pkgs, modulesPath, ... }: { - imports = [ - (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ - "xhci_pci" - "thunderbolt" - "vmd" - "nvme" - ]; + boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-intel" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = { - device = "/dev/disk/by-uuid/8eb0d6a2-b8cf-4ef2-ba2a-e25a5555b0bc"; - fsType = "ext4"; - }; + fileSystems."/" = + { device = "/dev/disk/by-uuid/d434c90f-e135-426e-b237-ead2f44e37c6"; + fsType = "ext4"; + }; - fileSystems."/boot/efi" = { - device = "/dev/disk/by-uuid/3B51-4A1C"; - fsType = "vfat"; - options = [ - "fmask=0077" - "dmask=0077" + fileSystems."/boot/EFI" = + { device = "/dev/disk/by-uuid/473A-B8FD"; + fsType = "vfat"; + options = [ "fmask=0077" "dmask=0077" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/e0cac471-0e32-4d5a-bf85-e8f93b304356"; } ]; - }; - - swapDevices = [ - { device = "/dev/disk/by-uuid/58ee9d19-292f-49b5-9979-341b42e8e09d"; } - ]; # Enables DHCP on each ethernet and wireless interface. In case of scripted networking # (the default) this is the recommended approach. When using systemd-networkd it's diff --git a/users/fish/cattop/home.nix b/users/fish/cattop/home.nix index b6c57b95e5cb64e35358d29a20134960a543f379..717ef04009d48832066d111b9c4df8fb9615b61c 100644 --- a/users/fish/cattop/home.nix +++ b/users/fish/cattop/home.nix @@ -1,13 +1,4 @@ -{ - inputs, - config, - pkgs, - lib, - userSettings, - systemSettings, - ... -}: - +{ pkgs, ... }: { home = { stateVersion = "23.05"; # Don't change this unless upgrading Home Manager versions @@ -15,17 +6,14 @@ packages = with pkgs; [ # General applications ghostty - stremio - julia - calibre - mpv signal-desktop - python3 - gh spotify + equibop # Gaming (prismlauncher.override { gamemodeSupport = true; }) + #bsdgames + space-cadet-pinball # System & desktop tools wofi @@ -37,18 +25,19 @@ ethtool grub2 efibootmgr - distrobox pqiv + imagemagick + toybox # Dev tools - legcord hyfetch - kicad - - # Unsorted + python3 + gh + cmake ripgrep - busybox - imagemagick + + # Unsorted + kicad ]; }; @@ -61,7 +50,15 @@ gitCredentialHelper.enable = true; }; - # Uncomment if you want to use MangoHud system-wide - # mangohud.enable = true; + ghostty = { + enable = true; + shader = "cursor-smear-black.glsl"; + settings = { + theme = "citruszest"; + adjust-cursor-thickness = 1; + background-opacity = 0.95; + background-blur = true; + }; + }; }; } diff --git a/users/fish/user.nix b/users/fish/user.nix index 5d8338389ba3f2abd622dc14d693e60fb71c5156..ed9ab2ccd80dd7db9b1a9d6d20c536e028b63c49 100644 --- a/users/fish/user.nix +++ b/users/fish/user.nix @@ -4,7 +4,7 @@ rec { email = "77413091+JulianBarbera@users.noreply.github.com"; # email (used for certain configurations) dotfilesDir = "~/config"; # absolute path of the local repo theme = "catppuccin-mocha"; # name of theme that stylix will use - browser = "firefox"; # Default browser; must select one from ./user/app/browser/ + browser = "zen-browser"; # Default browser; must select one from ./user/app/browser/ term = "ghostty"; # Default terminal command; font = "iosevka"; # Selected font editor = "neovim"; # Default editor; diff --git a/users/fish/vim.nix b/users/fish/vim.nix index 52c14b8cbb66a4eb826a85e044e9a453819720d1..9104cec4f818859d19d728dd01182ea540e9b9c7 100644 --- a/users/fish/vim.nix +++ b/users/fish/vim.nix @@ -1,3 +1,40 @@ -{ ... }: +{ pkgs, ... }: { + imports = [ + ./vim/default.nix + ]; + + vim = { + #enable python provider + withPython3 = true; + python3Packages = [ "pynvim" ]; + + autocmds = [ + #Autocommand to fall back to treesitter folding if LSP doesnt support it + { + event = [ "LspAttach" ]; + callback = pkgs.lib.generators.mkLuaInline '' + function(args) + local client = vim.lsp.get_client_by_id(args.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 + ''; + } + ]; + + tabline = { + nvimBufferline.enable = true; + }; + startPlugins = [ + "nui-nvim" + ]; + theme = { + name = "catppuccin"; + style = "mocha"; + }; + hideSearchHighlight = true; + }; } diff --git a/users/fish/vim/default.nix b/users/fish/vim/default.nix new file mode 100644 index 0000000000000000000000000000000000000000..9d7518bb41816b453399dd044663a511ba364078 --- /dev/null +++ b/users/fish/vim/default.nix @@ -0,0 +1,9 @@ +{ ... }: +{ + imports = [ + ./languages.nix + ./latex.nix + ./visuals.nix + ./mini.nix + ]; +} diff --git a/users/fish/vim/languages.nix b/users/fish/vim/languages.nix new file mode 100644 index 0000000000000000000000000000000000000000..6c370854799533d6388b8eb992df055f6df93b7a --- /dev/null +++ b/users/fish/vim/languages.nix @@ -0,0 +1,155 @@ +{ + flake, + user, + host, + pkgs, + ... +}: +{ + vim = { + extraPackages = with pkgs; [ + python312Packages.pylatexenc + ]; + languages = { + lua.lsp.enable = true; + lua.lsp.lazydev.enable = true; + python = { + format.type = "ruff"; + }; + markdown = { + enable = true; + extensions.render-markdown-nvim = { + enable = true; + }; + }; + nix = { + lsp.servers = [ + "nil" + "nixd" + ]; + }; + }; + + formatter.conform-nvim = { + enable = true; + setupOpts = { + formatters_by_ft = { + fish = [ "fish_indent" ]; + tex = [ "latexindent" ]; + }; + }; + }; + diagnostics = { + enable = true; + config = { + virtual_text = { + format = pkgs.lib.generators.mkLuaInline '' + function(diagnostic) + return string.format("%s (%s)", diagnostic.message, diagnostic.source) + end + ''; + }; + }; + nvim-lint = { + enable = true; + linters_by_ft = { + nix = [ "statix" ]; + tex = [ "chktex" ]; + haskell = [ "hlint" ]; + }; + + linters = { + chktex = { + ignore_exitcode = true; + }; + }; + }; + }; + treesitter = { + enable = true; + fold = true; + addDefaultGrammars = true; + highlight = { + additionalVimRegexHighlighting = true; + }; + + grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ + markdown_inline + markdown + ]; + + highlight.enable = true; + indent.enable = false; + }; + + visuals = { + fidget-nvim = { + setupOpts = { + logger.level = "trace"; + }; + }; + }; + + ui = { + nvim-ufo = { + enable = true; + }; + }; + autocomplete.blink-cmp = { + enable = true; + 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; + }; + }; + }; + + lazy.plugins."blink.pairs" = { + enabled = true; + package = pkgs.vimPlugins.blink-pairs; + setupModule = "blink.pairs"; + setupOpts = { + mappings = { + # -- you can call require("blink.pairs.mappings").enable() and require("blink.pairs.mappings").disable() to enable/disable mappings at runtime + enabled = true; + # -- see the defaults: https://github.com/Saghen/blink.pairs/blob/main/lua/blink/pairs/config/mappings.lua#L10 + pairs = [ ]; + }; + highlights = { + enabled = true; + groups = [ + "BlinkPairsOrange" + "BlinkPairsPurple" + "BlinkPairsBlue" + ]; + matchparen = { + enabled = true; + group = "MatchParen"; + }; + }; + debug = false; + }; + }; + }; +} diff --git a/users/fish/vim/latex.nix b/users/fish/vim/latex.nix new file mode 100644 index 0000000000000000000000000000000000000000..dd256a544add51076952ca5837f0ebc5631f0a06 --- /dev/null +++ b/users/fish/vim/latex.nix @@ -0,0 +1,118 @@ +{ pkgs, host, ... }: +{ + vim = { + extraPackages = with pkgs; [ + texliveFull + ]; + lazy.plugins.cmp-vimtex = { + enabled = true; + package = pkgs.vimPlugins.cmp-vimtex; + lazy = false; + + }; + lazy.plugins.vimtex = { + enabled = true; + package = pkgs.vimPlugins.vimtex; + lazy = false; + }; + + globals = { + tex_flavor = "latex"; + maplocalleader = "\\"; + vimtex_compiler_method = "latexmk"; + vimtex_view_method = if host.darwin then "skim" else "zathura"; + vimtex_view_automatic = 1; + vimtex_compiler_latexmk = { + callback = 1; + continuous = 1; + executable = "latexmk"; + hooks = [ ]; + options = [ + "-verbose" + "-file-line-error" + "-synctex=1" + "-interaction=nonstopmode" + "-shell-escape" + ]; + }; + vimtex_log_ignore = [ + "Underfull" + "Overfull" + "specifier changed to" + "Token not allowed in a PDF string" + ]; + vimtex_quickfix_ignore_filters = [ + "Underfull" + "Overfull" + ]; + }; + + autocomplete.blink-cmp = { + sourcePlugins = { + "blink.compat" = { + enable = true; + package = "blink-compat"; + module = "blink.compat.source"; + }; + }; + setupOpts = { + sources = { + default = [ "vimtex" ]; + providers = { + vimtex = { + name = "vimtex"; + module = "blink.compat.source"; + score_offset = 100; + }; + }; + }; + }; + }; + + augroups = [ + { + name = "VimTeX Events"; + } + ]; + autocmds = [ + { + pattern = [ "VimtexEventViewReverse" ]; + event = [ "User" ]; + desc = "Return to nvim after reverse search"; + command = "call b:vimtex.viewer.xdo_focus_vim()"; + group = "VimTeX Events"; + } + { + pattern = [ "VimtexEventQuit" ]; + event = [ "User" ]; + desc = "Close pdf after exiting nvim"; + command = "VimtexClean"; + group = "VimTeX Events"; + } + + { + pattern = [ "VimtexEventInitPost" ]; + event = [ "User" ]; + desc = "Start compiling when opening nvim to a tex file"; + command = "VimtexCompile"; + group = "VimTeX Events"; + } + + ]; + + lsp = { + servers = { + texlab = { + enable = true; + cmd = [ "${pkgs.texlab}/bin/texlab" ]; + filetypes = [ "tex" ]; + }; + }; + }; + treesitter = { + grammars = with pkgs.vimPlugins.nvim-treesitter.builtGrammars; [ + latex + ]; + }; + }; +} diff --git a/users/fish/vim/mini.nix b/users/fish/vim/mini.nix new file mode 100644 index 0000000000000000000000000000000000000000..b8119e7ae3dd250c84ec324309d6b0cbe8d30fc2 --- /dev/null +++ b/users/fish/vim/mini.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + vim = { + mini = { + icons.enable = true; + ai.enable = true; + surround.enable = true; + }; + }; +} diff --git a/users/fish/vim/visuals.nix b/users/fish/vim/visuals.nix new file mode 100644 index 0000000000000000000000000000000000000000..09759c3e78e9e3f9522cbc0a1ed03e17e2340614 --- /dev/null +++ b/users/fish/vim/visuals.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + vim = { + ui = { + noice = { + enable = true; + setupOpts = { + lsp = { + progress.enabled = false; + signature.enabled = true; + }; + presets = { + lsp_doc_border = true; + long_message_to_split = true; + inc_rename = false; + command_palette = false; + bottom_search = true; + }; + }; + }; + borders = { + enable = true; + }; + }; + + }; +} diff --git a/users/natalie/home.nix b/users/natalie/home.nix index b902b0c2d02b64fff482326c68dda270acc85ab4..295169243fda67476144879e74254928b7153da4 100644 --- a/users/natalie/home.nix +++ b/users/natalie/home.nix @@ -1,11 +1,5 @@ +{ lib, host, ... }@args: { - pkgs, - lib, - options, - ... -}@args: -{ - programs = { # sort-lines:start atuin.enable = true; @@ -29,6 +23,14 @@ }; }; # sort-lines:end + + fish = { + shellAliases = + { } + // lib.optionalAttrs (!host.darwin) { + reboot-windows = "sudo efibootmgr --bootnext 0000; sudo reboot -h now"; + }; + }; }; home.packages = import ./packages.nix args; diff --git a/users/natalie/vim/default.nix b/users/natalie/vim/default.nix index 63c80f97b3ccd455d32b881c008d631a5c84b5b4..9d7518bb41816b453399dd044663a511ba364078 100644 --- a/users/natalie/vim/default.nix +++ b/users/natalie/vim/default.nix @@ -1,7 +1,6 @@ { ... }: { imports = [ - ./keybinds.nix ./languages.nix ./latex.nix ./visuals.nix diff --git a/users/natalie/vim/keybinds.nix b/users/natalie/vim/keybinds.nix deleted file mode 100644 index 6caf7ac8721a35ba329f7e7771290dceff01d7e4..0000000000000000000000000000000000000000 --- a/users/natalie/vim/keybinds.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ ... }: -let - mkKeymap = mode: key: action: desc: { - inherit mode; - inherit key action desc; - }; - n = mkKeymap "n"; # normal mode -in -{ - vim = { - keymaps = [ - (n "e" ":lua require('snacks').explorer()" "File Explorer") - # Snacks Picker Replaces Telescope!? - (n "" ":lua require('snacks').picker.smart()" "Smart Find Files") - (n "ff" ":lua require('snacks').picker.files()" "Find File") - (n "fg" ":lua require('snacks').picker.grep()" "Grep Files") - ]; - }; -} diff --git a/users/natalie/vim/languages.nix b/users/natalie/vim/languages.nix index dda6dfd6ea01e5de9cc422a1b0d147c961534577..e3c5bc0c8862e72533b623da21c0efae46c77d66 100644 --- a/users/natalie/vim/languages.nix +++ b/users/natalie/vim/languages.nix @@ -11,6 +11,7 @@ python312Packages.pylatexenc ]; languages = { + lua.lsp.enable = true; lua.lsp.lazydev.enable = true; python = { format.type = "ruff";