Git Product home page Git Product logo

srcexpl's Introduction

SrcExpl

SrcExpl (Source Explorer) is a source code explorer that provides context for the currently selected keyword by displaying the function or type definition or declaration in a separate window. This plugin aims to recreate the context window available in the IDE.

Features

  • Display definitions and declarations of various languages supported by ctags and various types including functions, macros, structures, arrays, methods, classes, and variables.
  • Jump to the displayed context in the Source Explorer window using the mouse or your own key mapping.
  • Jump back from the context location with the mouse context menu or your own key mapping.
  • Automatically list all definitions if multiple definitions for a keyword is found.
  • Automatically create and update the tags file.

Installation

  1. Ensure ctags is installed on your system and that VIM can use it.
  2. Place the Source Explorer files in your Vim directory (such as ~/.vim) or have it installed by a bundle manager like Vundle or NeoBundle.
  3. Open the Source Explorer window with :SrcExpl or :SrcExplToggle or map these commands to keys in your .vimrc.

Requirements

Source Explorer requires:

  • Vim 7.0 or higher
  • ctags

Screenshots

One Declaration Found

One Declaration Found

Multiple Declarations Found

Multiple Declarations Found

Local Declaration Found

Local Declaration Found

Settings Example

" // The switch of the Source Explorer 
nmap <F8> :SrcExplToggle<CR> 

" // Set the height of Source Explorer window 
let g:SrcExpl_winHeight = 8 

" // Set 100 ms for refreshing the Source Explorer 
let g:SrcExpl_refreshTime = 100 

" // Set "Enter" key to jump into the exact definition context 
let g:SrcExpl_jumpKey = "<ENTER>" 

" // Set "Space" key for back from the definition context 
let g:SrcExpl_gobackKey = "<SPACE>" 

" // In order to avoid conflicts, the Source Explorer should know what plugins except
" // itself are using buffers. And you need add their buffer names into below list
" // according to the command ":buffers!"
let g:SrcExpl_pluginList = [
        \ "__Tag_List__",
        \ "_NERD_tree_",
        \ "Source_Explorer"
    \ ]

" // The color schemes used by Source Explorer. There are five color schemes
" // supported for now - Red, Cyan, Green, Yellow and Magenta. Source Explorer
" // will pick up one of them randomly when initialization.
let g:SrcExpl_colorSchemeList = [
        \ "Red",
        \ "Cyan",
        \ "Green",
        \ "Yellow",
        \ "Magenta"
    \ ]

" // Enable/Disable the local definition searching, and note that this is not 
" // guaranteed to work, the Source Explorer doesn't check the syntax for now. 
" // It only searches for a match with the keyword according to command 'gd' 
let g:SrcExpl_searchLocalDef = 1 

" // Workaround for Vim bug @https://goo.gl/TLPK4K as any plugins using autocmd for
" // BufReadPre might have conflicts with Source Explorer. e.g. YCM, Syntastic etc.
let g:SrcExpl_nestedAutoCmd = 1

" // Do not let the Source Explorer update the tags file when opening 
let g:SrcExpl_isUpdateTags = 0 

" // Use 'Exuberant Ctags' with '--sort=foldcase -R .' or '-L cscope.files' to 
" // create/update the tags file 
let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R ." 

" // Set "<F12>" key for updating the tags file artificially 
let g:SrcExpl_updateTagsKey = "<F12>" 

" // Set "<F3>" key for displaying the previous definition in the jump list 
let g:SrcExpl_prevDefKey = "<F3>" 

" // Set "<F4>" key for displaying the next definition in the jump list 
let g:SrcExpl_nextDefKey = "<F4>" 

Changelog

6.0
- Add color scheme feature - The user is able to easily identify the specific
  window by the color used for highlight when there are multi-windows open
  at the same time.
- Add a workaround for Vim bug @https://goo.gl/TLPK4K as any plugins using
  autocmd for BufReadPre might have conflicts with Source Explorer. e.g. YCM,
  Syntastic etc. - https://github.com/wesleyche/SrcExpl/issues/6
- Bug fix - https://github.com/wesleyche/SrcExpl/issues/4

5.3
- Fix a bug when operating the Quickfix window after closing the Source Explorer window.
- Handle the case when the cursor is located at the Quickfix window as same as other
  external plugins.

5.2
- Add the fast way for displaying the previous or next definition in the jump list.
  The new feature is similar with the commands called cprev and cnext for operating
  the Quickfix list. You can add below config lines in your .vimrc or just update your
  Trinity to v2.1.
    1. " // Set "<F3>" key for displaying the previous definition in the jump list 
       let g:SrcExpl_prevDefKey = "<F3>" 
    2. " // Set "<F4>" key for displaying the next definition in the jump list 
       let g:SrcExpl_nextDefKey = "<F4>" 
