Skip to content

support custom Ide commands #1666

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

Merged
merged 11 commits into from
Apr 8, 2021
Merged

support custom Ide commands #1666

merged 11 commits into from
Apr 8, 2021

Conversation

pepeiborra
Copy link
Collaborator

@pepeiborra pepeiborra commented Apr 4, 2021

Consolidated commands in defaultMain and added support for defining Custom ones

@pepeiborra
Copy link
Collaborator Author

haskell-language-server - GHC Haskell LSP server

Usage: haskell-language-server [--version | --numeric-version | --probe-tools | 
                                 [COMMAND | --lsp | FILES/DIRS...] [--cwd DIR] 
                                 [--shake-profiling DIR] [--test] [--example] 
                                 [-d|--debug] [-l|--logfile LOGFILE] [-j NUM] 
                                 [--project-ghc-version] |
                                 --vscode-extension-schema | 
                                 --generate-default-config]
  Used as a test bed to check your IDE Client will work

Available options:
  --version                Show haskell-language-server and GHC versions
  --numeric-version        Show numeric version of haskell-language-server
  --probe-tools            Show haskell-language-server version and other tools
                           of interest
  --lsp                    Start talking to an LSP server
  --cwd DIR                Change to this directory
  --shake-profiling DIR    Dump profiling reports to this directory
  --test                   Enable additional lsp messages used by the testsuite
  --example                Include the Example Plugin. For Plugin devs only
  -d,--debug               Generate debug output
  -l,--logfile LOGFILE     File to log to, defaults to stdout
  -j NUM                   Number of threads (0: automatic) (default: 0)
  --project-ghc-version    Work out the project GHC version and print it
  --vscode-extension-schema
                           Print generic config schema for plugins (used in the
                           package.json of haskell vscode extension)
  --generate-default-config
                           Print config supported by the server with default
                           values
  -h,--help                Show this help text

Available commands:
  typecheck                Used as a test bed to check your IDE will work
  hiedb                    Query .hie files
  index                    Load the given files and index all the known targets
  lsp                      Start talking to an LSP client

@pepeiborra
Copy link
Collaborator Author

ghcide - the core of a Haskell IDE

Usage: ghcide [--cwd DIR] [--version] [--vscode-extension-schema] 
              [--generate-default-config] [--shake-profiling DIR] 
              [--ot-memory-profiling] [--test] [--test-no-kick] [-j NUM] 
              [--verbose] [COMMAND | --lsp | FILES/DIRS...]

Available options:
  --cwd DIR                Change to this directory
  --version                Show ghcide and GHC versions
  --vscode-extension-schema
                           Print generic config schema for plugins (used in the
                           package.json of haskell vscode extension)
  --generate-default-config
                           Print config supported by the server with default
                           values
  --shake-profiling DIR    Dump profiling reports to this directory
  --ot-memory-profiling    Record OpenTelemetry info to the eventlog. Needs the
                           -l RTS flag to have an effect
  --test                   Enable additional lsp messages used by the testsuite
  --test-no-kick           Disable kick. Useful for testing cancellation
  -j NUM                   Number of threads (0: automatic) (default: 0)
  --verbose                Include internal events in logging output
  --lsp                    Start talking to an LSP client
  -h,--help                Show this help text

Available commands:
  typecheck                Used as a test bed to check your IDE will work
  hiedb                    Query .hie files
  index                    Load the given files and index all the known targets
  lsp                      Start talking to an LSP client

@pepeiborra
Copy link
Collaborator Author

dist-newstyle/build/x86_64-osx/ghc-8.10.4/ghcide-1.1.0.0/x/ghcide/build/ghcide/ghcide index ghcide/src/Development/IDE.hs

ghcide version: 1.1.0.0 (GHC: 8.10) (PATH: /Users/pepeiborra/scratch/ide/dist-newstyle/build/x86_64-osx/ghc-8.10.4/ghcide-1.1.0.0/x/ghcide/build/ghcide/ghcide) (GIT hash: 32a8e70cd894ac11ea2d0dd0360c6be2d437d268)
 [INFO] Consulting the cradle for "ghcide/src/Development/IDE.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/pepeiborra/scratch/ide", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - ghcide-1.1.0.0 (lib) (ephemeral targets)
