Files
libuev/.stuff/.vimrc.priv
T
2011-01-11 15:20:06 +01:00

174 lines
5.1 KiB
Plaintext

"
" Extra vim stuff
"
map `h <Plug>jdocConvertHere
map `c <Plug>jdocConvertCompact
nmap <F2> :call SetCHdr()<CR>
map gy "*y
map gp "*p
map g]p "*]p
map g[P "*[P
function! SetCHdr()
call append(0, ["/**",
\ " * @file ".strpart(bufname("%"), strridx(bufname("%"), "/")+1),
\ " * ABSTRACT HERE << ",
\ " *",
\ " * $Id$",
\ " *",
\ " * (C) Copyright ".strftime("%Y")." Amplex, ".$USER."@amplex.dk",
\ " */"])
call append(line('$'), ["", "// vim: set sw=3 sts=3 et:"])
normal 5G$
set sw=3 sts=3 et
endfunction
function! TextEnableCodeSnip(filetype,start,end) abort
let ft=toupper(a:filetype)
let group='textGroup'.ft
if exists('b:current_syntax')
let s:current_syntax=b:current_syntax
" Remove current syntax definition, as some syntax files (e.g. cpp.vim)
" do nothing if b:current_syntax is defined.
unlet b:current_syntax
endif
execute 'syntax include @'.group.' syntax/'.a:filetype.'.vim'
try
execute 'syntax include @'.group.' after/syntax/'.a:filetype.'.vim'
catch
endtry
if exists('s:current_syntax')
let b:current_syntax=s:current_syntax
else
unlet b:current_syntax
endif
exe 'syntax region textSnip'.ft.
\ ' matchgroup=textSnip '.
\ ' start="'.a:start.'" end="'.a:end.'" '.
\ ' contains=@'.group.' containedin=ALL'
hi link textSnip SpecialComment
endfunction
autocmd Private FileType sh call TextEnableCodeSnip('lua', '--LUA--', '--EOF--') |
\ call TextEnableCodeSnip('awk', '#AWK#', '#EOF#')
nmap gmd :Glimpse NodeType.<C-R><C-W><CR>
let vimrcdir = expand("<sfile>:h").".vim/macros"
func! CciPostLoad(Pattern, File)
augroup CciAutoLoad
exe "autocmd BufNewFile ".a:Pattern "source ".g:vimrcdir."/".a:File
\ ." |let b:isNew = 1 | autocmd! CciAutoLoad BufNewFile ".a:Pattern
augroup CCIstart
exe "autocmd BufNewFile ".a:Pattern "let b:autohdr = 1"
augroup END
endfunc
call CciPostLoad("GLM::*", "srcmgr.vim")
call CciPostLoad("GLW::*", "srcmgr.vim")
delfunction CciPostLoad
"exe "source ".expand("<sfile>:h")."/dot/usr/vim/"."utils.vim"
"exe "source ".expand("<sfile>:h")."/dot/usr/vim/"."newfmgr.vim"
nmap gG :call OpenSpec("GLW::<C-R><C-W>")<CR>
vmap gG :call VisualOpenSpec("GLM::")<CR>
command! -nargs=1 Glimpse call OpenSpec("GLM::<args>")
command! -nargs=1 GlimpseW call OpenSpec("GLW::<args>")
func! OpenSpec(str)
let Str = a:str
exe "edit ".Str
call histadd("cmd", "edit ".Str)
endfunction
func! VisualOpenSpec(Pre)
let Col1 = col("'<")
let Col2 = col("'>")
if line("'<") != line("'>") | return | endif
let Str = strpart(getline(line("'<")), Col1 - 1, Col2 - Col1)
let Str = substitute(Str, " ", ".", "g")
call OpenSpec(a:Pre.Str)
endfunc
set statusline=%<%f%=\ %2*%{VimBuddy()}%*\ %([%1*%M\%*%n%R\%Y
\%{VarExists(',GZ','b:zipflag')}]%)\ %02c%V(%02B)C\ %3l/%LL\ %P
highlight User2 ctermfg=blue ctermbg=gray guifg=darkblue guibg=gray
" OK. So here is the infamous VimBuddy. You can delete it, if it is not
" referenced from your 'statusline'
function! VimBuddy()
" Take a copy for others to see the messages
if ! exists("s:vimbuddy_msg")
let s:vimbuddy_msg = v:statusmsg
endif
if ! exists("s:vimbuddy_warn")
let s:vimbuddy_warn = v:warningmsg
endif
if ! exists("s:vimbuddy_err")
let s:vimbuddy_err = v:errmsg
endif
if ! exists("s:vimbuddy_onemore")
let s:vimbuddy_onemore = ""
endif
if g:actual_curbuf != bufnr("%")
" Not my buffer, sleeping
return "|-o"
elseif s:vimbuddy_err != v:errmsg
let v:errmsg = v:errmsg . " "
let s:vimbuddy_err = v:errmsg
return ":-("
elseif s:vimbuddy_warn != v:warningmsg
let v:warningmsg = v:warningmsg . " "
let s:vimbuddy_warn = v:warningmsg
return "(-:"
elseif s:vimbuddy_msg != v:statusmsg
let v:statusmsg = v:statusmsg . " "
let s:vimbuddy_msg = v:statusmsg
let test = matchstr(v:statusmsg, 'lines *$')
let num = substitute(v:statusmsg, '^\([0-9]*\).*', '\1', '') + 0
" How impressed should we be
if test != "" && num > 20
let str = ":-O"
elseif test != "" && num
let str = ":-o"
else
let str = ":-/"
endif
let s:vimbuddy_onemore = str
return str
elseif s:vimbuddy_onemore != ""
let str = s:vimbuddy_onemore
let s:vimbuddy_onemore = ""
return str
endif
if ! exists("b:lastcol")
let b:lastcol = col(".")
endif
if ! exists("b:lastlineno")
let b:lastlineno = line(".")
endif
let num = b:lastcol - col(".")
let b:lastcol = col(".")
if (num == 1 || num == -1) && b:lastlineno == line(".")
" Let VimBuddy rotate his nose
let num = b:lastcol % 4
if num == 0
let ch = '/'
elseif num == 1
let ch = '-'
elseif num == 2
let ch = '\'
else
let ch = '|'
endif
return ":" . ch . ")"
endif
let b:lastlineno = line(".")
" Happiness is my favourite mood
return ":-)"
endfunction