-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
executable file
·261 lines (229 loc) · 5.6 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
" Essentials {{{
let g:auto_save = 1
let g:auto_save_silent = 0
let g:auto_save_events = ["TextChanged", "FocusLost", "InsertLeave"]
" }}}
" Search & Code navigation {{{
nmap <leader>a :Grepper -tool rg -cword -noprompt<cr>
nmap <leader>G :Grepper -tool rg<cr>
" }}}
" Text {{{
autocmd FileType javascript.jsx setlocal commentstring={/*\ %s\ */}
autocmd FileType hyprlang setlocal commentstring=#\ %s
" }}}
" File management & Git {{{
let g:eunuch_no_maps = 1
" }}}
" Ruby {{{
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'json': ['jq'],
\}
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'ruby': ['rubocop'],
\ 'sql': ['pgformatter'],
\ 'python': ['autopep8'],
\ 'javascript': ['prettier'],
\ 'json': ['jq'],
\}
let g:ale_ruby_rubocop_options = '-A'
let b:ale_sql_pgformatter_options = '--spaces 2 --wrap-after 10'
let g:ale_history_log_output = 1
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_enter = 1
let g:ale_fix_on_save = 1
let g:ale_virtualtext_cursor = 0
highlight ALEWarning ctermbg=none cterm=underline
highlight ALEError ctermbg=none cterm=underline
" nmap <leader>F :!rubocop -a %<cr>
nmap <leader>F :ALEFix<cr>
let g:pasta_disabled_filetypes = ['yaml']
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
"}}}
" Msc languages {{{
let g:vim_json_conceal=0
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
" }}}
" tmux and testing {{{
" let g:VimuxOrientation = "h"
" let g:VimuxHeight = "45"
let g:VimuxOrientation = "v"
let g:VimuxHeight = "33"
let g:test#preserve_screen = 1
let g:test#echo_command = 0
" nmap <leader><space> :FloatermNew!<space>
nmap <leader><space> :VimuxPromptCommand<cr>
let test#strategy = "vimux"
nmap <silent> <leader>x :TestNearest<CR>
nmap <silent> <leader>X :TestFile<CR>
nmap <silent> <leader>q :TestLast<CR>
function! FloatermNewBang(cmd)
execute 'FloatermNew ' . a:cmd
endfunction
let g:test#custom_strategies = {'floatermbang': function('FloatermNewBang')}
let g:floaterm_width = 0.9
let g:floaterm_height = 0.9
let g:floaterm_autoclose = 1
let g:floaterm_keymap_toggle = '<F1>'
let g:floaterm_keymap_new = '<F2>'
let g:floaterm_keymap_prev = '<F3>'
let g:floaterm_keymap_next = '<F4>'
" let test#strategy = "floaterm"
" }}}
" UI {{{
" let g:lightline = {
" \ 'active': {
" \ 'left': [ [ 'mode', 'paste' ],
" \ [ 'gitbranch', 'readonly', 'relativepath', 'modified' ] ]
" \ },
" \ 'component_function': {
" \ 'gitbranch': 'FugitiveHead'
" \ },
" \ }
" }}}
" New {{{
" }}}
" }}}
" UI {{{
set termguicolors
if filereadable(expand("~/.darkmode"))
set background=dark
colorscheme catppuccin
else
set background=light
colorscheme catppuccin-latte
endif
syntax on
set colorcolumn=90
set synmaxcol=140
set title
set ffs=unix,mac,dos
" set scrolloff=999
" set autoindent
set smartindent
set showmode
set modeline
set showcmd
set hidden
set wildmode=full
set ruler
set backspace=indent,eol,start
set laststatus=2
set number
set splitbelow
set splitright
set encoding=utf-8
setglobal fileencoding=utf-8
" Resize splits when the win is resized
au VimResized * wincmd =
" https://bluz71.github.io/2017/05/15/vim-tips-tricks.html
set autoread
augroup autoRead
autocmd!
autocmd FocusLost * silent! wall
augroup END
" Text Formatting
set tabstop=2
set shiftwidth=2
set expandtab
set nowrap
set textwidth=90
" set list listchars=tab:»·,trail:·
"}}}
" Settings {{{
set history=500
set nobackup
set nowritebackup
set noswapfile
set undofile
set undodir=~/.tmp,/tmp
set mouse=a
" }}}
" Folding {{{
set foldenable
set foldnestmax=10
set foldlevelstart=10
set foldmethod=indent
nmap f1 :set foldlevel=0<cr>
nmap f2 :set foldlevel=1<cr>
nmap f3 :set foldlevel=2<cr>
nmap fa :set foldlevel=99<cr>
" }}}
" Key mappings {{{
map , <leader>
" Buffer management
nnoremap <tab> :bn<CR>
nnoremap <S-tab> :bp<CR>
"}}}
" Msc annoyances {{{
nnoremap K <nop>
" reselect visual lock after indent/outdent
vnoremap < <gv
vnoremap > >gv
" }}}
" Searching {{{
set hlsearch
set incsearch
" set ignorecase
set smartcase
set gdefault
set showmatch
set wildignore+=node_modules/*
set wildignore+=app/assets/images/**/*
set wildignore+=vendor/cache/**/*
nnoremap <leader>, :noh<cr>
" nnoremap <space> /
nnoremap <leader>f :%s///<left><left>
nnoremap <Leader>s :%s/\<<C-r><C-w>\>//g<Left><Left>
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" }}}
" Spell checking {{{
set spellfile+=~/.vim/spell/en.utf-8.add
set dict+=~/.vim/spell/en.utf-8.add
noremap <leader>ss :setlocal spell!<cr>
noremap <leader>sn ]s
noremap <leader>sp [s
noremap <leader>sa zg
noremap <leader>sd z=
au BufRead,BufNewFile COMMIT_EDITMSG setlocal ft=diff spell!
au BufRead,BufNewFile COMMIT_EDITMSG 1
au BufRead,BufNewFile *.md setlocal nolist
"}}}
" Edit .vimrc {{{
command! Ev :e ~/.vimrc
command! Ec :e ~/.config/nvim/
command! Ep :e ~/.config/nvim/lua/plugins.lua
augroup vimrc
autocmd!
au bufwritepost .vimrc source $MYVIMRC
au bufread .vimrc set foldmethod=marker
augroup END
" }}}
" Function Keys {{{
set pastetoggle=<F3>
" }}}
" Ruby {{{
noremap <Leader>m :Emodel<space>
noremap <Leader>c :Econtroller<space>
autocmd FileType ruby setlocal indentkeys-=.
" }}}
" New stuff {{{
au BufReadPost *.html* set formatoptions-=t
command! Gbrowse GBrowse
if has("nvim")
" Terminal inside vim
autocmd TermOpen * startinsert
command! -nargs=* T split | resize 25 | terminal <args>
" nnoremap <leader>c :T<cr>
endif
noremap <f1> <Nop>
nmap <silent> gx :!xdg-open '<cWORD>'<cr>
nmap Y yy
" Substitute in line
nnoremap gs "zye:%s/<C-R>z//g<left><left>
" }}}