diff --git a/README.md b/README.md index 0392010..fea6241 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,10 @@ you can also cycle the list in both directions :lua require("harpoon.ui").nav_next() -- navigates to next mark :lua require("harpoon.ui").nav_prev() -- navigates to previous mark ``` +from the quickmenu, open a file in: +a vertical split with control+v, +a horizontal split with control+x, +a new tab with control+t ### Terminal Navigation this works like file navigation except that if there is no terminal at the specified index diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 88aaa3d..d96a7b7 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -20,6 +20,38 @@ vim.api.nvim_create_autocmd({ "BufLeave, VimLeave" }, { group = the_primeagen_harpoon, }) +vim.api.nvim_create_autocmd("FileType", { + pattern = "harpoon", + group = the_primeagen_harpoon, + + callback = function() + -- Open harpoon file choice in useful ways + -- + -- vertical split (control+v) + vim.keymap.set("n", "", function() + local curline = vim.api.nvim_get_current_line() + local working_directory = vim.fn.getcwd() .. "/" + vim.cmd("vs") + vim.cmd("e " .. working_directory .. curline) + end, { buffer=true, noremap = true, silent = true }) + + -- horizontal split (control+x) + vim.keymap.set("n", "", function() + local curline = vim.api.nvim_get_current_line() + local working_directory = vim.fn.getcwd() .. "/" + vim.cmd("sp") + vim.cmd("e " .. working_directory .. curline) + end, { buffer=true, noremap = true, silent = true }) + + -- new tab (control+t) + vim.keymap.set("n", "", function() + local curline = vim.api.nvim_get_current_line() + local working_directory = vim.fn.getcwd() .. "/" + vim.cmd("tabnew") + vim.cmd("e " .. working_directory .. curline) + end, { buffer=true, noremap = true, silent = true }) + end +}) --[[ { projects = {