- Fix a bug when clicking the default prompt line in the Source Explorer window.

5.1
- Added two APIs for serving other plugins:
    1. SrcExpl_GetWin(), getting the Source Explorer window number for those plugins
       based on multiple windows.
    2. SrcExpl_GetVer(), getting the Source Explorer version for the forward compatibility.
- Added debug/logging functions for the internal development.

5.0
- Replaced use of preview window with a named buffer.
- Moved to github.
- Added documentation.

srcexpl's People

Contributors

naruyan avatar wenlongche avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

srcexpl's Issues

Use "nnoremap <buffer>" instead of mapping/unmapping keys?

Instead of mapping/unmapping the jump key and double click when entering/leaving srcexpl window, could you just use nnoremap for the mapping? This way the user don't the use only need to specific other plugins in SrcExpl_pluginList. He can simply map a custom key for "SrcExpl_GoBack".

Cursor jumps to top of source file

This seems to be a continuous issue. I love the script, but on linux I cannot get it to work. As I scroll down using any method, the cursor jumps back to the top of the file, normally not getting past the license part (40 or so lines).

Here is my vimrc if it helps. I have tried commenting out almost everything

set runtimepath+=~/.vim/addons/vam

:function! DirCheck()
:let homedir = $PWD
: if finddir("src", homedir."../;") != ""
: return "../src/"
: else
: return = "."
: endif
:endfunction

" call vam#ActivateAddons(['hg:http://hg.dfrank.ru/vim/bundle/dfrank_util'])
" call vam#ActivateAddons(['hg:http://hg.dfrank.ru/vim/bundle/vimprj'])
" call vam#ActivateAddons(['github:Shougo/vimproc.vim'])
call vam#ActivateAddons(['github:vim-scripts/taglist.vim'])
call vam#ActivateAddons(['github:plasticboy/vim-markdown'])
call vam#ActivateAddons(['github:wesleyche/SrcExpl'])
call vam#ActivateAddons(['github:wesleyche/Trinity'])
let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src"
let g:SrcExpl_pluginList = [ "Tag_List", "NERD_tree", "Quickfix List", "unite" ]
let g:SrcExpl_isUpdateTags = 0
" // Set the height of Source Explorer window
let g:SrcExpl_winHeight = 8

" // Set 100 ms for refreshing the Source Explorer
let g:SrcExpl_refreshTime = 100

" // Set "Enter" key to jump into the exact definition context
" let g:SrcExpl_jumpKey = ""

" // Set "Space" key for back from the definition context
" let g:SrcExpl_gobackKey = ""

"let g:vim_markdown_folding_disabled=1
call vam#ActivateAddons(['github:mattn/webapi-vim']) " for gist"
call vam#ActivateAddons(['github:mattn/gist-vim'])
"requires git config --global github.user Username
call vam#ActivateAddons(['github:vimoutliner/vimoutliner'])
call vam#ActivateAddons(['github:int3/vim-extradite'])
call vam#ActivateAddons(['github:kien/ctrlp.vim'])
let g:ctrlp_use_caching = 1
let g:ctrlp_max_files = 100000
let g:ctrlp_clear_cache_on_exit = 1
set wildignore+=/tmp/,.so,.swp,.zip,/build*/
nnoremap p :CtrlP ../src
call vam#ActivateAddons(['github:proyvind/Cpp11-Syntax-Support'])
call vam#ActivateAddons(['github:Valloric/YouCompleteMe'])
nnoremap j :YcmCompleter GoToDefinitionElseDeclaration
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_key_invoke_completion = ''
let g:ycm_confirm_extra_conf = 0

call vam#ActivateAddons(['github:scrooloose/syntastic'])
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
let g:syntastic_cpp_remove_include_errors = 1
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_check_on_open = 1
let g:syntastic_enable_signs = 1 " Put errors on left side
let g:syntastic_auto_loc_list = 0 " Only show errors when I ask
let g:syntastic_disabled_filetypes = ['html', 'js']
hi SpellBad ctermfg=007 ctermbg=000
hi SpellCap ctermfg=007 ctermbg=000
if has('unix')
let g:syntastic_error_symbol='★'
let g:syntastic_style_error_symbol='>'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_style_warning_symbol='>'
else
let g:syntastic_error_symbol='!'
let g:syntastic_style_error_symbol='>'
let g:syntastic_warning_symbol='.'
let g:syntastic_style_warning_symbol='>'
endif
"call vam#ActivateAddons(['github:flazz/vim-colorschemes'])
call vam#ActivateAddons(['github:Raimondi/delimitMate'])
call vam#ActivateAddons(['github:szw/vim-tags'])
" Create an empty tags dir in project root"
let g:vim_tags_project_tags_command = "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src 2>/dev/null"
let g:vim_tags_auto_generate = 1
let g:vim_tags_ignore_files = ['.gitignore', '.svnignore', '.cvsignore', 'build*']
call vam#ActivateAddons(['github:tpope/vim-fugitive'])
call vam#ActivateAddons(['github:xolox/vim-session'])
let g:session_autosave = 'yes'
let g:session_autoload = 'no'
call vam#ActivateAddons(['github:tomtom/tcomment_vim'])
call vam#ActivateAddons(['github:scrooloose/nerdtree'])
" " NerdTree"
" " Prevent :bd inside NERDTree buffer
au FileType nerdtree cnoreabbrev bd
au FileType nerdtree cnoreabbrev BD
au BufRead,BufNewFile *.md set filetype=markdown
set spelllang=en_gb
autocmd Filetype markdown setlocal wrap spell

