Last active
October 23, 2016 07:01
-
-
Save Abukamel/72a7eb26e753be751cd137bddd2d0d84 to your computer and use it in GitHub Desktop.
My vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Credits goes to- Fatih Arslan | |
" Make sure to install vim-plug first using the following command | |
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
" Then Install The plugins with command :PlugInstall | |
call plug#begin() | |
Plug 'fatih/vim-go' | |
Plug 'AndrewRadev/splitjoin.vim' | |
Plug 'SirVer/ultisnips' | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'tpope/vim-surround' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'scrooloose/syntastic' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'altercation/vim-colors-solarized' | |
Plug 'scrooloose/nerdtree' | |
Plug 'ervandew/supertab' | |
Plug 'Shougo/neocomplete.vim' | |
Plug 'bash-support.vim' | |
Plug 'jistr/vim-nerdtree-tabs' | |
Plug 'tpope/vim-fugitive' | |
Plug 'godlygeek/tabular' | |
Plug 'majutsushi/tagbar' | |
Plug 'tpope/vim-markdown' | |
Plug 'elzr/vim-json' | |
Plug 'c.vim' | |
Plug 'davidhalter/jedi-vim' | |
" Using neocomplete instead till there is a fix | |
" for snippets completion problem https://github.com/fatih/vim-go-tutorial/issues/7 | |
" Plug 'valloric/youcompleteme' | |
call plug#end() | |
"""""""""""""""""""""" | |
" Settings " | |
"""""""""""""""""""""" | |
set nocompatible " Enables us Vim specific features | |
filetype off " Reset filetype detection first ... | |
filetype plugin indent on " ... and enable filetype detection | |
set cc=80 " Limit line width to 80 characters | |
set ttyfast " Indicate fast terminal conn for faster redraw | |
set ttymouse=xterm2 " Indicate terminal type for mouse codes | |
set ttyscroll=3 " Speedup scrolling | |
set laststatus=2 " Show status line always | |
set encoding=utf-8 " Set default encoding to UTF-8 | |
set autoread " Automatically read changed files | |
set autoindent " Enabile Autoindent | |
set backspace=indent,eol,start " Makes backspace key more powerful. | |
set incsearch " Shows the match while typing | |
set hlsearch " Highlight found searches | |
set noerrorbells " No beeps | |
set number " Don't Show line numbers | |
set showcmd " Show me what I'm typing | |
set noswapfile " Don't use swapfile | |
set nobackup " Don't create annoying backup files | |
set splitright " Vertical windows should be split to right | |
set splitbelow " Horizontal windows should split to bottom | |
set autowrite " Automatically save before :next, :make etc. | |
set hidden " Buffer should still exist if window is closed | |
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats | |
set noshowmatch " Do not show matching brackets by flickering | |
set noshowmode " We show the mode with airline or lightline | |
set ignorecase " Search case insensitive... | |
set smartcase " ... but not it begins with upper case | |
set completeopt=menu,menuone " Show popup menu, even if there is one entry | |
set pumheight=10 " Completion window max size | |
set nocursorcolumn " Do not highlight column (speeds up highlighting) | |
set nocursorline " Do not highlight cursor (speeds up highlighting) | |
set lazyredraw " Wait to redraw | |
" Enable to copy to clipboard for operations like yank, delete, change and put | |
" http://stackoverflow.com/questions/20186975/vim-mac-how-to-copy-to-clipboard-without-pbcopy | |
if has('unnamedplus') | |
set clipboard^=unnamed | |
set clipboard^=unnamedplus | |
endif | |
" This enables us to undo files even if you exit Vim. | |
if has('persistent_undo') | |
set undofile | |
set undodir=~/.config/vim/tmp/undo// | |
endif | |
" Colorscheme | |
syntax enable | |
set background=light | |
"let g:solarized_termcolors=256 | |
colorscheme solarized | |
set t_Co=256 | |
"""""""""""""""""""""" | |
" Mappings " | |
"""""""""""""""""""""" | |
" Let SuperTab autocomplete using completion menu | |
let g:SuperTabDefaultCompletionType = "context" | |
" Set leader shortcut to a comma ','. By default it's the backslash | |
let mapleader = "," | |
" Jump to next error with Ctrl-n and previous error with Ctrl-m. Close the | |
" quickfix window with <leader>a | |
map <C-n> :cnext<CR> | |
map <C-m> :cprevious<CR> | |
nnoremap <leader>a :cclose<CR> | |
" Visual linewise up and down by default (and use gj gk to go quicker) | |
noremap <Up> gk | |
noremap <Down> gj | |
noremap j gj | |
noremap k gk | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
nnoremap n nzzzv | |
nnoremap N Nzzzv | |
" Act like D and C | |
nnoremap Y y$ | |
" Enter automatically into the files directory | |
autocmd BufEnter * silent! lcd %:p:h | |
""""""""""""""""""""" | |
" Plugins " | |
""""""""""""""""""""" | |
" vim-go | |
" Link to snippets https://github.com/fatih/vim-go/blob/master/gosnippets/UltiSnips/go.snippets | |
let g:go_fmt_command = "goimports" | |
let g:go_autodetect_gopath = 1 | |
let g:go_list_type = "quickfix" | |
let g:go_highlight_types = 1 | |
let g:go_highlight_fields = 1 | |
let g:go_highlight_functions = 1 | |
let g:go_highlight_methods = 1 | |
let g:go_highlight_extra_types = 1 | |
let g:go_highlight_generate_tags = 1 | |
" Open :GoDeclsDir with ctrl-g | |
nmap <C-g> :GoDeclsDir<cr> | |
imap <C-g> <esc>:<C-u>GoDeclsDir<cr> | |
augroup go | |
autocmd! | |
" Show by default 4 spaces for a tab | |
autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 | |
" :GoBuild and :GoTestCompile | |
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<CR> | |
" :GoTest | |
autocmd FileType go nmap <leader>t <Plug>(go-test) | |
" :GoRun | |
autocmd FileType go nmap <leader>r <Plug>(go-run) | |
" :GoDoc | |
autocmd FileType go nmap <Leader>d <Plug>(go-doc) | |
" :GoCoverageToggle | |
autocmd FileType go nmap <Leader>c <Plug>(go-coverage-toggle) | |
" :GoInfo | |
autocmd FileType go nmap <Leader>i <Plug>(go-info) | |
let g:go_auto_type_info = 1 | |
" :GoMetaLinter | |
autocmd FileType go nmap <Leader>l <Plug>(go-metalinter) | |
" :GoDef but opens in a vertical split | |
autocmd FileType go nmap <Leader>v <Plug>(go-def-vertical) | |
" :GoDef but opens in a horizontal split | |
autocmd FileType go nmap <Leader>s <Plug>(go-def-split) | |
" :GoAlternate commands :A, :AV, :AS and :AT | |
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit') | |
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit') | |
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split') | |
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe') | |
augroup END | |
" build_go_files is a custom function that builds or compiles the test file. | |
" It calls :GoBuild if its a Go file, or :GoTestCompile if it's a test file | |
function! s:build_go_files() | |
let l:file = expand('%') | |
if l:file =~# '^\f\+_test\.go$' | |
call go#cmd#Test(0, 1) | |
elseif l:file =~# '^\f\+\.go$' | |
call go#cmd#Build(0) | |
endif | |
endfunction | |
" Syntastic Recommended Settings | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
" End | |
" VIM-AIRLINE Settings | |
set laststatus=2 | |
" End | |
" vim-go Settings | |
" let all go lists types be quickfix so that navigation shortcuts works with | |
" all of them | |
let g:go_list_type = "quickfix" | |
" Navigate to next error with crtl+n | |
map <C-n> :cnext<CR> | |
" Navigate to previous error with ctrl+m | |
map <C-m> :cprevious<CR> | |
" Close the error buffer | |
nnoremap <leader>a :cclose<CR> | |
" I also use these shortcuts to build and run a Go program with <leader>b and <leader>r | |
autocmd FileType go nmap <leader>b <Plug>(go-build) | |
autocmd FileType go nmap <leader>r <Plug>(go-run) | |
autocmd FileType go nmap <leader>t <Plug>(go-test) | |
" let vim import needed packages before formatting after a file save | |
let g:go_fmt_command = "goimports" | |
" let GoMetaLinter check for everything | |
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck'] | |
" let GoMetaLinter be called on file save | |
let g:go_metalinter_autosave = 1 | |
let g:go_metalinter_autosave_enabled = ['vet', 'golint'] | |
let g:go_metalinter_deadline = "5s" | |
" let vim-go same ids highlighted | |
let g:go_auto_sameids = 1 | |
" End | |
" neocomplete Settings | |
" Use neocomplete. | |
let g:neocomplete#enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplete#enable_smart_case = 1" | |
" End | |
" Nerdtree toggle shortcut | |
map <Leader>n <plug>NERDTreeTabsToggle<CR> | |
let g:nerdtree_tabs_open_on_console_startup=1 | |
" End | |
" Tagbar toggle with f8 | |
nmap <F8> :TagbarToggle<CR> | |
" End | |
" Detects .md as markdown file | |
autocmd BufNewFile,BufReadPost *.md set filetype=markdown | |
" End | |
" Bash plugin | |
let g:BASH_AuthorName = 'AhmedKamel' | |
let g:BASH_Email = '[email protected]' | |
let g:BASH_Company = 'ZadGroup' | |
autocmd FileType sh setlocal shiftwidth=2 tabstop=2 | |
" End |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment