Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
utubo committed Oct 11, 2023
1 parent 9c29fd7 commit f997d91
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,23 @@ endif
tno <C-w>; <C-w>:
tno <C-w><C-w> <C-w>w
tno <C-w><C-q> exit<CR>
def g:Tapi_drop(a: number, b: list<string>)
const c = b[0]
var d = 1
var e = 'split'
if b[1] ==# '-t'
e = 'tabe'
d += 1
endif
var f = b[d]
if !isabsolutepath(f)
f = fnamemodify(c, ':p') .. f
endif
if bufwinnr(bufnr(f)) !=# -1
e = 'drop'
endif
exe e fnameescape(f)
enddef
def BE(a: string = '')
if &ft ==# 'qf'
return
Expand Down
7 changes: 7 additions & 0 deletions .zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,10 @@ linux)
;;
esac

# https://zenn.dev/vim_jp/articles/5fdad17d336c6d
if [ -n "$VIM_TERMINAL" ]; then
function drop() {
echo "\e]51;[\"call\", \"Tapi_drop\", [\"$(pwd)\", \"$1\", \"$2\"]]\x07"
}
fi

24 changes: 24 additions & 0 deletions src/.vimrc.src.vim
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,30 @@ endif
tnoremap <C-w>; <C-w>:
tnoremap <C-w><C-w> <C-w>w
tnoremap <C-w><C-q> exit<CR>
# https://zenn.dev/vim_jp/articles/5fdad17d336c6d
# (`-t`でタブで開けるように改造)
def g:Tapi_drop(bufnr: number, arglist: list<string>)
const cwd = arglist[0]
var index = 1
var opencmd = 'split'
if arglist[1] ==# '-t'
# -tオプションが指定された場合はタブで開く
opencmd = 'tabe'
index += 1
endif
var filepath = arglist[index]
if !isabsolutepath(filepath)
# 絶対パスでない時は絶対パスに変換する
filepath = fnamemodify(cwd, ':p') .. filepath
endif
if bufwinnr(bufnr(filepath)) !=# -1
# ファイルがすでに開かれていればそのウインドウに移動する
opencmd = 'drop'
endif
execute opencmd fnameescape(filepath)
enddef

#}}} -------------------------------------------------------

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

0 comments on commit f997d91

Please sign in to comment.