nnoremap n :NERDTree ../src
" NERDTree settings
let NERDTreeChDirMode=0
let NERDTreeIgnore=['\env','>vim$', '$', '&gt;pyc$', '>swp$', '>egg-info$', '>DS_Store$', '^dist$', '^build$']
let NERDTreeSortOrder=['^__>py$', '/$', '*', '>swp$', '
$']
let NERDTreeShowBookmarks=1
let NERDTreeHightlight=1

call vam#ActivateAddons(['github:Lokaltog/vim-easymotion'])
let g:EasyMotion_leader_key = ''
" call vam#ActivateAddons(['github:ervandew/supertab'])
call vam#ActivateAddons(['github:altercation/vim-colors-solarized'])
let g:solarized_termcolors = 16

syntax enable
set t_Co=16
set background=dark
colorscheme solarized
call vam#ActivateAddons(['github:SirVer/ultisnips'])
let g:rainbow_ctermfgs = [
\ 'brown',
\ 'Darkblue',
\ 'darkgreen',
\ 'darkcyan',
\ 'darkred',
\ 'darkmagenta',
\ 'darkmagenta',
\ 'Darkblue',
\ 'darkgreen',
\ 'darkcyan',
\ 'darkred',
\ 'red',
\ ]
call vam#ActivateAddons(['github:oblitum/rainbow'])
let g:rainbow_active = 1
" C++
au FileType cpp,objcpp set syntax=cpp11
au BufNewFile,BufRead *
\ if expand('%:e') =~ '^(h|hh|hxx|hpp|ii|ixx|ipp|inl|txx|tpp|tpl|cc|cxx|cpp)$' |
\ if &ft != 'cpp' |
\ set ft=cpp |
\ endif |
\ endif |

let g:rainbow_operators = 2
au FileType c,cpp,objc,objcpp call rainbow#activate()
autocmd BufRead *.lyx set syntax=lyx foldmethod=syntax foldcolumn=3
autocmd BufRead *.lyx syntax sync fromstart

filetype plugin indent on
" reset to vim-defaults
if &compatible " only if not set before:
set nocompatible " use vim-defaults instead of vi-defaults (easier, more user friendly)
endif

" display settings
set textwidth=0
set wrapmargin=0
set nowrap " don't wrap lines
set linebreak
set nolist
set fo+=l
set scrolloff=2 " 2 lines above/below cursor when scrolling
set number " show line numbers
set showmatch " show matching bracket (briefly jump)
set showmode " show mode in status bar (insert/replace/...)
set showcmd " show typed command in status bar
set ruler " show cursor position in status bar
set title " show file in titlebar
set wildmenu " completion with menu
set wildignore=.o,.obj,.bak,.exe,.py[co],.swp,~,.pyc,.svn
set laststatus=2 " use 2 lines for the status bar
set matchtime=2 " show matching bracket for 0.2 seconds
set matchpairs+=<:> " specially for html

" editor settings
set esckeys " map missed escape sequences (enables keypad keys)
set ignorecase " case insensitive searching
set smartcase " but become case sensitive if you type uppercase characters
set smartindent " smart auto indenting
set smarttab " smart tab handling for indenting
set magic " change the way backslashes are used in search patterns
set bs=indent,eol,start " Allow backspacing over everything in insert mode

set tabstop=2 " number of spaces a tab counts for
set shiftwidth=2 " spaces for autoindents
set expandtab " turn a tabs into spaces

set fileformat=unix " file mode is unix
"set fileformats=unix,dos # only detect unix file format, displays that ^M with dos files
set noautochdir
" system settings
" set lazyredraw " no redraws in macros
set confirm " get a dialog when :q, :w, or :wq fails
set nobackup " no backup~ files.
set viminfo='20,"500 " remember copy registers after quitting in the .viminfo file'
set hidden " remember undo after quitting
set history=100 " keep 50 lines of command history
set mouse=a " use mouse in visual, normal,insert,command,help mode (shift key disables)
set undodir=~/.vim/undodir
set undofile
set undolevels=10000 "maximum number of changes that can be undone
set undoreload=100000 "maximum number lines to save for undo on a buffer reload
set incsearch
" color settings (if terminal/gui supports it)
if &t_Co > 2 || has("gui_running")
syntax on " enable colors
set hlsearch " highlight search (very useful!)
set incsearch "search incremently (search while typing)
endif
let Tlist_Ctags_Cmd = "/usr/bin/ctags"
let Tlist_WinWidth = 50
"set makeprg=clang++\ -std=c++11\ -stdlib=libc++\ -lc++abi\ -ldl\ -o\ %<\ %
nmap :cnext
nmap :cprev
map :TlistToggle
set tags=./tags,tags;
map :tab split:exec("tag ".expand(""))
map <A-]> :vsp :exec("tag ".expand(""))
noremap zA
nnoremap zA
onoremap zA
vnoremap zf
noremap zR
map :setlocal spell! spelllang=en_gb
" map :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src
"open and close all the three plugins on the same time

