Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ call cornelis#bind_input("nat", "ℕ")

will add `<LocalLeader>nat` as an input remapping for `ℕ`.

The inverse of `cornelis#bind_input("foo", "...")` is `cornelis#unbind_input("foo")`.
Note that this cannot and will not attempt to undo any custom agda-input
management, such as through `g:cornelis_bind_input_hook` (see below).


#### Custom Hooks

Expand Down
21 changes: 21 additions & 0 deletions autoload/cornelis.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ function! cornelis#bind_input(key, result)
endif
endfunction

function! cornelis#unbind_input(key) abort
let l:cornelis_agda_prefix = get(g:, 'cornelis_agda_prefix', '<localleader>')
let l:lhs = l:cornelis_agda_prefix . substitute(a:key, '|', '<bar>', 'g')

execute 'silent! iunmap <buffer> ' . l:lhs
execute 'silent! cunmap <buffer> ' . l:lhs

if exists('g:agda_input') && type(g:agda_input) == type({})
let l:first = a:key[0:0]
let l:rest = (len(a:key) > 1) ? a:key[1:] : "\<CR>"

if has_key(g:agda_input, l:first)
if has_key(g:agda_input[l:first], l:rest)
call remove(g:agda_input[l:first], l:rest)
endif
if empty(g:agda_input[l:first])
call remove(g:agda_input, l:first)
endif
endif
endif
endfunction
Loading