Commits

ZyX_I committed 09c98bb

Partial :read aurum:// support (untested)

  • Participants
  • Parent commits da3cc84

Comments (0)

Files changed (1)

File plugin/aurum.vim

     " TODO revision completion
     " TODO improve files completion
     " TODO U (update), K and J mappings for aurum://file and aurum://diff
+    " TODO :Au[Read?] (read revision to current buffer) (?: cmd %r)
+    " TODO :Au[Grep?], :AuMove, :Au[Remove?], :AuBrowse
+    " TODO {count}K, {count}J
+    " TODO Global mappings for most commands
+    " TODO aurum#changeset() and aurum#repository()
+    " TODO More options
+    " TODO :read aurum://(annotate|status|glog)
     let s:glogfunc={}
     let s:glogcomp=[]
     call s:_f.command.add('AuGlog', s:glogfunc, {'nargs': '*',
     call FraworLoad('@/autocommands')
     let s:auefunc={}
     let s:aubwfunc={}
-    call s:_f.augroup.add('Aurum', [['BufReadCmd', 'aurum://*',0, s:auefunc],
-                \                   ['BufDelete',  'aurum://*',0, s:aubwfunc],
+    call s:_f.augroup.add('Aurum', [['BufReadCmd',  'aurum://*',0,  s:auefunc],
+                \                   ['FileReadCmd', 'aurum://*',0, [s:auefunc,1]],
+                \                   ['BufDelete',   'aurum://*',0,  s:aubwfunc],
                 \                  ])
     "▲2
     finish
             \           'Update to version of Vim that has undotree() '.
             \           'function available',
             \ 'recnof': 'No files were selected for commiting',
+            \'nocread': 'Cannot read aurum://commit',
         \}
 "▶1 Вторая загрузка — функции
 "▶2 hg
     return [repo]+strings+[opts]
 endfunction
 "▲3
-function s:auefunc.function() abort
+function s:auefunc.function(...) abort
     "▶3 Split <amatch> into command and arguments
     let tail=substitute(expand('<amatch>'), '\V\^aurum://', '', '')
     let command=tolower(matchstr(tail, '\v^\w+'))
                     \     'has_key(opts, v:val)')
             let opts[key]=+opts[key]
         endfor
-        let s:bufvars[buf]={'repo': repo, 'opts': opts}
-        setlocal filetype=aurumgraphlog bufhidden=wipe
+        let s:bufvars[buf]={'repo': repo, 'opts': opts, 'read': a:0}
+        if !a:0
+            setlocal filetype=aurumgraphlog bufhidden=wipe
+        endif
         runtime ftplugin/aurumgraphlog.vim
     "▶3 file command (repo:rev:file)
     elseif command is# 'file'
         else
             setlocal binary noendofline
         endif
-        call setline('.', fcontents)
+        if a:0
+            call append('.', fcontents)
+        else
+            call setline('.', fcontents)
+        endif
         let s:bufvars[buf]={'repo': repo, 'rev': rev, 'file': file}
     "▶3 annotate command (repo:rev:file)
     elseif command is# 'annotate'
         let [repo, rev, file]=s:F.comm.repotuplesplit(tail, 2)
-        let s:bufvars[buf]={'repo': repo, 'rev': rev, 'file': file}
-        setlocal filetype=aurumannotate bufhidden=wipe
+        let s:bufvars[buf]={'repo': repo, 'rev': rev, 'file': file, 'read': a:0}
+        if !a:0
+            setlocal filetype=aurumannotate bufhidden=wipe
+        endif
         runtime ftplugin/aurumannotate.vim
     "▶3 diff command (repo:rev1:rev2:files:opts)
     elseif command is# 'diff'
         call map(opts, '+v:val')
         let s:bufvars[buf]={'repo': repo, 'rev1': rev1, 'rev2': rev2,
                     \       'files': filelist, 'opts': opts}
-        call repo.functions.difftobuffer(repo, buf, rev1, rev2, filelist, opts)
-        setlocal filetype=diff
+        if a:0
+            call append('.', repo.functions.diff(repo, rev1, rev2, filelist, opts))
+        else
+            call repo.functions.difftobuffer(repo, buf, rev1, rev2, filelist, opts)
+            setlocal filetype=diff
+        endif
     "▶3 status command (repo:opts)
     elseif command is# 'status'
         let [repo, opts]=s:F.comm.repotupleoptssplit(tail, 0)
         for key in filter(['rev1', 'rev2'], 'has_key(opts, v:val)')
             let opts[key]=repo.functions.getrevhex(repo, opts[key])
         endfor
-        let s:bufvars[buf]={'repo': repo, 'opts': opts,}
-        setlocal filetype=aurumstatus bufhidden=wipe
+        let s:bufvars[buf]={'repo': repo, 'opts': opts, 'read': a:0}
+        if !a:0
+            setlocal filetype=aurumstatus bufhidden=wipe
+        endif
         runtime ftplugin/aurumstatus.vim
     "▶3 commit command  (repo:user:date:files)
     elseif command is# 'commit'
+        if a:0
+            call s:_f.throw('nocread')
+        endif
         let [repo, user, date, cb, files]=s:F.comm.repotuplesplit(tail, 4)
         let bvar={'repo': repo, 'user': user, 'date': date, 'closebranch': !!cb}
         let bvar.files=map(split(files, '\v%(\\@<!\\%(\\\\)*)@<!;'),
         else
             setlocal binary noendofline
         endif
-        call setline('.', fcontents)
+        if a:0
+            call append('.', fcontents)
+        else
+            call setline('.', fcontents)
+        endif
         let s:bufvars[buf]={'file': tail}
     "▶3 Unknown command
     else
 function s:filefunc.function(rev, file, opts)
     let opts=extend(copy(a:opts), {'rev': a:rev})
     if a:file isnot 0
-        let opts.file=a:file
+        if a:file isnot ':'
+            let opts.file=a:file
+        endif
     endif
     let [hasbuf, repo, rev, file]=s:F.comm.getrrf(opts, 'noffile')
     if repo is 0