diff --git a/home/programs/nvim/autocmds.nix b/home/programs/nvim/autocmds.nix new file mode 100644 index 0000000..2ed5178 --- /dev/null +++ b/home/programs/nvim/autocmds.nix @@ -0,0 +1,187 @@ +{ + programs.nixvim = { + autoGroups = { + auto_quit.clear = true; + autoview.clear = true; + bufferline.clear = true; + checktime.clear = true; + create_dir.clear = true; + editorconfig_filetype.clear = true; + file_user_events.clear = true; + highlighturl.clear = true; + highlightyank.clear = true; + large_buf_settings.clear = true; + q_close_windows.clear = true; + terminal_settings.clear = true; + unlist_quickfix.clear = true; + }; + + autoCmd = [ + # auto_quit + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L18-L46 + { + desc = + "Quit neovim if more than one window is open and only sidebar windows are list"; + event = "BufEnter"; + group = "auto_quit"; + + callback.__raw = '' + function() + local wins = vim.api.nvim_tabpage_list_wins(0) + -- Both neo-tree and aerial will auto-quit if there is only a single window left + if #wins <= 1 then return end + local sidebar_fts = { aerial = true, ["neo-tree"] = true } + for _, winid in ipairs(wins) do + if vim.api.nvim_win_is_valid(winid) then + local bufnr = vim.api.nvim_win_get_buf(winid) + local filetype = vim.bo[bufnr].filetype + -- If any visible windows are not sidebars, early return + if not sidebar_fts[filetype] then + return + -- If the visible window is a sidebar + else + -- only count filetypes once, so remove a found sidebar from the detection + sidebar_fts[filetype] = nil + end + end + end + if #vim.api.nvim_list_tabpages() > 1 then + vim.cmd.tabclose() + else + vim.cmd.qall() + end + end + ''; + } + + # autoview + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L49-L70 + { + desc = "Save view with mkview for real files"; + event = [ "BufWinLeave" "BufWritePost" "WinLeave" ]; + group = "autoview"; + + callback.__raw = '' + function(event) + if vim.b[event.buf].view_activated then vim.cmd.mkview { mods = { emsg_silent = true } } end + end + ''; + } + { + desc = + "Try to load file view if available and enable view saving for real files"; + event = "BufWinEnter"; + group = "autoview"; + + callback.__raw = '' + function(event) + if not vim.b[event.buf].view_activated then + local filetype = vim.bo[event.buf].filetype + local buftype = vim.bo[event.buf].buftype + local ignore_filetypes = { "gitcommit", "gitrebase", "svg", "hgcommit" } + if buftype == "" and filetype and filetype ~= "" and not vim.tbl_contains(ignore_filetypes, filetype) then + vim.b[event.buf].view_activated = true + vim.cmd.loadview { mods = { emsg_silent = true } } + end + end + end + ''; + } + + # checktime + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L118-L122 + { + desc = "Check if buffers changed on editor focus"; + event = [ "FocusGained" "TermClose" "TermLeave" ]; + group = "checktime"; + command = "checktime"; + } + + # editorconfig_filetype + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L135-L144 + { + desc = + "Configure editorconfig after filetype detection to override `ftplugin`s"; + event = "FileType"; + group = "editorconfig_filetype"; + + callback.__raw = '' + function(args) + if vim.F.if_nil(vim.b.editorconfig, vim.g.editorconfig, true) then + local editorconfig_avail, editorconfig = pcall(require, "editorconfig") + if editorconfig_avail then editorconfig.config(args.buf) end + end + end + ''; + } + + # highlightyank + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L206-L211 + { + desc = "Highlight yanked text"; + event = "TextYankPost"; + group = "highlightyank"; + pattern = "*"; + + callback.__raw = '' + function() + vim.highlight.on_yank() + end + ''; + } + + # q_close_windows + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L242-L255 + { + desc = "Make q close help, man, quickfix, dap floats"; + event = "BufWinEnter"; + group = "q_close_windows"; + + callback.__raw = '' + function(event) + if vim.tbl_contains({ "help", "nofile", "quickfix" }, vim.bo[event.buf].buftype) then + vim.keymap.set("n", "q", "close", { + desc = "Close window", + buffer = event.buf, + silent = true, + nowait = true, + }) + end + end + ''; + } + + # terminal_settings + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L258-L266 + { + desc = "Disable line number/fold column/sign column for terminals"; + event = "TermOpen"; + group = "terminal_settings"; + + callback.__raw = '' + function() + vim.opt_local.number = false + vim.opt_local.relativenumber = false + vim.opt_local.foldcolumn = "0" + vim.opt_local.signcolumn = "no" + end + ''; + } + + # unlist_quickfix + # https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/_astrocore_autocmds.lua#L270-L275 + { + desc = "Unlist quickfix buffers"; + event = "FileType"; + group = "unlist_quickfix"; + pattern = "qf"; + + callback.__raw = '' + function() + vim.opt_local.buflisted = false + end + ''; + } + ]; + }; +} diff --git a/home/programs/nvim/default.nix b/home/programs/nvim/default.nix index b9bac66..62ee34f 100644 --- a/home/programs/nvim/default.nix +++ b/home/programs/nvim/default.nix @@ -8,15 +8,17 @@ ./plugins/markdown.nix ./plugins/tree.nix ./plugins/ui.nix + ./plugins/lualine.nix ./plugins/utils.nix ./plugins/dap.nix ./plugins/telescope.nix - ./plugins/zenmode.nix + # ./plugins/zenmode.nix ./plugins/project.nix ./plugins/treesitter.nix ./options.nix ./keymaps.nix + ./autocmds.nix ]; programs.nixvim.enable = true; diff --git a/home/programs/nvim/keymaps.nix b/home/programs/nvim/keymaps.nix index fddc536..d62ec48 100644 --- a/home/programs/nvim/keymaps.nix +++ b/home/programs/nvim/keymaps.nix @@ -313,6 +313,16 @@ action = "lua require('dap').toggle_breakpoint()"; options.desc = "Toggle breakpoint"; } + { + key = ""; + action = "BufferLineCycleNext"; + options.desc = "Go to next buffer"; + } + { + key = ""; + action = "BufferLineCyclePrev"; + options.desc = "Go to previous buffer"; + } ]; }; } diff --git a/home/programs/nvim/options.nix b/home/programs/nvim/options.nix index 8039ad0..e2e8e10 100644 --- a/home/programs/nvim/options.nix +++ b/home/programs/nvim/options.nix @@ -1,40 +1,152 @@ { - programs.nixvim.globals.mapleader = " "; - programs.nixvim.opts = { - updatetime = 50; # Faster completion + programs.nixvim = { + globals.mapleader = " "; + opts = { + autoindent = true; - number = true; - relativenumber = true; + smartindent = true; - autoindent = true; - clipboard = "unnamed,unnamedplus"; + incsearch = true; + hlsearch = true; + wildmode = "list:longest"; + scrolloff = 8; - expandtab = true; - tabstop = 2; - softtabstop = 2; - shiftwidth = 2; - smartindent = true; - breakindent = true; + swapfile = false; + conceallevel = 3; + clipboard = "unnamed,unnamedplus"; - ignorecase = true; - incsearch = true; - hlsearch = true; - smartcase = true; - wildmode = "list:longest"; - completeopt = [ "menuone" "noselect" "noinsert" ]; - signcolumn = "yes"; - cursorline = false; - scrolloff = 8; - mouse = "a"; - termguicolors = true; - showmode = false; + # Don't stop backspace at insert + backspace.__raw = '' + vim.list_extend(vim.opt.backspace:get(), { "nostop" }) + ''; - wrap = false; - linebreak = true; + # Keep visual indentation on wrapped lines + breakindent = true; - swapfile = false; - undofile = true; - conceallevel = 3; + # Hide command line unless needed + cmdheight = 0; + + # Insert mode completion options + completeopt = [ "menu" "menuone" "noselect" ]; + + # Raise a dialog asking if you wish to save the current file(s) + confirm = true; + + # Copy previous indentation on autoindenting + copyindent = true; + + # Highlight current line + cursorline = true; + + # Enable linematch diff algorithm + diffopt.__raw = '' + vim.list_extend(vim.opt.diffopt:get(), { "algorithm:histogram", "linematch:60" }) + ''; + + # Expand to spaces + expandtab = true; + + # Disable `~` on nonexistent lines + fillchars = { eob = " "; }; + + # Enable fold with all code unfolded + foldcolumn = "1"; + foldenable = true; + foldlevel = 99; + foldlevelstart = 99; + + # Ignore case in search patterns + ignorecase = true; + + # Show substitution preview in split window + inccommand = "split"; + + # Infer casing on word completion + infercase = true; + + # Global statusline + laststatus = 3; + + # Wrap lines at 'breakat' + linebreak = true; + + # Enable mouse support + mouse = "a"; + + # Show line numbers + number = true; + + # Preserve indentation as much as possible + preserveindent = true; + + # Height of the popup menu + pumheight = 10; + + # Display line numbers relative to current line + relativenumber = true; + + # Minimal number of lines to keep around the cursor + # This has the effect to move the view along with current line + #scrolloff = 999; + + # Number of spaces to use for indentation + shiftwidth = 2; + + # Disable search count wrap and startup messages + shortmess.__raw = '' + vim.tbl_deep_extend("force", vim.opt.shortmess:get(), { s = true, I = true }) + ''; + + # Disable showing modes in command line + showmode = false; + + # Always show tabline + showtabline = 2; + + # Show signs column + signcolumn = "yes"; + + # Override ignorecase if search pattern contains uppercase characters + smartcase = true; + + # Number of spaces input on + softtabstop = 2; + + # Open horizontal split below (:split) + splitbelow = true; + + # Open vertical split to the right (:vsplit) + splitright = true; + + # Number of spaces to represent a + tabstop = 2; + + # Enables 24-bit RGB color + termguicolors = true; + + # Shorter timeout duration + timeoutlen = 500; + + # Set window title to the filename + title = true; + + # Save undo history to undo file (in $XDG_STATE_HOME/nvim/undo) + undofile = true; + + viewoptions.__raw = '' + vim.tbl_filter(function(val) return val ~= "curdir" end, vim.opt.viewoptions:get()) + ''; + + # Enable virtual edit in visual block mode + # This has the effect of selecting empty cells beyond lines boundaries + virtualedit = "block"; + + # Disable line wrapping + wrap = false; + + # Disable making a backup before overwriting a file + writebackup = false; + }; }; programs.nixvim.extraConfigLuaPost = '' vim.g.neovide_scale_factor = 1.0 diff --git a/home/programs/nvim/plugins/cmp.nix b/home/programs/nvim/plugins/cmp.nix index acaef28..6bbfbbe 100644 --- a/home/programs/nvim/plugins/cmp.nix +++ b/home/programs/nvim/plugins/cmp.nix @@ -111,6 +111,5 @@ }; }; }; - }; } diff --git a/home/programs/nvim/plugins/dashboard.nix b/home/programs/nvim/plugins/dashboard.nix index bbaca79..ea281ab 100644 --- a/home/programs/nvim/plugins/dashboard.nix +++ b/home/programs/nvim/plugins/dashboard.nix @@ -50,7 +50,17 @@ in { val = "󰭎 Find file"; on_press.__raw = "function() vim.cmd[[Telescope find_files]] end"; opts = { - shortcut = "nf"; + keymap = [ + "n" + "f" + ":Telescope find_files " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "f"; position = "center"; cursor = 3; width = 50; @@ -64,7 +74,17 @@ in { val = " New file"; on_press.__raw = "function() vim.cmd[[ene]] end"; opts = { - shortcut = "nn"; + keymap = [ + "n" + "n" + ":ene " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "n"; position = "center"; cursor = 3; width = 50; @@ -78,7 +98,17 @@ in { val = " NixOs Config"; on_press.__raw = "function() vim.cmd[[Neotree ${configDir}]] end"; opts = { - shortcut = "nc"; + keymap = [ + "n" + "c" + ":Neotree ${configDir} " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "c"; position = "center"; cursor = 3; width = 50; @@ -93,7 +123,17 @@ in { on_press.__raw = "function() vim.cmd[[e ${configDir}/docs/KEYBINDINGS.md]] end"; opts = { - shortcut = "nc"; + keymap = [ + "n" + "b" + ":e ${configDir}/docs/KEYBINDINGS.md " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "b"; position = "center"; cursor = 3; width = 50; @@ -107,7 +147,17 @@ in { val = " Recently used"; on_press.__raw = "function() vim.cmd[[Telescope oldfiles]] end"; opts = { - shortcut = "no"; + keymap = [ + "n" + "o" + ":Telescope oldfiles " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "o"; position = "center"; cursor = 3; width = 50; @@ -121,7 +171,17 @@ in { val = "󰱽 Find text"; on_press.__raw = "function() vim.cmd[[Telescope live_grep]] end"; opts = { - shortcut = "nt"; + keymap = [ + "n" + "t" + ":Telescope live_grep " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "t"; position = "center"; cursor = 3; width = 50; @@ -135,7 +195,17 @@ in { val = "󰩈 Quit Neovim"; on_press.__raw = "function() vim.cmd[[qa]] end"; opts = { - shortcut = "nq"; + keymap = [ + "n" + "q" + ":qa " + { + noremap = true; + silent = true; + nowait = true; + } + ]; + shortcut = "q"; position = "center"; cursor = 3; width = 50; diff --git a/home/programs/nvim/plugins/lualine.nix b/home/programs/nvim/plugins/lualine.nix new file mode 100644 index 0000000..3c5555e --- /dev/null +++ b/home/programs/nvim/plugins/lualine.nix @@ -0,0 +1,31 @@ +{ + programs.nixvim.plugins.lualine = { + enable = true; + settings = { + options.disabled_filetypes.statusline = + [ "dashboard" "alpha" "neo-tree" ]; + + alwaysDivideMiddle = true; + globalstatus = true; + ignoreFocus = [ "neo-tree" ]; + extensions = [ "fzf" ]; + theme = "auto"; + componentSeparators = { + left = "|"; + right = "|"; + }; + sectionSeparators = { + left = ""; #  + right = ""; #  + }; + sections = { + lualine_a = [ "mode" ]; + lualine_b = [ "branch" "diff" "diagnostics" ]; + lualine_c = [ "filename" ]; + lualine_x = [ "filetype" ]; + lualine_y = [ "progress" "selectioncount" ]; + lualine_z = [ ''" " .. os.date("%R")'' ]; + }; + }; + }; +} diff --git a/home/programs/nvim/plugins/markdown.nix b/home/programs/nvim/plugins/markdown.nix index c86fdeb..bc0a006 100644 --- a/home/programs/nvim/plugins/markdown.nix +++ b/home/programs/nvim/plugins/markdown.nix @@ -1,4 +1,3 @@ -# The render-markdown.nvim plugin is a plugin that renders markdown files in a neovim in a more readable way. { config, ... }: let accent = "#${config.lib.stylix.colors.base0D}"; @@ -11,7 +10,6 @@ in { plugins.mkdnflow = { enable = true; modules = { conceal = false; }; - toDo.symbols = [ " " "-" "x" "!" "/" ]; mappings = { MkdnCreateLink = false; @@ -132,8 +130,9 @@ in { RenderMarkdownH4.fg = accent-alt; RenderMarkdownH5.fg = accent-alt; RenderMarkdownH6.fg = accent-alt; - RenderMarkdownTodo.fg = muted; - RenderMarkdownWarning.fg = accent; + RenderMarkdownTodo.fg = "#f78c6c"; + RenderMarkdownWarning.fg = "#ff5370"; + RenderMarkdownDone.fg = muted; }; plugins.headlines = { enable = true; @@ -156,6 +155,7 @@ in { settings = { heading = { icons = [ "# " "󰲣 " "󰲥 " "󰲧 " "󰲩 " "󰲫 " ]; + sign = false; backgrounds = [ "RenderMarkdownBg" ]; foregrounds = [ "RenderMarkdownH1" @@ -168,7 +168,7 @@ in { }; checkbox = { unchecked = { highlight = "RenderMarkdownTodo"; }; - checked = { highlight = "RenderMarkdownTodo"; }; + checked = { highlight = "RenderMarkdownDone"; }; custom = { pending = { raw = "[-]"; @@ -177,13 +177,13 @@ in { }; important = { raw = "[!]"; - rendered = " "; + rendered = "󰰱 "; highlight = "RenderMarkdownWarning"; }; cancel = { raw = "[/]"; rendered = "󱋬 "; - highlight = "RenderMarkdownTodo"; + highlight = "RenderMarkdownWarning"; }; }; }; diff --git a/home/programs/nvim/plugins/ui.nix b/home/programs/nvim/plugins/ui.nix index f8212d4..d4dccad 100644 --- a/home/programs/nvim/plugins/ui.nix +++ b/home/programs/nvim/plugins/ui.nix @@ -1,54 +1,13 @@ { pkgs, ... }: { home.packages = with pkgs; [ ctags ]; - - programs.nixvim = { - plugins = { - lualine = { - enable = true; - settings = { - options.disabled_filetypes.statusline = - [ "dashboard" "alpha" "neo-tree" ]; - - alwaysDivideMiddle = true; - globalstatus = true; - ignoreFocus = [ "neo-tree" ]; - extensions = [ "fzf" ]; - theme = "auto"; - componentSeparators = { - left = "|"; - right = "|"; - }; - sectionSeparators = { - left = ""; #  - right = ""; #  - }; - sections = { - lualine_a = [ "mode" ]; - lualine_b = [ "branch" "diff" "diagnostics" ]; - lualine_c = [ "filename" ]; - lualine_x = [ "filetype" ]; - lualine_y = [ "progress" "selectioncount" ]; - lualine_z = [ ''" " .. os.date("%R")'' ]; - }; - }; - }; - web-devicons.enable = true; - noice.enable = true; - notify = { - enable = true; - level = "warn"; - }; - gitsigns = { - enable = true; - settings.current_line_blame = false; - }; - trouble.enable = true; - indent-blankline.enable = true; - colorizer.enable = true; - tagbar = { - enable = true; - tagsPackage = pkgs.universal-ctags; - }; + programs.nixvim.plugins = { + web-devicons.enable = true; + noice.enable = true; + gitsigns = { + enable = true; + settings.current_line_blame = false; }; + trouble.enable = true; + bufferline.enable = true; }; } diff --git a/home/programs/nvim/plugins/utils.nix b/home/programs/nvim/plugins/utils.nix index e7d5aa7..d7a84e0 100644 --- a/home/programs/nvim/plugins/utils.nix +++ b/home/programs/nvim/plugins/utils.nix @@ -16,7 +16,6 @@ tmux-navigator.enable = true; comment.enable = true; nvim-autopairs.enable = true; - friendly-snippets.enable = true; todo-comments.enable = true; harpoon = { enable = true; diff --git a/home/system/hyprland/windowrule.nix b/home/system/hyprland/windowrule.nix index 0e41d69..794e9d5 100644 --- a/home/system/hyprland/windowrule.nix +++ b/home/system/hyprland/windowrule.nix @@ -18,11 +18,12 @@ "float, class:^(.*blueman-manager.*)$" "size 530 300, class:^(.*blueman-manager.*)$" "move 100%-w-20 40, class:^(.*blueman-manager.*)$" - "noborder, class:^(.*dg-desktop-portal-.*)$" - "noblur, class:^(.*dg-desktop-portal-.*)$" - "noshadow, class:^(.*dg-desktop-portal-.*)$" - "float, class:^(*.dg-desktop-portal-.*)$" - "pin, class:^(*.dg-desktop-portal-.*)$" + "tag +portal, class:^(.*desktop-portal.*)$" + "noborder, tag:portal" + "noblur, class:portal" + "noshadow, class:portal" + "float, class:portal" + "pin, class:portal" "pin, class:^(gcr-prompter)$" "float, title:^(Volume Control)$" "pin, title:^(Volume Control)$" diff --git a/home/system/hyprpanel/default.nix b/home/system/hyprpanel/default.nix index 3c0ef35..113a1f6 100644 --- a/home/system/hyprpanel/default.nix +++ b/home/system/hyprpanel/default.nix @@ -13,14 +13,13 @@ let inherit (config.var.theme) rounding border-size gaps-in gaps-out; inherit (config.var.theme.bar) floating transparentButtons transparent position; - inherit (config.var) cpuTempSensor location username weatherapikey; + inherit (config.var) location username weatherapikey; in { imports = [ inputs.hyprpanel.homeManagerModules.hyprpanel ]; programs.hyprpanel = { enable = true; overlay.enable = true; - systemd.enable = true; hyprland.enable = true; overwrite.enable = true; layout = { @@ -34,7 +33,7 @@ in { "hyprsunset" "battery" "network" - "cputemp" + "cpu" "clock" "notifications" ]; @@ -51,7 +50,6 @@ in { bar.battery.hideLabelWhenFull = true; bar.bluetooth.label = false; bar.clock.format = "%a, %d %b %H:%M"; - bar.customModules.cpuTemp.sensor = cpuTempSensor; bar.customModules.hypridle.label = false; bar.customModules.hyprsunset.label = false; bar.launcher.icon = ""; @@ -120,7 +118,7 @@ in { theme.bar.buttons.workspaces.occupied = accent; theme.bar.buttons.y_margins = if floating && transparent then "0" else "8"; - theme.bar.dropdownGap = "4.5em"; + theme.bar.dropdownGap = "3em"; theme.bar.floating = if floating then "true" else "false"; theme.bar.location = position; theme.bar.margin_bottom = diff --git a/nixos/systemd-boot.nix b/nixos/systemd-boot.nix index 3f3f8a9..18139dc 100644 --- a/nixos/systemd-boot.nix +++ b/nixos/systemd-boot.nix @@ -11,7 +11,7 @@ }; tmp.cleanOnBoot = true; kernelPackages = - pkgs.linuxPackages_zen; # _zen, _hardened, _rt, _rt_latest, etc. + pkgs.linuxPackages_latest; # _zen, _hardened, _rt, _rt_latest, etc. # Silent boot kernelParams = [ @@ -24,6 +24,5 @@ ]; consoleLogLevel = 0; initrd.verbose = false; - plymouth = { enable = true; }; }; }