Skip to content

Commit

Permalink
feat: autojump config option (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Apr 27, 2023
1 parent 580bde0 commit 50ee951
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lua/aerial/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 9 additions & 2 deletions lua/aerial/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 50ee951

Please sign in to comment.