Skip to content

Commit dfc3e2b

Browse files
authored
Add keybindings and jump to hole to the README (#1712)
1 parent 0227133 commit dfc3e2b

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

plugins/hls-tactics-plugin/README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,78 @@ fill hole" code action, *et voila!*
3434
[hls]: https://github.com/haskell/haskell-language-server/releases
3535

3636

37+
## Editor Configuration
38+
39+
### Enabling Jump to Hole
40+
41+
Set the `haskell.plugin.tactics.config.hole_severity` config option to `4`, or
42+
`hint` if your editor uses a GUI for its configuration. This has the potential
43+
to negatively impact performance --- please holler if you notice any appreciable
44+
slowdown by enabling this option.
45+
46+
47+
### coc.nvim
48+
49+
The following vimscript maps Wingman code-actions to your leader key:
50+
51+
```viml
52+
" use [h and ]h to navigate between holes
53+
nnoremap <silent> [h :<C-U>call CocActionAsync('diagnosticPrevious', 'hint')<CR>
54+
nnoremap <silent> ]h :<C-U>call <SID>JumpToNextHole()<CR>
55+
56+
" <leader>d to perform a pattern match, <leader>n to fill a hole
57+
nnoremap <silent> <leader>d :<C-u>set operatorfunc=<SID>WingmanDestruct<CR>g@l
58+
nnoremap <silent> <leader>n :<C-u>set operatorfunc=<SID>WingmanFillHole<CR>g@l
59+
60+
" beta only
61+
nnoremap <silent> <leader>r :<C-u>set operatorfunc=<SID>WingmanRefine<CR>g@l
62+
nnoremap <silent> <leader>c :<C-u>set operatorfunc=<SID>WingmanUseCtor<CR>g@l
63+
nnoremap <silent> <leader>a :<C-u>set operatorfunc=<SID>WingmanDestructAll<CR>g@l
64+
65+
66+
function! s:JumpToNextHole()
67+
call CocActionAsync('diagnosticNext', 'hint')
68+
endfunction
69+
70+
function! s:GotoNextHole()
71+
" wait for the hole diagnostics to reload
72+
sleep 500m
73+
" and then jump to the next hole
74+
normal 0
75+
call <SID>JumpToNextHole()
76+
endfunction
77+
78+
function! s:WingmanRefine(type)
79+
call CocAction('codeAction', a:type, ['refactor.wingman.refine'])
80+
call <SID>GotoNextHole()
81+
endfunction
82+
83+
function! s:WingmanDestruct(type)
84+
call CocAction('codeAction', a:type, ['refactor.wingman.caseSplit'])
85+
call <SID>GotoNextHole()
86+
endfunction
87+
88+
function! s:WingmanDestructAll(type)
89+
call CocAction('codeAction', a:type, ['refactor.wingman.splitFuncArgs'])
90+
call <SID>GotoNextHole()
91+
endfunction
92+
93+
function! s:WingmanFillHole(type)
94+
call CocAction('codeAction', a:type, ['refactor.wingman.fillHole'])
95+
call <SID>GotoNextHole()
96+
endfunction
97+
98+
function! s:WingmanUseCtor(type)
99+
call CocAction('codeAction', a:type, ['refactor.wingman.useConstructor'])
100+
call <SID>GotoNextHole()
101+
endfunction
102+
```
103+
104+
### Other Editors
105+
106+
Please open a PR if you have a working configuration!
107+
108+
37109
## Features
38110

39111
* [Type-directed code synthesis][auto], including pattern matching and recursion

0 commit comments

Comments
 (0)