X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=plugin%2Fcodecomm.vim;h=27bd890d4be5020c83b604e16a35ccec9d81bcc3;hb=ed4e098bc2052fd305cb8517ab5c094c66f00657;hp=3a552be1c57d7b7eb35ac6ac2c773dcbc3e41633;hpb=2ca6e9439d81be8f59b4e8eb59ed3b19d629a32e;p=codecomm.git diff --git a/plugin/codecomm.vim b/plugin/codecomm.vim index 3a552be..27bd890 100644 --- a/plugin/codecomm.vim +++ b/plugin/codecomm.vim @@ -6,7 +6,9 @@ if exists("g:loaded_codecomm") | finish | endif let g:loaded_codecomm = 1 if !exists("g:codecomm_file") - let g:codecomm_file = "/tmp/codecomm.txt" + let tmpdir = getenv("TMPDIR") + if tmpdir == v:null | let tmpdir = "/tmp" | endif + let g:codecomm_file = tmpdir . "/" . "codecomm.txt" endif if !exists("g:codecomm_count") | let g:codecomm_count = 0 | endif @@ -43,16 +45,22 @@ function! s:CodeComm() range let ready = add(ready, fmted) endfor let ready = add(ready, "---------------------------------- >8 ----------------------------------") + " Place commented signs + sign define commented text=C texthl=Search + for linen in range(a:firstline, a:lastline) + let cmd = ":sign place " . linen . " line=" . linen + let cmd .= " name=commented buffer=" . bufnr("%") + execute cmd + endfor " Spawn a new small code commenting window nonbinded to file new CodeCommCommenting - setlocal noswapfile - setlocal buftype=acwrite + setlocal noreadonly noswapfile buftype=acwrite filetype=codecomm call append("^", ready) " Separate codecomm_file consolidating function, called when buffer is saved autocmd! BufWriteCmd CodeCommCommenting function! s:AppendCC() " Collect already written comments from file if it exists - let ccprev = [] + let ccprev = [" vim: filetype=codecomm", ""] if filereadable(g:codecomm_file) let ccprev = readfile(g:codecomm_file) endif @@ -63,9 +71,6 @@ function! s:CodeComm() range echohl MoreMsg | echomsg "Commented:" len(ready) "lines" | echohl None endfunction autocmd BufWriteCmd CodeCommCommenting call s:AppendCC() - " Simple syntax highlighting for that window - syntax region CCBlock start=/^-\{5}#/ end=/^-\+ >8 -\+/ - highlight link CCBlock Statement normal zR startinsert endfunction @@ -77,5 +82,6 @@ function! s:CodeCommClear() endfunction command! CodeCommClear call CodeCommClear() +command! CodeCommEdit :execute "edit " . g:codecomm_file command! -range CodeComm , call CodeComm() vnoremap cc :call CodeComm()