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

Brittany formatting not working anymore, using a different formatter #1376

Closed
andys8 opened this issue Feb 15, 2021 · 9 comments · Fixed by #1414 or #1631
Closed

Brittany formatting not working anymore, using a different formatter #1376

andys8 opened this issue Feb 15, 2021 · 9 comments · Fixed by #1414 or #1631
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@andys8
Copy link
Collaborator

andys8 commented Feb 15, 2021

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

haskell-language-server version: 0.9.0.0 (GHC: 8.8.3) (PATH: /home/andreas/.local/bin/haskell-language-server-wrapper) (GIT hash: d674178246d1303619013bd0435cbfcbb1463530)
Tool versions found on the $PATH
cabal:          3.2.0.0
stack:          2.5.1
ghc:            8.8.3

Which lsp-client do you use:

Vim/CoC

    "haskell-language-server": {
      "enable": true,
      "command": "haskell-language-server-wrapper",
      "args": ["--lsp", "--logfile", "/tmp/hls.log"],
      "filetypes": ["haskell", "lhaskell"],
      "rootPatterns": [
        "*.cabal",
        "stack.yaml",
        "cabal.project",
        "package.yaml",
        "hie.yaml"
      ],
      "initializationOptions": {
        "languageServerHaskell": {
          "hlintOn": true,
          "maxNumberOfProblems": 10,
          "completionSnippetsOn": true,
          "formattingProvider": "brittany"
        }
      }
    },

Installing hls with this command (from source):

stack ./install.hs hls-8.8.3 hls-8.8.4 hls-8.10.3

Steps to reproduce

  • Format a file

Expected behaviour

  • Should be formatted with brittany

Actual behaviour

  • Seems to be formatted with ormolu (because of trailing commas and logs)

brittany working with: e2bf01b
brittany working with: 57b78e7
brittany not being used with: d674178

It should be introduced with one of these changes: 57b78e7...d674178

The installation method wasn't changed (related to agpl instructions). The language server configuration wasn't changed.

Include debug information

Execute in the root of your project the command haskell-language-server --debug . and paste the logs here:

2021-02-15 19:28:53.664802546 [ThreadId 6] INFO hls:	Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-1499336395990540516) "file:///home/andreas/dev/repository/git-brunch"], clientSettings = hashed (Just (Object (fromList [("languageServerHaskell",Object (fromList [("hlintOn",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 10.0),("formattingProvider",String "brittany")]))])))}

2021-02-15 19:28:55.89830073 [ThreadId 229] INFO hls:	finish: Ormolu (took 0.00s)
Debug output:
2021-02-15 19:28:53.350653291 [ThreadId 6] INFO haskell-lsp.runWith:	




