]> Sergey Matveev's repositories - codecomm.git/blobdiff - plugin/codecomm.vim
Trivial CodeCommEdit
[codecomm.git] / plugin / codecomm.vim
index 3a552be1c57d7b7eb35ac6ac2c773dcbc3e41633..00efad25d0c739e6296c3ed315137dd817999bd2 100644 (file)
@@ -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,10 +45,16 @@ 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
     call append("^", ready)
     " Separate codecomm_file consolidating function, called when buffer is saved
     autocmd! BufWriteCmd CodeCommCommenting
@@ -77,5 +85,6 @@ function! s:CodeCommClear()
 endfunction
 
 command! CodeCommClear call <SID>CodeCommClear()
+command! CodeCommEdit :execute "edit " . g:codecomm_file
 command! -range CodeComm <line1>, <line2> call <SID>CodeComm()
 vnoremap <silent><Leader>cc :call <SID>CodeComm()<CR>