From 4a9f0c303d8c4aff35fa3db6470531569bb1db58 Mon Sep 17 00:00:00 2001 From: thek4n Date: Thu, 21 Mar 2024 19:54:42 +0300 Subject: [PATCH] nvim: harpoon, tmux: session manager --- .../.config/nvim/lua/base/plugins/harpoon.lua | 58 +++++++++++++++++++ home/user/.tmux.conf | 9 ++- home/user/.tmux/01.conf | 3 + install | 2 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 home/user/.config/nvim/lua/base/plugins/harpoon.lua create mode 100644 home/user/.tmux/01.conf diff --git a/home/user/.config/nvim/lua/base/plugins/harpoon.lua b/home/user/.config/nvim/lua/base/plugins/harpoon.lua new file mode 100644 index 0000000..44fbecd --- /dev/null +++ b/home/user/.config/nvim/lua/base/plugins/harpoon.lua @@ -0,0 +1,58 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-telescope/telescope.nvim" + }, + config = function() + local harpoon = require("harpoon") + + harpoon:setup() + + vim.keymap.set("n", "a", function() harpoon:list():append() end) + vim.keymap.set("n", "fh", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + + vim.keymap.set("n", "", function() harpoon:list():select(1) end) + vim.keymap.set("n", "", function() harpoon:list():select(2) end) + vim.keymap.set("n", "", function() harpoon:list():select(3) end) + vim.keymap.set("n", "", function() harpoon:list():select(4) end) + + -- Toggle previous & next buffers stored within Harpoon list + vim.keymap.set("n", "", function() harpoon:list():prev() end) + vim.keymap.set("n", "", function() harpoon:list():next() end) + + vim.keymap.set("n", "", + function() + vim.ui.input({ prompt = "Harpoon mark index: " }, function(input) + local num = tonumber(input) + if num then + require("harpoon"):list():select(num) + end + end) + end + ) + + local conf = require("telescope.config").values + + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + + vim.keymap.set("n", "fh", function() toggle_telescope(harpoon:list()) end, + { desc = "Open harpoon window" }) + + end +} \ No newline at end of file diff --git a/home/user/.tmux.conf b/home/user/.tmux.conf index d4c7995..f016226 100644 --- a/home/user/.tmux.conf +++ b/home/user/.tmux.conf @@ -60,4 +60,11 @@ set -g set-titles on set -g set-titles-string '#S:#I.#P #W' setw -g clock-mode-colour green -setw -g clock-mode-style 24 \ No newline at end of file +setw -g clock-mode-style 24 + + +bind 1 source-file ~/.tmux/01.conf +bind 2 source-file ~/.tmux/02.conf +bind 3 source-file ~/.tmux/03.conf +bind 4 source-file ~/.tmux/04.conf +bind 5 source-file ~/.tmux/05.conf \ No newline at end of file diff --git a/home/user/.tmux/01.conf b/home/user/.tmux/01.conf new file mode 100644 index 0000000..bf8cab1 --- /dev/null +++ b/home/user/.tmux/01.conf @@ -0,0 +1,3 @@ +new -s s01 -A -n main -c "$WORKING_PROJECT" "$EDITOR" +send-keys M-1 +splitw -d -h -l 40% -c '#{pane_current_path}' \ No newline at end of file diff --git a/install b/install index 5add9a1..520a8c6 100755 --- a/install +++ b/install @@ -12,7 +12,7 @@ declare -r -A TARGETS=( ["colors"]=".config/terminal-colors.d" ["bash"]=".config/bash .bashrc .profile %colors" ["zsh"]="%bash .config/zsh .zshenv .inputrc" - ["tmux"]=".tmux.conf" + ["tmux"]=".tmux.conf .tmux" ["alacritty"]=".config/alacritty" ["nvim"]=".config/nvim .editorconfig .local/bin/vim_askpass_helper" ["ssh"]=""