-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
180 lines (150 loc) · 5.9 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
set shell=/opt/homebrew/bin/zsh
set nocompatible
syntax enable
filetype on " without this vim emits a zero exit status, later, because of :ft off
filetype off
" vim-plug
call plug#begin()
if filereadable(expand("~/.vimrc.plugins"))
source ~/.vimrc.plugins
endif
call plug#end()
filetype plugin indent on
set autoindent
set autoread " reload files when changed on disk, i.e. via `git checkout`
set backspace=2 " Fix broken backspace in some setups
set backupcopy=yes " see :help crontab
set clipboard=unnamed " yank and paste with the system clipboard
set directory-=. " don't store swapfiles in the current directory
set encoding=utf-8
set expandtab " expand tabs to spaces
set ignorecase " case-insensitive search
set incsearch " search as you type
set laststatus=2 " always show statusline
set list " show trailing whitespace
set listchars=tab:▸\ ,trail:▫
set number " show line numbers
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 showcmd
set smartcase " case-sensitive search if any caps
set softtabstop=2 " insert mode tab and backspace use 2 spaces
set tabstop=8 " actual tabs occupy 8 characters
set wildignore=log/**,node_modules/**,target/**,tmp/**,*.rbc
set wildmenu " show a navigable menu for tab completion
set wildmode=longest,list,full
" keyboard shortcuts
let mapleader = ","
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
nnoremap <leader>a :Ag<space>
nnoremap <leader>g :GitGutterToggle<CR>
noremap <silent> <leader>V :source ~/.vimrc<CR>:filetype detect<CR>:exe ":echo 'vimrc reloaded'"<CR>
" nnoremap <leader>q :cwindow<CR>
nnoremap <leader>c :noh<CR>
nnoremap <leader>d :VimFilerExplorer -toggle -auto-cd -winwidth=60<CR>
nnoremap <leader>f :VimFilerExplorer -find -auto-cd -winwidth=60<CR>
nnoremap <leader>p :GFiles<CR>
nnoremap <leader>/ :Lines<CR>
nnoremap <leader><Tab> :Buffers<CR>
let g:lt_location_list_toggle_map = '<leader>l'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" Move up and down in autocomplete with <c-j> and <c-k>
inoremap <expr> <c-j> ("\<C-n>")
inoremap <expr> <c-k> ("\<C-p>")
" YCM
nnoremap <leader>b :YcmCompleter GoToDefinition<CR>
nnoremap <leader>t :YcmCompleter GetType<CR>
nnoremap <leader>r :YcmCompleter RefactorRename<space>
let g:ycm_key_list_select_completion = ['<C-j>']
let g:ycm_key_list_previous_completion = ['<C-k>']
" UltiSnips
inoremap <c-x><c-k> <c-x><c-k>
let g:UltiSnipsSnippetDirectories=[$HOME.'/.dotfiles/snippets']
let g:UltiSnipsJumpForwardTrigger="<CR>"
" in case you forgot to sudo
cnoremap w!! %!sudo tee > /dev/null %
" plugin settings
let g:gitgutter_enabled = 0
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
endif
augroup Misc
autocmd!
" md is markdown
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd BufRead,BufNewFile *.md set spell
" automatically rebalance windows on vim resize
autocmd VimResized * :wincmd =
" remove trailing whitespace on save
autocmd BufWritePre * :%s/\s\+$//e
augroup END
" 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
" Don't copy the contents of an overwritten selection.
vnoremap p "_dP
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
set nocursorline " don't highlight current line
let g:Powerline_symbols = 'fancy'
set t_Co=256
set fillchars+=stl:\ ,stlnc:\
set termencoding=utf-8
if filereadable(expand("~/.vimrc_background"))
let base16colorspace=256
source ~/.vimrc_background
endif
set hlsearch
" airline / bufferline
let g:airline_theme = 'base16'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:bufferline_echo = 0
" make Esc happen without waiting for timeoutlen
" fixes Powerline delay
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
set hidden
" GUI
set guioptions-=L
set guioptions-=r
set guioptions-=e
set guifont=Hack:h14
" Custom mappings for the unite buffer
augroup Unite
autocmd!
autocmd FileType unite call s:unite_settings()
augroup END
function! s:unite_settings()
" Enable navigation with control-j and control-k in insert mode
imap <buffer> <C-j> <Plug>(unite_select_next_line)
imap <buffer> <C-k> <Plug>(unite_select_previous_line)
" Quick exit unite buffers
imap <buffer> <ESC> <Plug>(unite_exit)
nmap <buffer> <ESC> <Plug>(unite_exit)
endfunction
nnoremap <C-W>o :MaximizerToggle<CR>
set autowrite
" deoplete
let g:deoplete#enable_at_startup = 1
" don't complete in txt files
let g:deoplete#lock_buffer_name_pattern = '\v(\.md|\.txt|\.git\/COMMIT_EDITMSG)'
" disable builtin snippets
let g:neosnippet#disable_runtime_snippets = {
\ '_' : 1,
\ }
let g:windowswap_map_keys = 0 "prevent default bindings
nnoremap <silent> <leader>ww :call WindowSwap#EasyWindowSwap()<CR>