Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Last active March 2, 2017 09:51
Show Gist options
  • Save mortymacs/638d4f7adeb564be0248fc2875295b7f to your computer and use it in GitHub Desktop.
Save mortymacs/638d4f7adeb564be0248fc2875295b7f to your computer and use it in GitHub Desktop.
My vim config file
" Default settings
set number
syntax enable
set showmatch
set encoding=utf-8
set nocompatible
set paste
set nowrap
set tabstop=2 shiftwidth=2
set expandtab
" Search config
set hlsearch
highlight Search cterm=None ctermbg=234 ctermfg=None
" Current line config
highlight CursorLine cterm=None ctermbg=234 ctermfg=None
set fillchars+=vert:│
" Windows border config
highlight VertSplit ctermfg=None ctermbg=None cterm=None
" Vundle config
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'vim-scripts/indentpython.vim'
Bundle 'Valloric/YouCompleteMe'
" Need cmake package. after installing go to .vim/bundle/YouCompleteMe/ and run ./install.py
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdtree'
Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Plugin 'nvie/vim-flake8'
Plugin 'dhruvasagar/vim-table-mode'
Plugin 'Shougo/vimshell.vim'
" After installing, it needs to run :VimProcInstall in vim to create 'so'.
Plugin 'Shougo/vimproc.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdcommenter'
Plugin 'airblade/vim-gitgutter'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'majutsushi/tagbar'
Plugin 'szw/vim-tags'
" Need exuberant-ctags package.
Bundle 'tiagofumo/vim-nerdtree-syntax-highlight'
Plugin 'ctrlpvim/ctrlp.vim'
call vundle#end()
" File type detection
filetype plugin indent on
" Auto completion config
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_confirm_extra_conf=0
let g:ycm_min_num_of_chars_for_completion=1
nnoremap gd :YcmCompleter GoToDefinition<cr>
nnoremap gv :YcmCompleter GoToDeclaration<cr>
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
" Python config
let python_highlight_all=1
highlight BadWhitespace ctermbg=red guibg=darkred
au BufNewFile,BufRead *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
au BufNewFile,BufRead *.py
\ set tabstop=4 |
\ set softtabstop=4 |
\ set shiftwidth=4 |
\ set textwidth=79 |
\ set expandtab |
\ set autoindent |
\ set fileformat=unix |
\ map bp :call append(line('.')-1, "import pdb; pdb.set_trace()")<cr>
"\ !ctags --langauge-force=python -R<cr>
"autocmd BufWritePost *.py call Flake8()
" Use Python virtualenv
let g:ycm_python_binary_path='./venv/bin/python'
" FullStack config
au BufNewFile,BufRead *.js, *.html, *.css
\ set tabstop=2 |
\ set softtabstop=2 |
\ set shiftwidth=2
" File manager config
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
" Ignore files/dirs in file manager
let g:NERDTreeIgnore=['\.pyc$', '\~$', 'venv', '.git', '__pycache__', '.tags']
let g:NERDTreeDirArrows=1
let g:nerdtree_tabs_focus_on_files=1
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
" Airline extension config
let g:airline#extensions#tabline#enable=1
let g:airline#extensions#tabline#fnamemod=':t'
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline_symbols = {}
" JSON config
let g:vim_json_syntax_conceal=0
" Tags
set tags+=.tags
" Hot keys
" Moving among windows
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Folding class/method
nnoremap <space> za
" Commenting current line
map ## <leader>c<space>
" Moving among tabs
map tt :tabnext<cr>
map tn :tabedit<cr>
" CtrlP
map ff :CtrlP<cr>
map gg :CtrlPTag<cr>
" Moving among buffers
map bt :bn<cr>
map bp :bn<cr>
map bd :bd<cr>
map bq :b#\|bd#<cr>
" Finding in file manager
map ,f :NERDTreeFind<cr>
" Resizing windows
map <C-Right> :vertical resize -1<cr>
map <C-Left> :vertical resize +1<cr>
map <C-Up> :resize -1<cr>
map <C-Down> :resize +1<cr>
" Tag bar
nmap <F8> :TagbarToggle<CR>
" Fold config
set foldmethod=indent
set foldlevel=99
" Git config
autocmd QuickFixCmdPost *grep* cwindow
" Table config
let g:table_mode_corner_corner="+"
let g:table_mode_header_fillchar="="
@mortymacs
Copy link
Author

mortymacs commented Feb 12, 2017

Required GNU/Linux packages: cmake, exuberant-ctags.

I would like to recommend get nerd-font manually before running :PluginInstall by this command:

$ cd ~/.vim/bundle/
$ git clone --depth=1 https://github.com/ryanoasis/nerd-fonts.git

After installing the packages by :PluginInstall, try this steps:

$ cd ~/.vim/bundle/YouCompleteMe/
$ ./install.py
$ cd ~/.vim/bundle/nerd-fonts/
./install.sh

And then choice a font for your terminal from Powerline fonts which are installed in your fonts directory.

To config your ctags based on your language add an alias in your bashrc:

alias pt='ctags -R -h ".py" -f .tags'

Finally run vim by vim . command to see development perspective.

@mortymacs
Copy link
Author

mortymacs commented Feb 15, 2017

I've add this config in my .tmux.conf to switch between tmux windows by Shift+Left/Right:

bind -n S-Right next-window
bind -n S-Left previous-window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment