-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
153 lines (119 loc) · 3.92 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
"""""""""""""""""""""""""""""" General Setting
source $VIMRUNTIME/defaults.vim
" indent
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set shiftround
set nofixeol
"set smartindent
"set autoindent
" fold
set nofoldenable
"set foldmethod=syntax
"set foldmethod=indent
" search
set hlsearch
set ignorecase
set smartcase
set magic
" recovery
set undofile
set undodir=~/.vim/undo-history
set directory=~/.vim/swap
set viminfo+=n~/.vim/viminfo
set viminfo^=!
set sessionoptions-=options
set viewoptions-=options
" timeout
set timeoutlen=500
set updatetime=1000
" Auto read the file again when it's detected to have been changed outside.
set autoread
" Auto save while moving thought the buffers.
"set autowrite
" Allow moving through the buffers without save.
set hidden
" Allow < > h l to move the cursor to the previous/next line
"set whichwrap+=<,>,h,l
" Delete comment character when joining commented lines.
set formatoptions+=j
" When a bracket is inserted, briefly jump to the matching one.
"set showmatch
"set mat=2
" Display the completion matches using the popup menu.
set wildoptions=pum
" Completion mode for wildchar, first tab to the longest common part, second tab to the full match.
set wildmode=longest:full,full
" Automatically creates `foo/bar/` as needed when `:w foo/bar/baz.txt`
autocmd BufWritePre,FileWritePre * silent! call mkdir(expand('<afile>:p:h'), 'p')
"""""""""""""""""""""""""""""" Appearance
set background=dark
if has("termguicolors")
" Require a vim compiled with `+termguicolors` and run in a true-color terminal.
set termguicolors
" https://github.com/lifepillar/vim-solarized8#troubleshooting
if $TERM ==# 'tmux-256color'
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
endif
endif
" Precede each line with its line number.
set number
" Always show the signcolumn, otherwise it would shift the text each time diagnostics appear/disappear.
set signcolumn=yes
" Highlight the current line and column of the cursor.
set cursorline
set cursorcolumn
" Lines will not wrap and only part of long lines will be displayed.
set nowrap
" Show a few lines of context around the cursor.
set scrolloff=5
set sidescrolloff=5
" The maximum number of items to show in the popup menu for completion.
set pumheight=20
" Put the new splitting window right of the current one by default.
set splitright
" Concealed text is completely hidden unless it has a custom replacement character defined.
set conceallevel=2
" Set default whitespace characters when using `:set list`
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
if $TERM ==# 'xterm-kitty'
set ttymouse=sgr
set balloonevalterm
autocmd VimEnter,VimLeave * call system('kitten @ set-background-opacity --toggle 1')
endif
"""""""""""""""""""""""""""""" Builtin Plugins
"""""""""" Comment
packadd comment
"""""""""" Termdebug
" Let termdebug split vertically.
let g:termdebug_wide = 1
"""""""""" Vimdiff
" Disable syntax highlight in vimdiff.
if &diff
syntax off
let g:syntax_on = 0
endif
"""""""""""""""""""""""""""""" Keyboard Mapping
" use <Space> as <Leader>
let mapleader = "\<space>"
" Quick select the whole file.
nnoremap <leader>a ggVG
" Clear highlights.
nnoremap <silent> <C-L> :nohlsearch<C-R>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-L>
" Blame the current line.
nmap <silent> <Leader>gb :call setbufvar(winbufnr(popup_atcursor(split(system("git log -n 1 -L " . line(".") . ",+1:" . expand("%:p")), "\n"), { "padding": [1,1,1,1], "pos": "botleft", "wrap": 0 })), "&filetype", "git")<CR>
" Toggle the spell checking.
nnoremap <Leader><Leader>s :setlocal spell! spelllang=en,cjk<CR>
" Echo the syntax highlight group of the word under cursor.
nmap <leader>sh :call <SID>SynStack()<CR>
function! s:SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
" %% -> local path
cnoremap <expr> %% getcmdtype( ) == ':' ? expand('%:h').'/' : '%%'