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

feat(symbols): Added symbol source #841

Merged
merged 19 commits into from
Apr 14, 2023

Conversation

nhat-vo
Copy link
Collaborator

@nhat-vo nhat-vo commented Apr 3, 2023

A simple source to view LSP symbols in the current file.
Features:

  • UI:
    • Display all symbols in the current file with symbol kinds
    • Symbols nesting
    • Configurable kinds' name and icon
    • Auto-refresh symbol list
  • Commands
    • Jump to symbols, open symbol in split,... (open_split and friends)
    • Rename symbols (rename)
    • Preview symbol (preview and friends)
    • Hover docs
    • Call hierarchy
  • LSP
    • LSP Support
    • LSP server selection (blacklist, use first, use all, etc.)
  • CoC Support

Feel free to let me know if you have any comments on what additional features should be desired.

@nhat-vo nhat-vo marked this pull request as ready for review April 3, 2023 21:54
@nhat-vo
Copy link
Collaborator Author

nhat-vo commented Apr 3, 2023

The document_symbol source is good for now (it is not enabled by default as there might still be bugs). I will implement the hover_docs, call_hierarchy, and CoC Support in a future PR.

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First off, it's awesome that you are undertaking this, I can't wait to start using it!

I do think there is more work to do before it's ready for merging though. I haven't dug deep into the code but I have some suggestions at the surface level here.

I also noticed that it does not automatically update when I change files, which is something that I think would be expected by anyone using it.

lua/neo-tree/defaults.lua Show resolved Hide resolved
lua/neo-tree/defaults.lua Outdated Show resolved Hide resolved
lua/neo-tree/setup/init.lua Outdated Show resolved Hide resolved
lua/neo-tree/sources/document_symbols/commands.lua Outdated Show resolved Hide resolved
lua/neo-tree/defaults.lua Outdated Show resolved Hide resolved
@nhat-vo
Copy link
Collaborator Author

nhat-vo commented Apr 4, 2023

I'm very glad to hear that you like this! Regarding the automatic update, I will have a look at why it is not auto-updating. Previously, I used the User LspRequest event, which updates the tree automatically on change and when the current buffer is changed (and every time any LSP Request is made), but this means that navigate is called twice every time the source is opened, so I switched to using these events instead.

@nhat-vo
Copy link
Collaborator Author

nhat-vo commented Apr 7, 2023

@cseickel I can't seem to reproduce your issue with automatic file changes. For me, whenever I change the file, the document_symbols source is updated accordingly. Could you provide the steps to reproduce this?

Edit: Actually, undoing doesn't refresh this, and it seems that there is no other way to hook onto undoing, so I'm falling back to using the User LspRequest event. I have added loading to the source's state, which will help limit repeated calls.

@nhat-vo nhat-vo requested a review from cseickel April 8, 2023 09:40
@nhat-vo
Copy link
Collaborator Author

nhat-vo commented Apr 10, 2023

Actually, I ended up changing it to several separate events and using utils.debounce. Seems to refresh at the right moment and the right amount now.

Copy link
Contributor

@cseickel cseickel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@cseickel
Copy link
Contributor

@nhat-vo I think this looks good as an initial release and I'll merge it now. The two things I would add to make it complete are:

  • Follow cursor: just like "follow current file", I would expect the symbol tree to always have the symbol I'm currently on be selected.
  • fuzzy search: I would implement the search commands to be able to search/filter the list of document symbols.

@cseickel cseickel linked an issue Apr 14, 2023 that may be closed by this pull request
@cseickel cseickel merged commit 5627811 into nvim-neo-tree:main Apr 14, 2023
2 checks passed
@nhat-vo
Copy link
Collaborator Author

nhat-vo commented Apr 17, 2023

@cseickel Great! I'm very glad to see this merged! I'll create an issue to track the features of this source.

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

Successfully merging this pull request may close these issues.

Add symbol and call sources
2 participants