forked from odedniv/.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimsettings.vim
449 lines (393 loc) · 11.8 KB
/
vimsettings.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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
set dictionary=C:\temp\words
"Vim settings
"includes autocmds and autocmds for file types and commands
"Should be indepdenent of plugins!
let $LC_ALL="en_US.UTF-8"
let $LANG="en_US.UTF-8"
let g:python3_host_prog='C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\python.exe'
let g:python_host_prog='C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\python.exe'
let $PYENV_ROOT='C:\Users\ekarni\.pyenv\pyenv-win'
let ver= "3.9.6" "system('pyenv version')
let g:on_windows=1
let g:pwmod=0
let g:sh = &shell
let g:shf=&shellcmdflag
let g:shr=&shellredir
let g:shellpipe=&shellpipe
let g:shq=&shellquote
let g:shxq=&shellxquote
let g:ver=ver
set ignorecase
"allows ctrl-c I think
set allowrevins
if has('nvim')
set inccommand=split
endif
command! -nargs=* -range PY <line1>,<line2>python3 <args>
set noerrorbells visualbell t_vb=
set noeb vb t_vb=
autocmd GUIEnter * set visualbell t_vb=
autocmd SessionLoadPost * windo filetype detect
function! OnWinEnter()
if !&filetype
filetype detect
endif
endfunction
autocmd BufWinEnter * call OnWinEnter()
"let g:yanktools_main_key = 'Z'
":20verbose
"message log
redi >> ~/.vim/vimlog.log
if or(or(has('python_dynamic'),has('python')),has('python3'))
"set termguicolors "for vimr bug terminal
set fillchars+=stl:\ ,stlnc:\
set laststatus=2
set showtabline=2
set encoding=utf-8
"set t_Co=256
"set t_AB=^[[48;5;%dm
"set t_AF=^[[38;5;%dm
"set term=xterm-256color
"set termencoding=utf-8 has
" #set noshowmode
set nowrap
set number
set completeopt=menuone
set completeopt+=noinsert
set mousemodel=popup
endif
"from shawn
"set relativenumber
set wildmenu
set cursorline
set nosplitright
set clipboard+=unnamed
":echo system('git --version')
"plus
"set paste
set go+=a "???
set cpoptions+=y
:noh
setlocal spell
set spellfile = "~/.vim/spell/en.utf-8.add"
set spelllang=en_us
set updatetime =3000
packadd cfilter
"packadd! syntax-vim-ex
"autocmd filetype python :call PythonSetup()
" Defaults
syntax on
filetype plugin indent on
"
"set noswapfile
"for swap files
set directory=c:\\users\\ekarni\\.vim\\swap
set shortmess=a "added now
set shm+=A
set shortmess+=A
set cmdheight=2
set showcmd
set list
set listchars=tab:>~,trail:~
set tabstop=4 shiftwidth=4 expandtab
set splitbelow
set splitright
"for workspaces
set hidden
" history
"
" default file /Users/eyalkarni/.local/share/nvim/shada/main.shada . save
" marks.
set shada=!,'100,<50,s10,h,f1,s100,%
"exec "set shadafile=".g:vimloc . "/shada"
set history=10000
" insert mode
set backspace=indent,eol,start
"set shiftwidth=4
"set expandtab
"
" line+
if has('gui_running')
"set lines=75
set scrolloff=3
endif
if !isdirectory($HOME."\\.vim")
call mkdir($HOME."\\.vim", "", 0770)
endif
if !isdirectory($HOME."\\.vim\\undo")
call mkdir($HOME."\\.vim\\undo", "", 0700)
endif
set undodir=~\\.vim\\undo
set undofile
"important autocmds
"
autocmd FileChangedShell * echohl WarningMsg | echo "File changed: " . @% | echohl None
"exit window using esc
:autocmd CmdwinEnter * nnoremap <buffer> <ESC> <C-c><C-c>
"exec and leave open
:autocmd CmdwinEnter * nmap <buffer> <F5> <CR>q:
":autocmd InsertLeave * :let g:EasyMotion_add_search_history=1
au SwapExists * nested call OnSwap()
function! OnSwap()
let swap_info = swapinfo(v:swapname)
echo "Recovery exist " . strftime("%Y %b %d %X",swap_info['mtime'])
let v:swapcommand='e'
endfunction
au VimEnter * nested call OnLoad()
au VimLeave * nested call OnEnd()
au ExitPre * nested call timer_stop(g:autosaveWS)
function! SetAltFone()
set guifont=JetBrains\ Mono\ Medium:h
endfunction
function! SetFont()
if exists('g:GuiLoaded')
":GuiFont! Fira\ Code:h12
"set guifont=Fira\ Code:h12
"set guifont =GoMono\ Nerd\ Font:h12
set guifont=Hasklug\ Nerd\ Font:h12
endif
endfunction
":GuiTabline 0
function! OnLoad()
let g:onedark_config = {
\ 'style': 'darker',
\ 'toggle_style_key': '<leader>ts',
\ 'ending_tildes': v:true,
\ 'diagnostics': {
\ 'background': v:false,
\ },
\ }
set nocursorline
"sleev 500
"Lazy reload vim-airline
"Lazy reload vim-arpeggio
"Lazy reload quic-kscope
"sleep 700ms
call PyAS()
"silent !aqcopy ~\.vim\profile ~\.vim\profile2
"silent !del ~\.vim\profile
:call DefineMapping()
set ambiwidth=single
let g:keys = ['jk', 'sd','kl', 'as','df']
for key in g:keys
execute 'silent Arpeggio inoremap ' key '<Esc>'
execute 'silent Arpeggio nnoremap ' key 'i'
endfor
:silent Arpeggio nnoremap qw :exec "normal a".nr2char(getchar())."\e"<CR>
if exists('g:GuiLoaded')
":GuiFont! Fira\ Code:h12
set guifont=Hasklug\ Nerd\ Font:h12
endif
"set guifont=JetBrains\ Mono\ Medium:h11
"sleep 500ms
"echom "onload"
cd ~/.vim
":profile start /Users/eyalkarni/ab.log
":profile file /Users/eyalkarni/vimpy3/plugged/vim-ctrlspace/autoload/ctrlspace/workspaces.vim
"call ToggleVerbose()
"!cp /Users/eyalkarni/vimpy3/.git/cs_workspaces /tmp/onload
". '~/vimpy3/'
":exe ":silent CtrlSpaceAddProjectRoot ". g:vimloc
if !has('nvim')
return
endif
call MakeItFaster(0)
if g:on_ek_computer
let g:SessionFile = ($HOME."\\.vim\\session_file")
if exists('g:GuiLoaded') || ( g:on_vimr) || exists(':GonvimWorkspaceNew')
let g:ctrlspaceWorkspace = ($HOME."\\.vim\\workspaces\\.cs_workspaces")
else
let g:ctrlspaceWorkspace = ($HOME."\\.vim\\workspaces\\.cs_workspacesCWD")
endif
let g:overrideCWD=1
endif
"Find the current process, the process parent, and use ps ax to obtain the path. Meant to work in mac. in Linux, it is easier with `/proc/XXX/cmdline'.
"if expand("%:p:t")=="special"
norm \<c-O>
":CtrlSpaceLoadWorkspace default
"endif
if argc()==0
"PY import vim
"PY import os
"PY pid=os.getpid()
"PY kk=os.popen('ps -o ppid= -p ' + str(pid)).read()
"PY kk=kk.replace('\n','')
"PY tt=("let uu=system('ps ax | grep \""+kk + "\" | grep -v grep')")
"PY vim.command(tt)
"let uuA=substitute(uu,"^.\\{-}\/","",'g')
"let uu="bash"
"PY kk=os.popen('ps -o ppid= -p ' + str(kk)).read()
"PY kk=kk.replace('\n','')
""if it is 1 then fail
"PY if kk!=1: tt=("let uu=system('ps ax | grep \""+kk + "\" | grep -v grep')")
"PY vim.command(tt)
"let uu=substitute(uu,"^.\\{-}\/","",'g')
"if (uu=~".*bash.*")
""too much indentation
"let uu=uuA
"endif
""echom 'cmdline: '.uu
""for neovim-qt
"let uu=substitute(uu," -psn.\\{-}$","",'g')
"PY vim.command('let uu='+str(vim.eval('uu').replace('\n','').find(' ')))
"if uu==-1
""echom "loading"
"":CocDisable
"":CtrlSpaceLoadWorkspace default
"endif
endif
"if exists('g:GuiLoaded') || ( g:on_vimr)
"imap <c-s> <esc>:let g:EasyMotion_add_search_history=0<CR>i<c-o><Plug>(easymotion-sn)
"endif
"if exists('g:GuiLoaded') || exists(':GonvimWorkspaceNew') || ( g:on_vimr)
"imap <c-s> <esc>:let g:EasyMotion_add_search_history=0<CR>i<c-o><Plug>(easymotion-sn)
"else
"nnoremap <c-s> :w<CR>
"endif
"nvimQT
let g:GuiLoaded=1
"echom "exists"
"set guifont=Meslo\ LG\ L\ DZ\ for\ Powerline:h12
"set guifont=Inconsolata-dz\ for\ powerline:h14
"if !exists(':GonvimWorkspaceNew')
":GuiTabline 0
""source /users/eyalkarni/nvim-osx64/share/nvim/runtime/macmap.vim
""it started to act normal
"imap <M-ß> :w<CR>
"nmap <D-W> :q<CR>
"nmap <D-w> :q<CR>
"nnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>
"inoremap <silent><RightMouse> <Esc>:call GuiShowContextMenu()<CR>
"vnoremap <silent><RightMouse> :call GuiShowContextMenu()<CR>gv
"if g:on_ek_computer
""source /Users/eyalkarni/neovim-0.4.2/runtime/macmap.vim
""nmap <leader>rv mwd:sleep 1<CR>:!osascript -e 'tell application "System Events" to keystroke "v" using {control down, shift down}'<CR>:qa!<CR>
""nmap <leader>RV mwd:sleep 1<CR>:!osascript -e 'tell application "System Events" to keystroke "v" using {command down, shift down}'<CR>:qa!<CR>
""nmap <leader>rv mwd:sleep 1<CR>:exec '!start \"powershell ps \| Where-Object -Property ProcessName -Like \"*goneovim*\" \| \%{Write-Host $_.Id ,$_.ProcessName ;$_.Kill()} ; C:\Users\ekarni\Downloads\Goneovim-v0.4.12-win64\goneovim.exe\"'
"endif
"else
""~/nvimMACfiles/macmap042.vim
"endif
if 1
if g:on_ek_computer
nmap <leader>rv :wshada!<CR>:exec "!start powershell ResetNeo"<CR>
"source /Users/eyalkarni/neovim-0.4.2/runtime/macmap.vim
endif
set shell=cmd
exec "silent !echo ". v:servername . " > c:\\temp\\listen.txt"
"override
nmap <D-f> <Plug>(easymotion-s2)
"imap <D-v> <c-o>P
nnoremap <Home> ^
vnoremap <Home> ^
"set guifont=Meslo\ LG\ S\ for\ Powerline:h14
" set guifont=Monaco\ for\ Powerline:h12
set mouse=a
inoremap <c-p> <c-v>
cnoremap <c-p> <c-v>
inoremap <c-v> <c-r><c-p>+
inoremap <c-v> <c-r><c-p>+
cnoremap <c-v> <c-r>+
nnoremap <c-v> p
nnoremap <M-v> <c-v>
nnoremap <M-a> ggVG
"nmap <D-v> p
"imap <D-V>
"imap <D-v>
"vmap <D-V> p
"vmap <D-v> p
"vmap <D-C> y
"vmap <D-c> y
"vmap <D-X> d
"vmap <D-x> d
"cmap <D-V> <c-r>+
"cmap <D-v> <c-r>+
else
if g:on_ek_computer
nmap <leader>rv mwd:!osascript -e 'do shell script "sh /users/eyalkarni/vimpy3/vimr.sh"'<CR>
endif
endif
"echom "ignore this no such mapping"
if getcwd()=='/' || getcwd()=="c:\\Windows\\system32"
cd ~
"normal \ov
endif
if !exists('g:dirs')
call LoadDir()
let g:lastdir=''
endif
":GitGutterEnable
let g:autosaveWS=timer_start(10000,'TimerFunc',{'repeat':-1})
let g:timerb=timer_start(3000,'TimerFuncB',{'repeat':-1})
let g:autoreg=timer_start(20000,'GetLine',{'repeat':-1})
let g:autosaveInserts = timer_start(200000,'SaveInsertsFunc',{'repeat':-1})
let tt = timer_start(1000,'LazyIt',{'repeat':1})
"for solving ctags bug
"au! GonvimAu OptionSet
set mouse=a
au! gutentags_detect
set ut=3000
silent! nunmap ,tt
silent! nunmap ,t
"call SetFont()
endfunction
function! LazyIt(a)
"let airline#extensions#tabline#enabled=0
"augroup airline
"au VimLeave echo "a"
"augroup end
"GuiTabline 0
"Lazy load vim-airline
"Lazy reload quick-scope
"sleep 200ms
"colorscheme onedark
"norm! \<esc>
endfunction
function! OnEnd()
"call ctrlspace#workspaces#SaveWorkspace("default")
endfunction
"autocmd VimEnter * call RestoreSession()
"function! RestoreSession()
"if argc() == 0 && filereadable(eval('g:ses')) "vim called without arguments
"execute "source " . g:ses
"endif
"endfunction
function! PyAS()
autocmd filetype python let b:auto_save = 1
autocmd filetype ps1 let b:auto_save = 1
autocmd filetype lua let b:auto_save = 1
endfunction
command! Pyauto call PyAS()
" autocmds for file types
autocmd filetype vim let b:auto_save = 1
"completing next function
:autocmd FileType vim nnoremap <buffer> ]m /^\(\s\)*function<CR>
:autocmd FileType vim nnoremap <buffer> [m ?^\(\s\)*function<CR>
:autocmd FileType vim nnoremap <buffer> ]M /^\(\s\)*endfunction/b<CR>
:autocmd FileType vim nnoremap <buffer> [M ?^\(\s\)*endfunction/b<CR>
"let $PATH="C:\\Users\\ekarni\\.pyenv\\pyenv-win\\versions\\3.9\\Scripts;". $PATH
"let $PATH='C:\Users\ekarni\AppData\Local\SumatraPDF;'. $PATH
"autocmd! TermEnter * :startinsert
"commands
"
command! -nargs=* -complete=file C call CloseAllNR()<bar>:sleep 200m<bar>:vert topleft split <args>
command! -nargs=* -complete=help VHelp vert :help <args>
" search
set incsearch
:noh
set hlsearch
"augroup vimrc-noincsearch-highlight
"autocmd!
"autocmd CmdlineLeave :echo "zzz" | :set noincsearch | :noh
"augroup END
let g:no_spec_maps=1
function! Aa()
if mode() != 'n' || getcmdwintype() != ''
return
endif
checktime
endf
autocmd BufEnter,FocusGained * call Aa()
"set noautoread #don't reload it when changed outside vim and no vim changes.
set synmaxcol=300
"