[vim] reorganize conf files

This commit is contained in:
Mathieu Maret 2011-05-26 14:01:52 +02:00
parent 27f8bca29a
commit 7be02219d4
10 changed files with 1435 additions and 479 deletions

View File

@ -0,0 +1,63 @@
" Display current function in status bar
"
" Use WhatFunction could create some problems with lines longer that the
" screen size. WhatFunction could be interesting for C++ function
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

1078
.vim/plugin/cctree.vim Normal file

File diff suppressed because it is too large Load Diff

130
.vim/plugin/cscope.vim Normal file
View File

@ -0,0 +1,130 @@
" if compiled with --enable-cscope
if has("cscope")
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" use ctags before cscope
set csto=0
" add any cscope database in current directory
if filereadable("cscope.out")
cscope add cscope.out
endif
" add the database pointed by environment variable.
" Cscope file added from db should contains full path to file. Otherwise they
" should be added with cscope add PATH_TO_CSCOPE_FILE PATH_TO_SRC_ROOT
if $CSCOPE_DB != ""
if filereadable($CSCOPE_DB)
cscope add $CSCOPE_DB
endif
endif
" show message when any other cscope db added
set cscopeverbose
" open include file with F4 and split with shift+F4
nmap <F4> :cscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <S-F4> :scscope find f <C-R>=expand("<cfile>")<CR><CR>
" find this C symbol with F5 and split with shift+F5
nmap <F5> :cscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <S-F5> :scscope find s <C-R>=expand("<cword>")<CR><CR>
" go to definition with F6 and split with shift+F6 and use ctags with alt+shift+F6
nmap <F6> :cscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <S-F6> :scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <M-S-F6> :tag <C-R>=expand("<cword>")<CR><CR>
" go to calls with F7 and split with shift+F7
nmap <F7> :cscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <S-F7> :scscope find c <C-R>=expand("<cword>")<CR><CR>
" go to ... with 'ctrl+s letter' and go back with ctrl+t
nmap <C-s>s :cscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>g :cscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>c :cscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>t :cscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>e :cscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>f :cscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-s>i :cscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-s>d :cscope find d <C-R>=expand("<cword>")<CR><CR>
" split to ... with 'ctrl+space letter'
nmap <C-@>s :scscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :scscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :scscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :scscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :scscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :scscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :scscope find d <C-R>=expand("<cword>")<CR><CR>
" vertical split to ... with 'ctrl+space ctrl+space letter'
nmap <C-@><C-@>s :vertical scscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>g :vertical scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>c :vertical scscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>t :vertical scscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>e :vertical scscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>f :vertical scscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@><C-@>i :vertical scscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@><C-@>d :vertical scscope find d <C-R>=expand("<cword>")<CR><CR>
" s symbol find all references to the token under cursor
" //find this C symbol
" g global find global definition of the token under cursor
" //find this definition
" c calls find all calls to the function name under cursor
" //find function calling this function
" d called find functions that function under cursor calls
" //find function called by this function
" t text find all instances of the text under cursor
" //find this text string
" e egrep egrep search for the word under cursor
" //find this egrep pattern
" f file open the filename under cursor
" //find this file
" i includes find files that include the filename under cursor
" //find files #including this file
function! GetCscopeDb(pathname)
if !isdirectory(a:pathname) || a:pathname == $HOME || a:pathname == '/'
return
endif
let l:has_link = 0
let l:tag_found = 0
if resolve(a:pathname) != a:pathname
let l:has_link = 1
endif
let s:cscopefile = $HOME."/.vim/cscope/".substitute(a:pathname, '/', '_', 'g').".cscope"
if filereadable(s:cscopefile)
execute "cscope add ".s:cscopefile
let l:tag_found = 1
endif
if l:tag_found == 0 && l:has_link == 1
let s:cscopefile = $HOME."/.vim/cscope/".substitute(resolve(a:pathname), '/', '_', 'g').".cscope"
if filereadable(s:cscopefile)
execute "cscope add ".s:cscopefile
let l:tag_found = 1
endif
endif
unlet s:cscopefile
call GetCscopeDb(fnamemodify(a:pathname, ":h"))
endfunction
function! GenerateCscopeDb()
let path = input('Create cscope db for: ', getcwd(), 'dir')
echohl WarningMsg
echo "Please wait, generating cscope db..."
let file = tempname()
let cscopefile = $HOME."/.vim/cscope/".substitute(path, '/', '_', 'g').".cscope"
call system("cd ".path."; find . -name '*.c' -or -name '*.h' > ".file."; cscope -b -i ".file." -f ".cscopefile)
call delete(file)
redraw
echo "Please wait, generating cscope db... Done"
echohl None
call GetCscopeDb(path)
endfunction
command! GenerateCscopeDb :call GenerateCscopeDb()
endif

