diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua index 098a968..13a6fde 100644 --- a/nvim/lua/keymaps.lua +++ b/nvim/lua/keymaps.lua @@ -1,45 +1,22 @@ -local M = {} - -function M.telescope() - local telescope = require("telescope") - local builtin = require("telescope.builtin") - - vim.keymap.set("", "ff", builtin.find_files) - vim.keymap.set("", "fh", builtin.help_tags) - vim.keymap.set("", "ft", builtin.builtin) - vim.keymap.set("", "fm", builtin.man_pages) - vim.keymap.set("", "fb", telescope.extensions.file_browser.file_browser) - - vim.keymap.set("", "fd", function() builtin.find_files({ - cwd = "$DOTS", - prompt_title = "< Dotfiles >" - }) end) -end - -function M.harpoon() - vim.keymap.set("", "ha", require("harpoon.mark").add_file) - vim.keymap.set("", "ho", require("harpoon.ui").toggle_quick_menu) - - vim.keymap.set("", "he", function() require("harpoon.ui").nav_file(1) end) - vim.keymap.set("", "hi", function() require("harpoon.ui").nav_file(2) end) -end - -function M.lsp(env) - local opts = { buffer = env.buffer } - - vim.keymap.set("", "dn", vim.diagnostic.goto_next, opts) - vim.keymap.set("", "dp", vim.diagnostic.goto_prev, opts) - vim.keymap.set("", "de", vim.diagnostic.open_float, opts) - vim.keymap.set("", "df", vim.lsp.buf.code_action, opts) - vim.keymap.set("", "rn", vim.lsp.buf.rename, opts) - vim.keymap.set("", "gD", vim.lsp.buf.declaration, opts) - vim.keymap.set("", "gd", vim.lsp.buf.definition, opts) -end - ------------------------------------------------------------------------------ -- Misc -- ------------------------------------------------------------------------------ +vim.keymap.set("i", "jk", "") +vim.keymap.set("i", "kj", "") + +vim.keymap.set("", "q", "confirm quit") +vim.keymap.set("", "x", "exit") +vim.keymap.set("", "x", "writesource %") + +vim.keymap.set("", "n", "nzz") +vim.keymap.set("", "N", "Nzz") +vim.keymap.set("", "", "nohls") + +vim.keymap.set("", "", "zz") +vim.keymap.set("", "", "zz") + + local function swap(a, b) vim.keymap.set("", a, b) vim.keymap.set("", b, a) @@ -62,19 +39,53 @@ window_map("j") window_map("k") window_map("l") +nvim_create_user_command("Format", "normal mzgg=G'zzz") -vim.keymap.set("", "q", "confirm quit") -vim.keymap.set("", "x", "exit") -vim.keymap.set("", "x", "writesource %") +------------------------------------------------------------------------------ +-- Plugin Maps -- +------------------------------------------------------------------------------ -vim.keymap.set("", "n", "nzz") -vim.keymap.set("", "N", "Nzz") -vim.keymap.set("", "", "nohls") +local M = {} -vim.keymap.set("", "", "zz") -vim.keymap.set("", "", "zz") +function M.telescope() + local telescope = require("telescope") + local builtin = require("telescope.builtin") -vim.keymap.set("i", "jk", "") -vim.keymap.set("i", "kj", "") + vim.keymap.set("", "ff", builtin.find_files) + vim.keymap.set("", "fh", builtin.help_tags) + vim.keymap.set("", "ft", builtin.builtin) + vim.keymap.set("", "fm", builtin.man_pages) + vim.keymap.set("", "fb", telescope.extensions.file_browser.file_browser) + + vim.keymap.set("", "fd", function() builtin.find_files({ + cwd = "$DOTS", + prompt_title = "< Dotfiles >" + }) end) +end + +function M.harpoon() + vim.keymap.set("", "ha", require("harpoon.mark").add_file) + vim.keymap.set("", "ho", require("harpoon.ui").toggle_quick_menu) + + vim.keymap.set("", "hf", function() require("harpoon.ui").nav_file(1) end) + vim.keymap.set("", "hd", function() require("harpoon.ui").nav_file(2) end) + vim.keymap.set("", "hs", function() require("harpoon.ui").nav_file(2) end) +end + +function M.lsp(env) + local opts = { buffer = env.buffer } + + vim.keymap.set("", "dn", vim.diagnostic.goto_next, opts) + vim.keymap.set("", "dp", vim.diagnostic.goto_prev, opts) + vim.keymap.set("", "de", vim.diagnostic.open_float, opts) + vim.keymap.set("", "df", vim.lsp.buf.code_action, opts) + vim.keymap.set("", "rn", vim.lsp.buf.rename, opts) + vim.keymap.set("", "gD", vim.lsp.buf.declaration, opts) + vim.keymap.set("", "gd", vim.lsp.buf.definition, opts) +end + +function M.fugitive() + vim.keymap.set("", "gs", "Git") +end return M diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 646ada3..c26e538 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -42,7 +42,7 @@ return { { "nvim-lualine/lualine.nvim", config = true }, { "windwp/nvim-autopairs", config = true }, - "tpope/vim-fugitive", + {"tpope/vim-fugitive", config = require("keymaps").fugitive}, "tpope/vim-repeat", "tpope/vim-surround", "tpope/vim-unimpaired",