From 6fae3be80b67abfda8e475542625169dd6e77f31 Mon Sep 17 00:00:00 2001 From: triethyl Date: Tue, 22 Jul 2025 12:50:08 -0400 Subject: working on custom neovim --- features/user/cli/shells/nushell/default.nix | 6 +++--- pkgs/custom-neovim/config/init.lua | 6 ++++-- pkgs/custom-neovim/config/lua/mappings.lua | 18 ++++++++++++------ pkgs/custom-neovim/config/lua/options.lua | 4 ++-- pkgs/custom-neovim/config/lua/plugins/lspconfig.lua | 4 +--- pkgs/custom-neovim/config/lua/plugins/mini/files.lua | 20 ++++++++++++++++++++ pkgs/custom-neovim/config/lua/plugins/oil.lua | 11 +++++++++++ pkgs/custom-neovim/config/lua/plugins/persisted.lua | 1 + pkgs/custom-neovim/default.nix | 1 + pkgs/custom-neovim/design.md | 10 +++++++++- pkgs/default.nix | 3 +-- pkgs/neovide-git.nix | 10 ---------- 12 files changed, 65 insertions(+), 29 deletions(-) create mode 100644 pkgs/custom-neovim/config/lua/plugins/mini/files.lua create mode 100644 pkgs/custom-neovim/config/lua/plugins/oil.lua delete mode 100644 pkgs/neovide-git.nix diff --git a/features/user/cli/shells/nushell/default.nix b/features/user/cli/shells/nushell/default.nix index 988308c..dbd66b3 100644 --- a/features/user/cli/shells/nushell/default.nix +++ b/features/user/cli/shells/nushell/default.nix @@ -72,11 +72,11 @@ in { if (try {git rev-parse --is-inside-work-tree e> /dev/null}) != null { direnv allow } else { - git init + # git init direnv allow } - git add $"($path)/." - git commit -m "initialized" + # git add $"($path)/." + # git commit -m "initialized" } # Quickly create a nix shell. diff --git a/pkgs/custom-neovim/config/init.lua b/pkgs/custom-neovim/config/init.lua index b30173b..6419790 100644 --- a/pkgs/custom-neovim/config/init.lua +++ b/pkgs/custom-neovim/config/init.lua @@ -13,11 +13,12 @@ require("mappings") -- UI Plugins: require("plugins.lualine") require("plugins.tabby") -require("plugins.snacks") require("plugins.mini.clue") require("plugins.mini.indentscope") require("plugins.mini.notify") require("plugins.treesitter") +-- require("plugins.oil") +require("plugins.mini.files") -- LSP Plugins: require("plugins.lspconfig") @@ -25,4 +26,5 @@ require("plugins.actions-preview") -- Misc Plugins: require("plugins.presence") -require("hardtime").setup() +require("plugins.snacks") +-- require("hardtime").setup() diff --git a/pkgs/custom-neovim/config/lua/mappings.lua b/pkgs/custom-neovim/config/lua/mappings.lua index 39f2bd3..9043096 100644 --- a/pkgs/custom-neovim/config/lua/mappings.lua +++ b/pkgs/custom-neovim/config/lua/mappings.lua @@ -7,7 +7,6 @@ vim.g.mapleader = ' ' -- Pickers mapkey("n", "f", "Open file picker", ":lua Snacks.picker.files()") mapkey("n", "l", "Open recent file picker", ":lua Snacks.picker.recent()") -mapkey("n", "e", "Open file explorer", ":lua Snacks.picker.explorer()") mapkey("n", "b", "Open buffer picker", ":lua Snacks.picker.buffers()") mapkey("n", "B", "Open buffer live grep picker", ":lua Snacks.picker.grep_buffers()") mapkey("n", "y", "Open clipboard history picker", ":lua Snacks.picker.cliphist()") @@ -31,14 +30,20 @@ mapkey("n", "tp", "Go to previous tab", ":tabprev") -- Sessions mapkey("n", "s", "Manage sessions", "") -mapkey("n", "ss", "Open session picker", ":SessionSelect") +mapkey("n", "sw", "Save current session", ":SessionSave") +mapkey("n", "ss", "Switch and save session", ":SessionSave :SessionSelect") +mapkey("n", "sp", "Open session picker", ":SessionSelect") +mapkey("n", "sd", "Delete current session", ":SessionDelete") +mapkey("n", "sl", "Open last session", ":SessionLoadLast") -- Terminals mapkey("n", "c", "Manage terminals", "") -- Git -mapkey("n", "g", "Manage git", "") -mapkey("n", "gg", "Open lazygit", ":lua Snacks.lazygit()") +mapkey("n", "g", "Open lazygit", ":lua Snacks.lazygit()") + +-- Other leader keys +mapkey("n", "e", "Open file manager", ":lua MiniFiles.open()") -- QOL Keys mapkey("t", "", "Exit terminal insert mode", "") @@ -47,10 +52,11 @@ vim.keymap.set("c", "", function() return '' end, { expr = true }) -- Make enter complete command. mapkey("n", "", "Clear highlights", ":noh") -- Make esc clear highlights +mapkey("n", "q", "Close buffer", ":bd") -- Visual Movement Keys. -mapkey({"n", "v"}, "j", "Go down visually", "gj") -mapkey({"n", "v"}, "k", "Go up visually", "gk") +-- mapkey({"n", "v"}, "j", "Go down visually", "gj") +-- mapkey({"n", "v"}, "k", "Go up visually", "gk") -- Learn hjkl. -- mapkey({"n", "v"}, "", "Correct the keypress", function() print("Try pressing h instead.") end) diff --git a/pkgs/custom-neovim/config/lua/options.lua b/pkgs/custom-neovim/config/lua/options.lua index cd59941..f2ffcc9 100644 --- a/pkgs/custom-neovim/config/lua/options.lua +++ b/pkgs/custom-neovim/config/lua/options.lua @@ -7,7 +7,8 @@ vim.o.ruler = false -- don't show #,# in the commandline. vim.o.icm = 'split' vim.o.cia = 'abbr,kind,menu' vim.o.mouse = "" -vim.o.relativenumber = true -- set numbered lines +vim.o.number = true -- set absolute numbered lines +vim.o.relativenumber = true -- set relative numbered lines vim.o.scrolloff = 4 -- minimal number of screen lines to keep above and below the cursor vim.o.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time vim.o.clipboard = "unnamedplus" -- use system clipboard @@ -39,4 +40,3 @@ vim.o.foldexpr = "v:lua.vim.treesitter.foldexpr()" -- Set folder to treesitter. vim.o.foldlevel = 99 -- Don't fold initially. vim.o.foldnestmax = 4 -- Don't fold if more than 4 folds deep. vim.o.foldtext = "" -- Color text in folds. - diff --git a/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua b/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua index 850ebe5..a18b80d 100644 --- a/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua +++ b/pkgs/custom-neovim/config/lua/plugins/lspconfig.lua @@ -1,5 +1,3 @@ --- vim.keymap.set('n', 'd', vim.diagnostic.setloclist, {desc = "Add buffer diagnostics to the location list."}) - -- Disable semantic tokens to stop weird highlighting. vim.api.nvim_create_autocmd('LspAttach', { callback = function(ev) @@ -40,7 +38,7 @@ vim.api.nvim_create_autocmd('LspAttach', { mapkey("n", "S", "Open workspace symbol picker", ":lua Snacks.picker.lsp_workspace_symbols()") -- LSP Pickers - mapkey({'n', 'v'}, "a", "Perform code action", require("actions-preview").code_actions) + mapkey('n', "a", "Perform code action", require("actions-preview").code_actions) mapkey("n", "D", "Open workspace diagnostic picker", ":lua Snacks.picker.diagnostics()") mapkey("n", "d", "Open diagnostic picker", [[:lua Snacks.picker.diagnostics_buffer()]]) diff --git a/pkgs/custom-neovim/config/lua/plugins/mini/files.lua b/pkgs/custom-neovim/config/lua/plugins/mini/files.lua new file mode 100644 index 0000000..e64aefa --- /dev/null +++ b/pkgs/custom-neovim/config/lua/plugins/mini/files.lua @@ -0,0 +1,20 @@ +require("mini.files").setup { + mappings = { + close = '', + go_in = 'l', + go_in_plus = 'L', + go_out = 'h', + go_out_plus = 'H', + mark_goto = "'", + mark_set = 'm', + reset = '', + reveal_cwd = '@', + show_help = 'g?', + synchronize = '=', + trim_left = '<', + trim_right = '>', + }, + windows = { + preview = true, + }, +} diff --git a/pkgs/custom-neovim/config/lua/plugins/oil.lua b/pkgs/custom-neovim/config/lua/plugins/oil.lua new file mode 100644 index 0000000..6682599 --- /dev/null +++ b/pkgs/custom-neovim/config/lua/plugins/oil.lua @@ -0,0 +1,11 @@ +require('oil').setup { + win_options = { + wrap = true, + }, + skip_confirm_for_simple_edits = true, + watch_for_changes = true, + float = { + max_width = 0.6, + max_height = 0.8, + }, +} diff --git a/pkgs/custom-neovim/config/lua/plugins/persisted.lua b/pkgs/custom-neovim/config/lua/plugins/persisted.lua index 6f0273e..043c130 100644 --- a/pkgs/custom-neovim/config/lua/plugins/persisted.lua +++ b/pkgs/custom-neovim/config/lua/plugins/persisted.lua @@ -1,3 +1,4 @@ require("persisted").setup { autostart = true, + autoload = true, } diff --git a/pkgs/custom-neovim/default.nix b/pkgs/custom-neovim/default.nix index 85099f8..6b78fde 100644 --- a/pkgs/custom-neovim/default.nix +++ b/pkgs/custom-neovim/default.nix @@ -21,6 +21,7 @@ in alpha-nvim # Dashboard. persisted-nvim # Session manager. snacks-nvim + oil-nvim # Colorschemes oxocarbon-nvim # IBM Carbon themes. diff --git a/pkgs/custom-neovim/design.md b/pkgs/custom-neovim/design.md index 1bdefb3..d9d667e 100644 --- a/pkgs/custom-neovim/design.md +++ b/pkgs/custom-neovim/design.md @@ -6,5 +6,13 @@ - Searchable Keybinds - Which-key (or something similar) - Good terminal multiplexing -- Start screen - Sessions + +## Todo + +- Figure out good session management +- install oil.nvim to replace default dir manager +- Configure snacks terminal manager +- add quick window switcher plugin +- make vertical dividers the same color as text + diff --git a/pkgs/default.nix b/pkgs/default.nix index 3c88487..16e43d6 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,7 +4,6 @@ ... }: { custom-hello = pkgs.callPackage ./custom-hello.nix {}; - custom-neovim = pkgs.callPackage ./custom-neovim {inherit inputs;}; setup-manager = pkgs.callPackage ./setup-manager {}; - neovide-git = pkgs.callPackage ./neovide-git.nix {}; + custom-neovim = pkgs.callPackage ./custom-neovim {inherit inputs;}; } diff --git a/pkgs/neovide-git.nix b/pkgs/neovide-git.nix deleted file mode 100644 index 5b67118..0000000 --- a/pkgs/neovide-git.nix +++ /dev/null @@ -1,10 +0,0 @@ -{pkgs}: -pkgs.neovide.overrideAttrs (old: { - version = "git"; - src = pkgs.fetchFromGitHub { - owner = "neovide"; - repo = "neovide"; - rev = "627956990b4d85a2a98a13e0c50da2155d15cd72"; - sha256 = "sha256-WwLEL6GyLLPbGEJrpSRLTJr+CqevZZ5MBZNUbXLWn3I="; - }; -}) -- cgit v1.2.3