-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
260 lines (227 loc) · 8.39 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
" Install vim-plug if we don't already have it
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'tpope/vim-fugitive'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-vinegar'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-surround'
Plug 'editorconfig/editorconfig-vim'
Plug 'oguzbilgic/vim-gdiff'
Plug 'dkarter/bullets.vim'
Plug 'alvan/vim-closetag'
" Syntax
Plug 'mboughaba/i3config.vim'
Plug 'ekalinin/Dockerfile.vim'
" Dev
Plug 'prabirshrestha/async.vim', { 'on': [] }
Plug 'jiangmiao/auto-pairs', { 'on': [] }
Plug 'Vimjas/vim-python-pep8-indent', { 'on': [] }
Plug 'pboettch/vim-highlight-cursor-words', { 'on': [] }
Plug 'Shougo/echodoc.vim', { 'on': [] }
Plug 'pangloss/vim-javascript', { 'on': [] }
Plug 'leafgarland/typescript-vim', { 'on': [] }
Plug 'leafOfTree/vim-svelte-plugin', { 'on': [] }
Plug 'cstrahan/vim-capnp', { 'on': [] }
let mapleader=" "
if has("nvim")
Plug 'sindrets/diffview.nvim', { 'on': [] }
Plug 'nvim-tree/nvim-web-devicons', { 'on': [] }
Plug 'neoclide/coc.nvim', {'branch': 'release'}
set laststatus=3
Plug 'maxmx03/solarized.nvim'
" -- Avante -- see in https://github.com/yetone/avante.nvim --
" Deps
Plug 'stevearc/dressing.nvim'
Plug 'nvim-lua/plenary.nvim'
Plug 'MunifTanjim/nui.nvim'
Plug 'MeanderingProgrammer/render-markdown.nvim', { 'on': [] }
" Optional deps
" Plug 'HakonHarnes/img-clip.nvim', { 'on': [] }
" Plug 'zbirenbaum/copilot.lua', { 'on': [] }
Plug 'yetone/avante.nvim', { 'branch': 'main', 'do': 'make', 'on': [] }
else
set laststatus=2
Plug 'altercation/vim-colors-solarized'
endif
call plug#end()
syntax enable
source ~/.vimrc.base
set background=light
silent! colorscheme solarized
set nocompatible
set nobackup
set noswapfile
set number
set relativenumber
set numberwidth=4
set tabstop=4
set shiftwidth=4
set softtabstop=4
set mouse=a
set autoread
set nosol
" Trying to respond to Esc faster, see https://www.johnhawthorn.com/2012/09/vi-escape-delays/
set timeoutlen=150 ttimeoutlen=0
set wildmenu
set wildmode=longest,list
set wildignorecase
set spelllang=en_us
set listchars=tab:>-
set scrolloff=2
" Toggle paste mode
set pastetoggle=<F2>
" Toggle line numbers (i.e. for easy copy over tmux).
" TODO: find a good way to toggle breaks (currently in the first time F3 is used,
" showbreak is removed)
nnoremap <F3> :set nu! rnu!<CR>:set showbreak=<CR>
" Toggle display of special characters
nnoremap <F4> :set list!<CR>
" Turn off highlight
nnoremap <F9> :nohl<CR>
inoremap <F9> <C-o>:nohl<CR>
" Show by F10 the highlight name
map <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
set autoindent
set smartindent
filetype plugin indent on
silent! set breakindent
silent! set showbreak=↳\
" Indent Python `func(\n` just one space rather than two
let g:pyindent_open_paren = '&sw'
" Indentation for C comments, see:
" https://www.reddit.com/r/vim/comments/9kz5rk/format_of_c_comments/
au FileType cpp setlocal comments=s1:/*,m:\ ,ex-4:*/,://
set cinoptions=c4N-sg0
au BufNewFile,BufRead *.ejs set filetype=ejs
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.svelte'
let g:netrw_liststyle = 1
let g:netrw_timefmt = "%a %Y-%m-%d %T"
let g:netrw_bufsettings = 'noma nomod nu nowrap ro nobl'
let g:netrw_winsize = 25
let g:netrw_sort_by = 'name'
" Don't abandon buffers when they get hidden, allowing to switch between
" buffers with unsaved changes.
" Ideally we'd just 'set hidden', however this creates an issue with netrw.
" As a workaround, keep 'nohidden', and use an autocmd to set non-netrw
" buffers to hidden: https://github.com/tpope/vim-vinegar/issues/13
set nohidden
augroup netrw_buf_hidden_fix
autocmd!
" Set all non-netrw buffers to bufhidden=hide
autocmd BufWinEnter *
\ if &ft != 'netrw'
\| set bufhidden=hide
\| endif
augroup end
" Switch buffers with Alt+Left/Right or Alt+h/l
nnoremap <M-Left> :bp<CR>
nnoremap <M-Right> :bn<CR>
nnoremap <M-h> :bp<CR>
nnoremap <M-l> :bn<CR>
" Move up/down/left/right on splits with Ctrl+h/j/k/l
nnoremap <C-k> <C-W><Up>
nnoremap <C-j> <C-W><Down>
nnoremap <C-h> <C-W><Left>
nnoremap <C-l> <C-W><Right>
set rtp+=~/.fzf
" Completion menu options. Source for some of them:
" http://vim.wikia.com/wiki/Make_Vim_completion_popup_menu_work_just_like_in_an_IDE
" Make completion menus accept the longest matching string
set completeopt=longest,menuone
" Make Enter accept the selected entry in a completion menu
" inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" Make ^P select the first entry
" inoremap <expr> <C-p> '<C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" Move up and down in autocomplete with <c-j> and <c-k>
inoremap <expr> <c-j> ("\<C-n>")
inoremap <expr> <c-k> ("\<C-p>")
" imap <c-space> <Plug>(asyncomplete_force_refresh)
" inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
" autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
" Make ^F in insert mode the same as ^X^F and also select the first entry
" inoremap <expr> <C-f> '<C-x><C-f><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
" Map Ctrl+h to the path of the current file when in command mode
cmap <C-h> %:p:h
" Remove the '=' sign from being counted as a file name, because it sometimes
" interferes with the ability to properly find a file name with ^X^F
set isfname-==
set clipboard^=unnamedplus
" Set search highlight and its color
hi Search ctermfg='red' guifg='white' guibg='#e69370'
hi IncSearch ctermfg=DarkMagenta guibg='#cb4b16' guifg='white'
set hlsearch
hi Type ctermfg=DarkBlue
hi Statement cterm=None
hi Operator cterm=bold
hi Statement cterm=bold
hi MatchParen gui=underline,bold guibg=LightMagenta
hi SpellBad gui=underline guisp=red
hi CocWarningHighlight guibg=#ffffd7
" hi CocErrorHighlight guibg=#ffff87
hi CocErrorHighlight gui=undercurl guisp=#ffa500
hi CocUnusedHighlight gui=strikethrough
hi CocMenuSel ctermfg=red guibg=white
" Use regular monospace fonts for comments rather than the non-monospace
" default in the theme
hi Comment gui=NONE
if has('gui_running')
set guioptions-=T " no toolbar
set anti enc=utf-8
set guifont=Office\ Code\ Pro\ 11
set lines=40 columns=100
endif
au FileType markdown set wrap linebreak
au FileType markdown set conceallevel=3
au FileType markdown setlocal spell
au FileType markdown set nofoldenable
au FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
au FileType typescript iabbrev imp import { } from '';<Left><Left>
" Note: there is code that turns off spell checking for Markdown in
" ~/.vim/after/syntax/markdown.vim
" (it must be loaded after the syntax file)
" Powerline modifiers
let g:airline_theme='bubblegum'
let g:airline#extensions#tabline#enabled = 1
let g:airline_section_y = ""
let g:airline#extensions#whitespace#checks = [ ]
let g:airline#extensions#tabline#buffer_min_count = 2
" <Leader>g to vimgrep the word under the cursor
" <Leader>f to grep something recursively and case-insensitive, and position
" the cursor where you'd enter text
if executable('rg') && executable('fzf')
" Make Ripgrep search only the text, not the file name, see https://github.com/junegunn/fzf.vim/issues/346
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
set grepprg=rg\ --vimgrep
nnoremap <Leader>r :Rg<CR>
nnoremap <Leader>s :silent grep -i
map <Leader>g :silent grep! <cword><CR>:copen<CR>
else
nnoremap <Leader>s :grep -RIi *<LEFT><LEFT>
map <Leader>g :silent grep! <cword> *<CR>:copen<CR>
endif
if executable('fd')
let $FZF_DEFAULT_COMMAND = 'fd --type f --color=never'
endif
let $FZF_DEFAULT_OPTS = '--bind=tab:toggle+up,btab:toggle+down'
" <Leader>f to run fzf search
map <Leader>f :Files<CR>
map <C-S-n> :Files<CR>
map <Leader>b :Buffers<CR>
" Comment/uncomment line or selection (vim-commentary)
map <Leader>c :Commentary<CR>
map <Leader>q :bd<CR>
map <Leader>w :w<CR>:bd<CR>
" Split
nmap <Leader>= <C-w>s<C-w>w
nnoremap <F5> :source ~/dotfiles/vimrc.dev<CR>