-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
214 lines (162 loc) · 3.38 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
"
" ~/.vimrc
"
" Auto reload
augroup myvimrc
au!
au BufWritePost .vimrc,_vimrc,vimrc,.nvimrc,_nvimrc,nvimrc,init.vim so $MYVIMRC
augroup END
"
" Plugins
"
call plug#begin('~/.vim/bundle')
Plug 'tpope/vim-dispatch'
Plug 'junegunn/vim-easy-align'
Plug 'jez/a.vim'
Plug 'chriskempson/base16-vim'
Plug 'morhetz/gruvbox'
call plug#end()
xmap ga <Plug>(EasyAlign)
nmap ga <Plug>(EasyAlign)
"
" colors
"
syntax enable
set background=dark
set termguicolors
"if filereadable(expand("~/.vimrc_background"))
" let base16colorspace=256
" source ~/.vimrc_background
"endif
colorscheme gruvbox
set guicursor=n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20
"set guicursor=n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50
" \,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor
" \,sm:block-blinkwait175-blinkoff150-blinkon175
" hide ~ on nontext lines
hi! NonText ctermfg=black
"
" options
"
set showmode
set mouse=a
set cursorline
set showcmd
set ruler
set laststatus=2
set showtabline=1
set hidden
set switchbuf=useopen,usetab
set confirm
set splitright
set tabstop=4
set shiftwidth=4
set shiftround
set expandtab
set smarttab
set autoindent
set smartindent
set copyindent
set timeout
set nottimeout
set timeoutlen=500
set ttimeoutlen=0
set matchtime=0
set nowrap
set textwidth=0
set wrapmargin=0
set sidescroll=1
set sidescrolloff=8
set synmaxcol=300
set number
set relativenumber
set noshowmatch
let loaded_matchparen = 1
set ignorecase
set smartcase
set hlsearch
set incsearch
set gdefault
set history=1000
set undolevels=1000
set wildignore=*.swp,*.un\~,*.o,*.d
set title
set novisualbell
set noerrorbells
set completeopt-=preview
set completeopt+=menu,longest
set cino+=(0
set clipboard=unnamed
set makeprg="make -j$(nproc)"
set path=.,**
filetype on
filetype plugin on
filetype indent on
set noswapfile
set nobackup
set nowritebackup
if !&diff
set undodir=~/.vim/undo
set undofile
endif
"
" Remaps
"
let mapleader = "\<space>"
" move cursor by screen line, not file line
nmap j gj
nmap k gk
" page up/down
nnoremap J <C-d>
vnoremap J <C-d>
nnoremap K <C-u>
vnoremap K <C-u>
" exit from insert to normal mode
inoremap jk <ESC>
" center screen on a line when jumped to
nmap gg gg zz
" switch between header and source files
nnoremap <leader>h :A<CR>
nnoremap <leader>H :AV<CR>
"nnoremap <C-_> :ls<CR>:b<space>
nnoremap <C-_> :find *
"
" Functions
"
function! EditConfig()
:edit $MYVIMRC
endfunction
function! StripWhitespace()
:%s/\s\+$//e
endfunction
function! SetMakePrg()
if filereadable("Makefile")
set makeprg=make
elseif filereadable("build.sh")
set makeprg=./build.sh
else
echoerr "No makefile or build script found."
endif
endfunction
function! RunBinary(headless)
let l:run_command = ""
if filereadable("run.sh")
let l:run_command = "./run.sh"
else
let l:dir_name = fnamemodify(getcwd(), ':t')
let l:run_command = "./bin/" . l:dir_name
endif
if (a:headless)
execute ":Dispatch!" run_command
else
execute ":Dispatch" run_command
endif
endfunction
nnoremap <silent> <F5> :call SetMakePrg()<CR> :Make<CR>
nnoremap <F6> :Make!<CR>
nnoremap <F7> :call RunBinary(0)<CR>
nnoremap <F8> :call RunBinary(1)<CR>
" quickfix error navigation
nnoremap <silent> <F9> :cc 1<CR> <silent> :cn<CR> <silent> :cp<CR>
nnoremap <silent> <F10> :cp<CR>
nnoremap <silent> <F11> :cn<CR>