-
-
Notifications
You must be signed in to change notification settings - Fork 367
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
Language Pragmas Auto-Insert After Module Docs #1726
Comments
I believe that the intended behaviour is to insert pragmas directly before the start of the first line of Haskell code, this is done using the following: endOfModuleHeader :: ParsedModule -> Range
endOfModuleHeader pm =
let mod = unLoc $ pm_parsed_source pm
modNameLoc = getLoc <$> hsmodName mod
firstImportLoc = getLoc <$> listToMaybe (hsmodImports mod)
firstDeclLoc = getLoc <$> listToMaybe (hsmodDecls mod)
line = maybe 0 (_line . _start) (modNameLoc <|> firstImportLoc <|> firstDeclLoc >>= srcSpanToRange)
loc = Position line 0
in Range loc loc We could include an option to always insert pragmas at the top of the file? I will open a PR for this shortly. |
I am afraid there was a pr that remove just that behaviour cause it put the pragma before she-bangs: #1340 which fixed #555 |
* added option to always insert pragmas at top of file * Revert "added option to always insert pragmas at top of file" This reverts commit 8cebdd5. * Pragmas inserted before comments (#1726) * Code style * Code style * Insert pragamas to existing pragma list * added cpp macro to pragma test for ghc < 810 * Refactor: using file contents to find pragma insertion position * Update getParsedModule action description * Code style Co-authored-by: Javier Neira <[email protected]> Co-authored-by: Potato Hatsue <[email protected]>
Your environment
Output of
haskell-language-server --probe-tools
orhaskell-language-server-wrapper --probe-tools
:haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: /Users/emilypi/.ghcup/bin/haskell-language-server-wrapper-1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b) Tool versions found on the $PATH cabal: 3.4.0.0 stack: 2.5.1 ghc: 8.10.4
Which OS do you use:
Big Sur OSX
Which lsp-client do you use:
Emacs lsp-haskell
Describe your project (alternative: link to the project):
Cabal project
Contents of
hie.yaml
:Steps to reproduce
On HLS 1.1, auto-insert any language pragma in a module with header documentation
Expected behaviour
Pragmas should be inserted before docs
Actual behaviour
Pragmas are inserted after docs:
The text was updated successfully, but these errors were encountered: