-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvimrc
More file actions
429 lines (359 loc) · 10.3 KB
/
Copy pathvimrc
File metadata and controls
429 lines (359 loc) · 10.3 KB
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
vim9script
# Name: Arnold Chand
# Github: https://github.com/creativenull
# Description: My vimrc config, aiming to be one file, self-contained.
# =============================================================================
# User Configuration (USER)
# =============================================================================
g:mapleader = "\<Space>"
const undopath = expand('$HOME/.cache/vim/undo')
if undopath->isdirectory() == 0
echomsg 'Creating undodir directory'
undopath->mkdir('p')
endif
# =============================================================================
# Options (OPT)
# =============================================================================
unlet! g:skip_defaults_vim
source $VIMRUNTIME/defaults.vim
&titlestring = printf("[vim] %s", fnamemodify(getcwd(), ":t"))
&undodir = undopath
set backspace=indent,eol,start
set clipboard-=autoselect
set cmdheight=2
set colorcolumn=81,121
set completeopt=menuone,noinsert,noselect,fuzzy
set conceallevel=2
set encoding=utf-8
set guicursor=n-v-c-sm:block,i-ci-ve:block,r-cr-o:hor20
set hidden
set history=10000
set hlsearch
set ignorecase
set incsearch
set laststatus=2
set lazyredraw
set mouse=nv
set nobackup
set noexpandtab
set nofoldenable
set nospell
set noswapfile
set nowrap
set number
set path=**
set scrolloff=1
set shiftwidth=4
set shortmess+=c
set showmatch
set showtabline=0
set signcolumn=yes
set smartcase
set smartindent
set softtabstop=4
set tabstop=4
set termguicolors
set title
set ttimeoutlen=50
set undofile
set undolevels=10000
set updatetime=250
set wildignore=*.git/*,*node_modules/*,*vendor/*,*dist/*,*build/*
set wildignorecase
set wildmenu
set wildmode=noselect:lastused,full
set wildoptions=pum,fuzzy
if has('termguicolors')
set termguicolors
&t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
&t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
# =============================================================================
# Keymaps (KEY)
# =============================================================================
nnoremap <Up> <Nop>
nnoremap <Down> <Nop>
nnoremap <Left> <Nop>
nnoremap <Right> <Nop>
inoremap <Up> <Nop>
inoremap <Down> <Nop>
inoremap <Left> <Nop>
inoremap <Right> <Nop>
nnoremap <C-k> <Nop>
nnoremap <C-j> <Nop>
nnoremap <C-h> <Nop>
nnoremap <C-l> <Nop>
inoremap <C-k> <Nop>
inoremap <C-j> <Nop>
inoremap <C-h> <Nop>
inoremap <C-l> <Nop>
nnoremap <Up> <Cmd>call <SID>ResizeHorizontal(2)<CR>
nnoremap <Down> <Cmd>call <SID>ResizeHorizontal(-2)<CR>
nnoremap <Left> <Cmd>call <SID>ResizeVertical(2)<CR>
nnoremap <Right> <Cmd>call <SID>ResizeVertical(-2)<CR>
# Map escape from terminal input to Normal mode
tnoremap <Esc> <C-\><C-n>
tnoremap <C-[> <C-\><C-n>
# Disable highlights
nnoremap <Leader><CR> <Cmd>noh<CR>
# Close all buffer, except current
nnoremap <Leader>bx <Cmd>%bd<Bar>e#<Bar>bd#<CR>
# Move a line of text Alt+[j/k]
nnoremap <M-j> mz:m+<CR>`z
vnoremap <M-j> :m'>+<CR>`<my`>mzgv`yo`z
nnoremap <M-k> mz:m-2<CR>`z
vnoremap <M-k> :m'<-2<CR>`>my`<mzgv`yo`z
# Edit vimrc
nnoremap <Leader>ve <Cmd>edit $MYVIMRC<CR>
# Source the vimrc to reflect changes
nnoremap <Leader>vs <Cmd>source $MYVIMRC<CR>
# Reload file
nnoremap <Leader>r <Cmd>edit!<CR>
# Copy/Paste from sytem clipboard
vnoremap p "_dP
vnoremap <Leader>y "+y
nnoremap <Leader>y "+y
nnoremap <Leader>p "+p
# =============================================================================
# Commands (CMD)
# =============================================================================
# Command Abbreviations, I can't release my shift key fast enough 😭
cnoreabbrev Q q
cnoreabbrev Qa qa
cnoreabbrev W w
cnoreabbrev Wq wq
# =============================================================================
# Functions (FUN)
# =============================================================================
def ResizeHorizontal(amount: number)
const wincount = getwininfo()->len()
if wincount > 1
execute(printf('resize %s%d', amount > 0 ? '+' : '', amount))
endif
enddef
def ResizeVertical(amount: number)
const wincount = getwininfo()->len()
if wincount > 1
execute(printf('vertical resize %s%d', amount > 0 ? '+' : '', amount))
endif
enddef
def VimGrep(qargs: string, bang: bool)
const sanitizedQargs = qargs->shellescape()
const sh = $'rg --column --line-number --no-heading --color=always --smart-case -- {sanitizedQargs}'
fzf#vim#grep(sh, 1, fzf#vim#with_preview({}), bang)
enddef
def FzfStatusline()
highlight fzf1 guibg=NONE
setlocal statusline=%#fzf1#\ >\ fzf
enddef
def FernInit()
nnoremap q <Cmd>bd<CR>
nmap <buffer> D <Plug>(fern-action-remove)
setlocal expandtab shiftwidth=2 tabstop=2
glyph_palette#apply()
enddef
def AutoTheme(config: dict<any>)
if has('mac')
const theme = system('defaults read -g AppleInterfaceStyle 2>/dev/null')->trim()
if theme == 'Dark'
SetDarkTheme(config.dark)
else
SetLightTheme(config.light)
endif
else
SetDarkTheme(config.dark)
endif
enddef
def SetLocalOptionsOnFileType(ft: string)
setlocal tabstop=2
setlocal softtabstop=2
setlocal shiftwidth=0
setlocal expandtab
setlocal iskeyword+=-
if ft == 'markdown'
setlocal spell
setlocal textwidth=120
inoreabbrev i I
inoreabbrev ive I've
inoreabbrev im I'm
endif
enddef
autocmd! FileType blade,css,html,javascript,javascriptreact,json,jsonc,lua,markdown,typescript,typescriptreact,vim,vue SetLocalOptionsOnFileType(get(b:, 'ft', ''))
# =============================================================================
# Builtin plugins (BUILT)
# =============================================================================
packadd! matchit
packadd! editorconfig
packadd! comment
packadd! nohlsearch
packadd! hlyank
# =============================================================================
# Plugin Manger (PLUG)
# =============================================================================
const data_dir = expand('$HOME/.vim')
const plug_filepath = $'{data_dir}/autoload/plug.vim'
if empty(glob(plug_filepath))
const cmd = [
'!curl',
'-fLo',
plug_filepath,
'--create-dirs',
'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim',
]->join(' ')
silent execute(cmd)
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
plug#begin()
# Deps
# ---
Plug 'lambdalisue/vim-nerdfont'
Plug 'vim-denops/denops.vim'
Plug 'vim-denops/denops-shared-server.vim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
# Core
# ---
Plug 'cohama/lexima.vim'
Plug 'creativenull/projectlocal-vim', { 'tag': 'v1.*' }
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'Shougo/context_filetype.vim'
Plug 'markonm/traces.vim', { 'commit': '9663fcf84de5776bee71b6c816c25ccb6ea11d1a' }
# AI
# ---
Plug 'Exafunction/windsurf.vim', { 'branch': 'main' }
# File explorer
# ---
Plug 'lambdalisue/vim-fern'
Plug 'lambdalisue/vim-fern-renderer-nerdfont'
Plug 'lambdalisue/vim-glyph-palette'
# Fuzzy finder/Code finder
# ---
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'linrongbin16/fzfx.vim', { 'commit': '9bd93e78f22c734751688cefd3ee2c475cd85ccd' }
# Git
# ---
Plug 'tpope/vim-fugitive'
Plug 'itchyny/vim-gitbranch'
Plug 'airblade/vim-gitgutter'
# Linters + Formatters
# ---
Plug 'dense-analysis/ale'
# Autocompletion
# ---
# UI/Aeshetics
# ---
Plug 'vim-airline/vim-airline'
# File syntax Plugins
# ---
# Colorschemes
# ---
Plug 'bluz71/vim-moonfly-colors'
Plug 'bluz71/vim-nightfly-guicolors'
Plug 'rakr/vim-one'
plug#end()
# =============================================================================
# Configure plugins (POST)
# =============================================================================
# windsurf.vim Config
# ---
g:codeium_disable_bindings = 1
g:codeium_filetypes = {
'fern-replacer': false,
'gitcommit': true,
}
imap <script><silent><nowait><expr> <Tab> codeium#Accept()
imap <M-]> <Cmd>call codeium#CycleCompletions(1)<CR>
imap <M-[> <Cmd>call codeium#CycleCompletions(-1)<CR>
# fzf.vim Config
# ---
$FZF_DEFAULT_COMMAND = 'rg --files --hidden --iglob !.git'
$FZF_DEFAULT_OPTS = '--reverse --color=border:#aaaaaa,gutter:-1,bg+:-1'
g:fzf_vim = {
preview_window: [],
grep_multi_line: 1,
}
command! -bang -nargs=* Rg VimGrep(<q-args>, <bang>0)
nnoremap <C-p> <Cmd>Files<CR>
nnoremap <C-t> <Cmd>Rg<CR>
nnoremap <C-y> <ScriptCmd>VimGrep(expand('<cword>'), 0)<CR>
nnoremap <C-Space> <Cmd>FzfxBuffers<CR>
# fern.vim Config
# ---
g:fern#hide_cursor = 1
g:fern#default_hidden = 1
g:fern#renderer = 'nerdfont'
g:fern#renderer#nerdfont#root_symbol = ' '
g:fern#renderer#nerdfont#indent_markers = 1
nnoremap <Leader>ff <Cmd>Fern . -reveal=%<CR>
autocmd! FileType fern FernInit()
# emmet-vim Config
# ---
g:user_emmet_leader_key = '<C-q>'
g:user_emmet_mode = 'in'
g:user_emmet_settings = {
blade: {
extends: 'html',
},
}
imap <C-x><C-y> <Plug>(emmet-expand-abbr)
nmap <Leader>er <Plug>(emmet-update-tag)
# indentLine Config
# ---
g:indentLine_char = '│'
g:indentLine_fileTypeExclude = ['help', 'fern', 'fzf']
# vim-airline Config
# ---
g:airline_experimental = 1
g:airline_powerline_fonts = 1
g:airline#extensions#ale#enabled = 1
g:airline_section_z = '℅:%v, :%L'
# hlyank Config
# ---
g:hlyank_hlgroup = 'IncSearch'
g:hlyank_duration = 300
g:hlyank_invisual = 1
# =============================================================================
# Configure theme (THEME)
# =============================================================================
def SetLightTheme(theme: string)
augroup colorset
autocmd!
autocmd ColorScheme one silent! highlight Normal guibg=NONE
autocmd ColorScheme one silent! highlight SignColumn guibg=NONE
augroup END
$FZF_DEFAULT_OPTS = [
'--reverse',
'--color=bg+:#b7c1e3',
'--color=bg:-1',
'--color=border:#4094a3',
'--color=fg:#3760bf',
'--color=gutter:#d0d5e3',
'--color=header:#b15c00',
'--color=hl+:#188092',
'--color=hl:#188092',
'--color=info:#8990b3',
'--color=marker:#d20065',
'--color=pointer:#d20065',
'--color=prompt:#188092',
'--color=query:#3760bf:regular',
'--color=scrollbar:#4094a3',
'--color=separator:#b15c00',
'--color=spinner:#d20065',
]->join(' ')
set background=light
printf('colorscheme %s', theme)->execute()
enddef
def SetDarkTheme(theme: string)
g:moonflyNormalFloat = v:true
g:moonflyTransparent = v:false
set background=dark
printf('colorscheme %s', theme)->execute()
enddef
AutoTheme({
light: 'one',
dark: 'moonfly',
})