Skip to content

Commit

Permalink
feat(sources): treesitter: handle cursor pos in insert mode differently
Browse files Browse the repository at this point in the history
  • Loading branch information
bekaboo committed Jul 4, 2023
1 parent c72bd7f commit c25bef8
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/dropbar/sources/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ local function get_symbols(buf, win, cursor)
local symbols = {}
local prev_type_rank = math.huge
local prev_row = math.huge
local current_node = vim.treesitter.get_node({
bufnr = buf,
pos = { cursor[1] - 1, cursor[2] },
})
local current_node =
vim.treesitter.get_node({
bufnr = buf,
pos = {
cursor[1] - 1,
cursor[2] - (cursor[2] >= 1 and vim.api
.nvim_get_mode().mode
:match('^i') and 1 or 0),
},
})
while current_node do
local name = get_node_short_name(current_node, buf)
local type, type_rank = get_node_short_type(current_node)
Expand Down

0 comments on commit c25bef8

Please sign in to comment.