nmap :TrinityToggleAll

" Open and close the srcexpl.vim separately
nmap :TrinityToggleSourceExplorer

" Open and close the taglist.vim separately
nmap :TrinityToggleTagList

" Open and close the NERD_tree.vim separately
nmap :TrinityToggleNERDTree

nmap j:call g:SrcExpl_Jump()
nmap :call g:SrcExpl_GoBack()

"#### EASY NAVIGATION IN INSERT MODE ################################
noremap
noremap
noremap
noremap
inoremap
inoremap
inoremap
inoremap

" Save and make current file.o
function! Make()
let curr_dir = expand('%:h')
if curr_dir == ''
let curr_dir = '.'
endif
echo curr_dir
execute 'lcd ' . curr_dir
execute 'make %:r'
execute 'lcd -'
endfunction

" nnoremap :update:make
"## ctr R for search and replace in visual mode
vnoremap "hy:%s/h//gc"

highlight LongLine ctermbg=Grey guibg=Yellow
highlight WhitespaceEOL ctermbg=Yellow guibg=Yellow
if v:version >= 702 && &ft == 'cpp'
" Lines longer than 100 columns.
au BufWinEnter * let w:m0=matchadd('LongLine', '%>100v.+', -1)

" Whitespace at the end of a line. This little dance suppresses
" whitespace that has just been typed.
au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s+$', -1)
au InsertEnter * call matchdelete(w:m1)
au InsertEnter * let w:m1=matchadd('WhitespaceEOL', '\s+%#@<!$', -1)
au InsertLeave * call matchdelete(w:m1)
au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s+$', -1)
" else
" au BufRead,BufNewFile * syntax match LongLine /%>100v.+/
" au InsertEnter * syntax match WhitespaceEOL /\s+%#@<!$/
" au InsertLeave * syntax match WhitespaceEOL /\s+$/
endif
set nocompatible
" FOLDING
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
nnoremap @=(foldlevel('.')?'za':"")
vnoremap zf
set nofoldenable
" Optional
" C/C++ programming helpers
augroup csrc
au!
autocmd FileType * set nocindent smartindent
autocmd FileType c,cpp,cc set cindent
au BufNewFile,BufRead .cpp,.cc.,.h,.hpp set syntax=cpp11
augroup END
" open quickfix after a grep
autocmd QuickFixCmdPost grep cwindow
" Set a few indentation parameters. See the VIM help for cinoptions-values for
" details. These aren't absolute rules; they're just an approximation of
" common style in LLVM source.
set cinoptions=:0,g0,(0,Ws,l1)
" Add and delete spaces in increments of `shiftwidth' for tabs
set smarttab
" Delete trailing whitespace and tabs at the end of each line
command! DeleteTrailingWs :%s/\s+$//
" Convert all tab characters to two spaces
command! Untab :%s/\t/ /g

