-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
270 lines (216 loc) · 6.79 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
" Enable syntax highlighting
syntax on
colo pablo
set colorcolumn=80,100
highlight ColorColumn ctermbg=7
" Start
set nocompatible
" Add line numbers
set number
" Disable line wrap
set nowrap
" Enhance command-line completion
set wildmenu
" Hide unsaved changes instead of closing them
set hidden
" Allow backspace to delete indentation and inserted text
" i.e. how it works in most programs
set backspace=indent,eol,start
" indent allow backspacing over autoindent
" eol allow backspacing over line breaks (join lines)
" start allow backspacing over the start of insert; CTRL-W and CTRL-U
" stop once at the start of insert.
set ttyfast
" Flash screen instead of beep sound
set visualbell
" Change how vim represents characters on the screen
set encoding=utf-8 nobomb
" Set the encoding of files written
set fileencoding=utf-8
" Set file format
set ffs=unix,dos,mac
" Highlight current line
set cursorline
" Highlight searches
set hlsearch
" Ignore case of searches
set ignorecase
" Highlight dynamically as pattern is typed
set incsearch
" Don’t reset cursor to start of line when moving around.
set nostartofline
" Show the cursor position
set ruler
" Don’t show the intro message when starting Vim
set shortmess=atI
" Show the current mode
set showmode
" Show the filename in the window titlebar
set title
" Show the (partial) command as it’s being typed
set showcmd
" Split below and to the right by default
set splitbelow
set splitright
" Disable modelines as a security precaution
set modelines=0
set nomodeline
" Automatically :write before running commands
set autowrite
" No backups or swap
set nobackup
set nowritebackup
set nowb
set noswapfile
" Large undo history
set undolevels=1000
" Centralize undo history
set undofile " Maintain undo history between sessions
set undodir=~/.vim/undos
" Update find path to search subdirectories
set path=$PWD/**
" Set leader to dot(.)
let mapleader = " "
" Remap hjkl to jkl;
" noremap ; l
" noremap l k
" noremap k j
" noremap j h
noremap s h
noremap , j
" Window movement with Ctrl+(hjkl)
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-s> <C-w>h
nnoremap <C-l> <C-w>l
" <C-,> won't work due to https://vimhelp.org/vim_faq.txt.html#faq-20.5
nnoremap bj 10<c-d>
nnoremap bk 10<c-u>
" Look for files with FZF on ff
nnoremap <silent> <C-p> :Files<CR>
map <silent> <leader>sf :Files<CR>
" Look for gitfiles with fg
map <silent> <leader>sg :GFiles<CR>
" Show buffers with lb
map <silent> <leader>lb :Buffers<CR>
" Show tags with lt
map <silent> <leader>lt :Tags<CR>
" Search all file contents with ripgrep on Ctrl+g
nnoremap <silent> <C-g> :Rg<CR>
map <silent> <leader>fa :Rg<CR>
" Search within file with FZF on Ctrl+f
nnoremap <silent> <C-f> :BLines<CR>
map <silent> <leader>fs :BLines<CR>
" Open buffer list ready to fill in on <space>b
nnoremap <Leader>b :ls<Cr>:b<Space>
" Remap escape to qq and <leader>e
inoremap qq <Esc>
inoremap <Leader>e <Esc>
" Open Netrw for file browsing with dash(-)
nnoremap <silent> - :Explore<CR>
if has('unix')
vmap <silent> <leader>cc "+y
elseif has('macunix')
vmap <silent> <leader>cc "*y
endif
" Tab sanity
set expandtab
set tabstop=4
set shiftwidth=4
" Show hidden characters, tabs, trailing whitespace
set list
set listchars=tab:→\ ,trail:·,nbsp:·
" Different tab/space stops"
autocmd Filetype html setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype yaml setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype css setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype scss setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype json setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
autocmd FileType make setlocal noexpandtab
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd Filetype go setlocal tabstop=4 shiftwidth=4 softtabstop=4
autocmd Filetype tf setlocal tabstop=2 shiftwidth=2 softtabstop=2 expandtab
autocmd Filetype js setlocal tabstop=2 shiftwidth=2 softtabstop=2 noexpandtab
au FileType go nmap <leader>gd <Plug>(go-def-vertical)
" Hardcore mode, disable arrow keys.
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
filetype plugin indent on
" Netrw
"
" Set treeview as default
let g:netrw_liststyle = 3
" Sort fix from https://github.com/tpope/vim-vinegar
function! s:sort_sequence(suffixes) abort
return '[\/]$,*' . (empty(a:suffixes) ? '' : ',\%(' .
\ join(map(split(a:suffixes, ','), 'escape(v:val, ".*$~")'), '\|') . '\)[*@]\=$')
endfunction
let g:netrw_sort_sequence = s:sort_sequence(&suffixes)
" --------------- PLUGIN CONFIG ---------------
" Don't search file names with rg
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
" Mucomplete
set completeopt+=menuone
set completeopt+=noselect
set shortmess+=c
let g:mucomplete#enable_auto_at_startup = 1
" Languageclient-neovim
nmap <silent>K <Plug>(lcn-hover)
nmap <silent> gd <Plug>(lcn-definition)
nmap <silent> <F2> <Plug>(lcn-rename)
" Colorscheme
set t_Co=256
set background=dark
colorscheme PaperColor
highlight ColorColumn ctermbg=238 guibg=#232728
" GO
"
" go-vim plugin specific commands
" Also run `goimports` on your current file on every save
" Might be be slow on large codebases, if so, just comment it out
let g:go_fmt_command = "goimports"
" Status line types/signatures.
let g:go_auto_type_info = 1
autocmd Filetype go inoremap <buffer> . .<C-x><C-o>
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" Launch gopls when Go files are in use
let g:LanguageClient_serverCommands = {
\ 'go': ['gopls']
\ }
" If you want to disable gofmt on save
" let g:go_fmt_autosave = 0
" TF
"
let g:terraform_align=1
let g:terraform_fmt_on_save=1
" air-line plugin specific commands
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = ''
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
" Autoformat
let g:python3_host_prog='/usr/bin/python3'
noremap <Leader>af :Autoformat<CR>
au BufWrite * silent! :Autoformat
let g:formatdef_autopep8 = "'autopep8 - --max-line-length 180 --range '.a:firstline.' '.a:lastline"
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0