diff --git a/home/programs/nvim/autocmds.nix b/home/programs/nvim/autocmds.nix index 2ed5178..6374304 100644 --- a/home/programs/nvim/autocmds.nix +++ b/home/programs/nvim/autocmds.nix @@ -1,120 +1,11 @@ { 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 { @@ -150,38 +41,6 @@ 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 317019c..1fae26d 100644 --- a/home/programs/nvim/default.nix +++ b/home/programs/nvim/default.nix @@ -7,10 +7,9 @@ ./plugins/telescope.nix ./plugins/cmp.nix ./plugins/ui.nix - ./plugins/lualine.nix ./plugins/utils.nix - ./plugins/dashboard.nix ./plugins/markdown.nix + ./plugins/mini.nix ./options.nix ./keymaps.nix diff --git a/home/programs/nvim/keymaps.nix b/home/programs/nvim/keymaps.nix index e4deb24..6b5684e 100644 --- a/home/programs/nvim/keymaps.nix +++ b/home/programs/nvim/keymaps.nix @@ -77,6 +77,11 @@ action = "Neotree toggle"; options.desc = "Neotree"; } + { + key = "g"; + action = "LazyGit"; + options.desc = "LazyGit"; + } { key = "s"; @@ -107,11 +112,6 @@ } # UI - { - key = "uz"; - action = "ZenMode"; - options.desc = "Toggle ZenMode"; - } { key = "uw"; action = "set wrap!"; diff --git a/home/programs/nvim/options.nix b/home/programs/nvim/options.nix index 2f1b7ea..5a9e983 100644 --- a/home/programs/nvim/options.nix +++ b/home/programs/nvim/options.nix @@ -38,11 +38,6 @@ # 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; @@ -92,11 +87,6 @@ # 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; @@ -133,10 +123,6 @@ # 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"; diff --git a/home/programs/nvim/plugins/dashboard.nix b/home/programs/nvim/plugins/dashboard.nix deleted file mode 100644 index 8bf9dd5..0000000 --- a/home/programs/nvim/plugins/dashboard.nix +++ /dev/null @@ -1,223 +0,0 @@ -{ config, ... }: -let - accent = "#${config.lib.stylix.colors.base0D}"; - muted = "#${config.lib.stylix.colors.base03}"; - foreground = "#${config.lib.stylix.colors.base05}"; - configDir = config.var.configDirectory; -in { - - programs.nixvim.highlight = { - AlphaHeaderColor.fg = accent; - AlphaTextColor.fg = foreground; - AlphaShortcutColor.fg = muted; - }; - - programs.nixvim.plugins.alpha = { - enable = true; - layout = [ - { - type = "padding"; - val = 4; - } - { - type = "text"; - opts = { - position = "center"; - hl = "AlphaHeaderColor"; - }; - val = [ - "  " - " ████ ██████ █████ ██ " - " ███████████ █████  " - " █████████ ███████████████████ ███ ███████████ " - " █████████ ███ █████████████ █████ ██████████████ " - " █████████ ██████████ █████████ █████ █████ ████ █████ " - " ███████████ ███ ███ █████████ █████ █████ ████ █████ " - " ██████ █████████████████████ ████ █████ █████ ████ ██████ " - " " - ]; - } - { - type = "padding"; - val = 4; - } - { - type = "group"; - - val = [ - { - type = "button"; - val = "󰭎 Find file"; - on_press.__raw = "function() vim.cmd[[Telescope find_files]] end"; - opts = { - keymap = [ - "n" - "nf" - ":Telescope find_files " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "nf"; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = " New file"; - on_press.__raw = "function() vim.cmd[[ene]] end"; - opts = { - keymap = [ - "n" - "nn" - ":ene " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "nn"; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = " NixOs Config"; - on_press.__raw = "function() vim.cmd[[Neotree ${configDir}]] end"; - opts = { - keymap = [ - "n" - "nc" - ":Neotree ${configDir} " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - shortcut = "nc"; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = " Keybindings"; - on_press.__raw = - "function() vim.cmd[[e ${configDir}/docs/KEYBINDINGS.md]] end"; - opts = { - shortcut = "nk"; - keymap = [ - "n" - "nk" - ":e ${configDir}/docs/KEYBINDINGS-HYPRLAND.md " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = " Recently used"; - on_press.__raw = "function() vim.cmd[[Telescope oldfiles]] end"; - opts = { - shortcut = "no"; - keymap = [ - "n" - "no" - ":Telescope oldfiles " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = "󰱽 Find text"; - on_press.__raw = "function() vim.cmd[[Telescope live_grep]] end"; - opts = { - shortcut = "ng"; - keymap = [ - "n" - "ng" - ":Telescope live_grep " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - { - type = "button"; - val = "󰩈 Quit Neovim"; - on_press.__raw = "function() vim.cmd[[qa]] end"; - opts = { - shortcut = "nq"; - keymap = [ - "n" - "nq" - ":qa " - { - noremap = true; - silent = true; - nowait = true; - } - ]; - position = "center"; - cursor = 3; - width = 50; - align_shortcut = "right"; - hl_shortcut = "AlphaShortcutColor"; - hl = "AlphaTextColor"; - }; - } - ]; - - } - ]; - }; - -} diff --git a/home/programs/nvim/plugins/lsp.nix b/home/programs/nvim/plugins/lsp.nix index 1ba8a78..3930c60 100644 --- a/home/programs/nvim/plugins/lsp.nix +++ b/home/programs/nvim/plugins/lsp.nix @@ -5,22 +5,12 @@ enable = true; servers = { bashls.enable = true; - clangd.enable = true; gopls.enable = true; - eslint.enable = true; ts_ls.enable = true; - nixd = { - enable = true; - extraOptions = { - expr = "import {}"; - # fix- encoding: https://github.com/nix-community/nixvim/issues/2390 - offset_encoding = "utf-8"; - }; - }; + nixd.enable = true; tailwindcss.enable = true; html.enable = true; svelte.enable = true; - marksman.enable = true; }; keymaps.lspBuf = { "gd" = "definition"; diff --git a/home/programs/nvim/plugins/lualine.nix b/home/programs/nvim/plugins/lualine.nix deleted file mode 100644 index d1d602b..0000000 --- a/home/programs/nvim/plugins/lualine.nix +++ /dev/null @@ -1,30 +0,0 @@ -{ - programs.nixvim.plugins.lualine = { - enable = true; - settings = { - options.disabled_filetypes.statusline = - [ "dashboard" "alpha" "neo-tree" ]; - - alwaysDivideMiddle = true; - globalstatus = true; - ignoreFocus = [ "neo-tree" ]; - extensions = [ "fzf" ]; - componentSeparators = { - left = "|"; - right = "|"; - }; - sectionSeparators = { - left = "█"; #  - right = "█"; #  - }; - sections = { - lualine_a = [ "mode" ]; - lualine_b = [ "branch" "diff" "diagnostics" ]; - lualine_c = [ "filename" ]; - lualine_x = [ "filetype" ]; - lualine_y = [ "progress" ]; - lualine_z = [ ''" " .. os.date("%R")'' ]; - }; - }; - }; -} diff --git a/home/programs/nvim/plugins/markdown.nix b/home/programs/nvim/plugins/markdown.nix index 180bf92..77d49a2 100644 --- a/home/programs/nvim/plugins/markdown.nix +++ b/home/programs/nvim/plugins/markdown.nix @@ -37,59 +37,6 @@ in { # Plugins plugins = { - # Paste images from clipboard - clipboard-image = { - enable = true; - settings = { default.img_dir = [ "%:p:h" "img" ]; }; - }; - - # Zen mode - zen-mode = { - enable = true; - settings = { - on_close = '' - function() - end - ''; - on_open = '' - function() - end - ''; - plugins = { - gitsigns = { enabled = false; }; - options = { - enabled = true; - ruler = false; - showcmd = false; - laststatus = "0"; - kitty = { - enabled = true; - font = "+4"; - }; - }; - }; - window = { - backdrop = 0.95; - height = 1; - options = { - signcolumn = "no"; - number = false; - relativenumber = false; - }; - width = 0.8; - }; - }; - }; - - # Display images in markdown - image = { - enable = true; - integrations.markdown = { - clearInInsertMode = true; - onlyRenderImageAtCursor = true; - }; - }; - # This one takes care of the markdown titles headlines = { enable = true; diff --git a/home/programs/nvim/plugins/mini.nix b/home/programs/nvim/plugins/mini.nix new file mode 100644 index 0000000..32b0c73 --- /dev/null +++ b/home/programs/nvim/plugins/mini.nix @@ -0,0 +1,33 @@ +{ config, ... }: { + programs.nixvim = { + plugins.mini = { + enable = true; + mockDevIcons = true; + + modules = { + + animate = { cursor = { enable = false; }; }; + icons = { }; + # TODO: Learn how to use this + bracketed = { }; + tabline = { }; + statusline = { }; + starter = { }; + pairs = { }; + notify = { }; + indentscope = { }; + git = { }; + cursorword = { }; + comment = { + mappings = { + comment = "/"; + comment_line = "/"; + comment_visual = "/"; + textobject = "/"; + }; + }; + starter = { }; + }; + }; + }; +} diff --git a/home/programs/nvim/plugins/ui.nix b/home/programs/nvim/plugins/ui.nix index ffa72b5..7b23162 100644 --- a/home/programs/nvim/plugins/ui.nix +++ b/home/programs/nvim/plugins/ui.nix @@ -2,13 +2,7 @@ home.packages = with pkgs; [ 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; + lazygit.enable = true; }; } diff --git a/home/programs/nvim/plugins/utils.nix b/home/programs/nvim/plugins/utils.nix index e0ba4f4..4d65615 100644 --- a/home/programs/nvim/plugins/utils.nix +++ b/home/programs/nvim/plugins/utils.nix @@ -1,16 +1,13 @@ { config, ... }: { programs.nixvim = { + nixpkgs.config.allowUnfree = true; # For copilot highlightOverride = { FloatBorder.fg = "#${config.lib.stylix.colors.base0D}"; }; - nixpkgs.config = { allowUnfree = true; }; plugins = { copilot-vim.enable = true; flash.enable = true; tmux-navigator.enable = true; - comment.enable = true; - nvim-autopairs.enable = true; - todo-comments.enable = true; treesitter = { enable = true; nixGrammars = true;