freelance-project-34-market.../dotfiles/.py3.vimrc
Siarhei Siniak 3a76eab761 [+] improve vim py3 modules
1. switch to file logging
    with rotation;
  2. test that at 100ms callback
    execution UI looks fast;
  3. test that <C-p> hotkey
    makes the switcher popu;
  3.1. TODO,
    select some better
    switching UI component;
    should support a list of more buffers
    than fit into the screen;
    should support some real time
    filtering via regex;
2025-10-13 18:39:44 +03:00

57 lines
1.1 KiB
Plaintext

py3 <<EOF
def load():
import logging
import logging.handlers
import json
import pathlib
import os
logging.basicConfig(
level=getattr(
logging,
os.environ.get('VIM_PY3_LEVEL', 'WARNING')
),
# filename=pathlib.Path('~/.py3.vimrc.log').expanduser(),
handlers=[
logging.handlers.RotatingFileHandler(
pathlib.Path('~/.py3.vimrc.log').expanduser(),
maxBytes=128 * 1024,
backupCount=3,
)
]
)
modules = [
pathlib.Path(o).expanduser()
for o in json.loads(os.environ.get('VIM_PY3_MODULES', '["~/.module.vimrc.py"]'))
]
for o in modules:
if not o.exists():
raise RuntimeError('not found %s' % str(o))
vim.command('py3file {}'.format(str(o)))
EOF
" py3file ~/.module.vimrc.py
python3 load()
augroup EditorConfigModeline
autocmd!
autocmd BufEnter * python3 EditorConfigModeline.singleton().on_buffer()
augroup END
function! F5(pattern, flags, info)
let res = py3eval(
\'f5_1(
\vim.bindeval("a:pattern").decode("utf-8"),
\vim.bindeval("a:flags"),
\vim.bindeval("a:info")
\)'
\)
return res
endfunc
set tagfunc=F5