<commit_before>" init.vim
" Entry point for oni-interop plugin

if exists("g:loaded_oni_interop_plugin")
    finish
endif

let g:loaded_oni_interop_plugin = 1

function OniNotify(args)
    call rpcnotify(1, "oni_plugin_notify", a:args)
endfunction

function OniNotifyBufferUpdate()

    if !exists("b:last_change_tick")
        let b:last_change_tick = -1
    endif

    if b:changedtick > b:last_change_tick
        let b:last_change_tick = b:changedtick
        if mode() == 'i'
            let buffer_line = getline(".")
            let context = OniGetContext()
            call OniNotify(["incremental_buffer_update", context, buffer_line, line(".")])
        else
            let buffer_lines = getline(1,"$")
            let context = OniGetContext()
            call OniNotify(["buffer_update", context, buffer_lines])
        endif
    endif
endfunction

function OniNotifyEvent(eventName)
    let context = OniGetContext()
    call OniNotify(["event", a:eventName, context])
endfunction

function OniOpenFile(strategy, file)
     if bufname('%') != ''
         exec a:strategy . a:file
     elseif &modified
         exec a:strategy . a:file
     else
         exec ":e " . a:file
     endif
 endfunction

augroup OniNotifyBufferUpdates
    autocmd!
    autocmd! CursorMovedI * :call OniNotifyBufferUpdate()
    autocmd! BufEnter * :call OniNotifyBufferUpdate()<commit_msg>Fix 'no matching autocommand' message by attaching no-op listeners to FocusLost/FocusGained (#623)<commit_after>" init.vim
" Entry point for oni-interop plugin

if exists("g:loaded_oni_interop_plugin")
    finish
endif

let g:loaded_oni_interop_plugin = 1

function OniNotify(args)
    call rpcnotify(1, "oni_plugin_notify", a:args)
endfunction

function OniNoop()

endfunction

function OniNotifyBufferUpdate()

    if !exists("b:last_change_tick")
        let b:last_change_tick = -1
    endif

    if b:changedtick > b:last_change_tick
        let b:last_change_tick = b:changedtick
        if mode() == 'i'
            let buffer_line = getline(".")
            let context = OniGetContext()
            call OniNotify(["incremental_buffer_update", context, buffer_line, line(".")])
        else
            let buffer_lines = getline(1,"$")
            let context = OniGetContext()
            call OniNotify(["buffer_update", context, buffer_lines])
        endif
    endif
endfunction

function OniNotifyEvent(eventName)
    let context = OniGetContext()
    call OniNotify(["event", a:eventName, context])
endfunction

function OniOpenFile(strategy, file)
     if bufname('%') != ''
         exec a:strategy . a:file
     elseif &modified
         exec a:strategy . a:file
     else
         exec ":e " . a:file
     endif
 endfunction

" Prevent 'no matching autocommand' message if FocusLost/FocusGained
" aren't registered
augroup OniNoop
    autocmd!
    autocmd! FocusLost * :call OniNoop()
    autocmd! FocusGained * :call OniNoop()
augroup END

augroup OniNotifyBufferUpdates
    autocmd!
    autocmd! CursorMovedI * :call OniNotifyBufferUpdate()
    autocmd! BufEnter * :call OniNotifyBufferUpdate()
{'fraction_non_alphanumeric': 0.09616005162955792, 'fraction_numerical': 0.0035495321071313327, 'mean_word_length': 3.172274562584118, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2261058', 'n_tokens_mistral': 1002, 'n_tokens_neox': 974, 'n_words': 241}