Skip to content

Commit

Permalink
Merge pull request #45 from blp1526/quickfix_e925
Browse files Browse the repository at this point in the history
Add storage#cnewer()
  • Loading branch information
blp1526 authored Nov 6, 2016
2 parents a584def + b35ebd8 commit 4a9f0a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
23 changes: 21 additions & 2 deletions autoload/storage.vim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function! storage#write(cmd, dict, path) abort
finally
silent execute 'edit' fnameescape(a:path)
endtry
" expected to be still 'modified' if storage#put_cmd failed
" NOTE:
" Expected to be still 'modified' if storage#put_cmd failed
setlocal nomodified
let &hidden = current_hidden
endfunction
Expand All @@ -49,11 +50,29 @@ function! storage#open_quickfix(ls_result) abort
let &errorformat = storage#errorformat()
let ls_result_array = split(a:ls_result, "\n")
call map(ls_result_array, 'storage#errorformatted_string(v:val)')
cgete join(ls_result_array, "\n")
cgetexpr join(ls_result_array, "\n")
copen
try
" NOTE:
" This 'colder' is required to prevent from throwing 'E925 Current quickfix was changed' error.
" Because above 'cgetexpr' creates new quickfix, and current quickfix is changed.
" See http://github.com/vim/vim/blob/0a9046fbcb33770517ab0220b8100c4494bddab2/src/quickfix.c#L2275-L2276
colder
let g:storage_vim_required_cnewer = 1
catch
echo ''
endtry
let &errorformat = current_errorformat
endfunction

function! storage#cnewer() abort
if g:storage_vim_required_cnewer == 1
cnewer
let g:storage_vim_required_cnewer = 0
echo ''
endif
endfunction

function! storage#last_string(str) abort
let last_index = strchars(a:str) - 1
return a:str[last_index]
Expand Down
5 changes: 5 additions & 0 deletions plugin/storage.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ if !exists('g:storage_vim_dict')
let g:storage_vim_dict = {}
endif

if !exists('g:storage_vim_required_cnewer')
let g:storage_vim_required_cnewer = 0
endif

augroup storage
autocmd!
autocmd BufReadCmd,FileReadCmd s3://* call storage#read(g:storage_vim_cmd, @%, g:storage_vim_dict)
autocmd TextChanged * call storage#cnewer()
autocmd BufWriteCmd,FileWriteCmd s3://* call storage#write(g:storage_vim_cmd, g:storage_vim_dict, @%)
augroup END

Expand Down

0 comments on commit 4a9f0a4

Please sign in to comment.