> Preprocessing library for ghcide-1.1.0.0..
[INFO] Using interface files cache dir: /Users/pepeiborra/.cache/ghcide/ghcide-1.1.0.0-inplace-fd5b55ee3ebaea18531542106613726f3620b9a0
[INFO] Making new HscEnv[ghcide-1.1.0.0-inplace]
[WARNING] File:     ghcide/src/Development/IDE.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message: 
  user error (Failed to get the immediate reverse dependencies of NormalizedFilePath
  "ghcide/src/Development/IDE.hs")
Indexing 57 targets
Writing index... 
[INFO] finish: Index (took 2.81s)
/Users/pepeiborra/.cache/ghcide/3a52ce780950d4d969792a2559cd519d7ee8c727--8.10.4-1.hiedb

@pepeiborra
Copy link
Collaborator Author

dist-newstyle/build/x86_64-osx/ghc-8.10.4/haskell-language-server-1.0.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server index ghcide/src/Development/IDE.hs 

haskell-language-server version: 1.0.0.0 (GHC: 8.10.4) (PATH: /Users/pepeiborra/scratch/ide/dist-newstyle/build/x86_64-osx/ghc-8.10.4/haskell-language-server-1.0.0.0/x/haskell-language-server/build/haskell-language-server/haskell-language-server) (GIT hash: 32a8e70cd894ac11ea2d0dd0360c6be2d437d268)
 2021-04-05 09:42:37.444791 [ThreadId 46] INFO hls:	Consulting the cradle for "ghcide/src/Development/IDE.hs"
Output from setting up the cradle Cradle {cradleRootDir = "/Users/pepeiborra/scratch/ide", cradleOptsProg = CradleAction: Cabal}
> Build profile: -w ghc-8.10.4 -O1
> In order, the following will be built (use -v for more details):
>  - ghcide-1.1.0.0 (lib) (ephemeral targets)
> Preprocessing library for ghcide-1.1.0.0..
2021-04-05 09:42:38.162667 [ThreadId 46] INFO hls:	Using interface files cache dir: /Users/pepeiborra/.cache/ghcide/ghcide-1.1.0.0-inplace-fd5b55ee3ebaea18531542106613726f3620b9a0
2021-04-05 09:42:38.163095 [ThreadId 46] INFO hls:	Making new HscEnv[ghcide-1.1.0.0-inplace]
2021-04-05 09:42:40.974549 [ThreadId 2881] WARNING hls:	File:     ghcide/src/Development/IDE.hs
Hidden:   no
Range:    1:1-2:1
Source:   compiler
Severity: DsError
Message: 
  user error (Failed to get the immediate reverse dependencies of NormalizedFilePath
  "ghcide/src/Development/IDE.hs")
Indexing 57 targets
Writing index... 
2021-04-05 09:42:41.047898 [ThreadId 3125] INFO hls:	finish: Index (took 2.70s)
/Users/pepeiborra/.cache/ghcide/3a52ce780950d4d969792a2559cd519d7ee8c727--8.10.4-1.hiedb

@pepeiborra pepeiborra force-pushed the index-command branch 3 times, most recently from 35ddb2a to 25fba56 Compare April 5, 2021 19:31
@pepeiborra pepeiborra marked this pull request as draft April 6, 2021 07:20
@pepeiborra pepeiborra marked this pull request as ready for review April 7, 2021 18:13
@pepeiborra
Copy link
Collaborator Author

In the end the index command wasn't exactly what I needed, but the changes in the PR are valuable. And to simplify the definition of custom commands, I have added a new Custom constructor

@pepeiborra pepeiborra changed the title Added a command to index the database and exit support custom Ide commands Apr 7, 2021
Copy link
Collaborator

@berberman berberman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pepeiborra pepeiborra added the merge me Label to trigger pull request merge label Apr 8, 2021
@mergify mergify bot merged commit 607ae3b into master Apr 8, 2021
@rayshih
Copy link
Contributor

rayshih commented Apr 8, 2021

a new Custom constructor

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Label to trigger pull request merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants