This document will briefly outline how to get started contributing to the vscode-hie-server
Haskell language client for the Haskell-IDE-Engine language server.
For development, all you need is to,
- run
npm install -g typescript
to get TypeScript, - then run
npm install
in the project root to install development dependencies.
You can now also package up the extension with,
npm install -g vsce
to get the Extension Manager,vsce package
which creates an extension package atvscode-hie-server-<version>.vsix
.
Note: that if you get errors running vsce package
, it might help running tsc -p ./
directly, since that gives the actual error output of the TypeScript compilation.
- Launch VS Code, press
File
>Open Folder
, open thevscode-hie-server
folder; - press
F5
to open a new window with thevscode-hie-server
loaded (this will overwrite existing ones, e.g. from the marketplace); - open a Haskell file with the new editor to test the LSP client;
You are now ready to make changes and debug. You can,
- set breakpoints in your code inside
src/extension.ts
to debug your extension; - find output from your extension in the debug console;
- make changes to the code, and then
- relaunch the extension from the debug toolbar
Note: you can also reload (Ctrl+R
or Cmd+R
on macOS) the VS Code window with your extension to load your changes
To keep a consistent style, it's best to run prettier on each save. If you are using VSCode, the settings are set to auto format on save.
There is usually an extension for your editor for prettier, e.g. esbenp.prettier-vscode
, which you can install through the marketplace or via ext install prettier-vscode
.
The configurations for prettier are located in .prettierrc
.
A brief overview of the files,
package.json
contains the basic information about the package, see the full manifest for more, such as telling VS Code which scope the LSP works on (Haskell and Literate Haskell in our case), and possible configurationsrc/extension.ts
handles activating and deactivating the HIE language server, along with checking if HIE is installedsrc/docsBrowser.ts
contains the logic for displaying the documentation browser (e.g. hover over a type likemapM_
and clickDocumentation
orSource
)src/commands/constants.ts
simply exports the rest of the commands in foldersrc/commands/showType.ts
handles showing a type usingghcmod:type
src/commands/insertType.ts
handles inserting a type using the output ofghcmod:type
We recommend checking out Your First VS Code Extension and Creating a Language Server for some introduction to VS Code extensions.
There are two ways to run (the same) tests, you can either
- press
F8
to run the tests usingnpm test
or
- open the debug viewlet (
Ctrl+Shift+D
orCmd+Shift+D
on Mac) and from the launch configuration dropdown pickLaunch Tests
- press
F5
to run the tests in a new window with your extension loaded - see the output of the test result in the debug console
- make changes to
test/extension.test.ts
or create new test files inside thetest
folder- by convention, the test runner will only consider files matching the name pattern
**.test.ts
- you can create folders inside the
test
folder to structure your tests any way you want
- by convention, the test runner will only consider files matching the name pattern