diff options
author | w0rp <devw0rp@gmail.com> | 2017-05-30 22:15:24 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-05-30 22:15:24 +0100 |
commit | b9f4b0373a62266ea5eadd3c90a47e82df995391 (patch) | |
tree | da74d7f529c4198351dbed579f5a0a7ffbd45114 /autoload | |
parent | 6ec965c8e4618c14b05b05bd554b3fed9c1191e1 (diff) | |
download | ale-b9f4b0373a62266ea5eadd3c90a47e82df995391.zip |
#591 Store buffer variables when fixing filess, and read them back in ale#Var
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale.vim | 11 | ||||
-rw-r--r-- | autoload/ale/fix.vim | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/autoload/ale.vim b/autoload/ale.vim index 4286e4af..9751225b 100644 --- a/autoload/ale.vim +++ b/autoload/ale.vim @@ -128,9 +128,18 @@ endfunction " " Every variable name will be prefixed with 'ale_'. function! ale#Var(buffer, variable_name) abort + let l:nr = str2nr(a:buffer) let l:full_name = 'ale_' . a:variable_name - return getbufvar(str2nr(a:buffer), l:full_name, g:[l:full_name]) + if bufexists(l:nr) + let l:vars = getbufvar(l:nr, '') + elseif has_key(g:, 'ale_fix_buffer_data') + let l:vars = get(g:ale_fix_buffer_data, l:nr, {'vars': {}}).vars + else + let l:vars = {} + endif + + return get(l:vars, l:full_name, g:[l:full_name]) endfunction " Initialize a variable with a default value, if it isn't already set. diff --git a/autoload/ale/fix.vim b/autoload/ale/fix.vim index 33f97ce4..d8a50a2d 100644 --- a/autoload/ale/fix.vim +++ b/autoload/ale/fix.vim @@ -305,6 +305,7 @@ function! ale#fix#InitBufferData(buffer, fixing_flag) abort " The 'done' flag tells the function for applying changes when fixing " is complete. let g:ale_fix_buffer_data[a:buffer] = { + \ 'vars': getbufvar(a:buffer, ''), \ 'lines_before': getbufline(a:buffer, 1, '$'), \ 'filename': expand('#' . a:buffer . ':p'), \ 'done': 0, |