-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
255 lines (199 loc) · 8.08 KB
/
vimrc
File metadata and controls
255 lines (199 loc) · 8.08 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
set nocompatible " Must come first because it changes other options.
" vim-plug
call plug#begin('~/.vim/bundle')
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'tpope/vim-commentary'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
call plug#end()
syntax enable " Turn on syntax highlighting.
filetype plugin indent on " Turn on file type detection.
set showcmd " Display incomplete commands.
set showmode " Display the mode you're in.
set backspace=indent,eol,start " Intuitive backspacing.
set hidden " Handle multiple buffers better.
" remember more commands and search history
set history=10000
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 number " Show line numbers.
set ruler " Show cursor position.
set incsearch " Highlight matches as you type.
set hlsearch " Highlight matches.
set scrolloff=3 " Show 3 lines of context around the cursor.
set title " Set the terminal's title
set nobackup " Don't make a backup before overwriting a file.
set nowritebackup " And again.
set noswapfile " no swap files
set tabstop=2 " Global tab width.
set shiftwidth=2 " And again, related.
set expandtab " Use spaces instead of tabs
set visualbell
set laststatus=2 " Show the status line all the time
" Useful status information at bottom of screen
set statusline=[%n]\ %<%.99f\ %h%w%m%r%y\ %{exists('*CapsLockStatusline')?CapsLockStatusline():''}%=%-16(\ %l,%c-%v\ %)%P
" Prevent Vim from clobbering the scrollback buffer. See
" http://www.shallowsky.com/linux/noaltscreen.html
set t_ti= t_te=
" enable copying to and from the mac clipboard
set clipboard=unnamed
" add plugins
packadd! matchit
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COLOR
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set termguicolors
set t_Co=256 " 256 colors
" Auto light/dark mode based on macOS appearance
if system('defaults read -g AppleInterfaceStyle 2>/dev/null') =~ 'Dark'
set background=dark
silent! colorscheme catppuccin_mocha
else
set background=light
silent! colorscheme catppuccin_latte
endif
" Use terminal background
hi Normal ctermbg=NONE guibg=NONE
hi NonText ctermbg=NONE guibg=NONE
set cursorline
let mapleader=","
cnoremap %% <C-R>=expand('%:h').'/'<cr>
" Move around splits with <c-hjkl>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" can't be bothered to understand ESC vs <c-c> in insert mode
imap <c-c> <esc>
" Clear the search buffer when hitting return
:nnoremap <CR> :nohlsearch<cr>
nnoremap <leader><leader> <c-^>
vmap <Tab> >gv
vmap <S-Tab> <gv
map ; :
noremap ;; ;
" vim-go
let g:go_fmt_command = "goimports"
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" Disable Copilot
" let g:copilot_enabled = v:false
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" ARROW KEYS ARE UNACCEPTABLE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
map <Left> :echo "no!"<cr>
map <Right> :echo "no!"<cr>
map <Up> :echo "no!"<cr>
map <Down> :echo "no!"<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MULTIPURPOSE TAB KEY
" Indent if we're at the beginning of a line. Else, do completion.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>
inoremap <s-tab> <c-n>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" RENAME CURRENT FILE
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! RenameFile()
let old_name = expand('%')
let new_name = input('New file name: ', expand('%'))
if new_name != '' && new_name != old_name
exec ':saveas ' . new_name
exec ':silent !rm ' . old_name
redraw!
endif
endfunction
map <leader>n :call RenameFile()<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COPY HIGHLIGHTED TEXT WITH FILE INFO
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CopyHighlightedWithFileInfo()
" Get the current file name
let l:filename = expand('%')
" Get the line range of the selected text
let l:start_line = line("'<")
let l:end_line = line("'>")
" Get the highlighted text
let l:highlighted_text = getline(l:start_line, l:end_line)
" Join the text into a single string
let l:joined_text = join(l:highlighted_text, "\n")
" Format the output with file name and line range
let l:formatted_output = printf("File: %s\nLines: %d-%d\n\n%s",
\ l:filename, l:start_line, l:end_line, l:joined_text)
" Copy the formatted text to the system clipboard
call setreg('+', l:formatted_output)
echo "Copied to clipboard: " . l:filename . " (" . l:start_line . "-" . l:end_line . ")"
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" COPY FILE NAME
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! CopyFilename()
" Get the current file name
let l:filename = expand('%')
" Copy the formatted text to the system clipboard
call setreg('+', l:filename)
echo "Copied to clipboard: " . l:filename
endfunction
map <leader>y :<C-u>call CopyHighlightedWithFileInfo()<CR>
map <leader>yf :<C-u>call CopyFilename()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" MAPS TO JUMP TO SPECIFIC FZF TARGETS AND FILES
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
let $FZF_DEFAULT_OPTS = '--bind ctrl-d:half-page-down,ctrl-b:half-page-up'
map <leader>f :FZF .<cr>
map <leader>fc :FZF --query=config<cr>
map <leader>fe :FZF --query=event<cr>
map <leader>fh :FZF --query=handler<cr>
map <leader>fi :FZF --query=infra<cr>
map <leader>fl :FZF --query=log<cr>
map <leader>fm :FZF --query=model<cr>
map <leader>fp :FZF --query=pipeline<cr>
map <leader>fr :FZF --query=route<cr>
map <leader>fs :FZF --query=service<cr>
map <leader>ft :FZF --query=task<cr>
map <leader>fx :FZF --query=schema<cr>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" coc.nvim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Typescript redraw fix
set re=0
" GoTo code navigation.
nmap <leader>d <Plug>(coc-definition)
nmap <leader>td <Plug>(coc-type-definition)
nmap <leader>i <Plug>(coc-implementation)
nmap <leader>r <Plug>(coc-references)
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Use K to show documentation in preview window.
nnoremap <leader>D :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
elseif (coc#rpc#ready())
call CocActionAsync('doHover')
else
execute '!' . &keywordprg . " " . expand('<cword>')
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" LEGACY vim-commentary support
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
xmap \\ <Plug>Commentary
nmap \\ <Plug>Commentary