Skip to content

Commit

Permalink
✨feat: vim-headtail
Browse files Browse the repository at this point in the history
  • Loading branch information
utubo committed Dec 19, 2024
1 parent 50c4ad3 commit c6c4228
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 43 deletions.
1 change: 1 addition & 0 deletions .vim/autoload/vimrc/ezpack.vim
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ EzpackO ctrlpvim/ctrlp.vim
EzpackO mattn/ctrlp-matchfuzzy
EzpackL sheerun/vim-polyglot
EzpackO utubo/vim-ezpack
EzpackL utubo/vim-headtail
EzpackL utubo/vim-hlpairs
EzpackL utubo/vim-minviml
EzpackO utubo/vim-reformatdate
Expand Down
25 changes: 4 additions & 21 deletions .vim/autoload/vimrc/lazyload.vim
Original file line number Diff line number Diff line change
Expand Up @@ -405,28 +405,11 @@ nn <script> g9 :<C-u>vim9cmd <SID>(exec_line)
xn g: "vy:<C-u><C-r>=@v<CR><CR>
xn g9 "vy:<C-u>vim9cmd <C-r>=@v<CR><CR>
nn <expr> <Space>hl $'<Cmd>hi {synID(line('.'), col('.'), 1)->synIDattr('name')->substitute('^$', 'Normal', '')}<CR>'
export def ToTail(a: string)
getpos("']")->setpos('.')
enddef
no <SID>(ToTail) <ScriptCmd>set operatorfunc=vimrc#lazyload#ToTail<CR>g@
nm Ga <SID>(ToTail)a
nm Gi <SID>(ToTail)i
no GG G
export def ToHead(a: string)
const p = getpos("'[")
setpos('.', p)
if p[2] <= 1
normal ^
elseif getline(p[1])->len() <= p[2]
normal j^
endif
enddef
no <SID>(ToHead) <ScriptCmd>set operatorfunc=vimrc#lazyload#ToHead<CR>g@
nm ga <SID>(ToHead)a
nm gi <SID>(ToHead)i
no <Leader>ga ga
nm g% gi%
nm G% Gi%
packadd vim-headtail
HeadTailMap g G
Each nmap,xmap g% gi%
Each nmap,xmap G% Gi%
if has('clipboard')
au vimrc FocusGained * @" = @+
au vimrc FocusLost * @+ = @"
Expand Down
1 change: 1 addition & 0 deletions src/.vim/autoload/vimrc/ezpack.src.vim
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EzpackL sheerun/vim-polyglot # 色んなファイルタイプに対応

# 🐶🍚
EzpackO utubo/vim-ezpack # 自作プラグインマネージャ
EzpackL utubo/vim-headtail # Textobjの先頭や末尾に移動
EzpackL utubo/vim-hlpairs # 括弧をハイライト強化版
EzpackL utubo/vim-minviml # vimscriptをminify
EzpackO utubo/vim-reformatdate # <C-a>で日付と曜日をインクリメントとか
Expand Down
26 changes: 4 additions & 22 deletions src/.vim/autoload/vimrc/lazyload.src.vim
Original file line number Diff line number Diff line change
Expand Up @@ -595,29 +595,11 @@ nnoremap <expr> <Space>hl $'<Cmd>hi {synID(line('.'), col('.'), 1)->synIDattr('n

# ------------------------------------------------------
# テキストオブジェクトの末尾や先頭に移動 {{{
export def ToTail(type: string)
getpos("']")->setpos('.')
enddef
noremap <SID>(ToTail) <ScriptCmd>set operatorfunc=vimrc#lazyload#ToTail<CR>g@
nmap Ga <SID>(ToTail)a
nmap Gi <SID>(ToTail)i
noremap GG G
export def ToHead(type: string)
const p = getpos("'[")
setpos('.', p)
if p[2] <= 1
normal ^
elseif getline(p[1])->len() <= p[2]
normal j^
endif
enddef
noremap <SID>(ToHead) <ScriptCmd>set operatorfunc=vimrc#lazyload#ToHead<CR>g@
nmap ga <SID>(ToHead)a
nmap gi <SID>(ToHead)i
noremap <Leader>ga ga
nmap g% gi%
nmap G% Gi%
packadd vim-headtail
HeadTailMap g G
Each nmap,xmap g% gi%
Each nmap,xmap G% Gi%
# }}}

# ------------------------------------------------------
Expand Down

0 comments on commit c6c4228

Please sign in to comment.