-
-
Notifications
You must be signed in to change notification settings - Fork 369
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
Cabal plugin outline view #4323
Conversation
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.
Needs some tests. I'll let the others comment on the symbol kind choices, I'm not sure what those constructors actually correspond to.
Thank you for working on this feature, it seems like a great addition to the plugin! |
I think, it could also make sense to not show leaf values in the outline at all? |
I thought that this will be an easy fix, but it looks like that it's unclear, who can provide such settings. It certanly can be done manualy, but I can't tell if it's possible to do by default. I will look into it, but I will be glad to hear any ideas for a soltion.
Right now the outline displays the cabal's AST without any modifications. I think it will be nice to see the if statements in one line, and looks like it can be done by jamming all |
At least for me it's not obvious, what data should be displayed, and what omitted. As far as I can tell, it can be independent with the depth in the cabal's AST. I think a collapsed outline would solve this issue as well. |
I don't think we have any control over whether or not the outline is expanded or not.
As I understand it, the outline view is generally used for navigation between named entities in the file. So I definitely don't think we should be including the values of fields, that's quite odd. I think having the top-level field names is probably useful, in that it allows jumping to them, but I think it would be nice to group them in a "top-level stanza" element, perhaps? |
Just | ||
(defDocumentSymbol range) | ||
{ LSP._name = decodeASCII fieldName, | ||
LSP._kind = LSP.SymbolKind_Object, |
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.
LSP._kind = LSP.SymbolKind_Object, | |
LSP._kind = LSP.SymbolKind_Field, |
where | ||
range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII string | ||
|
||
documentSymbolForFieldLine :: FieldLine Position -> Maybe LSP.DocumentSymbol |
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 think what I'm suggesting is that we get rid of this.
where | ||
range = cabalPositionToLSPRange pos `addNameLengthToLSPRange` decodeASCII fieldName | ||
|
||
documentSymbolForSectionArgs :: SectionArg Position -> Maybe LSP.DocumentSymbol |
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 unsure we want to include these either, what do they correspond to? It looks like this is responsible for e.g. the weirdness with conditionals.
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 think they can also include the names of stanzas so we definitely want to process them somehow but probably not into their own DocumentSymbol element
To fix the pre-commit failing, you will want to run the |
Once the functionality will be set I will implement the tests. |
The tests are now implemented as well. |
75ee342
to
f4d57a5
Compare
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.
LGTM, thanks! Just some documentation nitpicks, code looks good otherwise!
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Types.hs
Outdated
Show resolved
Hide resolved
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.
One more thing
This reverts commit f77dea5.
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
@VenInf You need to format some imports, but afterwards I think we're good to go to merge! |
I don't understand why this isn't merging... Or rather, why CircleCI seems to be hating @VenInf in particular. |
Maybe I have to register somewhere? Or provide some sort of credentials? |
This is an attempt to solve an issue #4282.
It adds an Outline for the cabal files.
Implementation details
Using runIdeAction we get parsed cabal fields with positions of the keywords.
This can be transformed with a series of functions to the DocumentSymbol. It is returned, and the
moduleOutline
can be plugged in to the cabal descriptor.