-
-
Notifications
You must be signed in to change notification settings - Fork 368
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 file completions #3268
Cabal file completions #3268
Conversation
aa47679
to
6dfd216
Compare
97a0cf6
to
9bf0eaf
Compare
cd58428
to
7f191db
Compare
2038fdb
to
182189b
Compare
0ec6fe4
to
c46ba7d
Compare
5c5a6a3
to
7a6d82b
Compare
70e7d3d
to
ada3138
Compare
ada3138
to
59f2968
Compare
0027a1c
to
9c3821f
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.
Generally look good! I think my main high-level worry is that this might not deal well with large files because it looks like it's doing a decent amount of stuff that's linear in the number of lines. Yes, cabal files tend to be short, but they could be long, e.g. imagine if we did actually merge all the HLS packages into a single package with many libraries!
I had two thoughts about fixing this:
- Use the
Rope
type that the VFS uses for file contents, which has good performance for line-based operations - Actually parse the file into some kind of structure which we can then use for efficiently looking up where a position is later. This would be more work, I'm not sure if we could reuse the cabal parser or whether we'd need to do something else, but in principle you could look at the source spans for syntax elements and try to descend into the closest piece of syntax while hopefully doing a number of operations proportional to the depth of the syntax tree instead.
Thank you! I will include this.
I have thought about this, since it would probably make a lot of the cabal plugin's features more neat in the long run. |
f0eff24
to
a1d6980
Compare
4954c68
to
c7bd418
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.
First review round! 🎊
I think this is in a good shape, couple of tests, couple of docs and then we can likely merge it, imo.
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Snippet.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Snippet.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Simple.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completions.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
c7bd418
to
c2962fc
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.
Ran out of time so I just commented on the file completions.
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/FilePath.hs
Outdated
Show resolved
Hide resolved
1abd3c5
to
7e998da
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, last review round, then we will merge this.
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Types.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Data.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Module.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Module.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Module.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Module.hs
Outdated
Show resolved
Hide resolved
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/Completer/Module.hs
Outdated
Show resolved
Hide resolved
7e998da
to
9a0eb7d
Compare
Includes: * completions for keywords, sensitive to stanzas * value completions for constant values, files, directories and exposed modules * completion of snippets for different stanzas and the required basic fields
9a0eb7d
to
e5e42ee
Compare
c798f1b
to
1123361
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, let's get this merged and get some user feedback.
Add completion suggestions for cabal files.
Related to #3664, by suggestion of #2940.
Current state:
Completions for keywords
Value completion for different kinds of values
We implement completion according to the cabal package description.
Snippet completion
common-warnings
Examples
Keyword completion inside a stanza:
Value completion for existing keyword:
Snippet for library stanza