haskell-lsp:Starting up server ...
2021-02-15 19:28:53.664802546 [ThreadId 6] INFO hls:	Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-1499336395990540516) "file:///home/andreas/dev/repository/git-brunch"], clientSettings = hashed (Just (Object (fromList [("languageServerHaskell",Object (fromList [("hlintOn",Bool True),("completionSnippetsOn",Bool True),("maxNumberOfProblems",Number 10.0),("formattingProvider",String "brittany")]))])))}
2021-02-15 19:28:53.668000847 [ThreadId 31] INFO hls:	Opened text document: file:///home/andreas/dev/repository/git-brunch/app/Main.hs
2021-02-15 19:28:53.668668652 [ThreadId 71] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Main.hs"
2021-02-15 19:28:53.66909833 [ThreadId 80] INFO hls:	Consulting the cradle for "app/Main.hs"
2021-02-15 19:28:55.876212634 [ThreadId 80] INFO hls:	Using interface files cache dir: ghcide
2021-02-15 19:28:55.876291187 [ThreadId 80] INFO hls:	Making new HscEnv[main]
2021-02-15 19:28:55.896621259 [ThreadId 143] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Main.hs"
2021-02-15 19:28:55.89830073 [ThreadId 229] INFO hls:	finish: Ormolu (took 0.00s)
2021-02-15 19:28:55.90191449 [ThreadId 248] INFO hls:	hlint:getIdeas:setExtensions:[Cpp,OverlappingInstances,UndecidableInstances,IncoherentInstances,UndecidableSuperClasses,MonomorphismRestriction,MonoPatBinds,MonoLocalBinds,RelaxedPolyRec,ExtendedDefaultRules,ForeignFunctionInterface,UnliftedFFITypes,InterruptibleFFI,CApiFFI,GHCForeignImportPrim,JavaScriptFFI,ParallelArrays,TemplateHaskell,TemplateHaskellQuotes,ImplicitParams,ImplicitPrelude,ScopedTypeVariables,AllowAmbiguousTypes,UnliftedNewtypes,BangPatterns,TypeFamilies,TypeFamilyDependencies,TypeInType,OverloadedStrings,OverloadedLists,NumDecimals,DisambiguateRecordFields,RecordWildCards,RecordPuns,ViewPatterns,GADTs,GADTSyntax,NPlusKPatterns,DoAndIfThenElse,BlockArguments,RebindableSyntax,ConstraintKinds,PolyKinds,DataKinds,InstanceSigs,ApplicativeDo,StandaloneDeriving,DeriveDataTypeable,AutoDeriveTypeable,DeriveFunctor,DeriveTraversable,DeriveFoldable,DeriveGeneric,DefaultSignatures,DeriveAnyClass,DeriveLift,DerivingStrategies,DerivingVia,TypeSynonymInstances,FlexibleContexts,FlexibleInstances,ConstrainedClassMethods,MultiParamTypeClasses,NullaryTypeClasses,FunctionalDependencies,UnicodeSyntax,ExistentialQuantification,MagicHash,EmptyDataDecls,KindSignatures,RoleAnnotations,ParallelListComp,MonadComprehensions,GeneralizedNewtypeDeriving,PostfixOperators,TupleSections,PatternGuards,LiberalTypeSynonyms,RankNTypes,ImpredicativeTypes,TypeOperators,ExplicitNamespaces,PackageImports,ExplicitForAll,AlternativeLayoutRuleTransitional,DatatypeContexts,NondecreasingIndentation,RelaxedLayout,TraditionalRecordSyntax,LambdaCase,MultiWayIf,BinaryLiterals,HexFloatLiterals,DuplicateRecordFields,OverloadedLabels,EmptyCase,PatternSynonyms,PartialTypeSignatures,NamedWildCards,TypeApplications,Strict,StrictData,MonadFailDesugaring,EmptyDataDeriving,NumericUnderscores,QuantifiedConstraints,ImportQualifiedPost,CUSKs,StandaloneKindSignatures,StarIsType]
2021-02-15 19:28:55.914352487 [ThreadId 31] INFO hls:	Modified text document: file:///home/andreas/dev/repository/git-brunch/app/Main.hs
2021-02-15 19:28:55.915615718 [ThreadId 421] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Main.hs"
2021-02-15 19:28:55.918582146 [ThreadId 500] INFO hls:	hlint:getIdeas:setExtensions:[Cpp,OverlappingInstances,UndecidableInstances,IncoherentInstances,UndecidableSuperClasses,MonomorphismRestriction,MonoPatBinds,MonoLocalBinds,RelaxedPolyRec,ExtendedDefaultRules,ForeignFunctionInterface,UnliftedFFITypes,InterruptibleFFI,CApiFFI,GHCForeignImportPrim,JavaScriptFFI,ParallelArrays,TemplateHaskell,TemplateHaskellQuotes,ImplicitParams,ImplicitPrelude,ScopedTypeVariables,AllowAmbiguousTypes,UnliftedNewtypes,BangPatterns,TypeFamilies,TypeFamilyDependencies,TypeInType,OverloadedStrings,OverloadedLists,NumDecimals,DisambiguateRecordFields,RecordWildCards,RecordPuns,ViewPatterns,GADTs,GADTSyntax,NPlusKPatterns,DoAndIfThenElse,BlockArguments,RebindableSyntax,ConstraintKinds,PolyKinds,DataKinds,InstanceSigs,ApplicativeDo,StandaloneDeriving,DeriveDataTypeable,AutoDeriveTypeable,DeriveFunctor,DeriveTraversable,DeriveFoldable,DeriveGeneric,DefaultSignatures,DeriveAnyClass,DeriveLift,DerivingStrategies,DerivingVia,TypeSynonymInstances,FlexibleContexts,FlexibleInstances,ConstrainedClassMethods,MultiParamTypeClasses,NullaryTypeClasses,FunctionalDependencies,UnicodeSyntax,ExistentialQuantification,MagicHash,EmptyDataDecls,KindSignatures,RoleAnnotations,ParallelListComp,MonadComprehensions,GeneralizedNewtypeDeriving,PostfixOperators,TupleSections,PatternGuards,LiberalTypeSynonyms,RankNTypes,ImpredicativeTypes,TypeOperators,ExplicitNamespaces,PackageImports,ExplicitForAll,AlternativeLayoutRuleTransitional,DatatypeContexts,NondecreasingIndentation,RelaxedLayout,TraditionalRecordSyntax,LambdaCase,MultiWayIf,BinaryLiterals,HexFloatLiterals,DuplicateRecordFields,OverloadedLabels,EmptyCase,PatternSynonyms,PartialTypeSignatures,NamedWildCards,TypeApplications,Strict,StrictData,MonadFailDesugaring,EmptyDataDeriving,NumericUnderscores,QuantifiedConstraints,ImportQualifiedPost,CUSKs,StandaloneKindSignatures,StarIsType]
2021-02-15 19:28:55.937798729 [ThreadId 31] INFO hls:	Saved text document: file:///home/andreas/dev/repository/git-brunch/app/Main.hs
2021-02-15 19:28:55.950131335 [ThreadId 660] INFO hls:	hlint:getIdeas:file:NormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Main.hs"
2021-02-15 19:28:55.956292248 [ThreadId 752] INFO hls:	hlint:getIdeas:setExtensions:[Cpp,OverlappingInstances,UndecidableInstances,IncoherentInstances,UndecidableSuperClasses,MonomorphismRestriction,MonoPatBinds,MonoLocalBinds,RelaxedPolyRec,ExtendedDefaultRules,ForeignFunctionInterface,UnliftedFFITypes,InterruptibleFFI,CApiFFI,GHCForeignImportPrim,JavaScriptFFI,ParallelArrays,TemplateHaskell,TemplateHaskellQuotes,ImplicitParams,ImplicitPrelude,ScopedTypeVariables,AllowAmbiguousTypes,UnliftedNewtypes,BangPatterns,TypeFamilies,TypeFamilyDependencies,TypeInType,OverloadedStrings,OverloadedLists,NumDecimals,DisambiguateRecordFields,RecordWildCards,RecordPuns,ViewPatterns,GADTs,GADTSyntax,NPlusKPatterns,DoAndIfThenElse,BlockArguments,RebindableSyntax,ConstraintKinds,PolyKinds,DataKinds,InstanceSigs,ApplicativeDo,StandaloneDeriving,DeriveDataTypeable,AutoDeriveTypeable,DeriveFunctor,DeriveTraversable,DeriveFoldable,DeriveGeneric,DefaultSignatures,DeriveAnyClass,DeriveLift,DerivingStrategies,DerivingVia,TypeSynonymInstances,FlexibleContexts,FlexibleInstances,ConstrainedClassMethods,MultiParamTypeClasses,NullaryTypeClasses,FunctionalDependencies,UnicodeSyntax,ExistentialQuantification,MagicHash,EmptyDataDecls,KindSignatures,RoleAnnotations,ParallelListComp,MonadComprehensions,GeneralizedNewtypeDeriving,PostfixOperators,TupleSections,PatternGuards,LiberalTypeSynonyms,RankNTypes,ImpredicativeTypes,TypeOperators,ExplicitNamespaces,PackageImports,ExplicitForAll,AlternativeLayoutRuleTransitional,DatatypeContexts,NondecreasingIndentation,RelaxedLayout,TraditionalRecordSyntax,LambdaCase,MultiWayIf,BinaryLiterals,HexFloatLiterals,DuplicateRecordFields,OverloadedLabels,EmptyCase,PatternSynonyms,PartialTypeSignatures,NamedWildCards,TypeApplications,Strict,StrictData,MonadFailDesugaring,EmptyDataDeriving,NumericUnderscores,QuantifiedConstraints,ImportQualifiedPost,CUSKs,StandaloneKindSignatures,StarIsType]
2021-02-15 19:28:55.974935615 [ThreadId 809] INFO hls:	Typechecking reverse dependencies for NormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Main.hs": Just []
2021-02-15 19:28:56.022402146 [ThreadId 844] INFO hls:	SUCCEEDED LOADING HIE FILE FOR:"/home/andreas/.cache/ghcide/main-73804d8cf6cf94b7cc4c97cf069a2e1f18fec96e/Paths_git_brunch.hie"
2021-02-15 19:28:56.022538296 [ThreadId 844] INFO hls:	Re-indexing hie file forNormalizedFilePath "/home/andreas/dev/repository/git-brunch/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.0.1.0/build/git-brunch/autogen/Paths_git_brunch.hs"
2021-02-15 19:28:56.101279921 [ThreadId 851] INFO hls:	SUCCEEDED LOADING HIE FILE FOR:"/home/andreas/.cache/ghcide/main-73804d8cf6cf94b7cc4c97cf069a2e1f18fec96e/Theme.hie"
2021-02-15 19:28:56.101377059 [ThreadId 851] INFO hls:	Re-indexing hie file forNormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Theme.hs"
2021-02-15 19:28:56.103126939 [ThreadId 858] INFO hls:	SUCCEEDED LOADING HIE FILE FOR:"/home/andreas/.cache/ghcide/main-73804d8cf6cf94b7cc4c97cf069a2e1f18fec96e/Git.hie"
2021-02-15 19:28:56.103206561 [ThreadId 858] INFO hls:	Re-indexing hie file forNormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/Git.hs"
2021-02-15 19:28:56.27953 [ThreadId 873] INFO hls:	SUCCEEDED LOADING HIE FILE FOR:"/home/andreas/.cache/ghcide/main-73804d8cf6cf94b7cc4c97cf069a2e1f18fec96e/GitBrunch.hie"
2021-02-15 19:28:56.279624712 [ThreadId 873] INFO hls:	Re-indexing hie file forNormalizedFilePath "/home/andreas/dev/repository/git-brunch/app/GitBrunch.hs"

