mirror of
https://github.com/haskell/haskell-language-server.git
synced 2024-08-16 20:10:30 +03:00
unify pre-commit hook & update Gitpod config (#2991)
* update Gitpod config * update nix shellHook & docs * install pre-commit hook * add kokobd as code owner to .gitpod.* * add gen-hie to Gitpod * add tools for doc * remove .pre-commit-config.yaml from .gitignore * set vscode formatter to stylish-haskell in Gitpod
This commit is contained in:
parent
0b8c793dfd
commit
771d8f44e6
3
.gitignore
vendored
3
.gitignore
vendored
@ -30,9 +30,6 @@ test/testdata/**/hie.yaml
|
||||
# shake build folder (used in benchmark suite)
|
||||
.shake/
|
||||
|
||||
# pre-commit-hook.nix
|
||||
.pre-commit-config.yaml
|
||||
|
||||
# direnv
|
||||
/.direnv/
|
||||
/.envrc
|
||||
|
18
.gitpod.Dockerfile
vendored
Normal file
18
.gitpod.Dockerfile
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
FROM gitpod/workspace-full
|
||||
|
||||
RUN sudo install-packages build-essential curl libffi-dev libffi7 libgmp-dev libgmp10 \
|
||||
libncurses-dev libncurses5 libtinfo5 && \
|
||||
BOOTSTRAP_HASKELL_NONINTERACTIVE=1 \
|
||||
BOOTSTRAP_HASKELL_MINIMAL=1 \
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh && \
|
||||
echo 'source $HOME/.ghcup/env' >> $HOME/.bashrc && \
|
||||
echo 'export PATH=$HOME/.cabal/bin:$HOME/.local/bin:$PATH' >> $HOME/.bashrc && \
|
||||
. /home/gitpod/.ghcup/env && \
|
||||
ghcup install ghc --set && \
|
||||
ghcup install hls --set && \
|
||||
ghcup install cabal --set && \
|
||||
ghcup install stack --set && \
|
||||
cabal update && \
|
||||
cabal install stylish-haskell hoogle implicit-hie && \
|
||||
pip install pre-commit && \
|
||||
npm install -g http-server
|
76
.gitpod.yml
76
.gitpod.yml
@ -1,42 +1,54 @@
|
||||
image:
|
||||
file: .gitpod.Dockerfile
|
||||
# List the start up tasks. Learn more https://www.gitpod.io/docs/config-start-tasks/
|
||||
tasks:
|
||||
- before: |
|
||||
# Only the /workspace folder is persistent
|
||||
export XDG_DATA_HOME=/workspace/.local/share
|
||||
export XDG_CONFIG_HOME=/workspace/.local/config
|
||||
export XDG_STATE_HOME=/workspace/.local/state
|
||||
export XDG_CACHE_HOME=/workspace/.cache
|
||||
export CABAL_DIR=/workspace/.cabal
|
||||
export STACK_ROOT=/workspace/.stack
|
||||
- name: Setup
|
||||
before: |
|
||||
# Make sure some folders not in /workspace persist between worksapce restarts.
|
||||
# You may add additional directories to this list.
|
||||
declare -a CACHE_DIRS=(
|
||||
$HOME/.local
|
||||
$HOME/.cabal
|
||||
$HOME/.stack
|
||||
$HOME/.ghcup
|
||||
/nix
|
||||
)
|
||||
for DIR in "${CACHE_DIRS[@]}"; do
|
||||
mkdir -p $(dirname /workspace/cache$DIR)
|
||||
mkdir -p $DIR # in case $DIR doesn't already exist
|
||||
# On a fresh start with no prebuilds, we move existing directory
|
||||
# to /workspace. 'sudo mv' fails with 'no permission', I don't know why
|
||||
if [ ! -d /workspace/cache$DIR ]; then
|
||||
sudo cp -rp $DIR /workspace/cache$DIR
|
||||
sudo rm -rf $DIR/*
|
||||
fi
|
||||
mkdir -p /workspace/cache$DIR # make sure it exists even if cp fails
|
||||
# Now /workspace/cache$DIR exists.
|
||||
# Use bind mount to make $DIR backed by /workspace/cache$DIR
|
||||
sudo mount --bind /workspace/cache$DIR $DIR
|
||||
done
|
||||
|
||||
# install ghcup, ghc and cabal
|
||||
export GHCUP_INSTALL_BASE_PREFIX=/workspace
|
||||
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
||||
export BOOTSTRAP_HASKELL_MINIMAL=1
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
|
||||
/workspace/.ghcup/bin/ghcup install ghc --set
|
||||
/workspace/.ghcup/bin/ghcup install cabal
|
||||
|
||||
# Add ghcup binaries to the PATH since VSCode does not see 'source .ghcup/env'
|
||||
pushd /usr/local/bin
|
||||
sudo ln -s /workspace/.ghcup/bin/* /usr/local/bin
|
||||
popd
|
||||
|
||||
# Fix the Cabal dir since VSCode does not see CABAL_DIR
|
||||
cabal update
|
||||
echo "Symlinking /workspace/.cabal to ~/.cabal"
|
||||
ln -s /workspace/.cabal ~
|
||||
# Install pre-commit hook
|
||||
pre-commit install
|
||||
|
||||
# Configure VSCode to use the locally built version of HLS
|
||||
mkdir -p .vscode
|
||||
echo '{ "haskell.serverExecutablePath": "/workspace/.cabal/bin/haskell-language-server" }' > .vscode/settings.json
|
||||
if [ ! -f .vscode/settings.json ]; then
|
||||
# Only write to .vscode/settings.json if it doesn't exist.
|
||||
echo '{' > .vscode/settings.json
|
||||
echo ' "haskell.serverExecutablePath": "/home/gitpod/.cabal/bin/haskell-language-server",' >> .vscode/settings.json
|
||||
echo ' "haskell.formattingProvider": "stylish-haskell"' >> .vscode/settings.json
|
||||
echo '}' >> .vscode/settings.json
|
||||
fi
|
||||
|
||||
init: |
|
||||
pushd docs
|
||||
pip install -r requirements.txt
|
||||
popd
|
||||
init: |
|
||||
cabal update
|
||||
cabal configure --enable-executable-dynamic
|
||||
cabal build --enable-tests
|
||||
cabal install exe:haskell-language-server
|
||||
command: |
|
||||
cabal build --enable-tests
|
||||
cabal build --enable-tests all
|
||||
cabal install exe:haskell-language-server
|
||||
|
||||
# List the ports to expose. Learn more https://www.gitpod.io/docs/config-ports/
|
||||
ports: []
|
||||
@ -62,4 +74,4 @@ vscode:
|
||||
extensions:
|
||||
- "haskell.haskell"
|
||||
- "justusadam.language-haskell"
|
||||
- "usernamehw.errorlens"
|
||||
- "EditorConfig.EditorConfig"
|
||||
|
@ -44,3 +44,4 @@
|
||||
# Build
|
||||
*.nix @berberman @michaelpj @guibou
|
||||
*.project @jneira
|
||||
.gitpod.* @kokobd
|
||||
|
@ -170,49 +170,13 @@ Please, try to follow those basic settings to keep the codebase as uniform as po
|
||||
|
||||
### Formatter pre-commit hook
|
||||
|
||||
We are using [pre-commit-hook.nix](https://github.com/cachix/pre-commit-hooks.nix) to configure git pre-commit hook for formatting. Although it is possible to run formatting manually, we recommend you to use it to set pre-commit hook as our CI checks pre-commit hook is applied or not.
|
||||
We are using [pre-commit](https://pre-commit.com/) to configure git pre-commit hook for formatting. Although it is possible to run formatting manually, we recommend you to use it to set pre-commit hook as our CI checks pre-commit hook is applied or not.
|
||||
|
||||
You can configure the pre-commit-hook by running
|
||||
If you are using Nix or Gitpod, pre-commit hook is automatically installed. Otherwise, follow instructions on
|
||||
[https://pre-commit.com/](https://pre-commit.com/) to install the `pre-commit` tool, then run the following command:
|
||||
|
||||
``` bash
|
||||
nix-shell
|
||||
```
|
||||
|
||||
If you don't want to use [nix](https://nixos.org/guides/install-nix.html), you can instead use [pre-commit](https://pre-commit.com) with the following config.
|
||||
|
||||
```json
|
||||
{
|
||||
"repos": [
|
||||
{
|
||||
"hooks": [
|
||||
{
|
||||
"entry": "stylish-haskell --inplace",
|
||||
"exclude": "(^Setup.hs$|test/testdata/.*$|test/data/.*$|test/manual/lhs/.*$|^hie-compat/.*$|^plugins/hls-tactics-plugin/.*$|^ghcide/src/Development/IDE/GHC/Compat.hs$|^ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs$|^ghcide/src/Development/IDE/GHC/Compat/Core.hs$|^ghcide/src/Development/IDE/Spans/Pragmas.hs$|^ghcide/src/Development/IDE/LSP/Outline.hs$|^plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs$|^ghcide/test/exe/Main.hs$|ghcide/src/Development/IDE/Core/Rules.hs|^hls-test-utils/src/Test/Hls/Util.hs$)",
|
||||
"files": "\\.l?hs$",
|
||||
"id": "stylish-haskell",
|
||||
"language": "system",
|
||||
"name": "stylish-haskell",
|
||||
"pass_filenames": true,
|
||||
"types": [
|
||||
"file"
|
||||
]
|
||||
}
|
||||
],
|
||||
"repo": "local"
|
||||
},
|
||||
{
|
||||
"repo": "https://github.com/pre-commit/pre-commit-hooks",
|
||||
"rev": "v4.1.0",
|
||||
"hooks": [
|
||||
{
|
||||
"id": "mixed-line-ending",
|
||||
"args": ["--fix", "lf"],
|
||||
"exclude": "test/testdata/.*CRLF*.hs$"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```sh
|
||||
pre-commit install
|
||||
```
|
||||
|
||||
#### Why some components are excluded from automatic formatting?
|
||||
|
49
flake.lock
49
flake.lock
@ -82,21 +82,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_3": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fourmolu": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -293,20 +278,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1645655918,
|
||||
"narHash": "sha256-ZfbEFRW7o237+A1P7eTKhXje435FCAoe0blj2n20Was=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "77a7a4197740213879b9a1d2e1788c6c8ade4274",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"poetry2nix": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
@ -327,25 +298,6 @@
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"pre-commit-hooks": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_3",
|
||||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1652714503,
|
||||
"narHash": "sha256-qQKVEfDe5FqvGgkZtg5Pc491foeiDPIOeycHMqnPDps=",
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "cachix",
|
||||
"repo": "pre-commit-hooks.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"ptr-poker": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
@ -392,7 +344,6 @@
|
||||
"myst-parser": "myst-parser",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"poetry2nix": "poetry2nix",
|
||||
"pre-commit-hooks": "pre-commit-hooks",
|
||||
"ptr-poker": "ptr-poker",
|
||||
"retrie": "retrie",
|
||||
"sphinx_rtd_theme": "sphinx_rtd_theme",
|
||||
|
50
flake.nix
50
flake.nix
@ -14,9 +14,6 @@
|
||||
flake = false;
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
pre-commit-hooks = {
|
||||
url = "github:cachix/pre-commit-hooks.nix";
|
||||
};
|
||||
gitignore = {
|
||||
url = "github:hercules-ci/gitignore.nix";
|
||||
flake = false;
|
||||
@ -92,7 +89,7 @@
|
||||
flake = false;
|
||||
};
|
||||
myst-parser = {
|
||||
url = "github:smunix/MyST-Parser?ref=fix.hls-docutils";
|
||||
url = "github:smunix/MyST-Parser?ref=fix.hls-docutils";
|
||||
flake = false;
|
||||
};
|
||||
# For https://github.com/readthedocs/sphinx_rtd_theme/pull/1185, otherwise lists are broken locally
|
||||
@ -103,7 +100,7 @@
|
||||
poetry2nix.url = "github:nix-community/poetry2nix/master";
|
||||
};
|
||||
outputs =
|
||||
inputs@{ self, nixpkgs, flake-compat, flake-utils, pre-commit-hooks, gitignore, ... }:
|
||||
inputs@{ self, nixpkgs, flake-compat, flake-utils, gitignore, ... }:
|
||||
{
|
||||
overlays.default = final: prev:
|
||||
with prev;
|
||||
@ -123,7 +120,7 @@
|
||||
in hsuper.mkDerivation (args // {
|
||||
jailbreak = if broken then true else jailbreak;
|
||||
doCheck = if broken then false else check;
|
||||
# Library profiling is disabled as it causes long compilation time
|
||||
# Library profiling is disabled as it causes long compilation time
|
||||
# on our CI jobs. Nix users are free tor revert this anytime.
|
||||
enableLibraryProfiling = false;
|
||||
doHaddock = false;
|
||||
@ -215,42 +212,11 @@
|
||||
config = { allowBroken = true; };
|
||||
};
|
||||
|
||||
# Pre-commit hooks to run stylish-haskell
|
||||
pre-commit-check = hpkgs: pre-commit-hooks.lib.${system}.run {
|
||||
src = ./.;
|
||||
hooks = {
|
||||
stylish-haskell.enable = true;
|
||||
# use stylish-haskell with our target ghc
|
||||
stylish-haskell.entry = pkgs.lib.mkForce "${hpkgs.stylish-haskell}/bin/stylish-haskell --inplace";
|
||||
stylish-haskell.excludes = [
|
||||
# Ignored files
|
||||
"^Setup.hs$"
|
||||
"test/testdata/.*$"
|
||||
"test/data/.*$"
|
||||
"test/manual/lhs/.*$"
|
||||
"^hie-compat/.*$"
|
||||
"^plugins/hls-tactics-plugin/.*$"
|
||||
|
||||
# Temporarily ignored files
|
||||
# Stylish-haskell (and other formatters) does not work well with some CPP usages in these files
|
||||
"^ghcide/src/Development/IDE/GHC/Compat.hs$"
|
||||
"^ghcide/src/Development/IDE/Plugin/CodeAction/ExactPrint.hs$"
|
||||
"^ghcide/src/Development/IDE/GHC/Compat/Core.hs$"
|
||||
"^ghcide/src/Development/IDE/Spans/Pragmas.hs$"
|
||||
"^ghcide/src/Development/IDE/LSP/Outline.hs$"
|
||||
"^plugins/hls-splice-plugin/src/Ide/Plugin/Splice.hs$"
|
||||
"^ghcide/test/exe/Main.hs$"
|
||||
"ghcide/src/Development/IDE/Core/Rules.hs"
|
||||
"^hls-test-utils/src/Test/Hls/Util.hs$"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
ghc902Config = (import ./configuration-ghc-90.nix) { inherit pkgs inputs; };
|
||||
ghc922Config = (import ./configuration-ghc-92.nix) { inherit pkgs inputs; };
|
||||
|
||||
# GHC versions
|
||||
# While HLS still works fine with 8.10 GHCs, we only support the versions that are cached
|
||||
# While HLS still works fine with 8.10 GHCs, we only support the versions that are cached
|
||||
# by upstream nixpkgs, which now only includes GHC version 9+
|
||||
supportedGHCs = let
|
||||
ghcVersion = "ghc" + (pkgs.lib.replaceStrings ["."] [""] pkgs.haskellPackages.ghc.version);
|
||||
@ -268,14 +234,14 @@
|
||||
myst-parser = pkgs.poetry2nix.mkPoetryEnv {
|
||||
projectDir = inputs.myst-parser;
|
||||
python = pkgs.python39;
|
||||
overrides = [
|
||||
overrides = [
|
||||
pkgs.poetry2nix.defaultPoetryOverrides
|
||||
];
|
||||
};
|
||||
sphinx_rtd_theme = pkgs.poetry2nix.mkPoetryEnv {
|
||||
projectDir = inputs.sphinx_rtd_theme;
|
||||
python = pkgs.python39;
|
||||
overrides = [
|
||||
overrides = [
|
||||
pkgs.poetry2nix.defaultPoetryOverrides
|
||||
(self: super: {
|
||||
# The RTD theme doesn't work with newer docutils
|
||||
@ -334,8 +300,8 @@
|
||||
export DYLD_LIBRARY_PATH=${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib
|
||||
export PATH=$PATH:$HOME/.local/bin
|
||||
|
||||
# Enable the shell hooks
|
||||
${self.checks.${system}.pre-commit-check.shellHook}
|
||||
# Install pre-commit hook
|
||||
pre-commit install
|
||||
|
||||
# If the cabal project file is not the default one.
|
||||
# Print a warning and generate an alias.
|
||||
|
Loading…
Reference in New Issue
Block a user