kristijanhusak / defx-git

Git status implementation for https://github.com/Shougo/defx.nvim
MIT License
71 stars 6 forks source link

Use defx internal custom option system #10

Closed rafi closed 5 years ago

rafi commented 5 years ago

This patch normalizes defx-git options to use defx's internal column options. It also avoids "Key not found" errors when reloading vimrc within vim:

Error detected while processing function dein#autoload#_on_cmd[13]..defx#util#call_defx[2]..defx#start[5]..defx#util#rpcrequest:
line   18:
Error invoking '_defx_start' on channel 5 (python3-rplugin-host):^@error caught in request handler '_defx_start [[[], {'columns': 'indent:git:icons:filename', 'auto_cd':
 0, 'prev_bufnr': 1, 'root_marker': '[in]: ', 'resume': 1, 'auto_recursive_level': 0, 'sort': 'filename', 'listed': 1, 'new': 0, 'ignored_files': '.mypy_cache,.pytest_ca
che,.git,.hg,.svn,.stversions,__pycache__,.sass-cache,*.egg-info,.DS_Store,*.pyc', 'direction': 'topleft', 'visual_end': 0, 'winheight': 30, 'profile': 0, 'search': '',
'buffer_name': 'tab1', 'winwidth': 25, 'split': 'vertical', 'visual_start': 0, 'cursor': 181, 'winrelative': 'editor', 'prev_winid': 1000, 'wincol': 42, 'winrow': 15, 's
ession_file': '', 'show_ignored_files': 0, 'toggle': 1}]]':^@Traceback (most recent call last):^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/Shougo/defx.n
vim/rplugin/python3/defx/__init__.py", line 36, in start^@    self._rplugin.start(args)^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/Shougo/defx.nvim/rplu
gin/python3/defx/rplugin.py", line 32, in start^@    views[0].init(paths, context, self._clipboard)^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/Shougo/de
fx.nvim/rplugin/python3/defx/view.py", line 51, in init^@    if not self._init_defx(paths, clipboard):^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/Shougo
/defx.nvim/rplugin/python3/defx/view.py", line 379, in _init_defx^@    self._init_all_columns()^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/Shougo/defx.n
vim/rplugin/python3/defx/view.py", line 473, in _init_all_columns^@    column = column(self._vim)^@  File "/Users/rafi/.cache/vim/dein/repos/github.com/kristijanhu
sak/defx-git/rplugin/python3/defx/column/git.py", line 23, in __init__^@    self.indicators = self.vim.vars['defx_git#indicators']^@  File "/Users/rafi/.cache/vim/
venv/neovim3/lib/python3.7/site-packages/pynvim/api/common.py", line 88, in __getitem__^@    return self._get(key)^@  File "/Users/rafi/.cache/vim/venv/neovim3/lib
/python3.7/site-packages/pynvim/api/nvim.py", line 182, in request^@    res = self._session.request(name, *args, **kwargs)^@  File "/Users/rafi/.cache/vim/venv/neo
vim3/lib/python3.7/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request^@    raise self.error_wrapper(err)^@pynvim.api.nvim.NvimError: b'Key not found: def
x_git#indicators'
kristijanhusak commented 5 years ago

Can you just make sure it's backward compatible? Someone probably already set up g:defx_git#indicators in their vimrc, and i don't want to break it for them.

rafi commented 5 years ago

@kristijanhusak I've added backward compatibility to the global variables. Thanks for the quick response.

kristijanhusak commented 5 years ago

Looks good, thanks!

kristijanhusak commented 5 years ago

@rafi i just updated it and noticed that mappings are not working. l:column_opts in s:search function doesn't return anything for column. I get only things that i defined in my vimrc, but i don't have any settings for defx_git.

Can you look into it? Thanks.