@andys8 andys8 changed the title Brittany formatting not working anymore, using a different format Brittany formatting not working anymore, using a different formatter Feb 15, 2021
@Ailrun Ailrun added component: plugins status: needs repro type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Feb 15, 2021
@pepeiborra
Copy link
Collaborator

Thanks for the awesome bug report with bisect !

pepeiborra added a commit that referenced this issue Feb 15, 2021
@prikhi
Copy link
Contributor

prikhi commented Feb 16, 2021

I'm getting this as well with neovim & minimal initialization options:

      "initializationOptions": {
        "languageServerHaskell": {
          "formattingProvider": "brittany"
        }

(w/ both haskell & languageServerHaskell as option keys)

My current workaround is to go into hls-plugin-api/src/Ide/Plugin/Config.hs & change the Default Config instance to use brittany instead of ormolu.

@andys8
Copy link
Collaborator Author

andys8 commented Feb 19, 2021

Is this an issue for more people? Is it only the case for brittany or every formatter?

pepeiborra added a commit that referenced this issue Feb 20, 2021
pepeiborra added a commit that referenced this issue Feb 20, 2021
pepeiborra added a commit that referenced this issue Feb 20, 2021
pepeiborra added a commit that referenced this issue Feb 20, 2021
* Add a test for #1376

* add missing files

* fix identifiers
@andys8
Copy link
Collaborator Author

andys8 commented Feb 21, 2021

With the new findings and based on the comment #1414 (comment) : Is the test in #1414 actually closing the issue?

The test is a good addition. Testing that the formatter is working is not addressing the issue that the config isn't parsed, which does seem to be the reason for this behavior. To test #1376 it should instead make sure initialize is in use. And the fix would actually parse the configuration in initialize.

I'm either missing something or this issue shouldn't be closed.

@asattelmaier
Copy link

asattelmaier commented Mar 6, 2021

I have a similar problem, I also don't have the option to change the default formatter to "stylish-haskell".

Output of haskell-language-server --probe-tools :

haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /root/.cabal/store/ghc-8.10.4/haskell-language-server-1.0.0.0-e-haskell-language-server-f40b1681e50c634981106ecfa8dcc20be9806ecccc598e501f60700f8219a145/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:          3.4.0.0
stack:          Not found
ghc:            8.10.4

Vim/CoC Client configuration:

{
  "languageserver": {
    "haskell": {
      "command": "haskell-language-server-wrapper",
      "args": ["--lsp"],
      "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
      "filetypes": ["haskell", "lhaskell"],
      "initializationOptions": {
        "languageServerHaskell": {
          "hlintOn": true,
          "maxNumberOfProblems": 10,
          "completionSnippetsOn": true,
          "formattingProvider": "stylish-haskell"
        }
      }
    }
  }
}

I installed hls with:

./cabal-hls-install hls-8.10.4

@andys8
Copy link
Collaborator Author

andys8 commented Mar 6, 2021

@asattelmaier As far as I can tell configuration with Vim/CoC (and language clients that behave the same) was broken before the 1.0.0 release. It should be fixed once https://github.com/haskell/lsp (containing haskell/lsp#285) will be released and updated in haskell-language-server. This means we should wait a bit and it is supposed to be working again eventually.

@andys8
Copy link
Collaborator Author

andys8 commented Mar 30, 2021

@pepeiborra Could we reopen this issue to track that it's still open?

@jneira jneira reopened this Mar 30, 2021
@jneira
Copy link
Member

jneira commented Mar 30, 2021

There is an ongoing pr that updates lsp: #1631, iiuc it would close this, right?

@andys8
Copy link
Collaborator Author

andys8 commented Mar 30, 2021

Yes, the next release of haskell-lsp should contain a fix.

@jneira jneira linked a pull request Mar 31, 2021 that will close this issue
@mergify mergify bot closed this as completed in #1631 Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: plugins type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
6 participants