From 38cb96c9878b33e820a4912af22fcf3f68c4efef Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Fri, 13 Apr 2018 14:49:25 +0200 Subject: [PATCH] Move b:sy_info to b:sy.info --- autoload/sy.vim | 16 +++++++--------- autoload/sy/repo.vim | 14 +++++++------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/autoload/sy.vim b/autoload/sy.vim index bde8258..cee241b 100644 --- a/autoload/sy.vim +++ b/autoload/sy.vim @@ -18,18 +18,11 @@ function! sy#start() abort call sy#verbose('Skip file: '. sy_path) if exists('b:sy') call sy#sign#remove_all_signs(bufnr('')) - unlet! b:sy b:sy_info + unlet! b:sy endif return endif - " sy_info is used in autoload/sy/repo - let b:sy_info = { - \ 'dir': fnamemodify(sy_path, ':p:h'), - \ 'path': sy#util#escape(sy_path), - \ 'file': sy#util#escape(fnamemodify(sy_path, ':t')), - \ } - if !exists('b:sy') || b:sy.path != sy_path call sy#verbose('Register new file: '. sy_path) let b:sy = { @@ -41,7 +34,12 @@ function! sy#start() abort \ 'hunks': [], \ 'signid': 0x100, \ 'updated_by': '', - \ 'stats': [-1, -1, -1] } + \ 'stats': [-1, -1, -1], + \ 'info': { + \ 'dir': fnamemodify(sy_path, ':p:h'), + \ 'path': sy#util#escape(sy_path), + \ 'file': sy#util#escape(fnamemodify(sy_path, ':t')) + \ }} if get(g:, 'signify_disable_by_default') call sy#verbose('Disabled by default.') return diff --git a/autoload/sy/repo.vim b/autoload/sy/repo.vim index 3b96bbd..3295f30 100644 --- a/autoload/sy/repo.vim +++ b/autoload/sy/repo.vim @@ -74,9 +74,9 @@ function! sy#repo#get_diff_start(vcs) abort let [cmd, options] = s:initialize_job(a:vcs) - call sy#verbose(printf('CMD: %s | CWD: %s', string(cmd), b:sy_info.dir), a:vcs) + call sy#verbose(printf('CMD: %s | CWD: %s', string(cmd), b:sy.info.dir), a:vcs) let b:sy_job_id_{a:vcs} = jobstart(cmd, extend(options, { - \ 'cwd': b:sy_info.dir, + \ 'cwd': b:sy.info.dir, \ 'on_stdout': function('s:callback_nvim_stdout'), \ 'on_exit': function('s:callback_nvim_exit'), \ })) @@ -91,7 +91,7 @@ function! sy#repo#get_diff_start(vcs) abort let [cwd, chdir] = sy#util#chdir() try - execute chdir fnameescape(b:sy_info.dir) + execute chdir fnameescape(b:sy.info.dir) call sy#verbose(printf('CMD: %s | CWD: %s', string(cmd), getcwd()), a:vcs) let opts = { \ 'in_io': 'null', @@ -262,7 +262,7 @@ function! sy#repo#diffmode() abort diffthis let [cwd, chdir] = sy#util#chdir() try - execute chdir fnameescape(b:sy_info.dir) + execute chdir fnameescape(b:sy.info.dir) leftabove vnew silent put =system(cmd) finally @@ -299,7 +299,7 @@ endfunction " Function: s:get_vcs_path {{{1 function! s:get_vcs_path(vcs) abort - return (a:vcs =~# '\v(git|cvs|accurev|tfs)') ? b:sy_info.file : b:sy_info.path + return (a:vcs =~# '\v(git|cvs|accurev|tfs)') ? b:sy.info.file : b:sy.info.path endfunction " Function: s:expand_cmd {{{1 @@ -308,7 +308,7 @@ function! s:expand_cmd(vcs) abort let cmd = s:replace(cmd, '%f', s:get_vcs_path(a:vcs)) let cmd = s:replace(cmd, '%d', s:difftool) let cmd = s:replace(cmd, '%n', s:devnull) - let b:sy_info.cmd = cmd + let b:sy.info.cmd = cmd return cmd endfunction @@ -325,7 +325,7 @@ endfunction function! s:run(vcs) let [cwd, chdir] = sy#util#chdir() try - execute chdir fnameescape(b:sy_info.dir) + execute chdir fnameescape(b:sy.info.dir) let ret = system(s:expand_cmd(a:vcs)) catch " This exception message can be seen via :SignifyDebugUnknown.