feat: autojump config option (#244)

This commit is contained in:
Steven Arcangeli 2023-04-27 05:58:39 -07:00
parent 580bde0ddf
commit 50ee9515f3
2 changed files with 12 additions and 2 deletions

View file

@ -126,6 +126,9 @@ local default_options = {
-- Set to false to disable
highlight_on_jump = 300,
-- Jump to symbol in source window when the cursor moves
autojump = false,
-- Define symbol icons. You can also specify "<Symbol>Collapsed" to change the
-- icon when the tree is collapsed at that symbol, or "Collapsed" to specify a
-- default collapsed icon. The default icon set is determined by the

View file

@ -25,14 +25,21 @@ local function create_aerial_buffer(bufnr)
vim.api.nvim_buf_set_option(aer_bufnr, "swapfile", false)
vim.api.nvim_buf_set_option(aer_bufnr, "modifiable", false)
if config.highlight_on_hover then
if config.highlight_on_hover or config.autojump then
vim.api.nvim_create_autocmd("CursorMoved", {
desc = "Aerial update highlights in the source buffer",
buffer = aer_bufnr,
callback = function()
render.update_highlights(bufnr)
if config.highlight_on_hover then
render.update_highlights(bufnr)
end
if config.autojump then
require("aerial.navigation").select({ jump = false })
end
end,
})
end
if config.highlight_on_hover then
vim.api.nvim_create_autocmd("BufLeave", {
desc = "Aerial clear highlights in the source buffer",
buffer = aer_bufnr,