From d9a8aebc78a5358d5b88100c587ade031ed9d72e Mon Sep 17 00:00:00 2001 From: Ekshef Date: Mon, 9 Jun 2025 21:07:53 -0700 Subject: [PATCH] added harpoon telescope toggle and config --- init.lua | 32 ++++++++++++++++++++++++++++++-- lua/custom/plugins/init.lua | 2 +- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/init.lua b/init.lua index b6efa710..8fcb237f 100644 --- a/init.lua +++ b/init.lua @@ -223,6 +223,8 @@ vim.api.nvim_create_autocmd('TextYankPost', { end, }) +-- Start of nvim terminal + vim.api.nvim_create_autocmd('TermOpen', { group = vim.api.nvim_create_augroup('custom-term-open', { clear = true }), callback = function() @@ -234,11 +236,13 @@ vim.api.nvim_create_autocmd('TermOpen', { local job_id = 0 vim.keymap.set('n', 'st', function() + local root = find_project_root() vim.cmd.vnew() vim.cmd.term() vim.cmd.wincmd 'J' vim.api.nvim_win_set_height(0, 15) job_id = vim.bo.channel + -- vim.fn.chansend(job_id, { 'cd ' .. root }) end, { desc = 'Opens [S]mall [T]erminal' }) -- [[ Install `lazy.nvim` plugin manager ]] @@ -272,7 +276,7 @@ require('lazy').setup({ -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. -- - -- Use `opts = {}` to automatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. + -- Use `opts = {}` to auomatically pass options to a plugin's `setup()` function, forcing the plugin to be loaded. -- -- Alternatively, use `config = function() ... end` for full control over the configuration. @@ -1117,9 +1121,33 @@ require('lazy').setup({ local harpoon = require 'harpoon' -- REQUIRED -harpoon:setup() +harpoon:setup {} -- REQUIRED +-- basic telescope configuration +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', '', function() + toggle_telescope(harpoon:list()) +end, { desc = 'Open harpoon window' }) + vim.keymap.set('n', 'a', function() harpoon:list():add() end, { desc = 'Add file to harpoon list.' }) diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index c7670abd..be0eb9d8 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -1,4 +1,4 @@ --- Yok can add your own plugins here or in other files in this directory! +-- You can add your own plugins here or in other files in this directory! -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information