You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use Flashy with my custom operator, I only had to change 2 functions to be autoload instead of script-local. For the sake of example, here's my Stage-and-commit-hunk-under-cursor-with-message-specified-by-motion, making use of vim-gitgutter, vim-operator-user, and vim-operator-flashy (plus some of my helper functions under git# namespace):
function!_vim_gitgutter#operators#commit_current_hunk_with_message(motion_wiseness)
if &modifiedecho'Buffer has unwritten changes'returnendififgit#diff#has_staged_changes()
echo'There are staged changes'returnendififempty(_vim_gitgutter#current_hunk())
echo'No hunk under cursor'returnendififs:is_empty_region()
returnendif" Save cursor position for linewise motion like 'yj'.ifa:motion_wisenessis# 'line'letw=winsaveview()
endiflet visual_command =operator#user#visual_command_from_wise_name(a:motion_wiseness)
letstart= [line("'["), virtcol("'[")]
letend= [line("']"), virtcol("']")]
let pattern =vital#_operator_flashy#Coaster#Search#pattern_by_range(visual_command, start, end)
normal! `[yv`]
GitGutterStageHunk
ifgit#commit#with_message(git#commit#flatten_message(getreg('"')))
echo'Commit ' . git#log#last_commit()
calloperator#flashy#flash(pattern, g:operator#flashy#flash_time)
endifendfunctionfunction!s:is_empty_region() abortreturnline("'[") is# line("']") +1endfunction
Things that had to be changed for this to work:
in vim-operator-flashy/autoload/operator/flashy.vim, make a public copy of s:flash named operator#flashy#flash;
in vim-operator-flashy/autoload/vital/_operator_flashy/Coaster/Search.vim, make a public copy of s:pattern_by_range named vital#_operator_flashy#Coaster#Search#pattern_by_range.
Of course the second one is very awkward with regards to how the import is originally used :)
What do you think about making calls to operator#flashy#flash officially supported? I wanted to do this to my custom operators for a while, however looking at operator-flashy internals the implementation is too robust to try to imitate in a simplified manner and too intricate to only rip out the things I need.
Thank you. Big fan of your works :)
The text was updated successfully, but these errors were encountered:
To use Flashy with my custom operator, I only had to change 2 functions to be autoload instead of script-local. For the sake of example, here's my Stage-and-commit-hunk-under-cursor-with-message-specified-by-motion, making use of vim-gitgutter, vim-operator-user, and vim-operator-flashy (plus some of my helper functions under
git#
namespace):Things that had to be changed for this to work:
vim-operator-flashy/autoload/operator/flashy.vim
, make a public copy ofs:flash
namedoperator#flashy#flash
;vim-operator-flashy/autoload/vital/_operator_flashy/Coaster/Search.vim
, make a public copy ofs:pattern_by_range
namedvital#_operator_flashy#Coaster#Search#pattern_by_range
.Of course the second one is very awkward with regards to how the import is originally used :)
What do you think about making calls to
operator#flashy#flash
officially supported? I wanted to do this to my custom operators for a while, however looking at operator-flashy internals the implementation is too robust to try to imitate in a simplified manner and too intricate to only rip out the things I need.Thank you. Big fan of your works :)
The text was updated successfully, but these errors were encountered: