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

feature: marker to ignore the following block #409

Open
imuli opened this issue Aug 30, 2022 · 2 comments
Open

feature: marker to ignore the following block #409

imuli opened this issue Aug 30, 2022 · 2 comments

Comments

@imuli
Copy link
Contributor

imuli commented Aug 30, 2022

I occasionally run into situations where I want to manually format a block, e.g. with servant-openapi3:

-- | The Work API
-- ...
data WorkAPI n mode = WorkAPI
   { workCreate :: mode
      :- Summary "Create a work from a design."
      :> Description "..."
      :> NamedRoutes (RunAPI (Design n) (WorkId n))
   , workIdDesignGet :: mode
      :- Summary "Fetch the most recent design on a work."
      :> Description "..."
      :> WorkId n :> "design" :> NamedRoutes (GetAPI (Design n))
   }
  deriving (Generic)

stylish-haskell, of course, will reformat that so each type definition is on a single line, which is what I want in most cases. This would also provide a workaround while waiting on a bug fix (or for me in the case of record GADTs with docs, bug filing!).

{- STYLISH ignore -} -- no special highlighting.
{-# STYLISH ignore #-} -- special highlighting, but makes ghc noisy without `-Wno-unrecognized-pragmas`
{-# ANN myDef ("STYLISH ignore" :: String) #-} -- extra special highlighting, but not usable for imports, verbose.
@andys8
Copy link

andys8 commented Sep 19, 2022

Would help with the haskell-language-server project where stylish-haskell is in use but fails to parse some files. Skipping these sections would format the rest of the file and help with failing pre-commit tasks.

plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs: <string>:442:26: error: parse error on input `='
ghcide/src/Development/IDE/Import/FindImports.hs: <string>:127:5: error:
    parse error (possibly incorrect indentation or mismatched brackets)
plugins/hls-refactor-plugin/src/Development/IDE/GHC/Compat/ExactPrint.hs: <string>:4:1: error: parse error on input `module'
ghcide/src/Development/IDE/Core/Compile.hs: <string>:372:7: error: parse error on input `go'

@imuli
Copy link
Contributor Author

imuli commented Oct 21, 2022

This imuli@22fd02d commit in my personal version is the minimal thing that meets (some) of my needs. It only handles the comment inside the data declaration though:

data {-STYLISH ignore-} WorkAPI n mode = WorkAPI

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

No branches or pull requests

2 participants