[+] 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;
This commit is contained in:
parent
cf2476ec28
commit
3a76eab761
1
Makefile
1
Makefile
@ -87,6 +87,7 @@ dotfiles_vim_put:
|
||||
cp dotfiles/.vimrc ~/.vimrc
|
||||
cp dotfiles/.py3.vimrc ~/.py3.vimrc
|
||||
cp dotfiles/.module.vimrc.py ~/.module.vimrc.py
|
||||
cp dotfiles/.beta.vimrc.py ~/.beta.vimrc.py
|
||||
|
||||
PLATFORM ?= macbook_air_2012
|
||||
PLATFORM_TMP ?= tmp/platform_dotfiles/$(PLATFORM)
|
||||
|
@ -1,5 +1,6 @@
|
||||
import functools
|
||||
import configparser
|
||||
import datetime
|
||||
import collections
|
||||
import asyncio
|
||||
import threading
|
||||
@ -20,9 +21,6 @@ from typing import (
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
|
||||
|
||||
MODULE_NAME = 'online_fxreader_pr34_vim'
|
||||
|
||||
def f1():
|
||||
@ -246,7 +244,7 @@ class EditorConfigModeline:
|
||||
class _Vim:
|
||||
@classmethod
|
||||
def run_command(cls, cmd) -> list[str]:
|
||||
logger.info(dict(cmd=cmd))
|
||||
# logger.info(dict(cmd=cmd))
|
||||
|
||||
output: list[str] = []
|
||||
for line in cmd.splitlines():
|
||||
@ -293,7 +291,7 @@ class FastSelect:
|
||||
endfunc
|
||||
''')
|
||||
_Vim.run_command(r'''
|
||||
call timer_start(1000, 'UIThread', {'repeat': -1})
|
||||
call timer_start(100, 'UIThread', {'repeat': -1})
|
||||
''')
|
||||
_Vim.run_command(r'''
|
||||
augroup {auto_group}
|
||||
@ -359,7 +357,7 @@ augroup END
|
||||
|
||||
logger.warning(dict(buffers=list(vim.buffers), id=selected_id))
|
||||
# print(vim.buffers, selected_id)
|
||||
if selected_id >= 0:
|
||||
if selected_id:
|
||||
vim.current.buffer = vim.buffers[buffers[selected_id][1]]
|
||||
|
||||
with self._lock:
|
||||
@ -427,6 +425,11 @@ augroup END
|
||||
|
||||
def ui_thread(self):
|
||||
with self._lock:
|
||||
#_Vim.run_command(r'''
|
||||
# set laststatus=2
|
||||
# set statusline={}
|
||||
#'''.format(datetime.datetime.now().isoformat()))
|
||||
|
||||
while len(self._queue) > 0:
|
||||
cmd = self._queue.pop();
|
||||
logger.warning(dict(msg='start command', cmd=inspect.getsource(cmd)))
|
||||
|
@ -20,7 +20,7 @@ from typing import (
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
# logging.basicConfig(level=logging.WARNING)
|
||||
|
||||
|
||||
MODULE_NAME = 'online_fxreader_pr34_vim'
|
||||
|
@ -1,4 +1,41 @@
|
||||
py3file ~/.module.vimrc.py
|
||||
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!
|
||||
|
@ -87,3 +87,5 @@ map <Leader>i5 :set sw=2 sts=2 ts=2 noet ai ci<CR>
|
||||
set foldmethod=indent
|
||||
set nofoldenable
|
||||
map <Leader>e :e #<cR>
|
||||
|
||||
map <C-p> :python3 FastSelect.singleton().switch_buffer()<CR>
|
||||
|
Loading…
Reference in New Issue
Block a user