-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_vimrc
More file actions
212 lines (179 loc) · 6.11 KB
/
dot_vimrc
File metadata and controls
212 lines (179 loc) · 6.11 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
" Vim settings for all instances
" Change Leader to <Space>. This needs to be set early because leader is used
" at the moment mappings are defined. Changing it after a mapping is defined
" has no effect on the mapping.
let mapleader=' '
set nocompatible
" Use local before config if available {{{
if filereadable(expand("~/.vimrc.before.local"))
source ~/.vimrc.before.local
endif
" }}}
" Load plugins config {{{
if filereadable(expand("~/.vimrc.plugins"))
source ~/.vimrc.plugins
endif
" }}}
" General options "{{{
set history=50 " keep 50 lines of command line history
set selection=exclusive
set selectmode=mouse,key
set mousemodel=popup
set keymodel=startsel,stopsel
set wildmenu
set wildmode=longest:full
"}}}
" Color scheme customizations "{{{
" Customizations must be defined before loading a color scheme.
" Iceberg scheme customizations
augroup iceberg-scheme-overrides
autocmd!
" Increase selection brightness for better visibility.
autocmd ColorScheme iceberg
\ hi Visual guibg=#313752 |
\ hi VisualNOS guibg=#313752 |
\ hi QuickFixLine guibg=#313752 |
\ hi SneakScope guibg=#313752
augroup END
" Load local scheme customizations if available {{{
if filereadable(expand("~/.vimrc.scheme.local"))
source ~/.vimrc.scheme.local
endif
" }}}
"}}}
" Appearance options "{{{
set laststatus=2 " show status line all the time
set ruler " show the cursor position all the time
set cursorline " highlight the current line
set statusline=%<%f%(\ %h%m%r%)\ %{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
set showcmd " display incomplete commands
if winwidth(0) >= 80
set number " show line numbers unless window is unusually narrow
endif
syntax on " syntax highlighting
" Enable 24-bit GUI colors in terminal if supported
if has('termguicolors') && $COLORTERM == "truecolor"
if !has('nvim') && exists('$TMUX') && &term == "screen-256color"
" Vim messes up the term codes inside tmux, so reset the term type.
set term=xterm-256color
endif
set termguicolors
endif
set background=dark " set background before colorscheme to avoid possible screen flash
colorscheme iceberg " default terminal color scheme, can be overridden for GUI in gvimrc
" Airline configuration settings
set noshowmode " only show mode in the airline status bar
let g:airline#extensions#tabline#enabled = 1
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
if stridx($TERM, "kitty") >= 0
" Powerline fonts are always available if running Kitty terminal.
let g:airline_powerline_fonts = 1
endif
" simplify the file position format
let g:airline_section_z='%#__accent_bold#%l/%L:%v%#__restore__# %p%%'
if get(g:, 'airline_powerline_fonts', 0)
" override some of the default powerline symbols (using Nerd Fonts)
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.colnr = " \ue0a3:"
let g:airline_symbols.dirty = "\u26a1\ufe0e"
endif
"}}}
" Search options "{{{
set incsearch " do incremental searching
set ignorecase " use smart case-insensitivity
set smartcase
set hlsearch " highlight the last used search pattern
" If ripgrep is available, use it as the grep prog.
" Otherwise, fall back to GNU grep.
if executable("rg")
set grepprg=rg\ --vimgrep\ --no-heading
set grepformat=%f:%l:%c:%m,%f:%l:%m
else
set grepprg=grep\ -nH
endif
"}}}
" File handling options "{{{
set nobackup " do not keep a backup file
" Enable file type detection and language-dependent indenting.
filetype on
filetype plugin indent on
if !has('nvim')
if !isdirectory($HOME.'/.local/share/vim/swap')
silent call mkdir($HOME.'/.local/share/vim/swap', 'p')
endif
set dir=~/.local/share/vim/swap//
endif
"}}}
" Default file options "{{{
" (these can be overridden later for specific filetypes)
set autoindent " always set autoindenting on
set tabstop=4 " I almost always use 4-space tabs
set softtabstop=4
set shiftwidth=4
set expandtab " use spaces, not hard tabs
set smarttab " use shiftwidth, not tabstop, at start of line
set shiftround " always shift to a multiple of 'shiftwidth'
"}}}
" Keyboard mappings "{{{
" Allow backspacing over everything in insert mode.
set backspace=indent,eol,start
" Use Q for formatting the current paragraph or selection.
nmap Q gqap
vmap Q gq
" Move up/down by screen lines, not file lines.
nnoremap j gj
nnoremap k gk
" Clear the search highlighting.
nmap <silent> <leader>/ :nohlsearch<CR>
" Reselect the text that was just pasted.
nnoremap <leader>v V`]
" Quit current window on <leader>q.
nnoremap <leader>q :q<CR>
" Buffer switching.
nnoremap <Tab> :bnext<CR>
nnoremap <S-Tab> :bprevious<CR>
" Quickfix navigation.
nnoremap <F2> :cnext<CR>
nnoremap <S-F2> :cprev<CR>
nnoremap <F3> :cnfile<CR>
nnoremap <S-F3> :cpfile<CR>
" Plugin key mappings
nnoremap <C-p> :<C-u>Files<CR>
"}}}
" Autocommands {{{
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" Writing pass/gopass files to disk might leak plaintext secrets.
au BufNewFile,BufRead /private/**/pass** setlocal noswapfile nobackup noundofile
au BufNewFile,BufRead /private/**/gopass** setlocal noswapfile nobackup noundofile
"}}}
" Diff Mode options "{{{
if &diff
" Add a mapping to toggle the 'ignore whitespace' option.
map gs :call IwhiteToggle()<CR>
function! IwhiteToggle()
if &diffopt =~ 'iwhite'
set diffopt-=iwhite
else
set diffopt+=iwhite
endif
endfunction
" Turn off cursorline highlighting because it hides line differences.
set nocursorline
endif
"}}}
" Use local vimrc if available {{{
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
" }}}
" vim:foldmethod=marker:foldlevel=0