Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add keybindings and jump to hole to the Wingman README #1712

Merged
merged 2 commits into from
Apr 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions plugins/hls-tactics-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,78 @@ fill hole" code action, *et voila!*
[hls]: https://github.com/haskell/haskell-language-server/releases


## Editor Configuration

### Enabling Jump to Hole

Set the `haskell.plugin.tactics.config.hole_severity` config option to `4`, or
`hint` if your editor uses a GUI for its configuration. This has the potential
to negatively impact performance --- please holler if you notice any appreciable
slowdown by enabling this option.


### coc.nvim

The following vimscript maps Wingman code-actions to your leader key:

```viml
" use [h and ]h to navigate between holes
nnoremap <silent> [h :<C-U>call CocActionAsync('diagnosticPrevious', 'hint')<CR>
nnoremap <silent> ]h :<C-U>call <SID>JumpToNextHole()<CR>

" <leader>d to perform a pattern match, <leader>n to fill a hole
nnoremap <silent> <leader>d :<C-u>set operatorfunc=<SID>WingmanDestruct<CR>g@l
nnoremap <silent> <leader>n :<C-u>set operatorfunc=<SID>WingmanFillHole<CR>g@l

" beta only
nnoremap <silent> <leader>r :<C-u>set operatorfunc=<SID>WingmanRefine<CR>g@l
nnoremap <silent> <leader>c :<C-u>set operatorfunc=<SID>WingmanUseCtor<CR>g@l
nnoremap <silent> <leader>a :<C-u>set operatorfunc=<SID>WingmanDestructAll<CR>g@l
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My kingdom for lambda functions!



function! s:JumpToNextHole()
call CocActionAsync('diagnosticNext', 'hint')
endfunction

function! s:GotoNextHole()
" wait for the hole diagnostics to reload
sleep 500m
" and then jump to the next hole
normal 0
call <SID>JumpToNextHole()
endfunction

function! s:WingmanRefine(type)
call CocAction('codeAction', a:type, ['refactor.wingman.refine'])
call <SID>GotoNextHole()
endfunction

function! s:WingmanDestruct(type)
call CocAction('codeAction', a:type, ['refactor.wingman.caseSplit'])
call <SID>GotoNextHole()
endfunction

function! s:WingmanDestructAll(type)
call CocAction('codeAction', a:type, ['refactor.wingman.splitFuncArgs'])
call <SID>GotoNextHole()
endfunction

function! s:WingmanFillHole(type)
call CocAction('codeAction', a:type, ['refactor.wingman.fillHole'])
call <SID>GotoNextHole()
endfunction

function! s:WingmanUseCtor(type)
call CocAction('codeAction', a:type, ['refactor.wingman.useConstructor'])
call <SID>GotoNextHole()
endfunction
```

### Other Editors

Please open a PR if you have a working configuration!


## Features

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