44
44
installation (recommended for better hoogle search performance)
45
45
- [ ` fast-tags ` ] ( https://github.com/elaforge/fast-tags )
46
46
(for automatic tag generation as a fallback for [ ` vim.lsp.tagfunc ` ] ( https://neovim.io/doc/user/lsp.html#vim.lsp.tagfunc() ) ).
47
+ - [ ` haskell-debug-adapter ` ] ( https://github.com/phoityne/haskell-debug-adapter/ ) and
48
+ [ ` nvim-dap ` ] ( https://github.com/mfussenegger/nvim-dap ) .
47
49
48
50
## Installation
49
51
@@ -97,7 +99,6 @@ To get started quickly with the default setup, add the following to `~/.config/n
97
99
98
100
``` lua
99
101
local ht = require (' haskell-tools' )
100
- local buffer = vim .api .nvim_get_current_buf ()
101
102
local def_opts = { noremap = true , silent = true , }
102
103
ht .start_or_attach {
103
104
hls = {
@@ -124,6 +125,10 @@ vim.keymap.set('n', '<leader>rf', function()
124
125
ht .repl .toggle (vim .api .nvim_buf_get_name (0 ))
125
126
end , def_opts )
126
127
vim .keymap .set (' n' , ' <leader>rq' , ht .repl .quit , opts )
128
+
129
+ -- Detect nvim-dap launch configurations
130
+ -- (requires nvim-dap and haskell-debug-adapter)
131
+ ht .dap .discover_configurations (bufnr )
127
132
```
128
133
129
134
> ** Note**
@@ -137,37 +142,31 @@ to generate a database.
137
142
138
143
## Features
139
144
140
- - [x] Basic haskell-language-server functionality on par with ` nvim-lspconfig.hls `
141
-
142
- ### Beyond ` nvim-lspconfig.hls `
143
-
144
- - [x] Dynamically load ` haskell-language-server ` settings per project from JSON files.
145
- - [x] Clean shutdown of language server on exit to prevent corrupted files
145
+ - [x] ** Set up a ` haskell-language-server ` client.**
146
+ - [x] ** Dynamically load ` haskell-language-server ` settings per project
147
+ from JSON files.**
148
+ - [x] ** Clean shutdown of language server on exit to prevent corrupted files**
146
149
([ see ghc #14533 ] ( https://gitlab.haskell.org/ghc/ghc/-/issues/14533 ) ).
147
- - [x] Automatically adds capabilities for the following plugins, if loaded:
150
+ - [x] ** Automatically adds capabilities for the following plugins, if loaded:**
148
151
- [ cmp-nvim-lsp] ( https://github.com/hrsh7th/cmp-nvim-lsp )
149
152
(provides completion sources for [ nvim-cmp] ( https://github.com/hrsh7th/nvim-cmp ) ).
150
153
- [ nvim-lsp-selection-range] ( https://github.com/camilledejoye/nvim-lsp-selection-range )
151
154
(Adds haskell-specific [ expand selection] ( https://haskell-language-server.readthedocs.io/en/latest/features.html#selection-range )
152
155
support).
153
- - [x] Automatically refreshes code lenses by default,
154
- which haskell-language-server heavily relies on. [ Can be disabled.] ( #advanced-configuration )
156
+ - [x] ** Automatically refreshes code lenses by default,**
157
+ which ` haskell-language-server ` heavily relies on. [ Can be disabled.] ( #advanced-configuration )
155
158
156
159
![ codeLens] ( https://user-images.githubusercontent.com/12857160/219738949-c20ed266-3b2d-441e-82fe-faf50f5c582a.gif )
157
160
158
- ### Beyond haskell-language-server
159
-
160
- The below features are not implemented by haskell-language-server.
161
-
162
- #### Evaluate all code snippets at once
161
+ - [x] ** Evaluate all code snippets at once**
163
162
164
163
` haskell-language-server ` can evaluate code snippets using code lenses.
165
164
` haskell-tools.nvim ` provides a ` require('haskell-tools').lsp.buf_eval_all() `
166
165
shortcut to evaluate all of them at once.
167
166
168
167
![ evalAll] ( https://user-images.githubusercontent.com/12857160/219743339-e7b7f4e0-478b-4310-a903-36d0a5564937.gif )
169
168
170
- #### Hoogle-search for signature
169
+ - [x] ** Hoogle-search for signature**
171
170
172
171
- Search for the type signature under the cursor.
173
172
- Falls back to the word under the cursor if the type signature cannot be determined.
@@ -182,14 +181,14 @@ require('haskell-tools').hoogle.hoogle_signature()
182
181
183
182
![ hoogleSig] ( https://user-images.githubusercontent.com/12857160/219745914-505a8fc8-9cb9-49fe-b763-a0dea2a3420b.gif )
184
183
185
- #### Hole-driven development powered by Hoogle
184
+ - [x] ** Hole-driven development powered by Hoogle**
186
185
187
186
With the ` <C-r> ` keymap,
188
187
the Hoogle search telescope integration can be used to fill holes.
189
188
190
189
![ hoogleHole] ( https://user-images.githubusercontent.com/12857160/219751911-f45e4131-afad-47b3-b016-1d341c71c114.gif )
191
190
192
- #### GHCi repl
191
+ - [x] ** GHCi repl**
193
192
194
193
Start a GHCi repl for the current project / buffer.
195
194
@@ -202,11 +201,11 @@ Start a GHCi repl for the current project / buffer.
202
201
203
202
![ repl] ( https://user-images.githubusercontent.com/12857160/219758588-68f3c06f-5804-4279-b23d-1bdcc050d892.gif )
204
203
205
- #### Open project/package files for the current buffer
204
+ - [x] ** Open project/package files for the current buffer**
206
205
207
206
![ commands] ( https://user-images.githubusercontent.com/12857160/219760916-06785cd5-f90a-4bb9-9ca8-94edbd655d46.gif )
208
207
209
- #### Hover actions
208
+ - [x] ** Hover actions**
210
209
211
210
Inspired by [ rust-tools.nvim] ( https://github.com/simrat39/rust-tools.nvim ) ,
212
211
this plugin adds the following hover actions (if available):
@@ -225,7 +224,7 @@ users can benefit from syntax highliting of code snippets.
225
224
226
225
![ hoverActions] ( https://user-images.githubusercontent.com/12857160/219763211-61fc4207-4300-41f2-99c4-6a420cf940f2.gif )
227
226
228
- #### Automatically generate tags
227
+ - [x] ** Automatically generate tags**
229
228
230
229
On attaching, Neovim's LSP client will set up [ ` tagfunc ` ] ( https://neovim.io/doc/user/lsp.html#vim.lsp.tagfunc() )
231
230
to query the language server for locations to jump to.
@@ -239,7 +238,20 @@ this plugin will set up `autocmd`s to automatically generate tags:
239
238
240
239
This feature can be tweaked or disabled in the [ advanced configuration] ( #advanced-configuration ) .
241
240
242
- ### Planned
241
+ - [x] ** Auto-detect ` haskell-debug-adapter ` configurations**
242
+
243
+ If the [ ` nvim-dap ` ] ( https://github.com/mfussenegger/nvim-dap ) plugin is installed,
244
+ you can use ` haskell-tools.nvim ` to auto-detect [ ` haskell-debug-adapter ` ] ( https://hackage.haskell.org/package/haskell-debug-adapter )
245
+ configurations.
246
+
247
+ ![ dap] ( https://user-images.githubusercontent.com/12857160/232348888-4fea5393-d624-417e-b994-6eb44113a3d9.gif )
248
+
249
+ > ** Note**
250
+ >
251
+ > ` haskell-debug-adapter ` is an experimental design and implementation of
252
+ > a debug adapter for Haskell.
253
+
254
+ - [ ] ** Planned**
243
255
244
256
For planned features, refer to the [ issues] ( https://github.com/MrcJkb/haskell-tools.nvim/issues?q=is%3Aopen+is%3Aissue+label%3Aenhancement ) .
245
257
@@ -312,6 +324,9 @@ require('haskell-tools').start_or_attach {
312
324
-- Events to trigger package tag generation
313
325
package_events = { ' BufWritePost' },
314
326
},
327
+ dap = {
328
+ cmd = { ' haskell-debug-adapter' },
329
+ },
315
330
},
316
331
hls = { -- LSP client options
317
332
-- ...
@@ -427,6 +442,14 @@ iron.setup {
427
442
}
428
443
```
429
444
445
+ ### Create ` haskell-debug-adapter ` launch configurations
446
+
447
+ There are two ways this plugin will detect ` haskell-debug-adapter ` launch configurations:
448
+
449
+ 1 . Automatically, by parsing Cabal or Stack project files.
450
+ 1 . By loading a [ ` launch.json ` ] ( https://github.com/phoityne/hdx4vsc/tree/master/configs )
451
+ file in the project root.
452
+
430
453
### Available functions and commands
431
454
432
455
For a complete overview, enter ` :help haskell-tools ` in Neovim.
@@ -517,10 +540,10 @@ ht.project.open_package_yaml()
517
540
ht .project .open_package_cabal ()
518
541
519
542
-- Search for files within the current (sub)package
520
- -- ` opts` : Optional telescope.nvim find_files options
543
+ --- @param opts : Optional telescope.nvim ` find_files` options
521
544
ht .project .telescope_package_files (opts )
522
545
-- Live grep within the current (sub)package
523
- -- ` opts` : Optional telescope.nvim live_grep options
546
+ --- @param opts : Optional telescope.nvim ` live_grep` options
524
547
ht .project .telescope_package_grep (opts )
525
548
```
526
549
@@ -532,14 +555,14 @@ The following functions depend on [`fast-tags`](https://github.com/elaforge/fast
532
555
local ht = require (' haskell-tools' )
533
556
534
557
-- Generate tags for the whole project
535
- -- ` path` : An optional file path, defaults to the current buffer
536
- -- ` opts` : Optional options:
537
- -- ` opts.refresh` : Whether to refresh tags
538
- -- if they have already been generated for a project
558
+ --- @param path : An optional file path , defaults to the current buffer
559
+ --- @param opts : Optional options :
560
+ --- @param opts .refresh : Whether to refresh tags
561
+ --- if they have already been generated for a project
539
562
ht .tags .generate_project_tags (path , opts )
540
563
541
564
-- Generate tags for the whole project
542
- -- ` path` : An optional file path, defaults to the current buffer
565
+ --- @param path : An optional file path , defaults to the current buffer
543
566
ht .tags .generate_package_tags (path )
544
567
```
545
568
@@ -562,6 +585,20 @@ To load the extension, call
562
585
require (' telescope' ).load_extension (' ht' )
563
586
```
564
587
588
+ #### DAP
589
+
590
+ ``` lua
591
+ local ht = require (' haskell-tools' )
592
+
593
+ --- @param bufnr integer The buffer number
594
+ --- @param opts table ? Optional
595
+ --- @param opts .autodetect : (boolean )
596
+ --- Whether to auto-detect launch configurations
597
+ --- @param opts .settings_file_pattern : (string )
598
+ --- File name or pattern to search for. Defaults to 'launch.json'
599
+ ht .dap .discover_configurations (bufnr , opts )
600
+ ```
601
+
565
602
## Troubleshooting
566
603
567
604
For a health check, run ` :checkhealth haskell-tools `
0 commit comments