-
-
Notifications
You must be signed in to change notification settings - Fork 388
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
Add Goto Definition for cabal common sections #4375
Add Goto Definition for cabal common sections #4375
Conversation
@VenInf I think this PR is relevant to you as well and might be implementing some util functions you could benefit from as well. Could you review this PR? |
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.
Thanks for the PR!
This looks very nice, just a couple of tests missing, then this is good to merge :)
case uriToFilePath' uri of | ||
Nothing -> | ||
pure $ InR $ InR Null | ||
Just filePath -> do |
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.
Prefer getNormalizedFilePathE
which takes care of the validation.
case uriToFilePath' uri of | |
Nothing -> | |
pure $ InR $ InR Null | |
Just filePath -> do | |
nfp <- getNormalizedFilePathE uri |
Then use fromNormalizedFilePath
if you need the underlying FilePath
.
@@ -1,12 +1,16 @@ | |||
module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs) where | |||
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} | |||
module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, findTextWord, findFieldLine, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs, getFieldEndPosition, getSectionArgEndPosition, getNameEndPosition, getFieldLineEndPosition, getFieldLSPRange) where |
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 am amazed stylish-haskell accepts this.
Would you mind introducing a couple of new lines to make this easier to read? E.g.
module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, findTextWord, findFieldLine, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs, getFieldEndPosition, getSectionArgEndPosition, getNameEndPosition, getFieldLineEndPosition, getFieldLSPRange) where | |
module Ide.Plugin.Cabal.Completion.CabalFields | |
( findStanzaForColumn, | |
findFieldSection, | |
findTextWord, | |
... | |
) where |
or something like that?
@@ -1,12 +1,16 @@ | |||
module Ide.Plugin.Cabal.Completion.CabalFields (findStanzaForColumn, findFieldSection, getOptionalSectionName, getAnnotation, getFieldName, onelineSectionArgs) where | |||
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} |
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.
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} |
Looks unused?
import Data.List.NonEmpty (NonEmpty) | ||
import qualified Data.List.NonEmpty as NE | ||
import qualified Data.Text as T | ||
import qualified Data.Text.Encoding as T | ||
import qualified Distribution.Fields as Syntax | ||
import qualified Distribution.Parsec.Position as Syntax | ||
import Ide.Plugin.Cabal.Completion.Types | ||
import qualified Language.LSP.Protocol.Types as LSPTypes |
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.
Nitpick:
import qualified Language.LSP.Protocol.Types as LSPTypes | |
import qualified Language.LSP.Protocol.Types as LSP |
Other parts of the codebase use this qualified import. Perhaps we should have some kind of style guide? Hard to tell.
-- that are not a space or column. | ||
|
||
-- This function currently only considers words inside of a @FieldLine@. |
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.
-- that are not a space or column. | |
-- This function currently only considers words inside of a @FieldLine@. | |
-- that are not a space or column. | |
-- | |
-- This function currently only considers words inside of a @FieldLine@. |
Otherwise, the haddock comment will not be attached to the function :)
Thank you for your work! The only comment I might have, is that I thought about mimicking |
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.
Very nice feature and the code looks great, thanks!
I think once we get some tests, we're ready to merge 🥳
plugins/hls-cabal-plugin/src/Ide/Plugin/Cabal/Completion/CabalFields.hs
Outdated
Show resolved
Hide resolved
62972ef
to
8f164e2
Compare
8f164e2
to
c2d980c
Compare
e35a426
to
d0d0f94
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, awesome, thank you very much!
* Add goto-definitions for cabal common sections * Add default direct cradle hie.yaml file to testdata * incorporate changes requested in haskell#4375 * add tests for cabal goto-definition
This PR is the start of a go to definition code action for cabal files.