From 9037a180defe3e7344e2eb9843cfa20a43d6f59f Mon Sep 17 00:00:00 2001 From: ZyX Date: Mon, 31 Aug 2015 21:45:33 +0300 Subject: runtime: Add [ft]plugin/shada.vim files that automatically open .shada --- runtime/plugin/shada.vim | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 runtime/plugin/shada.vim (limited to 'runtime/plugin') diff --git a/runtime/plugin/shada.vim b/runtime/plugin/shada.vim new file mode 100644 index 0000000000..ae08e01dcb --- /dev/null +++ b/runtime/plugin/shada.vim @@ -0,0 +1,39 @@ +if exists('g:loaded_shada_plugin') + finish +endif +let g:loaded_shada_plugin = 1 + +augroup ShaDaCommands + autocmd! + autocmd BufReadCmd *.shada,*.shada.tmp.[a-z] + \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif + \ |call setline('.', shada#get_strings(readfile(expand(''),'b'))) + \ |setlocal filetype=shada + autocmd FileReadCmd *.shada,*.shada.tmp.[a-z] + \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif + \ |call append("'[", shada#get_strings(readfile(expand(''), 'b'))) + autocmd BufWriteCmd *.shada,*.shada.tmp.[a-z] + \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif + \ |if writefile(shada#get_binstrings(getline(1, '$')), + \expand(''), 'b') == 0 + \ | let &l:modified = (expand('') is# bufname(+expand('')) + \? 0 + \: stridx(&cpoptions, '+') != -1) + \ |endif + autocmd FileWriteCmd *.shada,*.shada.tmp.[a-z] + \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif + \ |call writefile( + \shada#get_binstrings(getline(min([line("'["), line("']")]), + \max([line("'["), line("']")]))), + \expand(''), + \'b') + autocmd FileAppendCmd *.shada,*.shada.tmp.[a-z] + \ :if !empty(v:cmdarg)|throw '++opt not supported'|endif + \ |call writefile( + \shada#get_binstrings(getline(min([line("'["), line("']")]), + \max([line("'["), line("']")]))), + \expand(''), + \'ab') + autocmd SourceCmd *.shada,*.shada.tmp.[a-z] + \ :execute 'rshada' fnameescape(expand('')) +augroup END -- cgit