aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-12-17 17:17:40 -0500
committerJean-Pierre Appel <jeanpierre.appel01@gmail.com>2023-12-17 17:17:40 -0500
commit47d61c1cb5af62cc75218661dfc7c3a0dc3378a8 (patch)
tree906f5e4b1e6bb7b9eaea0fb45a9e7af82baff609
parent00fa9fb23ee3de7b60f0b5a88f905f3bf14a1485 (diff)
made nvim keymap locations sensible, add harpoon
Keymaps are now stored in the lua/plugins/<Plugin>.lua or lua/keymap.lua Installed harpoon v2
-rw-r--r--nvim/after/plugin/fugitive.lua3
-rw-r--r--nvim/after/plugin/keymap.lua9
-rw-r--r--nvim/after/plugin/keymap/explorer.lua9
-rw-r--r--nvim/after/plugin/telescope.lua36
-rw-r--r--nvim/init.lua4
-rw-r--r--nvim/lua/keymap.lua6
-rw-r--r--nvim/lua/plugins/fugitive.lua6
-rw-r--r--nvim/lua/plugins/harpoon.lua46
-rw-r--r--nvim/lua/plugins/init.lua7
-rw-r--r--nvim/lua/plugins/telescope.lua25
10 files changed, 87 insertions, 64 deletions
diff --git a/nvim/after/plugin/fugitive.lua b/nvim/after/plugin/fugitive.lua
deleted file mode 100644
index 38fe4d5..0000000
--- a/nvim/after/plugin/fugitive.lua
+++ /dev/null
@@ -1,3 +0,0 @@
-local remap = require('keymap')
-
-remap.nnoremap("<leader>gs", vim.cmd.Git)
diff --git a/nvim/after/plugin/keymap.lua b/nvim/after/plugin/keymap.lua
deleted file mode 100644
index 78ebff6..0000000
--- a/nvim/after/plugin/keymap.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local Remap = require("keymap")
-
-Remap.nmap("gf", function()
- vim.cmd([[:e <cfile>]])
-end)
-
-Remap.nnoremap("<Leader>qf", function()
- vim.cmd(':cope')
-end)
diff --git a/nvim/after/plugin/keymap/explorer.lua b/nvim/after/plugin/keymap/explorer.lua
deleted file mode 100644
index 00ded39..0000000
--- a/nvim/after/plugin/keymap/explorer.lua
+++ /dev/null
@@ -1,9 +0,0 @@
-local Remap = require("keymap")
-
--- TODO: move to separate config file
-vim.g.netrw_liststyle = 3
-vim.g.netrw_banner = 0
-
-Remap.nnoremap("<leader>ef", function()
- vim.cmd('Vexplore')
-end)
diff --git a/nvim/after/plugin/telescope.lua b/nvim/after/plugin/telescope.lua
deleted file mode 100644
index d164bd9..0000000
--- a/nvim/after/plugin/telescope.lua
+++ /dev/null
@@ -1,36 +0,0 @@
-local Remap = require("keymap")
-local builtin = require('telescope.builtin')
-local nnoremap = Remap.nnoremap
-
--- find file
--- TODO: add netrw open bind within context
-nnoremap("<Leader>ff", function()
- builtin.find_files()
-end)
-
--- find buffer
-nnoremap("<Leader>fb", function()
- builtin.buffers()
-end)
-
--- grep find
-nnoremap("<Leader>gf", function()
- builtin.live_grep()
-end)
-
--- lsp find refrences
-nnoremap("<Leader>fr", function()
- -- TODO: if lsp supports reference provider and lsp is attached
- -- [telescope.builtin.lsp_*]: server does not support referencesProvider
- if #vim.lsp.get_active_clients({bufnr = 0}) > 0 then
- builtin.lsp_references()
- else
- builtin.grep_string()
- end
-end)
-
--- -- find git, lists git pickers
--- TODO: write picker
--- nnoremap("<leader>fg", function()
--- builtin.
--- end)
diff --git a/nvim/init.lua b/nvim/init.lua
index 8dc3c5e..e929c30 100644
--- a/nvim/init.lua
+++ b/nvim/init.lua
@@ -67,3 +67,7 @@ vim.g.tex_flavor = "latex"
-- ripgrep
vim.opt.grepprg = "rg --vimgrep"
vim.opt.grepformat = "%f:%l:%c:%m"
+
+-- netrw config
+vim.g.netrw_liststyle = 3
+vim.g.netrw_banner = 0
diff --git a/nvim/lua/keymap.lua b/nvim/lua/keymap.lua
index 883321b..1e285c2 100644
--- a/nvim/lua/keymap.lua
+++ b/nvim/lua/keymap.lua
@@ -19,4 +19,10 @@ M.vnoremap = bind("v")
M.xnoremap = bind("x")
M.inoremap = bind("i")
+M.nnoremap("gf", function() vim.cmd([[:e <cfile>]]) end)
+M.nnoremap("<Leader>qf", function() vim.cmd(':cope') end)
+M.nnoremap("<leader>ef", function()
+ vim.cmd('Vexplore')
+end)
+
return M
diff --git a/nvim/lua/plugins/fugitive.lua b/nvim/lua/plugins/fugitive.lua
new file mode 100644
index 0000000..a203ea8
--- /dev/null
+++ b/nvim/lua/plugins/fugitive.lua
@@ -0,0 +1,6 @@
+return {
+ 'tpope/vim-fugitive', -- close to native git command integrations
+ keys = {
+ {"<leader>gs", vim.cmd.Git, desc = "Git Status"}
+ }
+}
diff --git a/nvim/lua/plugins/harpoon.lua b/nvim/lua/plugins/harpoon.lua
new file mode 100644
index 0000000..061ca9e
--- /dev/null
+++ b/nvim/lua/plugins/harpoon.lua
@@ -0,0 +1,46 @@
+return {
+ 'ThePrimeagen/harpoon', -- quick file navigator
+ branch = "harpoon2",
+ dependencies = 'nvim-lua/plenary.nvim',
+ config = function()
+ require("harpoon"):setup()
+ end,
+ keys = {
+ {"<leader><cr>", function()
+ local harpoon = require("harpoon")
+ harpoon.ui:toggle_quick_menu(harpoon:list())
+ end,
+ desc = "Open Harpoon Quickmenu"
+ },
+ {"<leader>m", function()
+ local harpoon = require("harpoon")
+ harpoon:list():append()
+ end,
+ desc = "Add file to harpoon"
+ },
+ {"<leader>1", function()
+ local harpoon = require("harpoon")
+ harpoon:list():select(1)
+ end,
+ desc = "Navigate to the first file"
+ },
+ {"<leader>2", function()
+ local harpoon = require("harpoon")
+ harpoon:list():select(2)
+ end,
+ desc = "Navigate to the second file"
+ },
+ {"<leader>3", function()
+ local harpoon = require("harpoon")
+ harpoon:list():select(3)
+ end,
+ desc = "Navigate to the third file"
+ },
+ {"<leader>4", function()
+ local harpoon = require("harpoon")
+ harpoon:list():select(4)
+ end,
+ desc = "Navigate to the fourth file"
+ },
+ }
+}
diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua
index c05f0f0..5c90a28 100644
--- a/nvim/lua/plugins/init.lua
+++ b/nvim/lua/plugins/init.lua
@@ -3,10 +3,6 @@ return {
-- common dependacy
"nvim-lua/plenary.nvim",
- -- git
- 'tpope/vim-fugitive', -- close to native git command integrations
-
-
-- completion
-- TODO:config completion and setup binds
'hrsh7th/nvim-cmp',
@@ -23,9 +19,6 @@ return {
dependencies = { 'hrsh7th/nvim-cmp' }
},
-
-
-
{
'numToStr/Comment.nvim', -- faster commentting
lazy = false,
diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua
index 55bc045..360994a 100644
--- a/nvim/lua/plugins/telescope.lua
+++ b/nvim/lua/plugins/telescope.lua
@@ -3,5 +3,30 @@ return {
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-tree/nvim-web-devicons'
+ },
+ keys = {
+ {"<leader>ff", function()
+ require("telescope.builtin").find_files()
+ end,
+ desc = "Search for files (respcting .gitignore)"
+ },
+ {"<Leader>fb", function()
+ require("telescope.builtin").buffers()
+ end
+ },
+ {"<Leader>gf", function()
+ require("telescope.builtin").live_grep()
+ end
+ },
+ {"<Leader>fr", function()
+ -- TODO: if lsp supports reference provider and lsp is attached
+ -- [telescope.builtin.lsp_*]: server does not support referencesProvider
+ if #vim.lsp.get_active_clients({bufnr = 0}) > 0 then
+ require("telescope.builtin").lsp_references()
+ else
+ require("telescope.builtin").grep_string()
+ end
+ end
+ }
}
}