-
Notifications
You must be signed in to change notification settings - Fork 2
/
.vimrc
275 lines (223 loc) · 8.21 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
set nocompatible
filetype off
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-sensible'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-fugitive'
Plugin 'airblade/vim-gitgutter'
Plugin 'tpope/vim-git'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'hashivim/vim-hashicorp-tools'
Plugin 'honza/vim-snippets'
Plugin 'ervandew/supertab'
Plugin 'godlygeek/tabular'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'w0rp/ale'
Plugin 'sheerun/vim-polyglot'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'ntpeters/vim-better-whitespace'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
Plugin 'dracula/vim', { 'name': 'dracula' }
Plugin 'github/copilot.vim'
Plugin 'google/vim-jsonnet'
call vundle#end()
filetype plugin indent on " load file type plugins + indentation
" Settings
set autoindent " match indentation of previous line
set autowrite " Automatically :write before running commands
set backspace=indent,eol,start " backspace through everything in insert mode
set clipboard=unnamed " For OSX clipboard
set cursorline " Highlight current line
set encoding=utf-8
set expandtab " use spaces, not tabs (optional)
set foldenable " Enable folding
set foldlevelstart=10 " Open most folds by default
set foldmethod=indent " Fold based on indent level
set foldnestmax=10 " 10 nested fold max
set hidden " Handle multiple buffers better.
set history=1000 " Store lots of :cmdline history
set hlsearch " Highlight search results
set ignorecase " Ignore case when searching
set incsearch " Makes search act like in modern browsers
set laststatus=2 " Always display the status line
set lazyredraw " Redraw only when we need to.
set noerrorbells
set novisualbell
set nowrap " don't wrap lines
set number " Show line numbers.
set numberwidth=5 " Width of the "gutter" column used for numbering
set relativenumber " Relative line numbers.
set ruler " Show cursor position.
set showcmd " Show command in bottom bar
set showmatch " Highlight matching [{()}]
set smartcase " When searching try to be smart about cases
set smarttab
set spelllang=en " Check all regions of English.
set tabstop=2 shiftwidth=2 " a tab is two spaces (or set this to 4)
set ttimeout " Fast VIM
set ttimeoutlen=100
set ttyfast " Ensure ttyfast is enabled
set undodir=~/.vimundo " Do not add ~un files everywhere I go
set undofile " Persistent undo
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
" Set the terminal's title
if &term == 'screen'
set t_ts=k
set t_fs=\
elseif &term == 'screen' || &term == 'xterm'
set title
endif
set guifont=Hack:h14
syntax enable
set background=dark
colorscheme dracula
if exists('+colorcolumn')
set colorcolumn=80
endif
" Disable modelines for security reasons
set modelines=0
set nomodeline
" always show the status line
set laststatus=2
" Update sign column every quarter second
set updatetime=250
" airline/tmuxline integration
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tmuxline#enabled = 0
" airline/powerline font interation
let g:airline_powerline_fonts=1
" enable airline/fugitive integration
let g:airline#extensions#branch#enabled=1
let g:airline#extensions#branch_prefix#enabled=1
" enable airline/syntastic integration
let g:airline#extensions#ale#enabled=1
" airline theme
let g:airline_theme='dracula'
" Use rubocop with the default ruby checker (mri)
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
" file fixer
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'css': ['prettier'],
\ 'javascript': ['prettier', 'eslint'],
\ 'json': ['prettier'],
\ 'sh': ['shfmt'],
\ 'typescript': ['prettier', 'eslint', 'tslint'],
\ 'yaml': ['prettier'],
\}
" keep the sign gutter open
let g:ale_sign_column_always = 1
" Better syntastic symbols
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚠'
" fix files when you save them.
let g:ale_fix_on_save = 1
" Disable download and install all necessary go binaries from vim-go plugin
let g:go_disable_autoinstall = 1
" Disable go version warning
let g:go_version_warning = 0
" Disable auto go fmt on save
let g:go_fmt_autosave = 0
" Ensure that this plugin works well with Tim Pope's fugitive
let g:EditorConfig_exclude_patterns = ['fugitive://.\*']
" Limeligth + Goyo integration
autocmd User GoyoEnter Limelight
autocmd User GoyoLeave Limelight!
" hashivim
let g:terraform_fmt_on_save=1
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
" Line number
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr>
augroup vimrcEx
autocmd!
" When editing a file, always jump to the last known cursor position.
" Don't do it for commit messages, when the position is invalid, or when
" inside an event handler (happens when dropping a file on gvim).
" https://github.com/thoughtbot/dotfiles/blob/master/vimrc#L34-L40
autocmd BufReadPost *
\ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Python
autocmd FileType python setlocal tabstop=8 expandtab shiftwidth=4 softtabstop=4
" Git commit
autocmd Filetype gitcommit setlocal spell textwidth=72 complete+=kspell
" Enable spellchecking for Markdown
autocmd BufRead,BufNewFile *.md set filetype=markdown
autocmd FileType markdown setlocal spell complete+=kspell
" Crontab http://calebthompson.io/crontab-and-vim-sitting-in-a-tree/
autocmd filetype crontab setlocal nobackup nowritebackup
" Let's tell Vim to automatically use absolute line numbers when we're in
" insert mode and relative numbers when we're in normal mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
augroup END
" Automatically source the .vimrc file after editing
augroup autosourcing
autocmd!
autocmd BufWritePost .vimrc source %
augroup END
" Key Bindings
let mapleader = ',' " leader is comma
inoremap jj <ESC>
" Turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
" :Ag - Start fzf with hidden preview window that can be enabled with "?" key
" :Ag! - Start fzf in fullscreen and display the preview window above
command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>,
\ <bang>0 ? fzf#vim#with_preview('up:60%')
\ : fzf#vim#with_preview('right:50%:hidden', '?'),
\ <bang>0)
nnoremap <Leader>a :Ag!<Space>
" Open fzf
nnoremap <silent> <leader>f :Files<CR>
" Open tig
nmap <leader>t :execute ":Silent !tig ".GetSmartWd()<CR><CR>
" Ale fix
nmap <leader>s :ALEFix<CR>
nmap <leader>se :let g:ale_fix_on_save=1<CR>
nmap <leader>sd :let g:ale_fix_on_save=0<CR>
" Easier split navigations
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>
" Unbind the cursor keys in insert, normal and visual modes.
for prefix in ['i', 'n', 'v']
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
exe prefix . "noremap " . key . " <Nop>"
endfor
endfor
" More natural split opening
set splitbelow
set splitright
" Store swap files in fixed location, not current directory.
"
" The '//' at the end ensure the swap file name will be built from the complete
" path to the file with all path separators substituted to percent '%' signs.
"
" This will ensure file name uniqueness in the preserve directory.
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
" Local config
if filereadable($HOME . "/.vimrc.local")
source ~/.vimrc.local
endif