From 248bb78805eda662be459ff173348751ba621656 Mon Sep 17 00:00:00 2001 From: David Leadbeater Date: Mon, 30 Dec 2024 13:43:18 +1100 Subject: [PATCH] Ghostty support --- plugin/terminaldocument.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/terminaldocument.vim b/plugin/terminaldocument.vim index 268d259..72958ba 100644 --- a/plugin/terminaldocument.vim +++ b/plugin/terminaldocument.vim @@ -6,13 +6,13 @@ autocmd BufEnter,BufFilePost * call s:update_document(0) " these events might change the nature of the file, " so we try to refresh its icon autocmd BufWritePost,FileChangedShellPost,ShellCmdPost * call s:update_document(1) -autocmd VimLeave * call s:set_osc6('') +autocmd VimLeave * call s:set_osc('') function! s:update_document(refresh) let path = expand('%:p') if empty(path) || !filereadable(path) " unnamed/unsaved file being edited - call s:set_osc6('') + call s:set_osc('') else let path = s:urlencode(path) if a:refresh @@ -21,14 +21,18 @@ function! s:update_document(refresh) " reference to the same file " (better than the flickering that happens when we temporarily set " to empty) - call s:set_osc6('file://' . path) + call s:set_osc('file://localhost' . path) endif - call s:set_osc6('file://' . hostname() . path) + call s:set_osc('file://' . hostname() . path) endif endfunction -function! s:set_osc6(pt) - call system('printf "\e]6;%s\a" >/dev/tty ' . shellescape(a:pt)) +function! s:set_osc(pt) + let osc = '6' + if &term == 'xterm-ghostty' + let osc = '7' + endif + call system('printf "\e]' . osc . ';%s\a" >/dev/tty ' . shellescape(a:pt)) endfunction