-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
324 lines (286 loc) · 12.2 KB
/
.vimrc
File metadata and controls
324 lines (286 loc) · 12.2 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
" ============================================================
" BASIC SETTINGS & ENVIRONMENT
" ============================================================
set nocompatible
filetype off
set clipboard=unnamed
if has("persistent_undo")
set undodir=~/.vim/undodir/
set undofile
endif
set number
set numberwidth=4
set scrolloff=25
set ruler
set showcmd
set showmatch
set backspace=indent,eol,start
set hidden
set autoread
set backupcopy=yes
set autowrite
set autowriteall
set noerrorbells
set hls
set ignorecase
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set wrap
set linebreak
set mouse=n
set noshowmode
set fileformats=unix,dos,mac
set iskeyword+=_,$,@,%,#
" Enable truecolor support and syntax highlighting
set termguicolors
syntax enable
" Set leader key
let mapleader = ","
" ============================================================
" PLUGIN MANAGER (Vundle) & PLUGINS
" ============================================================
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'honza/vim-snippets'
Plugin 'tomtom/tcomment_vim'
Plugin 'scrooloose/nerdtree'
Plugin 'mbbill/undotree'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'vim-airline/vim-airline'
Plugin 'allibell/vim-airline-themes'
" Plugin 'NLKNguyen/papercolor-theme'
" Plugin 'challenger-deep-theme/vim'
Plugin 'wincent/vim-clipper'
Plugin 'goerz/jupytext.vim'
Plugin 'cespare/vim-toml'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'git://git.wincent.com/command-t.git'
" Plugin 'git://github.com/digitaltoad/vim-pug.git'
call vundle#end()
filetype plugin indent on
" ============================================================
" THEME & COLORSCHEME CONFIGURATION
" ============================================================
" if &background == "dark"
" colorscheme challenger_deep
" else
" colorscheme PaperColor
" endif
" autocmd OptionSet background if &background == "dark" | colorscheme challenger_deep | else | colorscheme PaperColor | endif
" ============================================================
" UI ENHANCEMENTS & AIRLINE CONFIG
" ============================================================
let g:airline#extensions#default#layout = [['a', 'c'], ['z']]
let g:airline_section_z = "\ %3p%%\ %3l:%-2c\ "
let g:airline_powerline_fonts = 1
" let g:airline_theme='deus'
let g:airline_theme='papercolor'
let g:airline_mode_map = {"ic" : "INSERT", "ix" : "INSERT"}
" ============================================================
" MISCELLANEOUS SETTINGS & MAPPINGS
" ============================================================
" Jupytext: default to Python format
let g:jupytext_fmt = "py"
" Yank to clipboard using vim-clipper
function! YankToClipboard(type, ...)
if a:0
exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
exe "normal! '[V']y"
elseif a:type == 'block'
exe "normal! `[\<C-V>`]y"
else
exe "normal!(`[v`]y"
endif
execute ':Clip'
endfunction
nnoremap <silent> <leader>y :set opfunc=YankToClipboard<CR>g@
vnoremap <silent> <leader>y :<C-U>call YankToClipboard(visualmode(), 1)<CR>
" Open markdown files in Chrome
autocmd BufEnter *.md exe 'noremap <F5> :!google-chrome %:p<CR>'
" Command-T settings
let g:CommandTFileScanner="find"
let g:CommandTMaxFiles=500000
" Terminal-specific detection (for iterm, screen, tmux)
let s:iterm = exists('$ITERM_PROFILE') || exists('$ITERM_SESSION_ID') || filereadable(expand("~/.vim/.assume-iterm"))
let s:screen = &term =~ 'screen'
let s:tmux = exists('$TMUX')
" Undotree toggle
nnoremap <leader><C-r> :UndotreeToggle<CR>
" NERDTree mappings
nnoremap <leader>d :NERDTreeToggle %<CR>
nnoremap <leader>f :NERDTreeFind<CR>
" Faster normal mode for airline
set ttimeoutlen=8
" Prevent paste register overwrite in visual mode
xnoremap p pgvy
" Fix indentation and whitespace
map <F7> gg=G<C-o><C-o>
nnoremap <leader>fw :FixWhitespace<CR>
" Quick un-highlight search
nnoremap <silent> <leader>l :nohl<CR>
" Toggle paste mode with F2
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
" Window pane switching with Ctrl + [h,j,k,l]
nnoremap <C-j> <C-W>j
nnoremap <C-k> <C-W>k
nnoremap <C-h> <C-W>h
nnoremap <C-l> <C-W>l
" FZF integration (if installed)
set rtp+=/opt/homebrew/opt/fzf
" augroup MyRustBold
" autocmd!
" autocmd FileType rust highlight rustKeyword cterm=bold gui=bold
" autocmd FileType rust highlight rustIdentifier gui=bold guifg=#005faf cterm=bold ctermfg=31
" autocmd FileType rust highlight rustType cterm=bold gui=bold
" autocmd FileType rust highlight rustLifetime cterm=bold gui=bold
" autocmd FileType rust highlight rustAttribute cterm=bold gui=bold
" augroup END
"
"
"
augroup MyRustColors
autocmd!
" Base text
autocmd FileType rust highlight Normal gui=none guifg=#444444 cterm=none ctermfg=236
autocmd FileType rust highlight Comment gui=italic guifg=#878787 cterm=italic ctermfg=102
autocmd FileType rust highlight Constant gui=bold guifg=#5f8700 cterm=bold ctermfg=64
autocmd FileType rust highlight rustDerive gui=bold guifg=#008700 cterm=bold ctermfg=28
autocmd FileType rust highlight rustDeriveTrait gui=bold guifg=#008700 cterm=bold ctermfg=28
" Keywords and control flow (blue)
autocmd FileType rust highlight rustKeyword gui=bold guifg=#0087af cterm=bold ctermfg=31
autocmd FileType rust highlight rustConditional gui=bold guifg=#af0000 cterm=bold ctermfg=124
autocmd FileType rust highlight rustRepeat gui=bold guifg=#af0000 cterm=bold ctermfg=124
autocmd FileType rust highlight rustStorage gui=bold guifg=#0087af cterm=bold ctermfg=31
" Types and identifiers
autocmd FileType rust highlight rustType gui=bold guifg=#8700af cterm=bold ctermfg=91
autocmd FileType rust highlight rustTrait gui=bold guifg=#8700af cterm=bold ctermfg=91
autocmd FileType rust highlight rustIdentifier gui=bold guifg=#0087af cterm=bold ctermfg=31
" Functions and macros
autocmd FileType rust highlight rustFunction gui=bold guifg=#d75f00 cterm=bold ctermfg=166
autocmd FileType rust highlight rustMacro gui=bold guifg=#d75f00 cterm=bold ctermfg=166
autocmd FileType rust highlight rustAssert gui=bold guifg=#008700 cterm=bold ctermfg=28
" Attributes & lifetimes
autocmd FileType rust highlight rustAttribute gui=bold guifg=#008700 cterm=bold ctermfg=28
autocmd FileType rust highlight rustLifetime gui=bold guifg=#5f8700 cterm=bold ctermfg=64
" Dark-mode palette (so colors pop on dark terminals)
" function! s:ApplyRustColors(bg) abort
" if a:bg ==# 'dark'
" highlight Normal gui=none guifg=#dcdcdc cterm=none ctermfg=252
" highlight Comment gui=italic guifg=#7f9f9f cterm=italic ctermfg=103
" highlight Constant gui=bold guifg=#8be250 cterm=bold ctermfg=114
" highlight rustDerive gui=bold guifg=#8be250 cterm=bold ctermfg=114
" highlight rustDeriveTrait gui=bold guifg=#8be250 cterm=bold ctermfg=114
" highlight rustKeyword gui=bold guifg=#66d9ef cterm=bold ctermfg=81
" highlight rustConditional gui=bold guifg=#f07178 cterm=bold ctermfg=167
" highlight rustRepeat gui=bold guifg=#f07178 cterm=bold ctermfg=167
" highlight rustStorage gui=bold guifg=#66d9ef cterm=bold ctermfg=81
" highlight rustType gui=bold guifg=#b294bb cterm=bold ctermfg=139
" highlight rustTrait gui=bold guifg=#b294bb cterm=bold ctermfg=139
" highlight rustIdentifier gui=bold guifg=#66d9ef cterm=bold ctermfg=81
" highlight rustFunction gui=bold guifg=#f0c674 cterm=bold ctermfg=179
" highlight rustMacro gui=bold guifg=#f0c674 cterm=bold ctermfg=179
" highlight rustAssert gui=bold guifg=#8be250 cterm=bold ctermfg=114
" highlight rustAttribute gui=bold guifg=#b5bd68 cterm=bold ctermfg=143
" highlight rustLifetime gui=bold guifg=#b5bd68 cterm=bold ctermfg=143
" else
" " Light-mode palette (muted for light backgrounds)
" highlight Normal gui=none guifg=#444444 cterm=none ctermfg=236
" highlight Comment gui=italic guifg=#878787 cterm=italic ctermfg=102
" highlight Constant gui=bold guifg=#5f8700 cterm=bold ctermfg=64
" highlight rustDerive gui=bold guifg=#008700 cterm=bold ctermfg=28
" highlight rustDeriveTrait gui=bold guifg=#008700 cterm=bold ctermfg=28
" highlight rustKeyword gui=bold guifg=#0087af cterm=bold ctermfg=31
" highlight rustConditional gui=bold guifg=#af0000 cterm=bold ctermfg=124
" highlight rustRepeat gui=bold guifg=#af0000 cterm=bold ctermfg=124
" highlight rustStorage gui=bold guifg=#0087af cterm=bold ctermfg=31
" highlight rustType gui=bold guifg=#8700af cterm=bold ctermfg=91
" highlight rustTrait gui=bold guifg=#8700af cterm=bold ctermfg=91
" highlight rustIdentifier gui=bold guifg=#0087af cterm=bold ctermfg=31
" highlight rustFunction gui=bold guifg=#d75f00 cterm=bold ctermfg=166
" highlight rustMacro gui=bold guifg=#d75f00 cterm=bold ctermfg=166
" highlight rustAssert gui=bold guifg=#008700 cterm=bold ctermfg=28
" highlight rustAttribute gui=bold guifg=#008700 cterm=bold ctermfg=28
" highlight rustLifetime gui=bold guifg=#5f8700 cterm=bold ctermfg=64
" endif
" endfunction
" " Apply when a rust buffer opens
" autocmd FileType rust call s:ApplyRustColors(&background)
" " Reapply when background option changes (toggle light/dark)
" autocmd OptionSet background call s:ApplyRustColors(&background)
augroup END
" This Vim mapping inserts a timestamp when you press Ctrl+T in insert mode.
" Specifically:
"
" imap <C-t> creates a mapping that works in insert mode when you press Ctrl+T
" <C-R>= allows you to evaluate a Vim expression and insert the result
" strftime("[%m-%d-%A-%Y %I:%M %p]") formats the current time in the pattern:
" [month-day-dayofweek-year hour:minute AM/PM]
"
" For example, pressing Ctrl+T while in insert mode would insert something
" like:
" [04-20-Thursday-2023 02:30 PM
imap <C-t> <C-R>=strftime("`[%m-%d-%A-%Y %I:%M %p]`")<CR>
" Toggle markdown checkbox [ ] <-> [x] for current line or visual selection
function! s:ToggleCheckboxRange(startline, endline) abort
let l:lines = getline(a:startline, a:endline)
for i in range(len(l:lines))
let l = l:lines[i]
if l =~# '\v(^\s*([*+-]|\d+\.)\s*)\zs\[\s\]'
let l:lines[i] = substitute(l, '\v(^\s*([*+-]|\d+\.)\s*)\zs\[\s\]', '[x]', '')
elseif l =~# '\v(^\s*([*+-]|\d+\.)\s*)\zs\[x\]'
let l:lines[i] = substitute(l, '\v(^\s*([*+-]|\d+\.)\s*)\zs\[x\]', '[ ]', '')
elseif l =~# '\v\[\s\]'
let l:lines[i] = substitute(l, '\v\[\s\]', '[x]', '')
elseif l =~# '\v\[x\]'
let l:lines[i] = substitute(l, '\v\[x\]', '[ ]', '')
endif
endfor
call setline(a:startline, l:lines)
endfunction
" Wrapper callable from mappings
function! ToggleCheckboxWrapper(...) abort
if a:0 == 2
call s:ToggleCheckboxRange(a:1, a:2)
else
let lnum = line('.')
call s:ToggleCheckboxRange(lnum, lnum)
endif
endfunction
" --- Markdown checkbox mappings: define mappings from a function (robust) ---
function! s:SetupMarkdownCheckboxes() abort
" normal/visual toggle (buffer-local)
nnoremap <buffer> <nowait> <silent> ,c :call ToggleCheckboxWrapper()<CR>
vnoremap <buffer> <nowait> <silent> ,c <Esc>:call ToggleCheckboxWrapper(line("'<"), line("'>"))<CR>
" insert helpers
" make <C-b> use <C-o>I to jump to first non-blank for a single command then insert
" no more iabbrev >:(
inoremap <buffer> <nowait> <C-b> <C-o>I- [ ]
" normal-mode insert helpers
nnoremap <buffer> <silent> ,i ^i- [ ]
nnoremap <buffer> <silent> ,I o- [ ]
endfunction
augroup MarkdownCheckboxes
autocmd!
autocmd FileType markdown call s:SetupMarkdownCheckboxes()
augroup END
"
" " Function to insert 20 blank lines
" function! InsertBlankLines()
" for i in range(20)
" call append(line('.'), '')
" endfor
" endfunction
"
function! InsertBlankLines()
call append(line('.'), repeat([''], 20))
endfunction
" Map Ctrl-] in normal mode to call the function
nnoremap <C-]> :call InsertBlankLines()<CR>
inoremap <C-]> <Esc>:call InsertBlankLines()<CR>a