ziontee113/syntax-tree-surfer

How do you get the AST highlighted in visual mode like in the demo video?

llllvvuu opened this issue · 3 comments

https://github.com/ziontee113/syntax-tree-surfer#navigate-around-your-document-based-on-treesitters-abstract-syntax-tree-step-into-step-out-step-over-step-back it's show when random_array is highlighted

Mine just looks like this:

Screen.Recording.2023-07-17.at.8.44.18.PM.mov

You can use

-- Visual Selection from Normal Mode
vim.keymap.set("n", "vx", '<cmd>STSSelectMasterNode<cr>', opts)
vim.keymap.set("n", "vn", '<cmd>STSSelectCurrentNode<cr>', opts)```

to achieve that.

So it's supposed to show the AST indicators when pressing vn but not when pressing V?

Even with STSSelectCurrentNode I got only the selection/range but not the AST indicators. Do you know which part is repsonsible for those indicators?

I couldn't find it here:

function M.update_selection(buf, node, selection_mode) -- rip from the old ts_utils{{{
selection_mode = selection_mode or "charwise"
local start_row, start_col, end_row, end_col = ts_utils.get_vim_range({ vim.treesitter.get_node_range(node) }, buf)
vim.fn.setpos(".", { buf, start_row, start_col, 0 })
-- Start visual selection in appropriate mode
local v_table = { charwise = "v", linewise = "V", blockwise = "<C-v>" }
---- Call to `nvim_replace_termcodes()` is needed for sending appropriate
---- command to enter blockwise mode
local mode_string = vim.api.nvim_replace_termcodes(v_table[selection_mode] or selection_mode, true, true, true)
vim.cmd("normal! " .. mode_string)
vim.fn.setpos(".", { buf, end_row, end_col, 0 })
end --}}}

EDIT: maybe just the colorscheme need to set bgcolor, let me try...

OK, I figured it out, it's a feature of gruvbox: gruvbox-community/gruvbox#126