-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
373 lines (317 loc) · 9.31 KB
/
init.vim
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
363
364
365
366
367
368
369
370
371
372
373
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.vim/plugged')
" General
Plug 'tpope/vim-sensible'
Plug 'w0rp/ale'
Plug 'rhysd/devdocs.vim'
Plug 'ton/vim-bufsurf'
Plug 'scrooloose/nerdcommenter'
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-vinegar'
Plug 'editorconfig/editorconfig-vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'maksimr/vim-jsbeautify'
Plug 'github/copilot.vim'
Plug 'tpope/vim-sleuth'
Plug 'romainl/vim-qf'
" Syntax
Plug 'neoclide/vim-jsx-improve'
Plug '2072/PHP-Indenting-for-Vim'
Plug 'StanAngeloff/php.vim'
" Plug 'fatih/vim-go', { 'tag': 'v1.28', 'do': ':GoUpdateBinaries' }
Plug 'dart-lang/dart-vim-plugin'
" Plug 'evanleck/vim-svelte', {'branch': 'main'}
Plug 'hashivim/vim-terraform'
" Plug 'hashivim/vim-packer'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'leafgarland/typescript-vim'
" Golang
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'neovim/nvim-lspconfig'
Plug 'ray-x/go.nvim'
Plug 'ray-x/guihua.lua'
" Snippets
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'honza/vim-snippets'
" Color Schemes
Plug 'robertmeta/nofrils'
Plug 'wolverian/minimal'
Plug 'elmindreda/vimcolors'
Plug 'MidnaPeach/neonwave.vim'
Plug 'dgraham/xcode-low-key-vim'
Plug 'vim-scripts/mayansmoke'
Plug 'andreypopp/vim-colors-plain'
Plug 'Lokaltog/vim-monotone'
Plug 'logico-dev/typewriter'
Plug 'NLKNguyen/papercolor-theme'
Plug 'aunsira/macvim-light'
Plug 'chriskempson/base16-vim'
Plug 'mcchrish/zenbones.nvim'
" Initialize plugin system
call plug#end()
let mapleader = "\<Space>"
imap jk <Esc>
imap kj <Esc>
nnoremap <Leader>w :w<CR>
vmap <Leader>= "+y
" TYPO FIX
map q: :q
" Copy file path
nmap cp :let @" = expand("%")<CR>
set tm=900
set smartindent
set nu
set guioptions=
set mouse=a
set nowrap
set number
set relativenumber
set hidden
set backupcopy=yes
set inccommand=nosplit
set termguicolors
" Nofril
" let g:nofrils_heavylinenumbers=1
" let g:nofrils_strbackgrounds=1
syntax enable
if &diff
set background=light
colorscheme xcode-low-key
else
colorscheme PaperColor
set background=light
" colorscheme neonwave
" set background=dark
" set notermguicolors
endif
hi Search guibg=yellow guifg=black
hi Search cterm=NONE ctermfg=black ctermbg=yellow
if executable('win32yank.exe')
let g:clipboard = {
\ 'name': 'win32yank-wsl',
\ 'copy': {
\ '+': 'win32yank.exe -i --crlf',
\ '*': 'win32yank.exe -i --crlf',
\ },
\ 'paste': {
\ '+': 'win32yank.exe -o --lf',
\ '*': 'win32yank.exe -o --lf',
\ },
\ 'cache_enabled': 0,
\ }
endif
" ----------- AUTOCOMPLETION ----------- "
inoremap <C-l> <C-x><C-o>
" ----------- BUFFERS ----------- "
nmap <Leader>l :BufSurfForward<cr>
nmap <Leader>h :BufSurfBack<cr>
nmap <Leader>b :Buffers<cr>
" ---------- CUSTOM DIC --------- "
set dictionary+=~/.config/nvim/words
" ----------- FILE TYPES ------- "
au BufNewFile,BufRead *.ejs set filetype=javascript
au FileType yaml setl ts=2 sts=2 sw=2 et
au FileType php setl sw=4 ts=4
au FileType javascript setl sw=2 ts=2 et
au FileType json setl sw=2 ts=2 et
au BufNewFile,BufRead *.svelte set nowrap tabstop=2 shiftwidth=2 expandtab
au BufNewFile,BufRead *.ts set nowrap tabstop=2 shiftwidth=2 expandtab
let php_sql_query = 0
let php_sql_heredoc = 0
let php_sql_nowdoc = 0
let g:vim_markdown_folding_disabled = 1
let g:jsx_ext_required = 0
let g:javascript_plugin_jsdoc = 1
let g:dart_style_guide = 2
let g:dart_format_on_save = 1
" ----------- SNIPPETS --------- "
imap <C-k> <Plug>(neosnippet_expand_or_jump)
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory='~/.vim/bundle/vim-snippets/snippets'
" ----------- SEARCH ----------- "
" set wildignore=**/node_modules/*,**/vendor/*
nmap <Leader>s :grep -r --hidden --ignore composer.phar --ignore composer.lock --ignore-dir node_modules --ignore-dir vendor --ignore-dir php-app/fc/cdn_js/out --vimgrep --ignore tags "" ./<left><left><left><left>
nmap <Leader>c :botright copen<cr>
set hlsearch
if executable('ag')
" Use Ag over Grep
set grepprg=ag\ --nogroup\ --nocolor
endif
" ----------- Go NVIM ----------- "
lua <<EOF
local format_sync_grp = vim.api.nvim_create_augroup("GoFormat", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.go",
callback = function()
require('go.format').goimports()
end,
group = format_sync_grp,
})
require('go').setup()
EOF
nmap <Leader>t :GoTest<CR>
" ----------- DEVDOCS ----------- "
nmap <Leader>k <Plug>(devdocs-under-cursor)
" ----------- NERDCommenter ----------- "
let g:NERDSpaceDelims = 1
let g:NERDTreeHijackNetrw=1
map <Leader>/ <Leader>c<Leader>
map <c-/> <Leader>c<Leader>
" ----------- NETRW ----------- "
let g:netrw_banner = 0
nnoremap - - " Override vim-vinegar map
nmap _ <Plug>VinegarUp
nmap <C-p> :GFiles<cr>
" ------------- ALE ------------ "
let g:ale_completion_enabled = 1
filetype off
let &runtimepath.=',~/.vim/bundle/ale'
filetype plugin indent on
let g:ale_c_cc_executable = 'gcc' " Or use 'clang'
let g:ale_c_cc_options = '-std=c11 -Wall `pkg-config --cflags gtk+-3.0`'
let g:ale_php_phan_use_client = 1
let g:ale_linters = {'php': ['php', 'phan'], 'go': ['golint', 'govet', 'gopls']}
au BufRead,BufNewFile **/.github/workflows/*.yml let b:ale_linters = {'yaml': ['actionlint', 'yamllint'] }
let g:ale_fixers = {
\ 'javascript': [
\ 'eslint'
\ ],
\ 'typescript': [
\ 'eslint'
\ ],
\ 'dart': [
\ 'dartfmt'
\ ],
\ 'php': [
\ 'php_cs_fixer'
\ ],
\ 'go': [
\ 'gofmt'
\ ]
\}
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
let g:ale_statusline_format = ['X %d', '? %d', '']
let g:ale_echo_msg_format = '%linter% rule %code% says %s'
let g:ale_php_phpcs_standard = "./fc-standard.xml"
let g:ale_fix_on_save = 1
call ale#linter#Define('javascript', {
\ 'name': 'javascript-typescript-langserver',
\ 'lsp': 'stdio',
\ 'executable': 'node',
\ 'command': '%e /home/brandon/sources/javascript-typescript-langserver/lib/language-server-stdio.js',
\ 'project_root': './',
\ })
nnoremap gan :ALENextWrap<cr>
nnoremap gap :ALEPreviousWrap<cr>
" nmap gq :ALEFix<CR>
function! SmartInsertCompletion() abort
" Use the default CTRL-N in completion menus
if pumvisible()
return "\<C-n>"
endif
" Exit and re-enter insert mode, and use insert completion
return "\<C-c>a\<C-n>"
endfunction
inoremap <silent> <C-n> <C-R>=SmartInsertCompletion()<CR>
" ------------- EDITOR CONFIG ------------ "
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" ------------- SnipMate ------------- "
let g:snipMate = { 'snippet_version' : 1 }
" ------------- FUNCTIONS ------------ "
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
\}
nnoremap <silent> gd :ALEGoToDefinition<CR>
nnoremap <silent> gh :ALEHover<CR>
nnoremap <silent> gq :ALEFix<CR>
nnoremap <silent> gan :ALENextWrap<cr>
nnoremap <silent> gap :ALEPreviousWrap<cr>
" ------------- EDITOR CONFIG ------------ "
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" ------------- FUNCTIONS ------------ "
" vp doesn't replace paste buffer
function! RestoreRegister()
let @" = s:restore_reg
return ''
endfunction
function! s:Repl()
let s:restore_reg = @"
return "p@=RestoreRegister()\<cr>"
endfunction
" Hack fix enter being bound wrong
nnoremap <cr> <cr>
function! HlIndent()
let currLine = getline('.')
let matchs = matchstrpos(currLine, '^\(\s\+\)')
let regex = '^\s\{' . matchs[2] . '}'
execute 'normal! /' . regex . '<CR>'
endfunction
function! LineWidth()
execute("vertical resize " . (strwidth(getline(".")) + 10))
endfunction
nmap gl :call LineWidth()<cr>
nmap <Leader>r :%s //g<left><left>
nmap <Leader>y "ay
nmap <Leader>p "ap
function! Wipeout()
" list of *all* buffer numbers
let l:buffers = range(1, bufnr('$'))
" what tab page are we in?
let l:currentTab = tabpagenr()
try
" go through all tab pages
let l:tab = 0
while l:tab < tabpagenr('$')
let l:tab += 1
" go through all windows
let l:win = 0
while l:win < winnr('$')
let l:win += 1
" whatever buffer is in this window in this tab, remove it from
" l:buffers list
let l:thisbuf = winbufnr(l:win)
call remove(l:buffers, index(l:buffers, l:thisbuf))
endwhile
endwhile
" if there are any buffers left, delete them
if len(l:buffers)
execute 'bwipeout' join(l:buffers)
endif
finally
" go back to our original tab page
execute 'tabnext' l:currentTab
endtry
endfunction
" Makes it easier to deal with JS in PHP
function! JSPHP()
set filetype=javascript
set syntax=javascript
set shiftwidth=4
set noexpandtab
set tabstop=4
ALEDisable
endfunction
function! LightMode()
colorscheme PaperColor
set background=light
endfunction
function! DarkMode()
" set notermguicolors
" colorscheme neonwave
let g:zenbones_compat=1
colorscheme PaperColor
set background=dark
endfunction
" call DarkMode()