Skip to content

Commit

Permalink
メッセージ削除用のオペレータを実装
Browse files Browse the repository at this point in the history
  • Loading branch information
kamecha committed Dec 12, 2023
1 parent bfca5d5 commit 08f33c2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions autoload/traqvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@ function traqvim#yankMessageMarkdown(t) abort
call setreg(v:register, messageStart->get('content'))
endfunction

function traqvim#registerDeleteMessage() abort
let &opfunc = function('traqvim#deleteMessage')
return 'g@'
endfunction

function traqvim#deleteMessage(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
call denops#request('traqvim', 'messageDelete', [bufnr(), messageStart])
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 @@ -11,6 +11,8 @@ nnoremap <buffer><expr> <Plug>(traqvim-yank-message-link-operator)
\ traqvim#registerYankMessageLink()
nnoremap <buffer><expr> <Plug>(traqvim-yank-message-markdown-operator)
\ traqvim#registerYankMessageMarkdown()
nnoremap <buffer><expr> <Plug>(traqvim-delete-message-operator)
\ traqvim#registerDeleteMessage()
onoremap <silent> <Plug>(traqvim-message-motion)
\ :<C-u>call traqvim#message_motion()<CR>
Expand All @@ -24,6 +26,9 @@ nmap <buffer> <LocalLeader>y
nmap <buffer> <LocalLeader>Y
\ <Plug>(traqvim-yank-message-markdown-operator)
nmap <buffer> <LocalLeader>d
\ <Plug>(traqvim-delete-message-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 08f33c2

Please sign in to comment.