* feat(harpoon.lua): add keymaps for navigating between files and toggling quick menu

* feat(keymaps.lua): add keymap for deleting all buffers except current
* feat(nvim-tree.lua): add autocmd to go to last used hidden buffer when deleting a buffer
* chore(init.lua): add ThePrimeagen/harpoon plugin to the list of plugins

* chore(nvim-tree.lua): add missing comma in filters table
* feat(surround.lua): add kylechui/nvim-surround plugin configuration
This commit is contained in:
PeteChu 2023-04-03 23:14:15 +07:00
parent 5c8fa11c53
commit 431b1bf351
6 changed files with 46 additions and 4 deletions

View file

@ -21,3 +21,23 @@ end
vim.api.nvim_create_autocmd({"QuitPre"}, {
callback = function() vim.cmd("NvimTreeClose") end,
})
-- Go to last used hidden buffer when deleting a buffer
vim.api.nvim_create_autocmd("BufEnter", {
nested = true,
callback = function()
-- Only 1 window with nvim-tree left: we probably closed a file buffer
if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then
local api = require('nvim-tree.api')
-- Required to let the close event complete. An error is thrown without this.
vim.defer_fn(function()
-- close nvim-tree: will go to the last hidden buffer used before closing
api.tree.toggle({find_file = true, focus = true})
-- re-open nivm-tree
api.tree.toggle({find_file = true, focus = true})
-- nvim-tree is still the active window. Go to the previous window.
vim.cmd("wincmd p")
end, 0)
end
end
})