You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+23-58Lines changed: 23 additions & 58 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,93 +17,58 @@ If you don't have a project, first make sure you have the latest version of `ihp
17
17
# Set up a local IHP project
18
18
ihp-new myproject
19
19
cd myproject
20
-
devenv up
21
20
```
22
21
23
-
Running `devenv up` is necessary, even if you don't intend to run it this way (e.g. you intend to do development and don't intend to run it "normally"), to do some initial setup like creating the database. You can keep `devenv up` running, as it will pick up any changes to the custom app or the IHP, and save you the hassle of manually recompiling from ghci on every change.
24
-
25
22
Clone the IHP repository into the project directory. The `IHP` directory is added to the GHC search path in `applicationGhciConfig`. Therefore when the `IHP` directory exists, GHC will load all IHP modules from there.
# Go back to the project root (do not run inside the IHP directory)
33
-
cd -
34
-
```
35
27
36
-
If the compiler can't locate certain IHP dependencies, it may be due to nix not updating IHP. In these instances, run the following command from the host project:
28
+
# Patch flake.nix in the parent directory to use local IHP path
29
+
sed -i "s|ihp.url = .*|ihp.url = \"path://$(pwd)\";|" ../flake.nix
37
30
38
-
```
39
-
nix flake lock --update-input ihp
40
-
```
31
+
# Enable direnv
32
+
direnv allow
41
33
42
-
### Faster Haskell Builds
34
+
# Switch back to the host project directory
35
+
cd -
36
+
```
43
37
44
-
Uncomment the `configureFlags = [ "--flag FastBuild" ];` and `doHaddock = false;` lines in the `IHP/ihp.nix` for fast rebuilds, otherwise you could up waiting up to half an hour while IHP builds itself.
38
+
You can now run `devenv up` in the host project directory to start the development server. However, if you'd like to change the DevServer you should stay on the
45
39
46
-
We need to make sure not to commit the changes of `IHP/ihp.nix`
47
-
To help us with that, you can run this from the root of your project `cd IHP && git update-index --assume-unchanged ihp.nix`, so git will ignore your changes.
40
+
### Running the development server
48
41
49
-
### Nix Changes
50
42
51
-
If you're testing local nix changes, you need to change your `flake.nix` to point to the IHP project instead of pulling it from github:
43
+
When making changes to the development tooling, we have to start the server differently, without `devenv up`. We have run the following commands in the `IHP` directory:
52
44
53
-
```nix
54
-
{
55
-
inputs = {
56
-
# The path needs to be absolute
57
-
ihp.url = "path:///Users/myuser/someproject/IHP";
58
-
# ...
59
-
};
60
45
```
46
+
# Optional - you can set the `DEBUG` environment variable to enable debug logging
47
+
export DEBUG=1
61
48
62
-
After that run `nix flake update`.
63
-
64
-
### Running the latest IHP `master`
65
-
66
-
When contributing to IHP core you will want to have your PRs synced with `master`. Your `flake.nix` should have this line:
67
49
68
-
```nix
69
-
{
70
-
ihp.url = "github:digitallyinduced/ihp";
71
-
}
72
-
```
73
-
74
-
Then every time you'd like to update to the latest master, you'll run:
50
+
ghci
51
+
:l ihp/ihp-ide/exe/IHP/IDE/DevServer.hs
75
52
53
+
# Start the server
54
+
mainInParentDirectory
76
55
```
77
-
nix flake update
78
-
direnv allow
79
-
```
80
-
81
-
Note that it takes around 30 minutes for the IHP GitHub actions to prepare a binary build of IHP. If you run latest master and the GitHub actions aren't finished yet, you will notice that your computer needs to build IHP from scratch which takes a lot of time. You can wait for the GitHub action to complete or point to a specific IHP commit to avoid long build times.
82
-
83
-
### Running the development server
84
56
57
+
We don't need to start postgres as the IDE starts it automatically.
85
58
86
-
When making changes to the development tooling, we have to start the server differently, without `devenv up`. We have to
87
-
use `make console` to load your application together with the framework located in `IHP`.
59
+
If you ever switch back to using the upstream version, just restore the original line in flake.nix (e.g., ihp.url = "github:digitallyinduced/ihp";), and then run from the host directory:
88
60
89
61
```
90
-
ghci
91
-
:l ihp/ihp-ide/exe/IHP/IDE/DevServer.hs
92
-
main
62
+
nix flake lock --update-input ihp
93
63
```
94
64
95
-
We don't need to start postgres as the IDE starts it automatically.
65
+
### Faster Haskell Builds
96
66
97
-
#### Debugging the development server
67
+
Uncomment the `configureFlags = [ "--flag FastBuild" ];` and `doHaddock = false;` lines in the `IHP/ihp.nix` for fast rebuilds, otherwise you could up waiting up to half an hour while IHP builds itself.
98
68
99
-
You can enable additional debug logging for the development server by setting the env variable `DEBUG=1`. Like this:
69
+
We need to make sure not to commit the changes of `IHP/ihp.nix`
70
+
To help us with that, you can run this from the root of your project `cd IHP && git update-index --assume-unchanged ihp.nix`, so git will ignore your changes.
-`envrc-mode` – lets eglot find the PATH to Haskell Language Server etc.
99
99
100
-
At the very least you need `(add-hook 'haskell-mode-hook #'eglot-ensure)`
101
-
and `(envrc-global-mode +1)` in your `~/.emacs.d/init.el`, but you may also
102
-
want to set up some keybindings to common language server functions
103
-
(since by default none are included). Here's an example init file:
100
+
At the very least you need `(envrc-global-mode +1)` in your
101
+
`~/.emacs.d/init.el`, after that you should be able to `M-x eglot` to
102
+
start the language server for a project. You may also want to set up
103
+
some keybindings to common language server functions (since by default
104
+
none are included). Here's an example init file:
104
105
105
106
```emacs-lisp
106
107
(use-package envrc
@@ -109,6 +110,8 @@ want to set up some keybindings to common language server functions
109
110
110
111
(use-package eglot
111
112
:config
113
+
;; Optionally start the language server automatically (no need to
114
+
;; run `M-x eglot` on startup) for every Haskell project you open:
112
115
(add-hook 'haskell-mode-hook #'eglot-ensure)
113
116
;; Optionally add keybindings to some common functions:
114
117
:bind ((:map eglot-mode-map
@@ -130,6 +133,8 @@ want to set up some keybindings to common language server functions
130
133
(server-start) ; for emacsclient / quick startup
131
134
```
132
135
136
+
You should now be able to use the builtin go-to-definition bound to `M-.`.
137
+
133
138
(The built-in completion menu isn't very modern-looking, a good
134
139
alternative if you want to add another plugin is
135
140
[corfu](https://github.com/minad/corfu).)
@@ -149,8 +154,14 @@ and `chmod +x ~/bin/emacs-line`, then export this env var in your shell (e.g. in
149
154
export IHP_EDITOR="$HOME/bin/emacs-line"
150
155
```
151
156
152
-
Another useful package set that integrates with lsp/lsp-ui and loads the default nix environment from direnv as well as removing [common flycheck issue](https://github.com/joncol/dotfiles/blob/master/homedir/.emacs.d/init.el).
153
-
This config also adds a jump to definition for functions bound to "C-c p":
157
+
### lsp-mode instead of eglot
158
+
159
+
[lsp-mode](https://github.com/emacs-lsp/lsp-mode), with companion package [lsp-ui](https://emacs-lsp.github.io/lsp-ui/), is an alternative to the builtin eglot, with some different features.
160
+
They are installable with `M-x package-install`.
161
+
162
+
Below is an example configuration for this package set, which also uses the [emacs-direnv](https://github.com/wbolster/emacs-direnv) package instead of [envrc](https://github.com/purcell/envrc) to load the nix environment.
163
+
164
+
This config also adds a peek-definition for functions using lsp-ui, bound to `C-c p`:
154
165
155
166
```emacs
156
167
(use-package direnv
@@ -159,14 +170,17 @@ This config also adds a jump to definition for functions bound to "C-c p":
159
170
(direnv-always-show-summary nil)
160
171
:config
161
172
(direnv-mode))
173
+
162
174
(use-package lsp-mode
163
175
:custom
164
176
(lsp-lens-enable nil)
165
177
(lsp-enable-symbol-highlighting nil)
166
-
167
178
:hook
168
179
(lsp-mode . lsp-enable-which-key-integration)
169
-
180
+
:init
181
+
;; Optionally start the language server automatically (no need to
182
+
;; run `M-x lsp` on startup) for every Haskell project you open:
183
+
;; (add-hook 'haskell-mode-hook #'lsp)
170
184
:config
171
185
;; This is to make `lsp-mode' work with `direnv' and pick up the correct
172
186
;; version of GHC.
@@ -179,39 +193,32 @@ This config also adds a jump to definition for functions bound to "C-c p":
179
193
:config
180
194
(setq lsp-ui-doc-position 'bottom))
181
195
182
-
;; (add-hook 'haskell-mode-hook #'lsp)
183
-
(use-package flycheck-haskell
184
-
;; Disabling this package, since it only gives error:
185
-
;; "Reading Haskell configuration failed with exit code Segmentation fault and
186
-
;; output:", when trying to run it in Nix/direnv setup.
0 commit comments