Skip to content
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

Function listing in side panel #367

Open
zigsby opened this issue Dec 15, 2024 · 3 comments
Open

Function listing in side panel #367

zigsby opened this issue Dec 15, 2024 · 3 comments
Assignees
Labels
enhancement New feature or request

Comments

@zigsby
Copy link

zigsby commented Dec 15, 2024

I feel code navigability is lacking a bit. While code folding can help, I don't think it's quite up to the job.

Many editors have some sort of functionality to display and navigate the code structure, by showing objects, members etc. I don't actually use that sort of thing much, so I feel like it is a considerable amount of effort to implement for not that much payback. But a reduced version that just lists all the functions/prototypes in a file and allows quick navigation to the spot with a simple click would be very beneficial.

I would think the code folding feature should pretty much already provide all the locations where functions start. There should be little or no extra effort to get the function names. The rest would be rather straight forward GUI work to display a sortable and clickable list in a side bar tab.

I think sorting alphabetically or displaying in the order they appear in the code would suffice.

@SpartanJ
Copy link
Owner

I don't particularly like it as a side-panel so I never added a side panel for this, but ctrl+shift+l contains what you are describing, but it depends on the LSP, since this requires understanding about the abstract syntax tree of the code (it's not enough with the code-folding information, this just analice brackets/spaces). So you'll have to install the LSP for the language you're using and the functionality will appear (if the LSP provides it, which is pretty common).

simplescreenrecorder-2024-12-15_00.22.45.mp4

@SpartanJ SpartanJ self-assigned this Dec 15, 2024
@SpartanJ SpartanJ added the enhancement New feature or request label Dec 15, 2024
@zigsby
Copy link
Author

zigsby commented Dec 15, 2024

Thanks, that would be a good start. Unfortunately this feature does not actually exist. I checked the language health and C is supported. But ctrl+shift+I doesn't do anything. Not surprising, because there is no entry in the key bindings for mod+shift=i. If I knew the command I could add it or perhaps it is there with a different binding?

@SpartanJ
Copy link
Owner

Mhh the keybinding was not being displayed by default in the LSP options in the latest stable version. You can add it manually to rebind it, it's called lsp-show-document-symbols.
Anyway the breadcrumb is enabled by default so you should see it as in my previous comment video.

The relevant detail is that plugin keybindings are not part of the global keybindings so they are configured in the plugins configuration.

So in short: if you're working with C you need clangd installed, as you mentioned, at language health in the LSP column it should be marked in green. Breadcrumb functionality should be enabled by default in LSP, so documents will have the file path and the current cursor symbol.

The functionality of course it already exists, that's why I'm able to display it, here's another video demonstrating it, plus the symbol search, that can be accessed from the locate bar (or default keybinding is mod+shift+p or by just starting the search with . ).

simplescreenrecorder-2024-12-15_11.35.55.mp4

You can also download the nightly build that will have the lsp-show-document-symbols keybinding present in the LSP configuration file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants