Created
January 23, 2018 15:58
-
-
Save mguindin/7615faa672f2886d70dc03f886cdac88 to your computer and use it in GitHub Desktop.
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
set nocompatible " be iMproved, required | |
call plug#begin('~/.vim/plugged') | |
" Plugins go here | |
" syntax checking | |
Plug 'w0rp/ale' | |
" status bar | |
Plug 'bling/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'chriskempson/base16-vim' | |
" Git | |
Plug 'tpope/vim-fugitive' | |
Plug 'kien/ctrlp.vim' | |
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --all' } | |
" Go | |
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' } | |
" Ruby/Rails | |
Plug 'tpope/vim-rails' | |
Plug 'tpope/vim-bundler' | |
" JS/TS/Coffeescript | |
Plug 'kchmck/vim-coffee-script' | |
Plug 'pangloss/vim-javascript' | |
Plug 'leshill/vim-json' | |
" Vim/tmux | |
Plug 'spf13/vim-autoclose' | |
Plug 'christoomey/vim-tmux-navigator' | |
call plug#end() | |
" Required for operations modifying multiple buffers like rename. | |
set hidden | |
""let g:LanguageClient_serverCommands = { | |
"" \ 'rust': ['rustup', 'run', 'nightly', 'rls'], | |
"" \ 'javascript': ['/opt/javascript-typescript-langserver/lib/language-server-stdio.js'], | |
"" \ 'ruby': ['language_server-ruby'], | |
"" \ 'go': ['go-langserver']} | |
"" | |
""" Automatically start language servers. | |
""let g:LanguageClient_autoStart = 1 | |
""nnoremap <silent> K :call LanguageClient_textDocument_hover()<CR> | |
""nnoremap <silent> gd :call LanguageClient_textDocument_definition()<CR> | |
""nnoremap <silent> <F2> :call LanguageClient_textDocument_rename()<CR> | |
autocmd! GUIEnter * set vb t_vb= | |
set encoding=utf-8 | |
set t_ut= | |
"CtrlP plugins | |
let g:ctrlp_extensions=['tag'] | |
let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' " Make CtrlP faster by using Ag | |
"Show tab and whitespace chars | |
set list listchars=tab:→\ ,trail:· | |
"Write the old file out when switching between files. | |
set autowrite | |
set termguicolors | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum""]]" | |
if !has('nvim') | |
set ttyfast " u got a fast terminal | |
set ttyscroll=3 | |
set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20 | |
set ttymouse=sgr | |
endif | |
" Remap increment as C-g (C-a is used by tmux) | |
nnoremap <C-g> <C-a> | |
nnoremap <leader>t :NERDTreeToggle<CR> | |
" Set GoPath for vim-go | |
let $GOPATH = $HOME."/go" | |
" Set to auto read when a file is changed from the outside | |
set autoread | |
"Display current cursor position in lower right corner. | |
set ruler | |
" sudo write | |
cmap w!! w !sudo tee > /dev/null % | |
""Ever notice a slight lag after typing the leader key + command? This lowers | |
"the timeout. | |
set timeout timeoutlen=1000 ttimeoutlen=0 | |
""Switch between buffers without saving | |
set hidden | |
"Tab stuff | |
set tabstop=2 | |
set shiftwidth=2 | |
set softtabstop=2 | |
set expandtab | |
"Git commit messages | |
autocmd Filetype gitcommit setlocal spell textwidth=72 | |
""Show command in bottom right portion of the screen | |
set showcmd | |
"Indent stuff | |
set smartindent | |
set autoindent | |
"Always show the status line | |
set laststatus=2 | |
""Prefer a slightly higher line height | |
set linespace=3 | |
"Better line wrapping | |
set wrap | |
set textwidth=79 | |
set formatoptions=qrn1 | |
" | |
""Set incremental searching" | |
set incsearch | |
"Highlight searching | |
set hlsearch | |
"" case insensitive search | |
set ignorecase | |
set smartcase | |
""Hard-wrap paragraphs of text | |
nnoremap <leader>q gqip | |
"Enable code folding | |
set foldenable | |
" | |
""Hide mouse when typing | |
set mousehide | |
"Shortcut to fold tags with leader (usually \) + ft | |
nnoremap <leader>ft Vatzf | |
" | |
""Opens a vertical split and switches over (\v) | |
nnoremap <leader>v <C-w>v<C-w>l | |
"Split windows below the current window. | |
set splitbelow | |
"Session settings | |
"set sessionoptions=resize,winpos,winsize,buffers,tabpages,folds,curdir,help | |
"Saves time; maps the spacebar to colon | |
nmap <space> : | |
"Map code completion to , + tab | |
imap ,<tab> <C-x><C-o> | |
"http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE | |
"set completeopt=longest,menuone | |
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
"inoremap <expr> <C-n> pumvisible() ? '<C-n>' : | |
" \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>' | |
"inoremap <expr> <M-,> pumvisible() ? '<C-n>' : | |
" \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>' | |
"Map escape key to jj -- much faster | |
imap jj <esc> | |
"Delete all buffers (via Derek Wyatt) | |
nmap <silent> ,da :exec "1," . bufnr('$') . "bd"<cr> | |
"Bubble single lines (kicks butt) | |
"http://vimcasts.org/episodes/bubbling-text/ | |
nmap <C-Up> ddkP | |
nmap <C-Down> ddp | |
"Bubble multiple lines | |
vmap <C-Up> xkP`[V`] | |
vmap <C-Down> xp`[V`] | |
" Source the vimrc file after saving it. This way, you don't have to reload | |
" Vim to see the changes. | |
if has("autocmd") | |
autocmd bufwritepost .vimrc source $MYVIMRC | |
endif | |
" easier window navigation | |
nmap <C-h> <C-w>h | |
nmap <C-j> <C-w>j | |
nmap <C-k> <C-w>k | |
nmap <C-l> <C-w>l | |
"Spelling corrects. Just for example. Add yours below. | |
iab teh the | |
iab Teh The | |
"--------------------------" | |
" PERSONAL SETTINGS | |
" -------------------------" | |
" Scrollbar junk | |
set guioptions=aAce | |
" Colors and fonts | |
syntax enable | |
colorscheme base16-eighties | |
"Show lines numbers (hybrid for >= 7.4) | |
set number | |
if has('gui_running') | |
"Using a cool patched font for powerline | |
set guifont=Anonymice\ Powerline:h12 | |
"set background transparency and solarized style | |
set background=dark | |
autocmd vimenter * wincmd p | |
set relativenumber | |
else | |
set background=dark | |
set mouse=a | |
endif | |
" Yank text to the OS X clipboard | |
set clipboard=unnamed | |
noremap <leader>y "+y | |
noremap <leader>yy "+yy | |
" Preserve indentation while pasting text from the OS X clipboard | |
noremap <leader>p :set paste<CR>:put *<CR>:set nopaste<CR> | |
" Change cursor type in terminal (only works in iterm2) | |
if exists('$ITERM_PROFILE') | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_SR = "\<Esc>]50;CursorShape=2\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif | |
end | |
:autocmd InsertEnter * set cul | |
:autocmd InsertLeave * set nocul | |
" | |
" for tmux to automatically set paste and nopaste mode at the time pasting (as | |
" happens in VIM UI) | |
function! WrapForTmux(s) | |
if !exists('$TMUX') | |
return a:s | |
endif | |
let tmux_start = "\<Esc>Ptmux;" | |
let tmux_end = "\<Esc>\\" | |
return tmux_start . substitute(a:s, "\<Esc>", "\<Esc>\<Esc>", 'g') . tmux_end | |
endfunction | |
function! XTermPasteBegin() | |
set pastetoggle=<Esc>[201~ | |
set paste | |
return "" | |
endfunction | |
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin() | |
" for .hql files | |
au BufNewFile,BufRead *.hql set filetype=hive expandtab | |
" for .Dockerfile | |
au BufNewFile,BufRead Dockerfile* set filetype=Dockerfile expandtab | |
" for .q files | |
au BufNewFile,BufRead *.q set filetype=hive expandtab | |
" Stuff for Go | |
au FileType go nmap <leader>r <Plug>(go-run) | |
au FileType go nmap <leader>b <Plug>(go-build) | |
au FileType go nmap <leader>T <Plug>(go-test) | |
au FileType go nmap <leader>c <Plug>(go-coverage) | |
au FileType go nmap <Leader>ds <Plug>(go-def-split) | |
au FileType go nmap <Leader>dv <Plug>(go-def-vertical) | |
au FileType go nmap <Leader>dt <Plug>(go-def-tab) | |
au FileType go nmap <Leader>gd <Plug>(go-doc) | |
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical) | |
au FileType go nmap <Leader>gb <Plug>(go-doc-browser) | |
au FileType go nmap <Leader>s <Plug>(go-implements) | |
nnoremap <silent> <leader>lr :Lrun<CR> | |
nnoremap <silent> <leader>lb :Lbreakpoint<CR> | |
nnoremap <silent> <leader>lc :Lcontinue<CR> | |
nnoremap <silent> <leader>ln :Lnext<CR> | |
nnoremap <silent> <leader>ls :Lstep<CR> | |
nnoremap <silent> <leader>li :Lstepin<CR> | |
nnoremap <silent> <leader>lo :Lfinish<CR> | |
nnoremap <silent> <leader>lp :Lprint<CR> | |
nnoremap <silent> <leader>lv :Lframe variable<CR> | |
" Enable completion where available. | |
let g:ale_completion_enabled = 1 | |
"vim-airline | |
let g:airline_powerline_fonts = 1 | |
let g:airline#extensions#branch#enabled = 1 " Enable branches | |
let g:airline_theme='base16' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment