-
-
Notifications
You must be signed in to change notification settings - Fork 391
HLS seems confused about the source directory #1901
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
Comments
A direct cradle must enumerate all the source files - a Why are you using a direct cradle instead of letting HLS infer the default cradle for your project? |
I don't understand what that means. How do I specify my language flags without specifying a "direct" cradle? What is a "default cradle"? The documentation does not mention this. |
I tried adapting my ghci script to turn it into an hie-bios program instead: #! /usr/bin/env runhaskell
import qualified Data.List as List
import qualified System.Directory as Dir
import qualified System.Environment as Env
import qualified System.IO as IO
import qualified System.Process as Proc
main =
do
files <- findSourceFiles
out <- Env.getEnv "HIE_BIOS_OUTPUT"
IO.writeFile out (unlines (flags ++ files))
flags =
[ "-no-user-package-db"
, "-ignore-dot-ghci"
, "-Wall"
, "-fdefer-typed-holes"
, "-Werror=missing-fields"
, "-ihaskell/typeclasses/src"
]
++ hieFlags
++ extensionFlags
hieFlags =
[ "-fwrite-ide-info"
, "-hiedir=.hie"
]
extensionFlags = map ("-X" ++) extensions
extensions =
[ "ApplicativeDo"
, "BlockArguments"
, "DeriveFunctor"
, "DeriveAnyClass"
, "DeriveDataTypeable"
, "DeriveFoldable"
, "DeriveGeneric"
, "DeriveLift"
, "DerivingStrategies"
, "DerivingVia"
, "FunctionalDependencies"
, "GeneralizedNewtypeDeriving"
, "InstanceSigs"
, "LambdaCase"
, "NamedFieldPuns"
, "NoImplicitPrelude"
, "NumericUnderscores"
, "OverloadedStrings"
, "PartialTypeSignatures"
, "PatternSynonyms"
, "QuasiQuotes"
, "RecordWildCards"
, "ScopedTypeVariables"
, "StandaloneDeriving"
, "TemplateHaskell"
, "TypeApplications"
, "ViewPatterns"
]
findSourceFiles = findSourceFilesFrom "haskell/typeclasses/src"
findSourceFilesFrom x =
do
isDir <- Dir.doesDirectoryExist x
isFile <- Dir.doesFileExist x
let isHsFile = isFile && (".hs" `List.isSuffixOf` x)
case () of
_ | isHsFile -> return [x]
_ | isDir -> Dir.listDirectory x >>= foldMap (\y -> findSourceFilesFrom (x ++ "/" ++ y))
_ -> return []
cradle:
multi:
- path: "./haskell/typeclasses/src"
config:
cradle:
bios:
program: ./hie-bios.hs It seems that HLS can now find imported modules, but it still makes a bad recommendation about renaming the module. |
In the absence of a cradle, HLS resorts to implicit-hie to autogenerate one. Your language flags can be extracted from the Cabal descriptor, assuming you are using Cabal. |
As I mentioned above, I have not packaged any of this code for Cabal. Is cabal meant to be a requirement? |
Cabal is not a requirement, but if you are not using Cabal like >90% of our users, be prepared to invest a little bit more time learning and working around rough edges. |
My hie-bios program is now producing output that looks like this:
which seems like what it ought to be? Still I'm getting prompted to change every module name. |
The prompt to change module names could be a bug in the You are probably running into it because your bios script is producing module names instead of module paths. Which is fine and supported by ghcide, but both cabal and stack produce module paths so this plugin has probably never been tested with a cradle that outputs module names |
Should be paths be relative to the top level directory, to the source directory, or absolute? If relative, should I start them with ./? Is there some example of a result produced by a well-supported build tool, so that I may match my bios output as closely as possible? hie-bios does mention this:
but does not give an example. |
The main usage of a hie.yaml with a bios cradle i am aware of is ghc itself! It uses hadrian under the hood to produce the flags and modules:
So it is a less used hie-bios cradle but an important one imo. Maybe the documentation of the bios/direct cradle could be completed with the suggestions from this issue. (cc @fendor) |
I haven't been able to find anything named hls-module-name-plugin, am I looking in the wrong place? |
do you mean the place of the source code in this repo? |
Ah, of course, thanks. Since I saw some plugins published on hackage I just assumed they all were. |
FWIW, I haven't created the plugin, only extracted it :) (I believe it was at first one of the default plugins) |
Opened specific issue about wrong module name suggestions: #1903 |
Thank you all, I think this issue can probably be closed now. The only remaining problem I have is now better covered by #1903. Regarding potential documentation improvements, I've also opened haskell/hie-bios#298. |
I'm not sure how to describe the problem except that HLS doesn't seem to understand that
haskell/typeclasses/src
is the source directory.See the popup error message indicating that the
Typeclasses.Postgres.Connection.Concepts
cannot be found, and the file tree on the left where you can see it's right there - and also the erroneous suggestion at the top to rename the open module tohaskell.typeclasses.src.Typeclasses.Postgres.Connection.PoolSetup
.I'm a bit lost because I haven't found much documentation for using the "direct" configuration option. I'm not sure whether this is supported, or if the problem is with hie-bios, or what. I've always used nix and various scripts to launch ghci and to build this project, so I have no cabal file. I don't entirely understand, is using HLS without a cabal file meant to be supported?
$ haskell-language-server-wrapper --probe-tools haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: /nix/store/6k9vz0jiivzdifmfjn4s6r3bb9q0y4ca-haskell-language-server-1.1.0.0/bin/haskell-language-server-wrapper) Tool versions found on the $PATH cabal: Not found stack: Not found ghc: 8.10.4
NixOS, VSCode.
hie.yaml
:I have also tried adding
-ihaskell/typeclasses/src
to the flag list, but it doesn't help.What I see in the vscode output panel:
Also, below is the working script that I normally use to launch ghci for this project.
The text was updated successfully, but these errors were encountered: