-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
152 lines (117 loc) Β· 3.46 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
" vimrc
" ------------------------------------------------------------------------------
" Richard Zhao
" ------------------------------------------------------------------------------
" Plugins
call plug#begin('~/.vim/plugged')
Plug 'Yggdroot/indentLine'
Plug 'editorconfig/editorconfig-vim'
Plug 'godlygeek/tabular'
Plug 'junegunn/fzf.vim'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'tpope/vim-commentary'
Plug '~/.fzf'
call plug#end()
" ------------------------------------------------------------------------------
" General
set nocompatible
filetype plugin indent on
syntax on
syntax enable
" System clipboard
if $TMUX == ''
set clipboard=unnamed
endif
set hidden
set wildmenu
set showcmd
set hlsearch
set ignorecase
set smartcase
set backspace=indent,eol,start
set autoindent
set nostartofline
set ruler
set laststatus=2
set confirm
set visualbell
set mouse=a
set cmdheight=2
set number
set notimeout ttimeout ttimeoutlen=200
set pastetoggle=<F10>
set ttyfast
let g:indentLine_char = 'β'
" ------------------------------------------------------------------------------
" Mappings
let mapleader=" "
nnoremap <Leader>r :source ~/.vimrc<CR>:echo "Reloaded vimrc."<CR>
imap jk <Esc>
nnoremap ; :
nnoremap Y y$
" Strip trailing whitespace
nnoremap <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" Easier split switching
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
vmap <Leader>a= :Tabularize /=
vmap <Leader>a: :Tabularize /:
" fzf
nnoremap <Leader>e :Files<CR>
nnoremap <Leader>f :Buffers<CR>
nnoremap <Leader>l :Lines<CR>
nnoremap <Leader>; :Commands<CR>
" ------------------------------------------------------------------------------
" Visual
colorscheme gruvbox
set cursorline
set fillchars=vert:β
" Enable transparent background (let's terminal colors take precedence)
hi Normal guibg=NONE ctermbg=NONE
augroup BlendVertSplit
autocmd!
autocmd ColorScheme * highlight VertSplit cterm=NONE ctermbg=NONE guibg=NONE
augroup END
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" ------------------------------------------------------------------------------
" Editing
" TODO: Use editorconfig
set expandtab
set shiftwidth=2
set softtabstop=2
set tabstop=2
set shiftwidth=2
" C++ options
set cino+=N-s
set cino+=g0
set cino+=l1 " Switch statements
autocmd FileType vhdl setlocal commentstring=--\ %s
autocmd FileType cpp setlocal commentstring=//\ %s
" ------------------------------------------------------------------------------
" Statusline
function! ReadOnlyFlag() abort
if &readonly
return 'ξ’'
else
return ''
endif
endfunction
set statusline=\ %f\ ξ± " File path
set statusline+=\ %m " Modified flag
set statusline+=\ %{ReadOnlyFlag()} " Read-only flag
set statusline+=%= " LHR/RHS delimeter
set statusline+=%y " File type
set statusline+=\ ξ³\ %{&fileencoding} " File encoding
set statusline+=\ ξ³\ %3p%% " Percentage through file
set statusline+=\ ξ‘ " Make sure you have powerline glyphs
set statusline+=\ ξ³\ %5l\ :\ %-3c " Line : column
highlight StatusLine ctermfg=239 ctermbg=246
highlight StatusLineNC ctermfg=238 ctermbg=244