View File

@ -1,170 +0,0 @@
" Author: Eric Van Dewoestine
"
" Description: {{{
" Plugin which bootstraps the eclim environment.
"
" License:
"
" Copyright (C) 2005 - 2009 Eric Van Dewoestine
"
" This program is free software: you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation, either version 3 of the License, or
" (at your option) any later version.
"
" This program is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
"
" You should have received a copy of the GNU General Public License
" along with this program. If not, see <http://www.gnu.org/licenses/>.
"
" }}}
" Command Declarations {{{
if !exists(":EclimValidate")
command EclimValidate :call <SID>Validate()
endif
" }}}
" Validate() {{{
" Validates some settings and environment values required by eclim.
" NOTE: don't add command-line continuation characters anywhere in the
" function, just in case the user has &compatible set.
function! s:Validate()
" Check vim version.
if v:version < 700
let ver = strpart(v:version, 0, 1) . '.' . strpart(v:version, 2)
echom "Error: Your vim version is " . ver . "."
echom " Eclim requires version 7.x.x"
return
endif
let errors = []
" Check 'compatible' option.
if &compatible
call add(errors, "Error: You have 'compatible' set:")
call add(errors, " Eclim requires 'set nocompatible' in your vimrc.")
call add(errors, " Type \":help 'compatible'\" for more details.")
endif
" Check filetype support
redir => ftsupport
silent filetype
redir END
let ftsupport = substitute(ftsupport, '\n', '', 'g')
if ftsupport !~ 'detection:ON' || ftsupport !~ 'plugin:ON'
echo " "
let chose = 0
while string(chose) !~ '1\|2'
redraw
echo "Filetype plugin support looks to be disabled, but due to possible"
echo "language differences, please check the following line manually."
echo " " . ftsupport
echo "Does it have detection and plugin 'ON'?"
echo "1) Yes"
echo "2) No"
let chose = input("Please Choose (1 or 2): ")
endwhile
if chose != 1
call add(errors, "Error: Eclim requires filetype plugins to be enabled.")
call add(errors, " Please add 'filetype plugin indent on' to your vimrc.")
call add(errors, " Type \":help filetype-plugin-on\" for more details.")
endif
endif
" Print the results.
redraw
echohl Statement
if len(errors) == 0
echom "Result: OK, required settings are valid."
else
for error in errors
echom error
endfor
endif
echohl None
endfunction " }}}
" exit early if unsupported vim version, compatible is set, or eclim is
" disabled.
if v:version < 700 || &compatible || exists("g:EclimDisabled")
finish
endif
" EclimBaseDir() {{{
" Gets the base directory where the eclim vim scripts are located.
function! EclimBaseDir()
if !exists("g:EclimBaseDir")
let savewig = &wildignore
set wildignore=""
let file = findfile('plugin/eclim.vim', escape(&runtimepath, ' '))
let &wildignore = savewig
if file == ''
echoe 'Unable to determine eclim basedir. ' .
\ 'Please report this issue on the eclim user mailing list.'
let g:EclimBaseDir = ''
return g:EclimBaseDir
endif
let basedir = substitute(fnamemodify(file, ':p:h:h'), '\', '/', 'g')
let g:EclimBaseDir = escape(basedir, ' ')
endif
return g:EclimBaseDir
endfunction " }}}
" Init() {{{
" Initializes eclim.
function! s:Init()
" on windows, this eclim plugin gets called first, so force taglist to be
" called prior.
runtime! plugin/taglist.vim
" add eclim dir to runtime path.
let basedir = EclimBaseDir()
if basedir == ''
return
endif
exec 'set runtimepath+=' .
\ basedir . '/eclim,' .
\ basedir . '/eclim/after'
" Alternate version which inserts the eclim path just after the currently
" executing runtime path element and puts the eclim/after path at the very
" end.
"let paths = split(&rtp, ',')
"let index = 0
"for path in paths
" let index += 1
" if tolower(path) == tolower(basedir)
" break
" endif
"endfor
"let tail = paths[index :]
"for path in tail
" exec 'set runtimepath-=' . escape(path, ' ')
"endfor
"exec 'set runtimepath+=' . basedir . '/eclim'
"for path in tail
" exec 'set runtimepath+=' . escape(path, ' ')
"endfor
"exec 'set runtimepath+=' . basedir . '/eclim/after'
" need to be manually sourced
runtime! eclim/plugin/*.vim
runtime! eclim/after/plugin/*.vim
endfunction " }}}
call <SID>Init()
" vim:ft=vim:fdm=marker

Binary file not shown.

View File

@ -1,10 +1,10 @@
" Done in .vimrc
augroup IndentFinder augroup IndentFinder
au! IndentFinder au! IndentFinder
au BufRead *.* let b:indent_finder_result = system('python2 -c "import indent_finder; indent_finder.main()" --vim-output "' . expand('%') . '"' ) au BufRead *.* let b:indent_finder_result = system('python2 -c "import indent_finder; indent_finder.main()" --vim-output "' . expand('%') . '"' )
au BufRead *.* execute b:indent_finder_result au BufRead *.* execute b:indent_finder_result
"
" Uncomment the next line to see which indentation is applied on all your loaded files " " Uncomment the next line to see which indentation is applied on all your loaded files
" au BufRead *.* echo "Indent Finder: " . b:indent_finder_result " " au BufRead *.* echo "Indent Finder: " . b:indent_finder_result
augroup End augroup End

30
.vim/plugin/language.vim Normal file
View File

@ -0,0 +1,30 @@
"""""""""""""""""""""""""""""""""""""""""""
" Language
"""""""""""""""""""""""""""""""""""""""""""
" Using dictd
function! Translate()
let word = expand("<cword>")
let output = system("echo -n $(dict -d eng-fra -f " .word. " 2> /dev/null | tail -n +3 | head -n -1 | sed '1s/$/:/;2,$s/$/;/')")
if output != ""
echohl WarningMsg
echo output
echohl None
else
echohl WarningMsg
echo "No translation found"
echohl None
endif
endfunction
"default Leader is \
nnoremap <silent> <Leader>t :call Translate()<cr>
" to enable spellchecking :set spell"
" c.f. :help spell
" ]s search next misspelled
" [s search previous misspelled
" z= suggestion
" trad files should be under /usr/share/vim/vimfiles/spell
" or .vim/spell
" they can be download at http://ftp.vim.org/vim/runtime/spell/
set spell spelllang=en
set nospell

98
.vim/plugin/mycolor.vim Normal file
View File

@ -0,0 +1,98 @@
"""""""""""
" DISPLAY "
"""""""""""
" color palette
set t_Co=256
" syntax highlighting when the terminal has colors
if &t_Co > 2 || has("gui_running")
syntax on
" my colors
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
if &t_Co == 256
highlight! Normal ctermfg=77 ctermbg=Black
highlight! Statement ctermfg=254 ctermbg=Black
highlight! Comment ctermfg=191 ctermbg=Black
highlight! PreProc ctermfg=200 ctermbg=Black
else
highlight! Normal ctermfg=Green ctermbg=Black
highlight! Statement ctermfg=White ctermbg=Black
highlight! Comment ctermfg=Yellow ctermbg=Black
highlight! PreProc ctermfg=Magenta ctermbg=Black
endif
highlight! Constant ctermfg=Red ctermbg=Black
highlight! def link Structure Statement
highlight! def link StorageClass Statement
highlight! Type ctermfg=Grey ctermbg=Black
highlight! def link Identifier Type
highlight! Todo ctermfg=Black ctermbg=DarkRed
highlight! Search ctermfg=Black ctermbg=Yellow
highlight! def link IncSearch Visual
if &t_Co == 256
highlight! DiffAdd ctermbg=54 cterm=none
highlight! DiffDelete ctermfg=Black ctermbg=54 cterm=none
else
highlight! DiffAdd ctermbg=DarkMagenta cterm=none
highlight! DiffDelete ctermfg=Black ctermbg=DarkMagenta cterm=none
endif
highlight! def link DiffChange DiffAdd
highlight! DiffText ctermfg=White ctermbg=DarkBlue cterm=none
highlight! def link Folded TabLineSel
highlight! def link FoldColumn Folded
highlight! MatchParen ctermbg=Blue
if &t_Co == 256
highlight! BadWhitespace ctermbg=235
elseif &t_Co > 8
highlight! BadWhitespace ctermbg=DarkGrey
else
highlight! BadWhitespace ctermbg=DarkCyan
endif
highlight! Pmenu ctermfg=Grey ctermbg=DarkBlue
if &t_Co > 8
highlight! PmenuSel ctermfg=Yellow ctermbg=Blue
else
highlight! PmenuSel ctermfg=Yellow ctermbg=Cyan
endif
highlight! def link PmenuSbar Pmenu
highlight! PmenuThumb ctermbg=DarkMagenta cterm=none
if &t_Co == 256
highlight! LineNr ctermfg=DarkCyan ctermbg=235
highlight! CursorLine ctermbg=236 cterm=none
else
highlight! LineNr ctermfg=DarkCyan ctermbg=Black
highlight! CursorLine ctermbg=DarkGrey cterm=none
endif
highlight! def link CursorColumn CursorLine
highlight! Visual ctermfg=White ctermbg=Blue cterm=none
highlight! VertSplit ctermfg=Grey ctermbg=Grey cterm=none
highlight! StatusLine ctermfg=Black ctermbg=Grey cterm=none
if &t_Co > 8
highlight! StatusLineNC ctermfg=DarkGrey ctermbg=Grey cterm=none
else
highlight! StatusLineNC ctermfg=Cyan ctermbg=Grey cterm=none
endif
highlight! def link TabLine StatusLineNC
highlight! def link TabLineFill TabLine
if &t_Co == 256
highlight! TabLineSel ctermfg=White ctermbg=235 cterm=none
elseif &t_Co > 8
highlight! TabLineSel ctermfg=White ctermbg=Black cterm=none
else
highlight! TabLineSel ctermfg=White ctermbg=Black
endif
highlight! ModeMsg ctermfg=DarkCyan ctermbg=Black
highlight! WarningMsg ctermfg=Yellow ctermbg=Black
highlight! ErrorMsg ctermfg=Red ctermbg=Black
endif
" define whitespaces at end of line as bad whitespaces
match BadWhitespace /\s\+$/
" define extra spaces at the front of the line as bad whitespaces
match BadWhitespace /^\ \+/
" define redundant whitespaces as bad whitespaces
match BadWhitespace /\s\+$\| \+\ze\t/

337
.vimrc
View File

@ -12,7 +12,7 @@
" S-F8 build ctags/cscope databases " S-F8 build ctags/cscope databases
" M-F8 build kernel ctags/cscope databases " M-F8 build kernel ctags/cscope databases
" F9 view changes " F9 view changes
" F10 folding ? " F10 folding
" F11 unhighlight search " F11 unhighlight search
" F12 paste mode " F12 paste mode
" C-left/right switch tab " C-left/right switch tab
@ -66,92 +66,6 @@ set updatetime=1000
""""""""""" """""""""""
" DISPLAY " " DISPLAY "
""""""""""" """""""""""
" color palette
set t_Co=256
" syntax highlighting when the terminal has colors
if &t_Co > 2 || has("gui_running")
syntax on
" my colors
set background=dark
highlight clear
if exists("syntax_on")
syntax reset
endif
if &t_Co == 256
highlight! Normal ctermfg=77 ctermbg=Black
highlight! Statement ctermfg=254 ctermbg=Black
highlight! Comment ctermfg=191 ctermbg=Black
highlight! PreProc ctermfg=200 ctermbg=Black
else
highlight! Normal ctermfg=Green ctermbg=Black
highlight! Statement ctermfg=White ctermbg=Black
highlight! Comment ctermfg=Yellow ctermbg=Black
highlight! PreProc ctermfg=Magenta ctermbg=Black
endif
highlight! Constant ctermfg=Red ctermbg=Black
highlight! def link Structure Statement
highlight! def link StorageClass Statement
highlight! Type ctermfg=Grey ctermbg=Black
highlight! def link Identifier Type
highlight! Todo ctermfg=Black ctermbg=DarkRed
highlight! Search ctermfg=Black ctermbg=Yellow
highlight! def link IncSearch Visual
if &t_Co == 256
highlight! DiffAdd ctermbg=54 cterm=none
highlight! DiffDelete ctermfg=Black ctermbg=54 cterm=none
else
highlight! DiffAdd ctermbg=DarkMagenta cterm=none
highlight! DiffDelete ctermfg=Black ctermbg=DarkMagenta cterm=none
endif
highlight! def link DiffChange DiffAdd
highlight! DiffText ctermfg=White ctermbg=DarkBlue cterm=none
highlight! def link Folded TabLineSel
highlight! def link FoldColumn Folded
highlight! MatchParen ctermbg=Blue
if &t_Co == 256
highlight! BadWhitespace ctermbg=235
elseif &t_Co > 8
highlight! BadWhitespace ctermbg=DarkGrey
else
highlight! BadWhitespace ctermbg=DarkCyan
endif
highlight! Pmenu ctermfg=Grey ctermbg=DarkBlue
if &t_Co > 8
highlight! PmenuSel ctermfg=Yellow ctermbg=Blue
else
highlight! PmenuSel ctermfg=Yellow ctermbg=Cyan
endif
highlight! def link PmenuSbar Pmenu
highlight! PmenuThumb ctermbg=DarkMagenta cterm=none
if &t_Co == 256
highlight! LineNr ctermfg=DarkCyan ctermbg=235
highlight! CursorLine ctermbg=236 cterm=none
else
highlight! LineNr ctermfg=DarkCyan ctermbg=Black
highlight! CursorLine ctermbg=DarkGrey cterm=none
endif
highlight! def link CursorColumn CursorLine
highlight! Visual ctermfg=White ctermbg=Blue cterm=none
highlight! VertSplit ctermfg=Grey ctermbg=Grey cterm=none
highlight! StatusLine ctermfg=Black ctermbg=Grey cterm=none
if &t_Co > 8
highlight! StatusLineNC ctermfg=DarkGrey ctermbg=Grey cterm=none
else
highlight! StatusLineNC ctermfg=Cyan ctermbg=Grey cterm=none
endif
highlight! def link TabLine StatusLineNC
highlight! def link TabLineFill TabLine
if &t_Co == 256
highlight! TabLineSel ctermfg=White ctermbg=235 cterm=none
elseif &t_Co > 8
highlight! TabLineSel ctermfg=White ctermbg=Black cterm=none
else
highlight! TabLineSel ctermfg=White ctermbg=Black
endif
highlight! ModeMsg ctermfg=DarkCyan ctermbg=Black
highlight! WarningMsg ctermfg=Yellow ctermbg=Black
highlight! ErrorMsg ctermfg=Red ctermbg=Black
endif
" highlight the cursor line " highlight the cursor line
set cursorline set cursorline
" show the status line " show the status line
@ -164,10 +78,39 @@ set showmode
set showcmd set showcmd
" display line number" " display line number"
set number set number
" set status line
set statusline=%<%f\ %h%w%m%r%3.(\ %)%{fugitive#statusline()}%=%([%{Tlist_Get_Tagname_By_Line()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
" always display status line
set laststatus=2
""""""""""""""" """""""""""""""
" INDENTATION " " INDENTATION "
""""""""""""""" """""""""""""""
" use tabs at the start of a line, spaces elsewhere
" set smarttab
set smartindent
set autoindent
" tab=4
set tabstop=4
set softtabstop=4
set shiftwidth=4
" real tabs
set noexpandtab
if has("autocmd")
" python
" autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead,BufNewFile *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufRead,BufNewFile *.py set tabstop=4
autocmd BufRead,BufNewFile *.py set expandtab
autocmd BufRead,BufNewFile *.py set shiftwidth=4
autocmd BufRead,BufNewFile *.py set softtabstop=4
autocmd BufRead,BufNewFile *.py set modeline
endif
if has("autocmd") if has("autocmd")
" enable file type detection and do language-dependent indenting " enable file type detection and do language-dependent indenting
filetype plugin indent on filetype plugin indent on
@ -184,33 +127,6 @@ else
" indent-expr " indent-expr
"set indentexpr "" "set indentexpr ""
endif endif
" tab=4
set tabstop=4
set softtabstop=4
set shiftwidth=4
" real tabs
set noexpandtab
" use tabs at the start of a line, spaces elsewhere
set smarttab
if has("autocmd")
" python
" autocmd FileType python set tabstop=4|set shiftwidth=4|set expandtab
autocmd BufRead,BufNewFile *.py syntax on
autocmd BufRead,BufNewFile *.py set ai
autocmd BufRead,BufNewFile *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufRead,BufNewFile *.py set tabstop=4
autocmd BufRead,BufNewFile *.py set expandtab
autocmd BufRead,BufNewFile *.py set shiftwidth=4
autocmd BufRead,BufNewFile *.py set softtabstop=4
autocmd BufRead,BufNewFile *.py set modeline
endif
" define whitespaces at end of line as bad whitespaces
match BadWhitespace /\s\+$/
" define extra spaces at the front of the line as bad whitespaces
match BadWhitespace /^\ \+/
" define redundant whitespaces as bad whitespaces
match BadWhitespace /\s\+$\| \+\ze\t/
"""""""""" """"""""""
" SEARCH " " SEARCH "
@ -248,6 +164,7 @@ function GoToDefinition()
endfunction endfunction
nmap <silent> , :call GoToDefinition()<CR> nmap <silent> , :call GoToDefinition()<CR>
nmap <silent> ; <C-t> nmap <silent> ; <C-t>
" plugin taglist " plugin taglist
let Tlist_Ctags_Cmd = '/usr/bin/ctags' let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_Process_File_Always = 1 let Tlist_Process_File_Always = 1
@ -265,88 +182,7 @@ let Tlist_Inc_Winwidth = 0
let Tlist_Use_Right_Window = 1 let Tlist_Use_Right_Window = 1
" open/close tag list window with F8 " open/close tag list window with F8
map <silent> <F8> :TlistToggle<CR> map <silent> <F8> :TlistToggle<CR>
" shown current tag in status bar
" 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
set laststatus=2
"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 has("cscope")
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag
" use ctags before cscope
set csto=0
" add any cscope database in current directory
if filereadable("cscope.out")
cscope add cscope.out
endif
" add the database pointed by environment variable.
" Cscope file added from db should contains full path to file. Otherwise they
" should be added with cscope add PATH_TO_CSCOPE_FILE PATH_TO_SRC_ROOT
if $CSCOPE_DB != ""
if filereadable($CSCOPE_DB)
cscope add $CSCOPE_DB
endif
endif
" show message when any other cscope db added
set cscopeverbose
" open include file with F4 and split with shift+F4
nmap <F4> :cscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <S-F4> :scscope find f <C-R>=expand("<cfile>")<CR><CR>
" find this C symbol with F5 and split with shift+F5
nmap <F5> :cscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <S-F5> :scscope find s <C-R>=expand("<cword>")<CR><CR>
" go to definition with F6 and split with shift+F6 and use ctags with alt+shift+F6
nmap <F6> :cscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <S-F6> :scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <M-S-F6> :tag <C-R>=expand("<cword>")<CR><CR>
" go to calls with F7 and split with shift+F7
nmap <F7> :cscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <S-F7> :scscope find c <C-R>=expand("<cword>")<CR><CR>
" go to ... with 'ctrl+s letter' and go back with ctrl+t
nmap <C-s>s :cscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>g :cscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>c :cscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>t :cscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>e :cscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-s>f :cscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-s>i :cscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-s>d :cscope find d <C-R>=expand("<cword>")<CR><CR>
" split to ... with 'ctrl+space letter'
nmap <C-@>s :scscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>g :scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>c :scscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>t :scscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>e :scscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@>f :scscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@>i :scscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@>d :scscope find d <C-R>=expand("<cword>")<CR><CR>
" vertical split to ... with 'ctrl+space ctrl+space letter'
nmap <C-@><C-@>s :vertical scscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>g :vertical scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>c :vertical scscope find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>t :vertical scscope find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>e :vertical scscope find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-@><C-@>f :vertical scscope find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-@><C-@>i :vertical scscope find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <C-@><C-@>d :vertical scscope find d <C-R>=expand("<cword>")<CR><CR>
" s symbol find all references to the token under cursor
" //find this C symbol
" g global find global definition of the token under cursor
" //find this definition
" c calls find all calls to the function name under cursor
" //find function calling this function
" d called find functions that function under cursor calls
" //find function called by this function
" t text find all instances of the text under cursor
" //find this text string
" e egrep egrep search for the word under cursor
" //find this egrep pattern
" f file open the filename under cursor
" //find this file
" i includes find files that include the filename under cursor
" //find files #including this file
endif
" cat Makefile | grep '\-I\/' | tr '[:space:]' '\n' | grep '\-I/' | sort -u | tr '\n' ' ' " cat Makefile | grep '\-I\/' | tr '[:space:]' '\n' | grep '\-I/' | sort -u | tr '\n' ' '
" build tags database with shift+F8 or alt+F8 to ignore /usr/include " build tags database with shift+F8 or alt+F8 to ignore /usr/include
@ -528,23 +364,6 @@ set tags+=~/.vim/qttags
set tags+=~/.vim/qtembedded set tags+=~/.vim/qtembedded
set tags+=~/.vim/tags/linux-sh4-ST-2.6.23.17 set tags+=~/.vim/tags/linux-sh4-ST-2.6.23.17
" Affichage du prototype d'une fonction sur le
" plugin echofunc
" Eclim
command -range -nargs=* Google call eclim#web#SearchEngine(
\ 'http://www.google.com/search?q=<query>', <q-args>, <line1>, <line2>)
" QT manual with C-b
function! QtClassDoc()
let qt_dir = "/usr/share/qt4/doc/html/"
let class = tolower(expand("<cword>"))
silent execute "!x-www-browser " . qt_dir . class . ".html &>/dev/null" . " &" | redraw!
endfunction
nmap <silent> <C-b> :call QtClassDoc()<CR>
"""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""
"Poser une marque visible avec F7 "Poser une marque visible avec F7
""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""
@ -554,98 +373,6 @@ nmap <silent> <C-b> :call QtClassDoc()<CR>
"map <C-F7> :sign unplace<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()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
" Use WhatFunction could create some problems with lines longer that the
" screen size. WhatFunction could be interesting for C++ function
" set statusline=%<%f\ %h%w%m%r%3.(\ %)%{fugitive#statusline()}%=%([%{Tlist_Get_Tagname_By_Line()}%{WhatFunction()}]%)%3.(\ %)%-14.(%l,%c%V%)\ %P
"""""""""""""""""""""""""""""""""""""""""""
" Language
"""""""""""""""""""""""""""""""""""""""""""
" Using dictd
function! Translate()
let word = expand("<cword>")
let output = system("echo -n $(dict -d eng-fra -f " .word. " 2> /dev/null | tail -n +3 | head -n -1 | sed '1s/$/:/;2,$s/$/;/')")
if output != ""
echohl WarningMsg
echo output
echohl None
else
echohl WarningMsg
echo "No translation found"
echohl None
endif
endfunction
"default Leader is \
nnoremap <silent> <Leader>t :call Translate()<cr>
" to enable spellchecking :set spell"
" c.f. :help spell
" ]s search next misspelled
" [s search previous misspelled
" z= suggestion
" trad files should be under /usr/share/vim/vimfiles/spell
" or .vim/spell
" they can be download at http://ftp.vim.org/vim/runtime/spell/
set spell spelllang=en
set nospell
""""""""""""" """""""""""""
" Latex " " Latex "