-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
130 lines (107 loc) · 4.27 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
set nocompatible
set number " show current line number even in relative mode
filetype off
syntax enable
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
" let Vundle manage Vundle
Plugin 'chriskempson/tomorrow-theme', {'rtp': 'vim/'}
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'digitaltoad/vim-jade'
Plugin 'fatih/vim-go'
Plugin 'jeffkreeftmeijer/vim-numbertoggle'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'kchmck/vim-coffee-script'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'prettier/vim-prettier'
Plugin 'raimondi/delimitmate'
Plugin 'roman/golden-ratio'
Plugin 'scrooloose/syntastic'
Plugin 'tomtom/tcomment_vim'
Plugin 'tpope/vim-endwise'
Plugin 'Valloric/YouCompleteMe'
call vundle#end()
filetype plugin indent on " fix html and js indenting
set autoindent
set backspace=2 " fix broken backspace in some setups
set clipboard=unnamed " yank and paste with the system clipboard
set directory-=. " don't store swapfiles in the current directory
set expandtab " expand tabs to spaces
set ignorecase " case-insensitive search
set incsearch " search as you type
set laststatus=2 " always show statusline
set ruler " show where you are
set scrolloff=3 " show context above/below cursorline
set shiftwidth=2 " normal mode indentation commands use 2 spaces
set smartcase " case-sensitive search if any caps
set smartindent
set softtabstop=2 " insert mode tab and backspace use 2 spaces
set splitbelow
set splitright
set tabstop=8 " actual tabs occupy 8 characters
set wildmode=longest:full
set wildchar=<Tab>
set wildmenu
" sets a colored column at 80 chars at a visual reference
set colorcolumn=80
" Add tomorrow night eighties colorscheme
set t_Co=256
colorscheme tomorrow-night-eighties
" Fix Cursor in TMUX
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\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_EI = "\<Esc>]50;CursorShape=0\x7"
endif
" Enable basic mouse behavior such as resizing buffers.
set mouse=a
if exists('$TMUX') " Support resizing in tmux
set ttymouse=xterm2
endif
" ############################ keyboard shortcuts ############################
" vim hard mode, forget those arrow keys!!
noremap <up> <nop>
noremap <down> <nop>
noremap <left> <nop>
noremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" vim splits
" easier mappings for switching panes
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>
" correct :W to :w, :Q to :q, & :Wq to :wq
cnoreabbrev <expr> W ((getcmdtype() is# ':' && getcmdline() is# 'W')?('w'):('W'))
cnoreabbrev <expr> Q ((getcmdtype() is# ':' && getcmdline() is# 'Q')?('q'):('Q'))
cnoreabbrev <expr> Wq ((getcmdtype() is# ':' && getcmdline() is# 'Wq')?('wq'):('Wq'))
let mapleader = ','
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Copy the current filename
nmap ,cs :let @*=expand("%")<CR>
" fix my syntax highlightings
au BufNewFile,BufRead *.json.jbuilder set ft=ruby"
au BufNewFile,BufRead *.ejs set ft=html
au BufNewFile,BufRead *.xm set filetype=objc
au BufNewFile,BufRead Vagrantfile set ft=ruby"
" ignore node_modules DS_Store and git when using ctrlp
let g:ctrlp_custom_ignore = 'node_modules\|DS_Store\|git'
" make .handlebars files have the same syntax highlighting as .html files
au BufRead,BufNewFile *.handlebars,*.hbs set ft=html syntax=html
" Follow links within .rST files using 'gf'
let &includeexpr = 'substitute(v:fname,"^/",substitute(system("git rev-parse --show-cdup"),"\n$","", ""), "")'
" :w!!
" write the file when you accidentally opened it without root privileges
cmap w!! w !sudo tee % > /dev/null
" make ctrlp use .gitignore
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" Run prettier on all of the following file formats automatically on save
let g:prettier#autoformat = 0
autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md PrettierAsync