Skip to content

Navigate to the top-level function's definition where the cursor is located#32

Open
usfbih8u wants to merge 4 commits into
Andriamanitra:mainfrom
usfbih8u:feat_goto_current_function
Open

Navigate to the top-level function's definition where the cursor is located#32
usfbih8u wants to merge 4 commits into
Andriamanitra:mainfrom
usfbih8u:feat_goto_current_function

Conversation

@usfbih8u
Copy link
Copy Markdown
Contributor

@usfbih8u usfbih8u commented Feb 4, 2025

No description provided.

@usfbih8u
Copy link
Copy Markdown
Contributor Author

usfbih8u commented Feb 4, 2025

This PR uses documentSymbols and ranges to find the function where the cursor is located.

This is a functionality that I find useful when I am in a long function.

In languages that use {} for scopes, I created a plugin that allows me to do that (and more), but in Lua, I need something different.

If you find this out of scope (it is, in my opinion, but useful) for the project, feel free to close this PR. I will keep it for myself.

The name could be better, but if you are not merging it, I don't care about the name.

@Andriamanitra Andriamanitra added the enhancement New feature or request label Feb 4, 2025
@Andriamanitra
Copy link
Copy Markdown
Owner

If you find this out of scope (it is, in my opinion, but useful) for the project, feel free to close this PR. I will keep it for myself.

I don't mind adding functionality that is not directly provided by the LSP.

I'm not sure about the implementation though, I feel like there is a way to make it more widely useful by making it more generic. I'll need to think about it some more.

@usfbih8u
Copy link
Copy Markdown
Contributor Author

usfbih8u commented Feb 4, 2025

Obviously, it is not generic at all; it is tailored specifically to my personal use case.

Feel free to take this PR in a different direction in the future if you want to.

@usfbih8u
Copy link
Copy Markdown
Contributor Author

The LSP specification states that in SymbolInformation[], there is no range that can "be used to re-construct a hierarchy of the symbols." However, after using clangd and receiving SymbolInformation[], I noticed that sym.location.range is, in fact, the range of the function.

I do not know if this is a clangd thing or if it is widespread enough to be usable. It could be reverted otherwise.

@Andriamanitra Andriamanitra added the experimental Experimental feature, good for testing but not to be merged label May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request experimental Experimental feature, good for testing but not to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants