diff --git a/modules/editor/neovim/default.nix b/modules/editor/neovim/default.nix index b3b0447..7af1d68 100644 --- a/modules/editor/neovim/default.nix +++ b/modules/editor/neovim/default.nix @@ -35,8 +35,8 @@ # Always run packer.nvim sync home.activation.nvimPackerSync = config.home-manager.users.${config.user}.lib.dag.entryAfter - [ "onFilesChange" ] '' - $DRY_RUN_CMD nvim +PackerSync +qa + [ "writeBoundary" ] '' + $DRY_RUN_CMD nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' ''; }; diff --git a/modules/editor/neovim/init.lua b/modules/editor/neovim/init.lua index 4ab1489..8267993 100644 --- a/modules/editor/neovim/init.lua +++ b/modules/editor/neovim/init.lua @@ -1,4 +1,3 @@ require("packer_init") require("settings") -require("functions") require("keybinds") diff --git a/modules/editor/neovim/lua/functions.lua b/modules/editor/neovim/lua/functions.lua deleted file mode 100644 index 5731ba6..0000000 --- a/modules/editor/neovim/lua/functions.lua +++ /dev/null @@ -1,38 +0,0 @@ --- =========================================================================== --- Custom Functions --- =========================================================================== - -grep_notes = function() - local opts = { - prompt_title = "Search Notes", - cwd = "$NOTES_PATH", - } - require("telescope.builtin").live_grep(opts) -end - -find_notes = function() - local opts = { - prompt_title = "Find Notes", - cwd = "$NOTES_PATH", - } - require("telescope.builtin").find_files(opts) -end - -find_downloads = function() - local opts = { - prompt_title = "Find Downloads", - cwd = "~/downloads", - } - require("telescope").extensions.file_browser.file_browser(opts) -end - -command_history = function() - local opts = require("telescope.themes").get_ivy({ - layout_config = { - bottom_pane = { - height = 15, - }, - }, - }) - require("telescope.builtin").command_history(opts) -end diff --git a/modules/editor/neovim/lua/keybinds.lua b/modules/editor/neovim/lua/keybinds.lua index 35606d8..9135e0a 100644 --- a/modules/editor/neovim/lua/keybinds.lua +++ b/modules/editor/neovim/lua/keybinds.lua @@ -23,60 +23,19 @@ key("n", "", ":noh", { silent = true }) -- Shuffle lines around key("n", "", ":m .+1==") key("n", "", ":m .-2==") --- key("i", "", ":m .+1==gi") --- key("i", "", ":m .-2==gi") key("v", "", ":m '>+1gv=gv") key("v", "", ":m '<-2gv=gv") --- Telescope (fuzzy finder) -local telescope = require("telescope.builtin") -local telescope_ext = require("telescope").extensions -key("n", "k", telescope.keymaps) -key("n", "/", telescope.live_grep) -key("n", "ff", telescope.find_files) -key("n", "fp", telescope.git_files) -key("n", "fN", find_notes) -key("n", "N", grep_notes) -key("n", "fD", find_downloads) -key("n", "fa", telescope_ext.file_browser.file_browser) -key("n", "fw", telescope.grep_string) --- key("n", "wt", ":Telescope tmux sessions") --- key("n", "ww", ":Telescope tmux windows") --- key("n", "w/", ":Telescope tmux pane_contents") -key("n", "fz", telescope_ext.zoxide.list) -key("n", "b", telescope.buffers) -key("n", "hh", telescope.help_tags) -key("n", "fr", telescope.oldfiles) -key("n", "cc", telescope.commands) -key("n", "cr", command_history) -key("n", "s", telescope.current_buffer_fuzzy_find) -key("n", "gc", telescope.git_commits) -key("n", "gf", telescope.git_bcommits) -key("n", "gb", telescope.git_branches) -key("n", "gs", telescope.git_status) +-- Buffer tabs +key("n", "", "gt") +key("i", "", "gt") +key("n", "", "gT") +key("i", "", "gT") --- Buffer tabs (tmux interferes) --- key("n", "", "gt") --- key("i", "", "gt") --- key("n", "", "gT") --- key("i", "", "gT") - --- Swap buffers +-- Move buffers key("n", "L", ":bnext") key("n", "H", ":bprevious") --- LSP -key("n", "gd", vim.lsp.buf.definition, { silent = true }) -key("n", "gT", vim.lsp.buf.type_definition, { silent = true }) -key("n", "gi", vim.lsp.buf.implementation, { silent = true }) -key("n", "gh", vim.lsp.buf.hover, { silent = true }) -key("n", "gr", telescope.lsp_references, { silent = true }) -key("n", "R", vim.lsp.buf.rename, { silent = true }) -key("n", "]e", vim.diagnostic.goto_next, { silent = true }) -key("n", "[e", vim.diagnostic.goto_prev, { silent = true }) -key("n", "e", vim.diagnostic.open_float, { silent = true }) -key("n", "E", vim.lsp.buf.code_action, { silent = true }) - -- File commands key("n", "q", ":quit") key("n", "Q", ":quitall") @@ -93,13 +52,7 @@ key("n", "wv", ":vsplit") key("n", "wh", ":split") key("n", "wm", ":only") --- Tabularize -key("", "ta", ":Tabularize /") -key("", "t#", ":Tabularize /#") -key("", "tl", ":Tabularize /---") - -- Vimrc editing -key("n", "fv", ":edit $DOTS/nvim.configlink/init.lua") key("n", "rr", ":luafile $MYVIMRC") key("n", "rp", ":luafile $MYVIMRC:PackerInstall:") key("n", "rc", ":luafile $MYVIMRC:PackerCompile") diff --git a/modules/editor/neovim/lua/packer/lsp.lua b/modules/editor/neovim/lua/packer/lsp.lua index ffd06b5..b1ce138 100644 --- a/modules/editor/neovim/lua/packer/lsp.lua +++ b/modules/editor/neovim/lua/packer/lsp.lua @@ -48,6 +48,17 @@ M.packer = function(use) capabilities = capabilities, }) end + + vim.keymap.set("n", "gd", vim.lsp.buf.definition) + vim.keymap.set("n", "gT", vim.lsp.buf.type_definition) + vim.keymap.set("n", "gi", vim.lsp.buf.implementation) + vim.keymap.set("n", "gh", vim.lsp.buf.hover) + -- vim.keymap.set("n", "gr", telescope.lsp_references) + vim.keymap.set("n", "R", vim.lsp.buf.rename) + vim.keymap.set("n", "]e", vim.diagnostic.goto_next) + vim.keymap.set("n", "[e", vim.diagnostic.goto_prev) + vim.keymap.set("n", "e", vim.diagnostic.open_float) + vim.keymap.set("n", "E", vim.lsp.buf.code_action) end, }) diff --git a/modules/editor/neovim/lua/packer/misc.lua b/modules/editor/neovim/lua/packer/misc.lua index a489c58..e8c6980 100644 --- a/modules/editor/neovim/lua/packer/misc.lua +++ b/modules/editor/neovim/lua/packer/misc.lua @@ -20,7 +20,14 @@ M.packer = function(use) }) -- Alignment tool - use("godlygeek/tabular") + use({ + "godlygeek/tabular", + config = function() + vim.keymap.set("", "ta", ":Tabularize /") + vim.keymap.set("", "t#", ":Tabularize /#") + vim.keymap.set("", "tl", ":Tabularize /---") + end, + }) -- Markdown renderer / wiki notes use("vimwiki/vimwiki") diff --git a/modules/editor/neovim/lua/packer/telescope.lua b/modules/editor/neovim/lua/packer/telescope.lua index 8136dee..e6416c7 100644 --- a/modules/editor/neovim/lua/packer/telescope.lua +++ b/modules/editor/neovim/lua/packer/telescope.lua @@ -28,13 +28,56 @@ M.packer = function(use) }, extensions = { fzy_native = {}, - -- tmux = {}, zoxide = {}, project = { base_dirs = { "~/dev" }, }, }, }) + + local telescope = require("telescope.builtin") + + vim.keymap.set("n", "k", telescope.keymaps) + vim.keymap.set("n", "/", telescope.live_grep) + vim.keymap.set("n", "ff", telescope.find_files) + vim.keymap.set("n", "fp", telescope.git_files) + vim.keymap.set("n", "fw", telescope.grep_string) + vim.keymap.set("n", "b", telescope.buffers) + vim.keymap.set("n", "hh", telescope.help_tags) + vim.keymap.set("n", "fr", telescope.oldfiles) + vim.keymap.set("n", "cc", telescope.commands) + vim.keymap.set("n", "gc", telescope.git_commits) + vim.keymap.set("n", "gf", telescope.git_bcommits) + vim.keymap.set("n", "gb", telescope.git_branches) + vim.keymap.set("n", "gs", telescope.git_status) + vim.keymap.set("n", "s", telescope.current_buffer_fuzzy_find) + + vim.keymap.set("n", "N", function() + local opts = { + prompt_title = "Search Notes", + cwd = "$NOTES_PATH", + } + telescope.live_grep(opts) + end) + + vim.keymap.set("n", "fN", function() + local opts = { + prompt_title = "Find Notes", + cwd = "$NOTES_PATH", + } + telescope.find_files(opts) + end) + + vim.keymap.set("n", "cr", function() + local opts = require("telescope.themes").get_ivy({ + layout_config = { + bottom_pane = { + height = 15, + }, + }, + }) + telescope.command_history(opts) + end) end, }) @@ -47,7 +90,10 @@ M.packer = function(use) -- Jump directories use({ "jvgrootveld/telescope-zoxide", - requires = { "nvim-lua/popup.nvim" }, + requires = { "nvim-lua/popup.nvim", "nvim-telescope/telescope.nvim" }, + config = function() + vim.keymap.set("n", "fz", require("telescope").extensions.zoxide.list) + end, }) -- Jump projects @@ -57,7 +103,7 @@ M.packer = function(use) config = function() require("telescope").load_extension("project") - choose_project = function() + vim.keymap.set("n", "", function() local opts = require("telescope.themes").get_ivy({ layout_config = { bottom_pane = { @@ -66,9 +112,7 @@ M.packer = function(use) }, }) require("telescope").extensions.project.project(opts) - end - - vim.keymap.set("n", "", choose_project) + end) end, }) @@ -78,6 +122,16 @@ M.packer = function(use) requires = { "nvim-telescope/telescope.nvim" }, config = function() require("telescope").load_extension("file_browser") + + vim.keymap.set("n", "fa", require("telescope").extensions.file_browser.file_browser) + + vim.keymap.set("n", "fD", function() + local opts = { + prompt_title = "Find Downloads", + cwd = "~/downloads", + } + require("telescope").extensions.file_browser.file_browser(opts) + end) end, }) end