Skip to content

Commit 859848b

Browse files
authored
Merge pull request #362 from jneira/only-hls
Make hls the unique language server variant
2 parents 18cb567 + 2bfc83f commit 859848b

File tree

3 files changed

+48
-94
lines changed

3 files changed

+48
-94
lines changed

README.md

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Haskell for Visual Studio Code
22

3-
[![](https://vsmarketplacebadge.apphb.com/version/haskell.haskell.svg)](https://marketplace.visualstudio.com/items?itemName=haskell.haskell)
3+
[![vsmarketplacebadge](https://vsmarketplacebadge.apphb.com/version/haskell.haskell.svg)](https://marketplace.visualstudio.com/items?itemName=haskell.haskell)
44

55
This extension adds language support for [Haskell](https://haskell.org), powered by the [Haskell Language Server](https://github.com/haskell/haskell-language-server).
66

@@ -12,27 +12,37 @@ This extension adds language support for [Haskell](https://haskell.org), powered
1212
- Document symbols
1313
- Highlight references in document
1414
- Code completion
15-
- Formatting via Brittany, Floskell, Ormolu or Stylish Haskell
15+
- Formatting via Brittany, Floskell, Fourmolu, Ormolu or Stylish Haskell
1616
- [Multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces) support
1717
- Code evaluation (Haskell Language Server), see ([Tutorial](https://github.com/haskell/haskell-language-server/blob/master/plugins/hls-eval-plugin/README.md))
1818

19-
![Eval Demo](https://raw.githubusercontent.com/haskell/haskell-language-server/master/plugins/hls-eval-plugin/demo.gif)
19+
![Eval Demo](https://raw.githubusercontent.com/haskell/haskell-language-server/master/plugins/hls-eval-plugin/demo.gif)
2020

21-
## Requirements
21+
- Integration with [retrie](https://hackage.haskell.org/package/retrie)
2222

23-
- For standalone `.hs`/`.lhs` files, [ghc](https://www.haskell.org/ghc/) must be installed and on the PATH. The easiest way to install it is with [ghcup](https://www.haskell.org/ghcup/) or [Chocolatey](https://www.haskell.org/platform/windows.html) on Windows.
24-
- For Cabal based projects, both ghc and [cabal-install](https://www.haskell.org/cabal/) must be installed and on the PATH. It can also be installed with [ghcup](https://www.haskell.org/ghcup/) or [Chocolatey](https://www.haskell.org/platform/windows.html) on Windows.
25-
- For Stack based projects, [stack](http://haskellstack.org) must be installed and on the PATH.
23+
![Retrie Demo](https://i.imgur.com/Ev7B87k.gif)
24+
25+
- Code lenses for explicit import lists
26+
27+
![Imports code lens Demo](https://imgur.com/pX9kvY4.gif)
2628

27-
## Language Servers
29+
- Generate functions from type signatures, and intelligently complete holes using [Wingman (tactics)](https://github.com/haskell/haskell-language-server/tree/master/plugins/hls-tactics-plugin)
2830

29-
Whilst this extension is powered by the Haskell Language Server by default, it also supports several others which can be manually installed:
31+
![Wingman Demo](https://user-images.githubusercontent.com/307223/92657198-3d4be400-f2a9-11ea-8ad3-f541c8eea891.gif)
3032

31-
- [Haskell Language Server](https://github.com/haskell/haskell-language-server#installation): This is the default language server which will automatically be downloaded, so it does not need manual installation. It builds upon ghcide by providing extra plugins and features.
32-
- [ghcide](https://github.com/digital-asset/ghcide#install-ghcide): A fast and reliable LSP server with support for [basic features](https://github.com/digital-asset/ghcide#features).
33-
- [Haskell IDE Engine](https://github.com/haskell/haskell-ide-engine#installation): A legacy language server, you probably shouldn't use this one. Haskell Language Server replaces it instead.
33+
- Integration with [hlint](https://github.com/ndmitchell/hlint) to show diagnostics and apply hints via [apply-refact](https://github.com/mpickering/apply-refact)
3434

35-
You can choose which language server to use from the "Haskell > Language Server Variant" configuration option.
35+
![Hlint Demo](https://user-images.githubusercontent.com/54035/110860028-8f9fa900-82bc-11eb-9fe5-6483d8bb95e6.gif)
36+
37+
- Module name suggestions for insertion or correction
38+
39+
![Module Name Demo](https://user-images.githubusercontent.com/54035/110860755-78ad8680-82bd-11eb-9845-9ea4b1cc1f76.gif)
40+
41+
## Requirements
42+
43+
- For standalone `.hs`/`.lhs` files, [ghc](https://www.haskell.org/ghc/) must be installed and on the PATH. The easiest way to install it is with [ghcup](https://www.haskell.org/ghcup/) or [Chocolatey](https://www.haskell.org/platform/windows.html) on Windows.
44+
- For Cabal based projects, both ghc and [cabal-install](https://www.haskell.org/cabal/) must be installed and on the PATH. It can also be installed with [ghcup](https://www.haskell.org/ghcup/) or [Chocolatey](https://www.haskell.org/platform/windows.html) on Windows.
45+
- For Stack based projects, [stack](http://haskellstack.org) must be installed and on the PATH.
3646

3747
## Configuration options
3848

@@ -49,8 +59,6 @@ There are a few placeholders which will be expanded:
4959
- `~`, `${HOME}` and `${home}` will be expanded into your users' home folder.
5060
- `${workspaceFolder}` and `${workspaceRoot}` will expand into your current project root.
5161

52-
## Haskell Language Server specifics
53-
5462
### Local documentation
5563

5664
Haskell Language Server can display Haddock documentation on hover and completions if the project and
@@ -59,19 +67,23 @@ its dependencies have been built with the `-haddock` GHC flag.
5967
- For cabal:
6068

6169
- Add to your global config file (e.g. `~/.cabal/config`):
62-
```
70+
71+
```yaml
6372
program-default-options
6473
ghc-options: -haddock
6574
```
75+
6676
- Or, for a single project, run `cabal configure --ghc-options=-haddock`
6777

6878
- For stack, add to global `$STACK_ROOT\config.yaml`, or project's `stack.yaml`:
69-
```
79+
80+
```yaml
7081
ghc-options:
7182
"$everything": -haddock
7283
```
84+
7385
Note that this flag will cause compilation errors if a dependency contains invalid Haddock markup,
74-
until GHC 8.12 which [will report warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377)
86+
until GHC 9.0 which [will report warnings](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/2377)
7587
instead.
7688

7789
### Downloaded binaries
@@ -101,7 +113,7 @@ These are the versions of GHC that there are binaries of `haskell-language-serve
101113
| 8.6.5 | ✓ | ✓ | ✓ |
102114
| 8.6.4 | ✓ | ✓ | ✓ |
103115

104-
The exact list of binaries can be checked in the last release of haskell-language-server: https://github.com/haskell/haskell-language-server/releases/latest
116+
The exact list of binaries can be checked in the last release of haskell-language-server: <https://github.com/haskell/haskell-language-server/releases/latest>
105117

106118
## Using multi-root workspaces
107119

@@ -111,25 +123,19 @@ The language server is now started for each workspace folder you have in your mu
111123

112124
## Investigating and reporting problems
113125

114-
1. Go to extensions and right click `Haskell Language Server` and choose `Extensions Settings`
115-
2. Scroll down to `Language Server Haskell › Trace: Server` and set it to `messages`
116-
3. Restart vscode and reproduce your problem
117-
4. Go to the main menu and choose `View -> Output` (`Ctrl + Shift + U`)
118-
5. On the new Output panel that opens on the right side in the drop down menu choose `Haskell (<your project>)`
126+
1. Go to extensions and right click `Haskell Language Server` and choose `Extensions Settings`
127+
2. Scroll down to `Language Server Haskell › Trace: Server` and set it to `messages`
128+
3. Restart vscode and reproduce your problem
129+
4. Go to the main menu and choose `View -> Output` (`Ctrl + Shift + U`)
130+
5. On the new Output panel that opens on the right side in the drop down menu choose `Haskell (<your project>)`
119131

120-
Please include the output when filing any issues on the relevant language server's issue tracker.
132+
Please include the output when filing any issues on the [haskell-language-server](https://github.com/haskell/haskell-language-server/issues/new) issue tracker.
121133

122134
### Troubleshooting
123135

124136
- Sometimes the language server might get stuck in a rut and stop responding to your latest changes.
125137
Should this occur you can try restarting the language server with <kbd>Ctrl</kbd> <kbd>shift</kbd> <kbd>P</kbd>/<kbd>⌘</kbd> <kbd>shift</kbd> <kbd>P</kbd> > Restart Haskell LSP Server.
126-
- Usually the error or unexpected behaviour is already reported in the haskell language server [used by the extension](#hie-variant). Finding the issue in its issue tracker could be useful to help resolve it. Sometimes even it includes a workaround for the issue.
127-
- Haskell language servers issue trackers:
128-
- haskell-language-server: https://github.com/haskell/haskell-language-server/issues
129-
- ghcide: https://github.com/haskell/ghcide/issues
130-
- _Common issues_:
131-
- For now, the extension is not able to open a single haskell source file. You need to open a workspace or folder, configured to be built with cabal, stack or other hie-bios compatible program.
132-
- Check you don't have other haskell extensions active, they can interfere with each other.
138+
- Usually the error or unexpected behaviour is already reported in the [haskell language server issue tracker](https://github.com/haskell/haskell-language-server/issues). Finding the issue could be useful to help resolve it and sometimes includes a workaround for the issue.
133139

134140
## Contributing
135141

package.json

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "haskell",
33
"displayName": "Haskell",
4-
"description": "Haskell language support powered by the Haskell Language Server and ghcide",
4+
"description": "Haskell language support powered by the Haskell Language Server",
55
"version": "1.3.0",
66
"license": "MIT",
77
"publisher": "haskell",
@@ -130,16 +130,6 @@
130130
"default": "",
131131
"description": "If set, redirects the logs to a file."
132132
},
133-
"haskell.languageServerVariant": {
134-
"scope": "resource",
135-
"type": "string",
136-
"enum": [
137-
"haskell-language-server",
138-
"ghcide"
139-
],
140-
"default": "haskell-language-server",
141-
"description": "Which language server to use."
142-
},
143133
"haskell.releasesURL": {
144134
"scope": "resource",
145135
"type": "string",
@@ -166,7 +156,7 @@
166156
"Don't check for newer versions"
167157
],
168158
"default": "keep-up-to-date",
169-
"markdownDescription": "Only applicable with `#haskell.languageServerVariant#` set to `haskell-language-server`. Determine what to do when a new version of the language server is available."
159+
"markdownDescription": "Determine what to do when a new version of the language server is available."
170160
},
171161
"haskell.plugin.importLens.codeActionsOn": {
172162
"scope": "resource",

src/extension.ts

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,7 @@ function findManualExecutable(uri: Uri, folder?: WorkspaceFolder): string | null
9090

9191
/** Searches the PATH for whatever is set in serverVariant */
9292
function findLocalServer(context: ExtensionContext, uri: Uri, folder?: WorkspaceFolder): string | null {
93-
const serverVariant = workspace.getConfiguration('haskell', uri).languageServerVariant;
94-
95-
// Set the executable, based on the settings.
96-
let exes: string[] = []; // should get set below
97-
switch (serverVariant) {
98-
case 'haskell-ide-engine':
99-
exes = ['hie-wrapper', 'hie'];
100-
break;
101-
case 'haskell-language-server':
102-
exes = ['haskell-language-server-wrapper', 'haskell-language-server'];
103-
break;
104-
case 'ghcide':
105-
exes = ['ghcide'];
106-
break;
107-
}
93+
const exes: string[] = ['haskell-language-server-wrapper', 'haskell-language-server'];
10894

10995
for (const exe of exes) {
11096
if (executableExists(exe)) {
@@ -151,13 +137,8 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
151137
serverExecutable = findManualExecutable(uri, folder) ?? findLocalServer(context, uri, folder);
152138
if (serverExecutable === null) {
153139
// If not, then try to download haskell-language-server binaries if it's selected
154-
if (workspace.getConfiguration('haskell', uri).languageServerVariant === 'haskell-language-server') {
155-
serverExecutable = await downloadHaskellLanguageServer(context, uri, folder);
156-
if (!serverExecutable) {
157-
return;
158-
}
159-
} else {
160-
showNotInstalledErrorMessage(uri);
140+
serverExecutable = await downloadHaskellLanguageServer(context, uri, folder);
141+
if (!serverExecutable) {
161142
return;
162143
}
163144
}
@@ -170,16 +151,12 @@ async function activateServerForFolder(context: ExtensionContext, uri: Uri, fold
170151

171152
let args: string[] = ['--lsp'];
172153

173-
const serverVariant = workspace.getConfiguration('haskell', uri).languageServerVariant;
174-
// ghcide does not accept -d and -l params
175-
if (serverVariant !== 'ghcide') {
176-
if (logLevel === 'messages') {
177-
args = args.concat(['-d']);
178-
}
154+
if (logLevel === 'messages') {
155+
args = args.concat(['-d']);
156+
}
179157

180-
if (logFile !== '') {
181-
args = args.concat(['-l', logFile]);
182-
}
158+
if (logFile !== '') {
159+
args = args.concat(['-l', logFile]);
183160
}
184161

185162
// If we're operating on a standalone file (i.e. not in a folder) then we need
@@ -251,22 +228,3 @@ export async function deactivate() {
251228
}
252229
await Promise.all(promises);
253230
}
254-
255-
function showNotInstalledErrorMessage(uri: Uri) {
256-
const variant = workspace.getConfiguration('haskell', uri).languageServerVariant;
257-
let projectUrl = '';
258-
switch (variant) {
259-
case 'haskell-ide-engine':
260-
projectUrl = '/haskell/haskell-ide-engine';
261-
break;
262-
case 'haskell-language-server':
263-
projectUrl = '/haskell/haskell-language-server';
264-
break;
265-
case 'ghcide':
266-
projectUrl = '/digital-asset/ghcide';
267-
break;
268-
}
269-
const notInstalledMsg: string =
270-
variant + ' executable missing, please make sure it is installed, see https://github.com' + projectUrl + '.';
271-
window.showErrorMessage(notInstalledMsg);
272-
}

0 commit comments

Comments
 (0)