au BufReadPost * if line("'"") > 0 && line("'"") <= line("$") |
\ exe "normal g'"" | endif
" Automatically open, but do not go to (if there are errors) the quickfix /
" " location list window, or close it when is has become empty.
" "
" " Note: Must allow nesting of autocmds to enable any customizations for
" quickfix
" " buffers.
" " Note: Normally, :cwindow jumps to the quickfix window if the command opens
" it
" " (but not if it's already open). However, as part of the autocmd, this
" doesn't
" " seem to happen.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
":cc see the current error
":cn next error
":cp previous error
":clist list all errors
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd "
endfunction
set switchbuf+=usetab,newtab
map :tabr
map :tabl
map :tabp
map :tabn
set errorformat^=%-GIn\ file\ included\ %.%#
set path=../src/
/include,../src/_/src/,../src/,../src/third_party_libs/boost/,../src/,/usr/include/

" cd to the directory containing the file in the buffer
" nmap ,cd :lcd %:h

" chdir to current file
" nnoremap ,cd :cd %:p:h:pwd
" "no cursor keys
" nnoremap
" nnoremap
" nnoremap
" nnoremap
" inoremap
" inoremap
" inoremap
" inoremap
" nnoremap j gj
" nnoremap k gk
"save on lost focus
au FocusLost * :wa
" save on lost fucus/make etc.
set autoread autowrite
" Easy window navigation
map h
map j
map k
map l
"forgot to sudo before editing a file that requires root privileges
cmap w!! w !sudo tee % >/dev/null
set statusline=
set statusline+=%{fugitive#statusline()}
set statusline+=[%n] "buffernr
set statusline+=%<%F\ "File+path
set statusline+=\ %y\ "FileType
set statusline+=\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=\ %{(&bomb?",BOM":"")}\ "Encoding2
set statusline+=\ %{&ff}\ "FileFormat (dos/unix..)
set statusline+=\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=\ col:%03c\ "Colnr
set statusline+=\ \ %m%r%w\ %P\ \ "Modified? Readonly? Top/bot.

suggestions

I like the context window very much

but I have some suggestions:

  1. why don't you use cscope, bug ctags??
  2. why do you generate ctags file in the source file dir, but not the top dir. (this is bad in large projects)
    see here http://asciinema.org/a/6582
    when I open util/concurrency/mvar.h, and user SrcExpl
    the current dir change to 'util/concurrency' , I don't like it
  3. conflict with quickfix window, (I can see both window)

I will try to improve it.

Current Path Error

When open SrcExpl, and open a file in a sub dir, the current path will be change to that sub dir, therefore, if use cscope to open another file, the path of the file will not be found. Therefore cannot work with cscope.

if bufname("%") ==# item in SrcExpl_AdaptPlugins() can not support NERD_tree_* and __Tagbar__.*

829 " SrcExpl_AdaptPlugins() {{{
830
831 " The Source Explorer window will not work when the cursor on the
832
833 " window of other plugins, such as 'Taglist', 'NERD tree' etc.
834
835 function! SrcExpl_AdaptPlugins()
836
837 " Traversal the list of other plugins
838 for item in g:SrcExpl_pluginList
839 " If they acted as a split window
840 if bufname("%") ==# item
841 " Just avoid this operation
842 return -1
843 endif
844 endfor
845
846 " Aslo filter the Quickfix window
847 if &buftype ==# "quickfix"
848 return 0
849 endif
850
851 " Safe
852 return 0
853
854 endfunction " }}}

it discrupts cscope

srcexpl makes cscope can't work properly
After I toggle on srcexpl, cscope command can't work correctly
eg. it displays all keyword refences files name, but all files are displayed as empty.
eg. when I search for the keyword definition, it said the file "xxxx.c" does not exist, but it is just there.

the fix is to quit and re-enter the file, but this whole thing is so annoying.

Cursor jumps to top of source file

This seems to be a continuous issue. I love the script, but on linux I cannot get it to work. As I scroll down using any method, the cursor jumps back to the top of the file, normally not getting past the license part (40 or so lines).

Here is my vimrc if it helps. I have tried commenting out almost everything

set runtimepath+=~/.vim/addons/vam

:function! DirCheck()
:let homedir = $PWD
: if finddir("src", homedir."../;") != ""
: return "../src/"
: else
: return = "."
: endif
:endfunction

" call vam#ActivateAddons(['hg:http://hg.dfrank.ru/vim/bundle/dfrank_util'])
" call vam#ActivateAddons(['hg:http://hg.dfrank.ru/vim/bundle/vimprj'])
" call vam#ActivateAddons(['github:Shougo/vimproc.vim'])
call vam#ActivateAddons(['github:vim-scripts/taglist.vim'])
call vam#ActivateAddons(['github:plasticboy/vim-markdown'])
call vam#ActivateAddons(['github:wesleyche/SrcExpl'])
call vam#ActivateAddons(['github:wesleyche/Trinity'])
let g:SrcExpl_updateTagsCmd = "ctags --sort=foldcase -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src"
let g:SrcExpl_pluginList = [ "Tag_List", "NERD_tree", "Quickfix List", "unite" ]
let g:SrcExpl_isUpdateTags = 0
" // Set the height of Source Explorer window
let g:SrcExpl_winHeight = 8

" // Set 100 ms for refreshing the Source Explorer
let g:SrcExpl_refreshTime = 100

" // Set "Enter" key to jump into the exact definition context
" let g:SrcExpl_jumpKey = ""

" // Set "Space" key for back from the definition context
" let g:SrcExpl_gobackKey = ""

"let g:vim_markdown_folding_disabled=1
call vam#ActivateAddons(['github:mattn/webapi-vim']) " for gist"
call vam#ActivateAddons(['github:mattn/gist-vim'])
"requires git config --global github.user Username
call vam#ActivateAddons(['github:vimoutliner/vimoutliner'])
call vam#ActivateAddons(['github:int3/vim-extradite'])
call vam#ActivateAddons(['github:kien/ctrlp.vim'])
let g:ctrlp_use_caching = 1
let g:ctrlp_max_files = 100000
let g:ctrlp_clear_cache_on_exit = 1
set wildignore+=/tmp/,.so,.swp,.zip,/build*/
nnoremap p :CtrlP ../src
call vam#ActivateAddons(['github:proyvind/Cpp11-Syntax-Support'])
call vam#ActivateAddons(['github:Valloric/YouCompleteMe'])
nnoremap j :YcmCompleter GoToDefinitionElseDeclaration
let g:ycm_complete_in_comments = 1
let g:ycm_collect_identifiers_from_tags_files = 1
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_add_preview_to_completeopt = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_key_invoke_completion = ''
let g:ycm_confirm_extra_conf = 0

call vam#ActivateAddons(['github:scrooloose/syntastic'])
let g:syntastic_cpp_check_header = 1
let g:syntastic_cpp_config_file = '.syntastic_cpp_config'
let g:syntastic_cpp_remove_include_errors = 1
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_check_on_open = 1
let g:syntastic_enable_signs = 1 " Put errors on left side
let g:syntastic_auto_loc_list = 0 " Only show errors when I ask
let g:syntastic_disabled_filetypes = ['html', 'js']
hi SpellBad ctermfg=007 ctermbg=000
hi SpellCap ctermfg=007 ctermbg=000
if has('unix')
let g:syntastic_error_symbol='★'
let g:syntastic_style_error_symbol='>'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_style_warning_symbol='>'
else
let g:syntastic_error_symbol='!'
let g:syntastic_style_error_symbol='>'
let g:syntastic_warning_symbol='.'
let g:syntastic_style_warning_symbol='>'
endif
"call vam#ActivateAddons(['github:flazz/vim-colorschemes'])
call vam#ActivateAddons(['github:Raimondi/delimitMate'])
call vam#ActivateAddons(['github:szw/vim-tags'])
" Create an empty tags dir in project root"
let g:vim_tags_project_tags_command = "ctags -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src 2>/dev/null"
let g:vim_tags_auto_generate = 1
let g:vim_tags_ignore_files = ['.gitignore', '.svnignore', '.cvsignore', 'build*']
call vam#ActivateAddons(['github:tpope/vim-fugitive'])
call vam#ActivateAddons(['github:xolox/vim-session'])
let g:session_autosave = 'yes'
let g:session_autoload = 'no'
call vam#ActivateAddons(['github:tomtom/tcomment_vim'])
call vam#ActivateAddons(['github:scrooloose/nerdtree'])
" " NerdTree"
" " Prevent :bd inside NERDTree buffer
au FileType nerdtree cnoreabbrev bd
au FileType nerdtree cnoreabbrev BD
au BufRead,BufNewFile *.md set filetype=markdown
set spelllang=en_gb
autocmd Filetype markdown setlocal wrap spell

nnoremap n :NERDTree ../src
" NERDTree settings
let NERDTreeChDirMode=0
let NERDTreeIgnore=['\env','>vim$', '$', '&gt;pyc$', '>swp$', '>egg-info$', '>DS_Store$', '^dist$', '^build$']
let NERDTreeSortOrder=['^__>py$', '/$', '*', '>swp$', '
$']
let NERDTreeShowBookmarks=1
let NERDTreeHightlight=1

call vam#ActivateAddons(['github:Lokaltog/vim-easymotion'])
let g:EasyMotion_leader_key = ''
" call vam#ActivateAddons(['github:ervandew/supertab'])
call vam#ActivateAddons(['github:altercation/vim-colors-solarized'])
let g:solarized_termcolors = 16

syntax enable
set t_Co=16
set background=dark
colorscheme solarized
call vam#ActivateAddons(['github:SirVer/ultisnips'])
let g:rainbow_ctermfgs = [
\ 'brown',
\ 'Darkblue',
\ 'darkgreen',
\ 'darkcyan',
\ 'darkred',
\ 'darkmagenta',
\ 'darkmagenta',
\ 'Darkblue',
\ 'darkgreen',
\ 'darkcyan',
\ 'darkred',
\ 'red',
\ ]
call vam#ActivateAddons(['github:oblitum/rainbow'])
let g:rainbow_active = 1
" C++
au FileType cpp,objcpp set syntax=cpp11
au BufNewFile,BufRead *
\ if expand('%:e') =~ '^(h|hh|hxx|hpp|ii|ixx|ipp|inl|txx|tpp|tpl|cc|cxx|cpp)$' |
\ if &ft != 'cpp' |
\ set ft=cpp |
\ endif |
\ endif |

let g:rainbow_operators = 2
au FileType c,cpp,objc,objcpp call rainbow#activate()
autocmd BufRead *.lyx set syntax=lyx foldmethod=syntax foldcolumn=3
autocmd BufRead *.lyx syntax sync fromstart

filetype plugin indent on
" reset to vim-defaults
if &compatible " only if not set before:
set nocompatible " use vim-defaults instead of vi-defaults (easier, more user friendly)
endif

" display settings
set textwidth=0
set wrapmargin=0
set nowrap " don't wrap lines
set linebreak
set nolist
set fo+=l
set scrolloff=2 " 2 lines above/below cursor when scrolling
set number " show line numbers
set showmatch " show matching bracket (briefly jump)
set showmode " show mode in status bar (insert/replace/...)
set showcmd " show typed command in status bar
set ruler " show cursor position in status bar
set title " show file in titlebar
set wildmenu " completion with menu
set wildignore=.o,.obj,.bak,.exe,.py[co],.swp,~,.pyc,.svn
set laststatus=2 " use 2 lines for the status bar
set matchtime=2 " show matching bracket for 0.2 seconds
set matchpairs+=<:> " specially for html

" editor settings
set esckeys " map missed escape sequences (enables keypad keys)
set ignorecase " case insensitive searching
set smartcase " but become case sensitive if you type uppercase characters
set smartindent " smart auto indenting
set smarttab " smart tab handling for indenting
set magic " change the way backslashes are used in search patterns
set bs=indent,eol,start " Allow backspacing over everything in insert mode

set tabstop=2 " number of spaces a tab counts for
set shiftwidth=2 " spaces for autoindents
set expandtab " turn a tabs into spaces

set fileformat=unix " file mode is unix
"set fileformats=unix,dos # only detect unix file format, displays that ^M with dos files
set noautochdir
" system settings
" set lazyredraw " no redraws in macros
set confirm " get a dialog when :q, :w, or :wq fails
set nobackup " no backup~ files.
set viminfo='20,"500 " remember copy registers after quitting in the .viminfo file'
set hidden " remember undo after quitting
set history=100 " keep 50 lines of command history
set mouse=a " use mouse in visual, normal,insert,command,help mode (shift key disables)
set undodir=~/.vim/undodir
set undofile
set undolevels=10000 "maximum number of changes that can be undone
set undoreload=100000 "maximum number lines to save for undo on a buffer reload
set incsearch
" color settings (if terminal/gui supports it)
if &t_Co > 2 || has("gui_running")
syntax on " enable colors
set hlsearch " highlight search (very useful!)
set incsearch "search incremently (search while typing)
endif
let Tlist_Ctags_Cmd = "/usr/bin/ctags"
let Tlist_WinWidth = 50
"set makeprg=clang++\ -std=c++11\ -stdlib=libc++\ -lc++abi\ -ldl\ -o\ %<\ %
nmap :cnext
nmap :cprev
map :TlistToggle
set tags=./tags,tags;
map :tab split:exec("tag ".expand(""))
map <A-]> :vsp :exec("tag ".expand(""))
noremap zA
nnoremap zA
onoremap zA
vnoremap zf
noremap zR
map :setlocal spell! spelllang=en_gb
" map :!/usr/bin/ctags -R --c++-kinds=+p --fields=+iaS --extra=+q /home/dirvine/Devel/MaidSafe/src
"open and close all the three plugins on the same time

nmap :TrinityToggleAll

" Open and close the srcexpl.vim separately
nmap :TrinityToggleSourceExplorer

" Open and close the taglist.vim separately
nmap :TrinityToggleTagList

" Open and close the NERD_tree.vim separately
nmap :TrinityToggleNERDTree

nmap j:call g:SrcExpl_Jump()
nmap :call g:SrcExpl_GoBack()

"#### EASY NAVIGATION IN INSERT MODE ################################
noremap
noremap
noremap
noremap
inoremap
inoremap
inoremap
inoremap

" Save and make current file.o
function! Make()
let curr_dir = expand('%:h')
if curr_dir == ''
let curr_dir = '.'
endif
echo curr_dir
execute 'lcd ' . curr_dir
execute 'make %:r'
execute 'lcd -'
endfunction

" nnoremap :update:make
"## ctr R for search and replace in visual mode
vnoremap "hy:%s/h//gc"

highlight LongLine ctermbg=Grey guibg=Yellow
highlight WhitespaceEOL ctermbg=Yellow guibg=Yellow
if v:version >= 702 && &ft == 'cpp'
" Lines longer than 100 columns.
au BufWinEnter * let w:m0=matchadd('LongLine', '%>100v.+', -1)

" Whitespace at the end of a line. This little dance suppresses
" whitespace that has just been typed.
au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s+$', -1)
au InsertEnter * call matchdelete(w:m1)
au InsertEnter * let w:m1=matchadd('WhitespaceEOL', '\s+%#@<!$', -1)
au InsertLeave * call matchdelete(w:m1)
au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s+$', -1)
" else
" au BufRead,BufNewFile * syntax match LongLine /%>100v.+/
" au InsertEnter * syntax match WhitespaceEOL /\s+%#@<!$/
" au InsertLeave * syntax match WhitespaceEOL /\s+$/
endif
set nocompatible
" FOLDING
augroup vimrc
au BufReadPre * setlocal foldmethod=indent
au BufWinEnter * if &fdm == 'indent' | setlocal foldmethod=manual | endif
augroup END
nnoremap @=(foldlevel('.')?'za':"")
vnoremap zf
set nofoldenable
" Optional
" C/C++ programming helpers
augroup csrc
au!
autocmd FileType * set nocindent smartindent
autocmd FileType c,cpp,cc set cindent
au BufNewFile,BufRead .cpp,.cc.,.h,.hpp set syntax=cpp11
augroup END
" open quickfix after a grep
autocmd QuickFixCmdPost grep cwindow
" Set a few indentation parameters. See the VIM help for cinoptions-values for
" details. These aren't absolute rules; they're just an approximation of
" common style in LLVM source.
set cinoptions=:0,g0,(0,Ws,l1)
" Add and delete spaces in increments of `shiftwidth' for tabs
set smarttab
" Delete trailing whitespace and tabs at the end of each line
command! DeleteTrailingWs :%s/\s+$//
" Convert all tab characters to two spaces
command! Untab :%s/\t/ /g

au BufReadPost * if line("'"") > 0 && line("'"") <= line("$") |
\ exe "normal g'"" | endif
" Automatically open, but do not go to (if there are errors) the quickfix /
" " location list window, or close it when is has become empty.
" "
" " Note: Must allow nesting of autocmds to enable any customizations for
" quickfix
" " buffers.
" " Note: Normally, :cwindow jumps to the quickfix window if the command opens
" it
" " (but not if it's already open). However, as part of the autocmd, this
" doesn't
" " seem to happen.
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
":cc see the current error
":cn next error
":cp previous error
":clist list all errors
au FileType qf call AdjustWindowHeight(3, 10)
function! AdjustWindowHeight(minheight, maxheight)
exe max([min([line("$"), a:maxheight]), a:minheight]) . "wincmd "
endfunction
set switchbuf+=usetab,newtab
map :tabr
map :tabl
map :tabp
map :tabn
set errorformat^=%-GIn\ file\ included\ %.%#
set path=../src/
/include,../src/_/src/,../src/,../src/third_party_libs/boost/,../src/,/usr/include/

" cd to the directory containing the file in the buffer
" nmap ,cd :lcd %:h

" chdir to current file
" nnoremap ,cd :cd %:p:h:pwd
" "no cursor keys
" nnoremap
" nnoremap
" nnoremap
" nnoremap
" inoremap
" inoremap
" inoremap
" inoremap
" nnoremap j gj
" nnoremap k gk
"save on lost focus
au FocusLost * :wa
" save on lost fucus/make etc.
set autoread autowrite
" Easy window navigation
map h
map j
map k
map l
"forgot to sudo before editing a file that requires root privileges
cmap w!! w !sudo tee % >/dev/null
set statusline=
set statusline+=%{fugitive#statusline()}
set statusline+=[%n] "buffernr
set statusline+=%<%F\ "File+path
set statusline+=\ %y\ "FileType
set statusline+=\ %{''.(&fenc!=''?&fenc:&enc).''} "Encoding
set statusline+=\ %{(&bomb?",BOM":"")}\ "Encoding2
set statusline+=\ %{&ff}\ "FileFormat (dos/unix..)
set statusline+=\ %=\ row:%l/%L\ (%03p%%)\ "Rownumber/total (%)
set statusline+=\ col:%03c\ "Colnr
set statusline+=\ \ %m%r%w\ %P\ \ "Modified? Readonly? Top/bot.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.