mnv9script

# MNV plugin for OSC52 clipboard support
#
# Maintainer:	The MNV Project <https://github.com/Project-Tick/Project-Tick>
# Last Change:	2026 Mar 01

if !has("timers")
  finish
endif

import autoload "../autoload/osc52.mnv" as osc

var provider: dict<any> = {
  "available": osc.Available,
  "copy": {
    "*": osc.Copy,
    "+": osc.Copy
  },
}

if !get(g:, 'osc52_disable_paste', 0)
  provider->extend({
    "paste": {
      "*": osc.Paste,
      "+": osc.Paste
    }
  })
endif

v:clipproviders["osc52"] = provider

def SendDA1(): void
  if !has("gui_running") && !get(g:, 'osc52_force_avail', 0)
      && !get(g:, 'osc52_no_da1', 0)
    echoraw("\<Esc>[c")
  endif
enddef

if v:mnv_did_enter
  SendDA1()
endif

augroup MNVOSC52Plugin
  autocmd!
  # Query support for OSC 52 using a DA1 query
  autocmd TermResponseAll da1 {
    if match(v:termda1, '?\zs.*52\ze') != -1
      osc.allowed = true
      :silent! clipreset
    else
      osc.allowed = false
      :silent! clipreset
    endif
  }
  autocmd MNVEnter * SendDA1()
augroup END

# mnv: set sw=2 sts=2 :
