feat: add harpoon toggle

main
jaredgoldman 2024-04-11 16:00:37 -04:00
parent 74781e2d6d
commit bbd51a0b85
4 changed files with 72 additions and 70 deletions

View File

@ -22,9 +22,9 @@
"nvim-comment": { "branch": "main", "commit": "e9ac16ab056695cad6461173693069ec070d2b23" },
"nvim-dap": { "branch": "master", "commit": "405df1dcc2e395ab5173a9c3d00e03942c023074" },
"nvim-grey": { "branch": "main", "commit": "e5fc8cc1e0c88c23bc6c92845f19a342f561c409" },
"nvim-lspconfig": { "branch": "master", "commit": "e25c4cdecd3d58c0deccce0f372426c8c480bcce" },
"nvim-lspconfig": { "branch": "master", "commit": "b3014f2209503944f2714cf27c95591433a0c7d8" },
"nvim-tree.lua": { "branch": "master", "commit": "81eb8d519233c105f30dc0a278607e62b20502fd" },
"nvim-treesitter": { "branch": "master", "commit": "2bad828b48aed74efe8f7e4ea15550e18c7b482d" },
"nvim-treesitter": { "branch": "master", "commit": "5c4892b0556d1258c423e2369d6a602d9b2a4988" },
"nvim-ts-autotag": { "branch": "main", "commit": "531f48334c422222aebc888fd36e7d109cb354cd" },
"nvim-web-devicons": { "branch": "master", "commit": "6e355632387a085f15a66ad68cf681c1d7374a04" },
"plenary.nvim": { "branch": "master", "commit": "8aad4396840be7fc42896e3011751b7609ca4119" },

View File

@ -20,6 +20,7 @@ local function toggle_telescope(harpoon_files)
})
:find()
end
local function toggle_mark()
local current_file = api.nvim_buf_get_name(0) -- Get the current buffer's file path
local item, index = harpoon:list():get_by_value(current_file)

View File

