-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
362 lines (294 loc) · 11.3 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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
" +---------------------------------------------------------------------------+
" | .vimrc file - Jerome Basa <[email protected]> |
" | |
" | Disclaimer: |
" | I just copied most of these stuff, so credits goes to them |
" +---------------------------------------------------------------------------+
" +---------------------------------------------------------------------------+
" | VIM Settings |
" +---------------------------------------------------------------------------+
call plug#begin('~/.vim/plugged')
Plug '/usr/local/opt/fzf' " needed by fzf.vim
Plug 'airblade/vim-gitgutter' " git diff in the gutter
" Plug 'edkolev/tmuxline.vim' " tmux statusline generator
Plug 'edkolev/promptline.vim'
Plug 'fenetikm/falcon' " theme
Plug 'jgdavey/tslime.vim' " send text to running tmux buffer
Plug 'junegunn/fzf.vim' " fzf
Plug 'junegunn/goyo.vim' " distraction free writing in vim
Plug 'junegunn/limelight.vim' " hyperfocus writing
Plug 'junegunn/vim-easy-align'
Plug 'myusuf3/numbers.vim' " display line number (relative or absolute)
" Plug 'NLKNguyen/papercolor-theme' "theme
Plug 'scrooloose/nerdtree' " file system explorer
Plug 'sheerun/vim-polyglot' " language pack
Plug 'thoughtbot/vim-rspec' " running rspec
Plug 'townk/vim-autoclose' " complete chars which works in pairs
Plug 'tpope/vim-commentary' " comment stuff
Plug 'tpope/vim-fugitive' " git wrapper
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-surround' " surroundings ([ etc.
Plug 'vim-airline/vim-airline' " status bar
Plug 'vim-airline/vim-airline-themes'
Plug 'vimwiki/vimwiki'
Plug 'w0rp/ale' " async linting engine
Plug 'cormacrelf/vim-colors-github'
Plug 'catppuccin/vim', { 'as': 'catppuccin' } " theme
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
" To evaluate:
" janko-m/vim-test
" Plugin 'tpope/vim-git'
" Plugin 'msanders/snipmate.vim'
" Plugin 'tpope/vim-markdown'
" Plugin 'scrooloose/syntastic'
" Plugin 'slim-template/vim-slim'
" Plugin 'tpope/vim-rails'
" Plugin 'mattn/gist-vim'
" Plugin 'mattn/webapi-vim'
call plug#end()
" Promptline
" sections (a, b, c, x, y, z, warn) are optional
" let g:promptline_preset = {
" \'a' : [ promptline#slices#cwd() ],
" \'warn' : [ promptline#slices#last_exit_code() ]}
" let g:promptline_preset = {
" \'a' : [ promptline#slices#cwd(), promptline#slices#git_status(), promptline#slices#vcs_branch(), '$(kubectl config current-context)', promptline#slices#last_exit_code()]}
let os = substitute(system('uname'), "\n", "", "")
set nocompatible
set encoding=utf-8
set nolist " hide hidden characters
set listchars=tab:▸\ ,eol:¬ " Use the same symbols as TextMate for tabstops and EOLs
set pastetoggle=<f9>
" set color scheme
if has('gui_running')
" colorscheme Tomorrow-Night-Eighties
colorscheme catppuccin_mocha
" colorscheme github
" colorscheme PaperColor
else
" colorscheme Tomorrow-Night-Eighties
colorscheme catppuccin_mocha
" colorscheme github
" colorscheme PaperColor
end
set termguicolors
let g:falcon_airline = 1
let g:airline_theme='falcon'
set tags=./tags; " Set the tag file search order
set number
set t_Co=256 " Tell the term has 256 colors
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set background=light
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
set wildmenu " Enhanced command line completion.
set wildmode=list:longest " Complete files like a shell.
set ignorecase " Case-insensitive searching.
set smartcase " But case-sensitive if expression contains a capital letter.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set wrap " Turn on line wrapping.
set scrolloff=3 " Show 3 lines of context around the cursor.
set linebreak " Wrap lines at convenient points
set formatoptions=tq
set wrapmargin=4
set title " Set the terminal's title
set visualbell " No beeping.
syntax on " Turn on syntax highlighting
set noswapfile " Don't create swapfile
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set directory=$HOME/.vim/tmp//,. " Keep swap files in one location
set autoread
set tabstop=2 " Global tab width.
set softtabstop=2 " When hitting backspace
set shiftwidth=2 " When using indentation
set expandtab " Use spaces instead of tabs
set smarttab
set laststatus=2 " Show the status line all the time
set autoindent
set smartindent
set shell=/bin/bash " Some commands seem to have problems with zsh"
set wildignore+=vendor,log,tmp,*.swp
set splitbelow " Split opening
set splitright
"set vim to handle long lines correctly
set wrap
set textwidth=120
set formatoptions=qrn1
set colorcolumn=125
filetype plugin on
" Source the vimrc file after saving it
" if has("autocmd")
" autocmd bufwritepost .vimrc source $MYVIMRC
" endif
" Folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1
" +---------------------------------------------------------------------------+
" | Whitespace preferences and filetypes |
" +---------------------------------------------------------------------------+
" Only do this part when compiled with support for autocommands
if has("autocmd")
" Enable file type detection
filetype on
" Syntax of these languages is fussy over tabs Vs spaces
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Customisations based on house-style (arbitrary)
autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=4 sts=4 sw=4 noexpandtab
" Treat .rss files as XML
autocmd BufNewFile,BufRead *.rss setfiletype xml
autocmd BufWritePre *.rb,*.js :call <SID>StripTrailingWhitespaces()
endif
" +---------------------------------------------------------------------------+
" | Mappings |
" +---------------------------------------------------------------------------+
let mapleader = "\<Space>"
nnoremap <f1> :NERDTreeToggle<cr>
nnoremap <f4> :NumbersToggle<CR>
nnoremap <silent> <F5> :call <SID>StripTrailingWhitespaces()<CR>
nnoremap <Leader>w :w<CR>
" fzf mappings
" nnoremap <f1> :Buffers<cr>
nnoremap <silent> ;; :Buffers<cr>
nnoremap <Leader>o :Files<CR>
nnoremap <silent> <Leader><Leader> :Files<CR>
nnoremap <Leader>l :Lines<CR>
" nnoremap <Leader>ag :Ag <C-R><C-W><CR>
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
nnoremap <silent> <Leader>AG :Ag <C-R><C-A><CR>
xnoremap <silent> <Leader>ag y:Ag <C-R>"<CR>
" move between splits
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>
" Shortcut to rapidly toggle `set list`
" nmap <leader>l :set list!<CR>
" Open vimrc
nmap <leader>v :tabedit $MYVIMRC<CR>
"clean-up whitespace
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
"remap esc with jj
inoremap jj <ESC>
" make Y yank till end of line
nnoremap Y y$
" tabs
" For mac users (using the 'apple' key)
if os == "Darwin"
map <D-S-]> gt
map <D-S-[> gT
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-0> :tablast<CR>
else
" for linux and windows users (using the control key)
map <C-S-]> gt
map <C-S-[> gT
map <C-1> 1gt
map <C-2> 2gt
map <C-3> 3gt
map <C-4> 4gt
map <C-5> 5gt
map <C-6> 6gt
map <C-7> 7gt
map <C-8> 8gt
map <C-9> 9gt
map <C-0> :tablast<CR>
endif
" Rspec.vim mappings
map <Leader>f :call RunCurrentSpecFile()<CR>
map <Leader>s :call RunNearestSpec()<CR>
map <Leader>d :call RunLastSpec()<CR>
map <Leader>a :call RunAllSpecs()<CR>
map <leader>c :Tmux bundle exec rubocop --rails --display-cop-names --display-style-guide<CR>
" +---------------------------------------------------------------------------+
" | Plugins Specific Settings |
" +---------------------------------------------------------------------------+
"makegreen - MakeGreen plugin and Ruby RSpec. Uncomment to use.
"autocmd BufNewFile,BufRead *_spec.rb compiler rspec
" Vim Wiki
let g:vimwiki_list = [{'path': '~/Documents/wiki/', 'syntax': 'markdown'}]
au FileType vimwiki setlocal shiftwidth=6 tabstop=6 noexpandtab
" Align GitHub-flavored Markdown tables
au FileType markdown vmap <Leader><Bslash> :EasyAlign*<Bar><Enter>
"syntastic settings
let g:syntastic_enable_signs=1
let g:syntastic_auto_loc_list=2
"Rspec.vim
"let g:rspec_command = "!bundle exec rspec {spec}"
let g:rspec_command = 'call Send_to_Tmux("bundle exec rspec {spec}\n")'
" let g:rspec_command = "bundle exec rspec {spec}"
" let g:rspec_runner = "os_x_iterm2"
" let g:rspec_runner = "os_x_terminal"
let g:rspec_runner = "os_x_iterm2"
let g:ackprg = 'ag --vimgrep'
"NERDTree
let g:NERDSpaceDelims = 1
let g:NERDTrimTrailingWhitespace = 1
"limelight
let g:limelight_conceal_ctermfg = 'gray'
"ale
let g:ale_enabled = 0
" +---------------------------------------------------------------------------+
" | Misc |
" +---------------------------------------------------------------------------+
if has("eval")
function! SL(function)
if exists('*'.a:function)
return call(a:function,[])
else
return ''
endif
endfunction
endif
function! s:LongLines()
let threshold = (&tw ? &tw : 80)
let spaces = repeat(" ", &ts)
let long_line_lens = []
let i = 1
while i <= line("$")
let len = strlen(substitute(getline(i), '\t', spaces, 'g'))
if len > threshold
call add(long_line_lens, len)
endif
let i += 1
endwhile
return long_line_lens
endfunction
function! s:Median(nums)
let nums = sort(a:nums)
let l = len(nums)
if l % 2 == 1
let i = (l-1) / 2
return nums[i]
else
return (nums[l/2] + nums[(l/2)-1]) / 2
endif
endfunction
function! <SID>StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction