]> Sergey Matveev's repositories - codecomm.git/blobdiff - plugin/codecomm.vim
codecomm filetype syntax highlight
[codecomm.git] / plugin / codecomm.vim
index 9226b4239e57ad15f64cef2f2451e54feb8d997c..c13f3787fb0eefca3a3b8ba4d9667de6e3127043 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
@@ -51,9 +53,8 @@ function! s:CodeComm() range
         execute cmd
     endfor
     " Spawn a new small code commenting window nonbinded to file
-    new +set\ noreadonly CodeCommCommenting
-    setlocal noswapfile
-    setlocal buftype=acwrite
+    new CodeCommCommenting
+    setlocal noreadonly noswapfile buftype=acwrite filetype=codecomm
     call append("^", ready)
     " Separate codecomm_file consolidating function, called when buffer is saved
     autocmd! BufWriteCmd CodeCommCommenting
@@ -70,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
@@ -84,5 +82,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>