@ -2,73 +2,73 @@ local keymap = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
local mappings = {
n = {
-- highlighting
["<leader>nh"] = ":nohl<CR>",
-- move between buffers
["<c-h>"] = "<C-w>h",
["<c-j>"] = "<C-w>j",
["<c-k>"] = "<C-w>k",
["<c-l>"] = "<C-w>l",
-- open and close buggers
["<leader>sv"] = "<C-w>s",
["<leader>sh"] = "<C-w>v",
["<leader>se"] = "<C-w>=",
["<leader>sx"] = ":close<CR>",
-- nvim-tree
["<leader>e"] = ":NvimTreeFindFileToggle<CR>",
["<leader>cf"] = ":NvimTreeCollapse<CR>",
-- LSP
["<leader>ls"] = ":lspstop<CR>",
["<leader>lo"] = ":lspstart<CR>",
-- Telescope
["<leader>ff"] = "<cmd>Telescope find_files<CR>",
["<leader>fw"] = "<cmd>Telescope live_grep<CR>",
["<leader>fc"] = "<cmd>Telescope grep_string<CR>",
["<leader>th"] = "<cmd>Themery<CR>",
["<leader>sm"] = ":MaximizerToggle<CR>",
-- FTerm
["<leader>h"] = "<cmd>FTermToggle<CR>",
-- Harpoon
["<leader>a"] = "<cmd>HarpoonToggleFile<CR>",
["<C-e>"] = "<cmd>HarpoonUI<CR>",
["<leader>c"] = "<cmd>HarpoonClear<CR>",
-- Formating
["<leader>fm"] = "<cmd>Format<CR>",
-- Disable help menu
["<F1>"] = "<nop>",
},
x = {
["<A-j>"] = ":move '>+1<CR>gv-gv",
["<A-k>"] = ":move '<-2<CR>gv-gv",
},
i = {
["<C-Space>"] = { 'copilot#Accept("<CR>")', expr = true },
["<A-l>"] = "<esc>",
["C-BS"] = "<cmd>HarpoonRemove<CR>",
-- Disable help menu
["<F1>"] = "<nop>",
},
t = {
["C-h"] = "<C-\\><C-n>:FTermClose<CR>",
},
n = {
-- highlighting
["<leader>nh"] = ":nohl<CR>",
-- move between buffers
["<c-h>"] = "<C-w>h",
["<c-j>"] = "<C-w>j",
["<c-k>"] = "<C-w>k",
["<c-l>"] = "<C-w>l",
-- open and close buggers
["<leader>sv"] = "<C-w>s",
["<leader>sh"] = "<C-w>v",
["<leader>se"] = "<C-w>=",
["<leader>sx"] = ":close<CR>",
-- nvim-tree
["<leader>e"] = ":NvimTreeFindFileToggle<CR>",
["<leader>cf"] = ":NvimTreeCollapse<CR>",
-- LSP
["<leader>ls"] = ":lspstop<CR>",
["<leader>lo"] = ":lspstart<CR>",
-- Telescope
["<leader>ff"] = "<cmd>Telescope find_files<CR>",
["<leader>fw"] = "<cmd>Telescope live_grep<CR>",
["<leader>fc"] = "<cmd>Telescope grep_string<CR>",
["<leader>th"] = "<cmd>Themery<CR>",
["<leader>sm"] = ":MaximizerToggle<CR>",
-- FTerm
["<leader>h"] = "<cmd>FTermToggle<CR>",
-- Harpoon
["<leader>a"] = "<cmd>HarpoonToggleFile<CR>",
["<C-e>"] = "<cmd>HarpoonUI<CR>",
["<leader>c"] = "<cmd>HarpoonClear<CR>",
-- Formating
["<leader>fm"] = "<cmd>Format<CR>",
-- Disable help menu
["<F1>"] = "<nop>",
},
x = {
["<A-j>"] = ":move '>+1<CR>gv-gv",
["<A-k>"] = ":move '<-2<CR>gv-gv",
},
i = {
["<C-Space>"] = { 'copilot#Accept("<CR>")', expr = true },
["<A-l>"] = "<esc>",
["C-BS"] = "<cmd>HarpoonRemove<CR>",
-- Disable help menu
["<F1>"] = "<nop>",
},
t = {
["C-h"] = "<C-\\><C-n>:FTermClose<CR>",
},
}
for mode, mode_mappings in pairs(mappings) do
for key, mapping in pairs(mode_mappings) do
if type(mapping) == "function" then
-- For direct Lua function calls; ensure your function returns a string command
keymap(mode, key, "<cmd>lua " .. mapping() .. "<CR>", opts)
elseif type(mapping) == "table" and mapping.expr then
-- For expression mappings, like for copilot
local expr_opts = vim.tbl_extend("force", opts, { expr = true })
keymap(mode, key, mapping[1], expr_opts)
elseif type(mapping) == "table" then
-- For mappings that have their options specified directly
keymap(mode, key, mapping[1], mapping[2] or opts)
else
-- For simple string command mappings
keymap(mode, key, mapping, opts)
end
end
for key, mapping in pairs(mode_mappings) do
if type(mapping) == "function" then
-- For direct Lua function calls; ensure your function returns a string command
keymap(mode, key, "<cmd>lua " .. mapping() .. "<CR>", opts)
elseif type(mapping) == "table" and mapping.expr then
-- For expression mappings, like for copilot
local expr_opts = vim.tbl_extend("force", opts, { expr = true })
keymap(mode, key, mapping[1], expr_opts)
elseif type(mapping) == "table" then
-- For mappings that have their options specified directly
keymap(mode, key, mapping[1], mapping[2] or opts)
else
-- For simple string command mappings
keymap(mode, key, mapping, opts)
end
end
end

View File

@ -1,10 +1,11 @@
# Requirements for my setup
- file tree x
- lsp with mason x
- telescope x
- theming x
- tabfluline x
- rice x
- rice x
- terminal x
- harpoon x
- extended history x
@ -12,5 +13,5 @@
- lua vim linting x
- dashboard x
- suppress vim global warnings x
- harpoon toggle file
- harpoon toggle file x
- debugger