-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.vim
294 lines (240 loc) · 6.88 KB
/
init.vim
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
if has('win32')
set runtimepath^=$VIM
set runtimepath^=$VIMRUNTIME
let &packpath = &runtimepath
endif
" ================ python ================
if has('win32')
let g:python_host_prog = expand('$PY27_64_CONDA\python.exe')
let g:python3_host_prog = expand('$PY3_CONDA\python.exe')
else
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
endif
" ================ plugins_install ================
source $NEOVIM_MY/plugins_install.vim
" ================ main ================
filetype off
" ================ base ================
set laststatus=2 " Always display the statusline in all windows
syntax on
filetype plugin indent on
set encoding=utf-8
set autochdir
" == default, windows ==
if has('win32')
source $VIMRUNTIME/mswin.vim
behave mswin
endif
" == session ==
set sessionoptions+=resize,winpos
set sessionoptions+=tabpages,globals
set sessionoptions-=options
" == menu in command line ==
set wildmenu
set wildmode=list:longest,full
" == color ==
colorscheme wombat
set background=dark
hi Search guibg=Orange2
" search pattern: the first match gets highlighted.
" when typing the replacement field, the document is modified live.
set inccommand=nosplit
" current curson color
"hi CursorLine guibg=#1B1B1B
"hi CursorLine guibg=#121212
hi CursorLine guibg=#000000
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" diff
highlight DiffAdd cterm=none ctermfg=black ctermbg=Red gui=none guibg=#133209
highlight DiffDelete cterm=none ctermfg=black ctermbg=Red gui=none guibg=#4D1D14
highlight DiffChange cterm=none ctermfg=black ctermbg=Yellow gui=none guibg=#444444
highlight DiffText cterm=none ctermfg=black ctermbg=Magenta gui=none guibg=#000000
"guifg=white
" == font ==
"set lines=40 columns=150
" spacing between lines
set linespace=0
" width of sign column
set signcolumn=yes:1
" == width ==
set textwidth=79
if has('win32')
set colorcolumn=81
endif
hi ColorColumn guibg=#292929
set formatoptions+=t
" == wrap ==
set breakindent
set showbreak=>>>>
" don't wrap lines by inserting a new line character at a predefined limit
set tw=0
" == gui menus ==
set guioptions-=T " remove toolbar
set guioptions-=m " remove menu
set guioptions-=r " remove right scrollbar
set guioptions-=L " remove left scrollbar
set guioptions-=b " remove bottom scrollbar
" == height ==
" the height of the command line
set cmdheight=1
" ==== fold ====
set foldmethod=indent
set foldnestmax=2
set foldcolumn=1
set foldlevel=0
set foldlevelstart=1
set foldminlines=2
set nofoldenable
" = fold-color =
hi Folded guibg=#292929 guifg=#818181
hi FoldColumn guibg=#292929 guifg=#818181
" = toggle fold =
map z<Space> za
" = tab settings =
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
" == case search settings ==
set ignorecase
set smartcase
nmap // :nohlsearch<cr>
" == number ==
set numberwidth=3
set number
set relativenumber
setglobal relativenumber
" ================ remaps ================
let mapleader = ";"
" find next, previus
noremap <Space> ;
noremap <M-Space> ,
map <Leader>w *
" ==== window ====
" = resize =
if bufwinnr(1)
map <Up> <C-W>+
map <Down> <C-W>-
map <Left> <C-W><
map <Right> <C-W>>
map <M-o> 16<C-W>+
endif
" = close/save =
map <M-w> :close<CR>
map <M-s> :update<CR>
map <C-s> :update<CR>
" = move between windows =
map <A-k> <C-w>k
map <A-j> <C-w>j
map <A-l> <C-w>l
map <A-h> <C-w>h
" https://technotales.wordpress.com/2010/04/29/vim-splits-a-guide-to-doing-exactly-what-you-want/
function! MoveBuf(direction)
let bufno = bufnr("%")
hide
exec "wincmd " . a:direction
new
exec "buffer " . bufno
endfunction
" = move windows inside tab =
map <C-W><M-h> :call MoveBuf("h")<CR>
map <C-W><M-l> :call MoveBuf("l")<CR>
map <C-W><M-j> :call MoveBuf("j")<CR>
map <C-W><M-k> :call MoveBuf("k")<CR>
" ==== tab ====
" = move between tabs =
map <C-h> :tabp<CR>
map <C-l> :tabn<CR>
map <M-n> :tabnew<CR>
" = move tabs in tabline =
map <M-Left> :tabm -1<CR>
map <M-Right> :tabm +1<CR>
" = go to tab by number =
"noremap <M-1> 1gt
"noremap <M-2> 2gt
"noremap <M-3> 3gt
"noremap <M-4> 4gt
"noremap <M-5> 5gt
"noremap <M-6> 6gt
"noremap <M-7> 7gt
"noremap <M-8> 8gt
"noremap <M-9> 9gt
"noremap <M-0> :tablast<cr>
" = go to last active tab =
au TabLeave * let g:lasttab = tabpagenr()
nnoremap <silent> <M-y> :exe "tabn ".g:lasttab<cr>
vnoremap <silent> <M-y> :exe "tabn ".g:lasttab<cr>
" == move ==
" move cursor position in insert mode
inoremap <A-o> <C-o>$
inoremap <A-h> <left>
inoremap <A-l> <right>
inoremap <A-j> <down>
inoremap <A-k> <up>
if has('win32')
" mswin.vim remaps <C-y>.
" I want the normal <C-y> that moves screen down one line
unmap <C-y>
endif
" move to middle of current line
map gm :call cursor(0, len(getline('.'))/2)<CR>
" == execute ==
" Start Terminal
map <Leader>st :let @+ = "python " . expand("%:t")<CR><bar>:!start ConEmu64.exe /Single /cmd {cmd}<CR><CR>
" == diff ==
map <Leader>dt :windo diffthis<CR>
map <Leader>do :windo diffoff!<CR>
" == other ==
map <C-o> :let @+ = expand("%:p")<CR>
" == spell ==
"set spell spelllang=en
"set nospell
" ================ functions ================
source $NEOVIM_MY/functions.vim
" ================ complete ================
source $NEOVIM_MY/autocomplete.vim
" ================ plugins ================
source $NEOVIM_MY/plugins_conf.vim
" ================ override ===============
" setting that some plugins override
" Hide the default mode text (-- INSERT -- below the statusline)
set noshowmode
" == buffers update some features in update interval - increased to reduce lag ==
autocmd BufEnter * set updatetime=4000
" how many lines before/max current line to start syntax highlighting parsing
" autocmd Syntax * syn sync clear | syntax sync minlines=1024 | syntax sync maxlines=1024
" Center screen on next/previous selection.
nnoremap n nzz
nnoremap N Nzz
" Last and next jump should center too.
"nnoremap <C-o> <C-o>zz
"nnoremap <C-i> <C-i>zz
" ================ changed ===============
" https://github.com/neovim/neovim/issues/2127#issuecomment-150954047
augroup AutoSwap
autocmd!
autocmd SwapExists * call AS_HandleSwapfile(expand('<afile>:p'), v:swapname)
augroup END
function! AS_HandleSwapfile (filename, swapname)
" if swapfile is older than file itself, just get rid of it
if getftime(v:swapname) < getftime(a:filename)
call delete(v:swapname)
let v:swapchoice = 'e'
endif
endfunction
autocmd CursorHold,BufWritePost,BufReadPost,BufLeave *
\ if isdirectory(expand("<amatch>:h")) | let &swapfile = &modified | endif
augroup checktime
au!
if !has("gui_running")
"silent! necessary otherwise throws errors when using command
"line window.
autocmd BufEnter,CursorHold,CursorHoldI,CursorMoved,CursorMovedI,FocusGained,BufEnter,FocusLost,WinLeave * checktime
endif
augroup END