<commit_before>"   vim-hackpad
"   -----------
"   Browse Hackpad (hackpad.com) inside Vim
"   Author:  ccraciun
"   License: MIT (see LICENSE file)
"   Version: 0.1-dev

" We need filetype plugins
filetype plugin on

" TODO(cosmic): Refresh after/before almost everything, but add rate limiting.
autocmd! InsertEnter,CursorHold,BufReadCmd hackpad://*/?* call HackPadRead(expand("<amatch>"))
autocmd! InsertLeave,BufWriteCmd hackpad://*/?* call HackPadWrite(expand("<amatch>"))

if has('python')
    command! -nargs=1 Python python <args>
elseif has('python3')
    command! -nargs=1 Python python3 <args>
else
    echo "Hackepad.vim Error: Requires Vim compiled with +python or +python3"
    finish
endif

execute "Python import sys"
execute "python sys.path.append(r'" . expand("<sfile>:p:h")  . "')"

Python << EOF
if 'vimhackpad' not in sys.modules:
    import vimhackpad
else:
    import imp
    vimhackpad = imp.reload(vimhackpad)
EOF


" Defaults
if !exists("g:hackpad_credential_file")
    let g:hackpad_credential_file = expand('~') . '/.hackpad.cred.json'
endif

if !exists("g:hackpad_list_summary_lines")
    let g:hackpad_list_summary_lines = 3
endif

" Open Hackpad Pad or show Hackpad Pad List by URL
function! HackPad(...)
    if a:0 > 0
        let g:hackpad_url = a:1
    else
        let g:hackpad_url = ""
    endif

    execute "Python vimhackpad.load()"
endfunction

function! HackPadRead(pad_uri)
    let g:hackpad_url = a:pad_uri
    execute "Python vimhackpad.read()"
endfunction

function! HackPadWrite(pad_uri)
    let g:hackpad_url = a:pad_uri
    execute "Python vimhackpad.save()"
endfunction

command! -nargs=* Hackpad call HackPad(<q-args>)<commit_msg>Keep cursor position; hit server on request only<commit_after>"   vim-hackpad
"   -----------
"   Browse Hackpad (hackpad.com) inside Vim
"   Author:  ccraciun
"   License: MIT (see LICENSE file)
"   Version: 0.1-dev

" We need filetype plugins
filetype plugin on

"autocmd! InsertEnter,CursorHold,BufReadCmd hackpad://*/?* call HackPadRead(expand("<amatch>"))
"autocmd! InsertLeave,BufWriteCmd hackpad://*/?* call HackPadWrite(expand("<amatch>"))
" TODO: Use hackpad/client/ios updating so we're less disruptive.
autocmd! BufReadCmd hackpad://*/?* call HackPadRead(expand("<amatch>"))
autocmd! BufWriteCmd hackpad://*/?* call HackPadWrite(expand("<amatch>"))

if has('python')
    command! -nargs=1 Python python <args>
elseif has('python3')
    command! -nargs=1 Python python3 <args>
else
    echo "Hackepad.vim Error: Requires Vim compiled with +python or +python3"
    finish
endif

execute "Python import sys"
execute "python sys.path.append(r'" . expand("<sfile>:p:h")  . "')"

Python << EOF
if 'vimhackpad' not in sys.modules:
    import vimhackpad
else:
    import imp
    vimhackpad = imp.reload(vimhackpad)
EOF


" Defaults
if !exists("g:hackpad_credential_file")
    let g:hackpad_credential_file = expand('~') . '/.hackpad.cred.json'
endif

if !exists("g:hackpad_list_summary_lines")
    let g:hackpad_list_summary_lines = 3
endif

" Open Hackpad Pad or show Hackpad Pad List by URL
function! HackPad(...)
    if a:0 > 0
        let g:hackpad_url = a:1
    else
        let g:hackpad_url = ""
    endif

    execute "Python vimhackpad.load()"
endfunction

function! HackPadRead(pad_uri)
    let l:winview = winsaveview()
    let g:hackpad_url = a:pad_uri
    execute "Python vimhackpad.read()"
    call winrestview(l:winview)
endfunction

function! HackPadWrite(pad_uri)
    let l:winview = winsaveview()
    let g:hackpad_url = a:pad_uri
    execute "Python vimhackpad.save()"
    call winrestview(l:winview)
endfunction

command! -nargs=* Hackpad call HackPad(<q-args>)
{'fraction_non_alphanumeric': 0.1287506819421713, 'fraction_numerical': 0.006001091107474086, 'mean_word_length': 4.093055555555556, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '7085964', 'n_tokens_mistral': 1365, 'n_tokens_neox': 1300, 'n_words': 335}