Skip to content

Commit

Permalink
pinのトグル用のオペレータを追加した
Browse files Browse the repository at this point in the history
  • Loading branch information
kamecha committed Dec 13, 2023
1 parent 5e8e922 commit 7c70956
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions autoload/traqvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,27 @@ function traqvim#deleteMessage(t) abort
call denops#request('traqvim', 'messageDelete', [bufnr(), messageStart])
endfunction

function traqvim#registerTogglePin() abort
let &opfunc = function('traqvim#togglePin')
return 'g@'
endfunction

function traqvim#togglePin(t) abort
if a:t != 'line'
return
endif
let messageStart = traqvim#get_message_buf(line("'["), bufnr('%'))
let messageEnd = traqvim#get_message_buf(line("']"), bufnr('%'))
if messageStart->get('id') != messageEnd->get('id')
return
endif
if messageStart->get('pinned')
call denops#request('traqvim', 'removePin', [bufnr(), messageStart])
else
call denops#request('traqvim', 'createPin', [bufnr(), messageStart])
endif
endfunction

function traqvim#message_motion() abort
let position = traqvim#get_message()->get('position')
call cursor(position->get('start'), 1)
Expand Down
5 changes: 5 additions & 0 deletions ftplugin/traqvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ nnoremap <buffer><expr> <Plug>(traqvim-yank-message-markdown-operator)
\ traqvim#registerYankMessageMarkdown()
nnoremap <buffer><expr> <Plug>(traqvim-delete-message-operator)
\ traqvim#registerDeleteMessage()
nnoremap <buffer><expr> <Plug>(traqvim-toggle-pin-operator)
\ traqvim#registerTogglePin()
onoremap <silent> <Plug>(traqvim-message-motion)
\ :<C-u>call traqvim#message_motion()<CR>
Expand All @@ -35,6 +37,9 @@ nmap <buffer> <LocalLeader>Y
nmap <buffer> <LocalLeader>d
\ <Plug>(traqvim-delete-message-operator)
nmap <buffer> <LocalLeader>p
\ <Plug>(traqvim-toggle-pin-operator)
command! -buffer -nargs=0 TraqYankMessageLink
\ call denops#request('traqvim', 'yankMessageLink', [traqvim#get_message()])
command! -buffer -nargs=0 TraqYankMessageMarkdown
Expand Down

0 comments on commit 7c70956

Please sign in to comment.