-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add context jump function #260
Conversation
lua/treesitter-context.lua
Outdated
return contexts | ||
end | ||
|
||
function M.previous_context() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really comfortable exposing the internals of the context object. Can we add functions for simple navigation instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! how do you see the API? something like M.go_next_context
and M.go_to_previous_context
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
goto_next
doesn't make much sense since that information isn't available. I think just go_to_previous_context()
(no arguments).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated and rebased.
lua/treesitter-context.lua
Outdated
@@ -65,6 +65,9 @@ local ns = api.nvim_create_namespace('nvim-treesitter-context') | |||
--- @type TSNode[]? | |||
local previous_nodes | |||
|
|||
--- @type Context[] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be per buffer.
--- @type Context[] | |
--- @type table<integer,Context[]> |
lua/treesitter-context.lua
Outdated
@@ -803,6 +806,26 @@ function M.setup(options) | |||
end | |||
end | |||
|
|||
function M.go_to_previous_context() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second though a better name will be just go_to_context
, since this won't work if the cursor isn't inside of a context.
E.g.
function foo()
....
end
<cursor> -- go_to_previous_context() won't go to foo
lua/treesitter-context.lua
Outdated
return | ||
end | ||
|
||
vim.fn.setpos( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use vim.api.nvim_win_set_cursor
.
#190