mirror of
https://gitlab.com/sagidayan/linux-config.git
synced 2024-11-22 07:15:25 +00:00
nvim: Added harpoon + autocmd
Signed-off-by: Sagi Dayan <sagidayan@gmail.com>
This commit is contained in:
parent
c3784e0a65
commit
90dfbaf600
5 changed files with 63 additions and 1 deletions
13
files/dotfiles/nvim/lua/user/autocmd.lua
Normal file
13
files/dotfiles/nvim/lua/user/autocmd.lua
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
-- update tree if open on file enter
|
||||||
|
local api = vim.api
|
||||||
|
api.nvim_create_autocmd('BufEnter', {
|
||||||
|
callback = function()
|
||||||
|
local tree_ok, tree_api = pcall(require, "nvim-tree.api")
|
||||||
|
if tree_ok and tree_api.tree.is_visible() then
|
||||||
|
-- local win_number = api.nvim_get_current_win()
|
||||||
|
tree_api.tree.find_file()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
})
|
|
@ -10,6 +10,7 @@ require("user.treesitter")
|
||||||
require("user.keymaps")
|
require("user.keymaps")
|
||||||
require("user.lualine")
|
require("user.lualine")
|
||||||
require("user.colors")
|
require("user.colors")
|
||||||
|
require("user.autocmd")
|
||||||
|
|
||||||
-- Make sure plugins are installed
|
-- Make sure plugins are installed
|
||||||
--vim.cmd(":PackerClean")
|
--vim.cmd(":PackerClean")
|
||||||
|
|
|
@ -78,3 +78,13 @@ local notify_ok, notify = pcall(require, "notify")
|
||||||
if notify_ok then
|
if notify_ok then
|
||||||
vim.notify = notify
|
vim.notify = notify
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local harpoon_ok, harpoon = pcall(require, "harpoon")
|
||||||
|
if harpoon_ok then
|
||||||
|
harpoon.setup({
|
||||||
|
settings = {
|
||||||
|
save_on_toggle = false,
|
||||||
|
sync_on_ui_close = true,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
|
@ -32,6 +32,39 @@ if telescope_status_ok then
|
||||||
nnoremap("<C-f>", telescope.current_buffer_fuzzy_find)
|
nnoremap("<C-f>", telescope.current_buffer_fuzzy_find)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Harpoon
|
||||||
|
|
||||||
|
local harpoon_ok, harpoon = pcall(require, "harpoon")
|
||||||
|
if harpoon_ok then
|
||||||
|
nnoremap("<leader>hx", function() harpoon:list():add() end)
|
||||||
|
nnoremap("<leader>hn", function() harpoon:list():next() end)
|
||||||
|
nnoremap("<leader>hp", function() harpoon:list():prev() end)
|
||||||
|
if telescope_status_ok then
|
||||||
|
-- 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
|
||||||
|
|
||||||
|
nnoremap("<leader>hh", function() toggle_telescope(harpoon:list()) end,
|
||||||
|
{ desc = "Open harpoon window" })
|
||||||
|
else
|
||||||
|
nnoremap("<leader>hh", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Copy to system clipboard
|
-- Copy to system clipboard
|
||||||
vnoremap('<leader>y', '"+y')
|
vnoremap('<leader>y', '"+y')
|
||||||
nnoremap('<leader>Y', '"+yg_')
|
nnoremap('<leader>Y', '"+yg_')
|
||||||
|
|
|
@ -68,11 +68,16 @@ return require("packer").startup(function(use)
|
||||||
config = function() require("nvim-autopairs").setup {} end
|
config = function() require("nvim-autopairs").setup {} end
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Telescope (fzf)
|
-- Telescope (fzf) and Harpoon
|
||||||
use {
|
use {
|
||||||
'nvim-telescope/telescope.nvim',
|
'nvim-telescope/telescope.nvim',
|
||||||
requires = { { 'nvim-lua/plenary.nvim' } }
|
requires = { { 'nvim-lua/plenary.nvim' } }
|
||||||
}
|
}
|
||||||
|
use {
|
||||||
|
"ThePrimeagen/harpoon",
|
||||||
|
branch = "harpoon2",
|
||||||
|
requires = { { "nvim-lua/plenary.nvim" } }
|
||||||
|
}
|
||||||
|
|
||||||
if is_workstation then
|
if is_workstation then
|
||||||
use {
|
use {
|
||||||
|
|
Loading…
Reference in a new issue