vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

osc52.vim (1057B)


      1 vim9script
      2 
      3 # Vim plugin for OSC52 clipboard support
      4 #
      5 # Maintainer:	The Vim Project <https://github.com/vim/vim>
      6 # Last Change:	2026 Mar 01
      7 
      8 if !has("timers")
      9   finish
     10 endif
     11 
     12 import autoload "../autoload/osc52.vim" as osc
     13 
     14 var provider: dict<any> = {
     15   "available": osc.Available,
     16   "copy": {
     17     "*": osc.Copy,
     18     "+": osc.Copy
     19   },
     20 }
     21 
     22 if !get(g:, 'osc52_disable_paste', 0)
     23   provider->extend({
     24     "paste": {
     25       "*": osc.Paste,
     26       "+": osc.Paste
     27     }
     28   })
     29 endif
     30 
     31 v:clipproviders["osc52"] = provider
     32 
     33 def SendDA1(): void
     34   if !has("gui_running") && !get(g:, 'osc52_force_avail', 0)
     35       && !get(g:, 'osc52_no_da1', 0)
     36     echoraw("\<Esc>[c")
     37   endif
     38 enddef
     39 
     40 if v:vim_did_enter
     41   SendDA1()
     42 endif
     43 
     44 augroup VimOSC52Plugin
     45   autocmd!
     46   # Query support for OSC 52 using a DA1 query
     47   autocmd TermResponseAll da1 {
     48     if match(v:termda1, '?\zs.*52\ze') != -1
     49       osc.allowed = true
     50       :silent! clipreset
     51     else
     52       osc.allowed = false
     53       :silent! clipreset
     54     endif
     55   }
     56   autocmd VimEnter * SendDA1()
     57 augroup END
     58 
     59 # vim: set sw=2 sts=2 :