[vim] add current function name in status line
This commit is contained in:
parent
bc85901612
commit
ac8abd1629
72
.vimrc
72
.vimrc
@ -54,7 +54,7 @@ set backspace=indent,eol,start
|
|||||||
" don't use Ex mode, use Q for formatting
|
" don't use Ex mode, use Q for formatting
|
||||||
map Q gq
|
map Q gq
|
||||||
" disable mouse
|
" disable mouse
|
||||||
set mouse=a
|
set mouse=a
|
||||||
" key combination timeout
|
" key combination timeout
|
||||||
set notimeout
|
set notimeout
|
||||||
"set timeoutlen=4000
|
"set timeoutlen=4000
|
||||||
@ -255,7 +255,7 @@ let Tlist_Display_Prototype = 0
|
|||||||
let Tlist_Display_Tag_Scope = 0
|
let Tlist_Display_Tag_Scope = 0
|
||||||
let Tlist_Show_One_File = 1
|
let Tlist_Show_One_File = 1
|
||||||
let Tlist_Compact_Format = 1
|
let Tlist_Compact_Format = 1
|
||||||
let Tlist_Enable_Fold_Column = 0
|
let Tlist_Enable_Fold_Column = 1
|
||||||
"let Tlist_File_Fold_Auto_Close = 1
|
"let Tlist_File_Fold_Auto_Close = 1
|
||||||
let Tlist_Inc_Winwidth = 0
|
let Tlist_Inc_Winwidth = 0
|
||||||
"let Tlist_Use_Horiz_Window = 1
|
"let Tlist_Use_Horiz_Window = 1
|
||||||
@ -266,7 +266,7 @@ map <silent> <F8> :TlistToggle<CR>
|
|||||||
" set statusline=%<%f\ %h%m%r%=%([%{Tlist_Get_Tagname_By_Line()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
|
" set statusline=%<%f\ %h%m%r%=%([%{Tlist_Get_Tagname_By_Line()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
|
||||||
" include Git status(plugin vim-fugitiv) and tag name in status
|
" include Git status(plugin vim-fugitiv) and tag name in status
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
set statusline=%<%f\ %h%w%m%r%3.(\ %)%{fugitive#statusline()}%=%([%{Tlist_Get_Tagname_By_Line()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
|
"set statusline=%<%f\ %h%w%m%r%3.(\ %)%{fugitive#statusline()}%=%([%{Tlist_Get_Tagname_By_Line()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
|
||||||
" if compiled with --enable-cscope
|
" if compiled with --enable-cscope
|
||||||
if has("cscope")
|
if has("cscope")
|
||||||
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
|
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
|
||||||
@ -496,4 +496,70 @@ endfunction
|
|||||||
|
|
||||||
nmap <silent> <C-b> :call QtClassDoc()<CR>
|
nmap <silent> <C-b> :call QtClassDoc()<CR>
|
||||||
|
|
||||||
|
""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
"Poser une marque visible avec F7
|
||||||
|
"""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
|
"hi Mark guibg=indianred guifg=white gui=bold cterm=bold ctermfg=7 ctermbg=1
|
||||||
|
"sign define mark text=!> texthl=Mark
|
||||||
|
"map <F7> :exe 'sign place 001 name=mark line='.line(".").' buffer='.winbufnr(0)<CR>
|
||||||
|
"map <C-F7> :sign unplace<CR>
|
||||||
|
|
||||||
|
|
||||||
|
function! GetProtoLine()
|
||||||
|
let ret = ""
|
||||||
|
let line_save = line(".")
|
||||||
|
let col_save = col(".")
|
||||||
|
let top = line_save - winline() + 1
|
||||||
|
let so_save = &so
|
||||||
|
let &so = 0
|
||||||
|
let istypedef = 0
|
||||||
|
" find closing brace
|
||||||
|
let closing_lnum = search('^}','cW')
|
||||||
|
if closing_lnum > 0
|
||||||
|
if getline(line(".")) =~ '\w\s*;\s*$'
|
||||||
|
let istypedef = 1
|
||||||
|
let closingline = getline(".")
|
||||||
|
endif
|
||||||
|
" go to the opening brace
|
||||||
|
normal! %
|
||||||
|
" if the start position is between the two braces
|
||||||
|
if line(".") <= line_save
|
||||||
|
if istypedef
|
||||||
|
let ret = matchstr(closingline, '\w\+\s*;')
|
||||||
|
else
|
||||||
|
" find a line contains function name
|
||||||
|
let lnum = search('^\w','bcnW')
|
||||||
|
if lnum > 0
|
||||||
|
let ret = getline(lnum)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
" restore position and screen line
|
||||||
|
exe "normal! " . top . "Gz\<CR>"
|
||||||
|
call cursor(line_save, col_save)
|
||||||
|
let &so = so_save
|
||||||
|
return ret
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! WhatFunction()
|
||||||
|
if &ft != "c" && &ft != "cpp"
|
||||||
|
return ""
|
||||||
|
endif
|
||||||
|
let proto = GetProtoLine()
|
||||||
|
if proto == ""
|
||||||
|
return "?"
|
||||||
|
endif
|
||||||
|
if stridx(proto, '(') > 0
|
||||||
|
let ret = matchstr(proto, '\w\+(\@=')
|
||||||
|
elseif proto =~# '\<struct\>'
|
||||||
|
let ret = matchstr(proto, 'struct\s\+\w\+')
|
||||||
|
elseif proto =~# '\<class\>'
|
||||||
|
let ret = matchstr(proto, 'class\s\+\w\+')
|
||||||
|
else
|
||||||
|
let ret = strpart(proto, 0, 15) . "..."
|
||||||
|
endif
|
||||||
|
return ret
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
set statusline=%<%f\ %h%w%m%r%3.(\ %)%{fugitive#statusline()}%=%([%{Tlist_Get_Tagname_By_Line()}%{WhatFunction()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
|
||||||
|
Loading…
Reference in New Issue
Block a user