More clean-ups
Better Cross-platform stuff https://vimways.org/2018/from-vimrc-to-vim/
This commit is contained in:
19
autoload/option.vim
Normal file
19
autoload/option.vim
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
" From https://sanctum.geek.nz/cgit/dotfiles.git/tree/vim/autoload/option.vim
|
||||||
|
|
||||||
|
" Split a comma-separated option value into parts, accounting for escaped
|
||||||
|
" commas and leading whitespace as Vim itself does internally
|
||||||
|
"
|
||||||
|
function! option#Split(expr, ...) abort
|
||||||
|
if a:0 > 1
|
||||||
|
echoerr 'Too many arguments'
|
||||||
|
endif
|
||||||
|
let keepempty = a:0 ? a:1 : 0
|
||||||
|
let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
|
||||||
|
return map(copy(parts), 'substitute(v:val, ''\\,'', '','', ''g'')')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Escape the right-hand side of a :set option value
|
||||||
|
"
|
||||||
|
function! option#Escape(expr) abort
|
||||||
|
return escape(a:expr, ' |"\')
|
||||||
|
endfunction
|
||||||
@@ -1,18 +1,19 @@
|
|||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
let g:plug_path=expand(g:vim_files . '/autoload/plug.vim')
|
let s:plug_path=expand($MYVIM . '/autoload/plug.vim')
|
||||||
let g:have_plug=filereadable(g:plug_path)
|
let g:have_plug=filereadable(s:plug_path)
|
||||||
if(!g:have_plug && executable('curl'))
|
if(!g:have_plug && executable('curl'))
|
||||||
echo 'Installing Plug'
|
echo 'Installing Plug'
|
||||||
|
|
||||||
execute '!curl -fLo "' . g:plug_path . '" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
execute '!curl -fLo "' . s:plug_path . '" --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
|
||||||
execute 'source ' . g:plug_path
|
execute 'source ' . s:plug_path
|
||||||
let g:have_plug = 1
|
let g:have_plug = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if(g:have_plug)
|
if(g:have_plug)
|
||||||
call plug#begin(g:vim_files . '/plugged')
|
let s:plugged=resolve($MYVIM . '/.cache/plugged')
|
||||||
|
call plug#begin(s:plugged)
|
||||||
|
|
||||||
Plug 'tpope/vim-sensible' " Sensible defaults for vim
|
Plug 'tpope/vim-sensible' " Sensible defaults for vim
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ if(g:have_plug)
|
|||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
if empty(glob(g:vim_files . '/plugged'))
|
if empty(glob(s:plugged))
|
||||||
PlugInstall --sync
|
PlugInstall --sync
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@@ -69,19 +70,10 @@ let g:loaded_netrwPlugin = 1 " Disable netrw
|
|||||||
|
|
||||||
let g:airline_powerline_fonts = 1
|
let g:airline_powerline_fonts = 1
|
||||||
let g:airline#extensions#tabline#enabled = 1
|
let g:airline#extensions#tabline#enabled = 1
|
||||||
let g:airline_section_error = '%{airline#util#wrap(airline#extensions#coc#get_error(),0)}'
|
|
||||||
let g:airline_section_warning = '%{airline#util#wrap(airline#extensions#coc#get_warning(),0)}'
|
|
||||||
|
|
||||||
let g:ale_sign_column_always = 1
|
let g:ale_sign_column_always = 1
|
||||||
let g:ale_sign_error = ''
|
let g:ale_sign_error = ''
|
||||||
let g:ale_sign_warning = ''
|
let g:ale_sign_warning = ''
|
||||||
let g:ale_fix_on_save = 1
|
|
||||||
|
|
||||||
let g:ale_linters = {
|
|
||||||
\ 'typescript': ['tsserver'],
|
|
||||||
\ 'typescript.tsx': ['tsserver'],
|
|
||||||
\ 'cs': ['OmniSharp']
|
|
||||||
\}
|
|
||||||
|
|
||||||
let g:coverage_json_report_path = 'coverage/coverage-final.json'
|
let g:coverage_json_report_path = 'coverage/coverage-final.json'
|
||||||
let g:coverage_sign_covered = ''
|
let g:coverage_sign_covered = ''
|
||||||
@@ -89,20 +81,7 @@ let g:coverage_sign_uncovered = ''
|
|||||||
|
|
||||||
let g:signify_vcs_list = [ 'git' ]
|
let g:signify_vcs_list = [ 'git' ]
|
||||||
|
|
||||||
let g:neoformat_html_prettier = {
|
|
||||||
\ 'exe': 'prettier',
|
|
||||||
\ 'typescript': ['typescript-language-server', '--stdio'],
|
|
||||||
\ 'javascript': ['javascript-typescript-stdio'],
|
|
||||||
\ 'javascript.jsx': ['javascript-typescript-stdio'],
|
|
||||||
\ }
|
|
||||||
|
|
||||||
let g:neoformat_enabled_html = ['prettier']
|
let g:neoformat_enabled_html = ['prettier']
|
||||||
|
|
||||||
let g:neoformat_nginx_nginxbeautifier = {
|
|
||||||
\ 'exe': 'nginxbeautifier',
|
|
||||||
\ 'replace': 1,
|
|
||||||
\ }
|
|
||||||
|
|
||||||
let g:neoformat_enabled_nginx = ['nginxbeautifier']
|
let g:neoformat_enabled_nginx = ['nginxbeautifier']
|
||||||
|
|
||||||
let g:OmniSharp_server_stdio = 1
|
let g:OmniSharp_server_stdio = 1
|
||||||
|
|||||||
@@ -45,85 +45,3 @@ imap jk <Esc>
|
|||||||
|
|
||||||
" set wildignore+=*/Deploy/*,*/node_modules/*,*/build/*,*/lib/*,*/bower_components/*,*/jspm_packages/*
|
" set wildignore+=*/Deploy/*,*/node_modules/*,*/build/*,*/lib/*,*/bower_components/*,*/jspm_packages/*
|
||||||
set completeopt=longest,menuone,preview
|
set completeopt=longest,menuone,preview
|
||||||
|
|
||||||
" Stolen from maralla/dotvim
|
|
||||||
function! EnsureExists(path) abort
|
|
||||||
if !isdirectory(expand(a:path))
|
|
||||||
call mkdir(expand(a:path))
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
" persistent undo
|
|
||||||
if exists('+undofile')
|
|
||||||
set undofile
|
|
||||||
set undodir=~/.vim/.cache/undo
|
|
||||||
endif
|
|
||||||
|
|
||||||
" backups
|
|
||||||
set backup
|
|
||||||
set backupdir=~/.vim/.cache/backup
|
|
||||||
|
|
||||||
" swap files
|
|
||||||
set directory=~/.vim/.cache/swap
|
|
||||||
set noswapfile
|
|
||||||
|
|
||||||
call EnsureExists('~/.vim/.cache')
|
|
||||||
call EnsureExists(&undodir)
|
|
||||||
call EnsureExists(&backupdir)
|
|
||||||
call EnsureExists(&directory)
|
|
||||||
|
|
||||||
" Set up CtrlP with faster alternative, if possible
|
|
||||||
if executable('ag')
|
|
||||||
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
|
|
||||||
set grepprg=ag\ --nogroup\ --nocolor
|
|
||||||
" Use ag in CtrlP for listing files. Lightning fast, respects .gitignore
|
|
||||||
" and .agignore. Ignores hidden files by default.
|
|
||||||
let g:ctrlp_user_command = 'ag %s -l --nocolor -f -g ""'
|
|
||||||
let g:ctrlp_use_caching = 0
|
|
||||||
else
|
|
||||||
if executable('rg')
|
|
||||||
set grepprg=rg\ --color=never
|
|
||||||
|
|
||||||
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
|
|
||||||
let g:ctrlp_use_caching = 0
|
|
||||||
else
|
|
||||||
"ctrl+p ignore files in .gitignore
|
|
||||||
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if has('gui_running')
|
|
||||||
set guioptions-=mTr " disable toolbar, menubar and scrollbar
|
|
||||||
if has('win32')
|
|
||||||
set guifont=Source_Code_Pro:h12:cANSI
|
|
||||||
endif
|
|
||||||
if has('osx')
|
|
||||||
set guifont=Source_Code_Pro:h13
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
if(has('mouse'))
|
|
||||||
set mouse=a
|
|
||||||
endif
|
|
||||||
if $TERM_PROGRAM ==? 'iTerm.app'
|
|
||||||
" different cursors for insert vs normal mode
|
|
||||||
if exists('$TMUX')
|
|
||||||
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
|
|
||||||
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
|
|
||||||
else
|
|
||||||
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
|
|
||||||
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
" Windows-specific setting allowing for 256-colors etc
|
|
||||||
if($ConEmuANSI ==? 'ON')
|
|
||||||
set term=xterm
|
|
||||||
set t_Co=256
|
|
||||||
let &t_AB='\e[48;5;%dm' " background color
|
|
||||||
let &t_AF='\e[38;5;%dm' " foreground color
|
|
||||||
inoremap <Esc>[62~ <C-X><C-E>
|
|
||||||
inoremap <Esc>[63~ <C-X><C-Y>
|
|
||||||
nnoremap <Esc>[62~ <C-E>
|
|
||||||
nnoremap <Esc>[63~ <C-Y>
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
autocmd FileType cs nnoremap <F12> :OmniSharpGetCodeActions<CR>
|
autocmd FileType cs nnoremap <F12> :OmniSharpGetCodeActions<CR>
|
||||||
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
augroup Signs
|
augroup Signs
|
||||||
autocmd BufEnter * sign define dummy
|
autocmd BufEnter * sign define dummy
|
||||||
autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
|
autocmd BufEnter * execute 'sign place 9999 line=1 name=dummy buffer=' . bufnr('')
|
||||||
|
|||||||
30
plugin/folders.vim
Normal file
30
plugin/folders.vim
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
" Stolen from maralla/dotvim
|
||||||
|
function! s:EnsureExists(path) abort
|
||||||
|
let l:path = expand(a:path)
|
||||||
|
if !isdirectory(l:path)
|
||||||
|
try
|
||||||
|
call mkdir(l:path)
|
||||||
|
catch
|
||||||
|
echom "Could not create directory " . l:path
|
||||||
|
endtry
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
call s:EnsureExists(resolve($MYVIM . '/.cache'))
|
||||||
|
|
||||||
|
" persistent undo
|
||||||
|
if exists('+undofile')
|
||||||
|
let &undodir = resolve($MYVIM . '/.cache/undo')
|
||||||
|
set undofile
|
||||||
|
call s:EnsureExists(&undodir)
|
||||||
|
endif
|
||||||
|
|
||||||
|
" backups
|
||||||
|
let &backupdir=resolve($MYVIM . '/.cache/backup')
|
||||||
|
set backup
|
||||||
|
call s:EnsureExists(&backupdir)
|
||||||
|
|
||||||
|
" swap files
|
||||||
|
let &directory=resolve($MYVIM . '/.cache/swap')
|
||||||
|
set noswapfile
|
||||||
|
call s:EnsureExists(&directory)
|
||||||
21
plugin/grep.vim
Normal file
21
plugin/grep.vim
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
" Set up CtrlP with faster alternative, if possible
|
||||||
|
if executable('ag')
|
||||||
|
" Use The Silver Searcher https://github.com/ggreer/the_silver_searcher
|
||||||
|
set grepprg=ag\ --nogroup\ --nocolor
|
||||||
|
" Use ag in CtrlP for listing files. Lightning fast, respects .gitignore
|
||||||
|
" and .agignore. Ignores hidden files by default.
|
||||||
|
let g:ctrlp_user_command = 'ag %s -l --nocolor -f -g ""'
|
||||||
|
let g:ctrlp_use_caching = 0
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
if executable('rg')
|
||||||
|
set grepprg=rg\ --color=never
|
||||||
|
|
||||||
|
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
|
||||||
|
let g:ctrlp_use_caching = 0
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
"ctrl+p ignore files in .gitignore
|
||||||
|
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f']
|
||||||
13
plugin/gui.vim
Normal file
13
plugin/gui.vim
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
if has('gui_running')
|
||||||
|
set guioptions-=mTr " disable toolbar, menubar and scrollbar
|
||||||
|
if has('win32')
|
||||||
|
set guifont=Source_Code_Pro:h12:cANSI
|
||||||
|
endif
|
||||||
|
if has('osx')
|
||||||
|
set guifont=Source_Code_Pro:h13
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
if(has('mouse'))
|
||||||
|
set mouse=a
|
||||||
|
endif
|
||||||
|
endif
|
||||||
30
plugin/ui.vim
Normal file
30
plugin/ui.vim
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
if $TERM_PROGRAM ==? 'iTerm.app'
|
||||||
|
" different cursors for insert vs normal mode
|
||||||
|
if exists('$TMUX')
|
||||||
|
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
|
||||||
|
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
|
||||||
|
else
|
||||||
|
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
|
||||||
|
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Windows-specific setting allowing for 256-colors etc
|
||||||
|
if($ConEmuANSI ==? 'ON')
|
||||||
|
set term=xterm
|
||||||
|
set t_Co=256
|
||||||
|
let &t_AB='\e[48;5;%dm' " background color
|
||||||
|
let &t_AF='\e[38;5;%dm' " foreground color
|
||||||
|
inoremap <Esc>[62~ <C-X><C-E>
|
||||||
|
inoremap <Esc>[63~ <C-X><C-Y>
|
||||||
|
nnoremap <Esc>[62~ <C-E>
|
||||||
|
nnoremap <Esc>[63~ <C-Y>
|
||||||
|
endif
|
||||||
|
|
||||||
|
if(exists('$WT_SESSION'))
|
||||||
|
set t_Co=256
|
||||||
|
inoremap <Esc>[62~ <C-X><C-E>
|
||||||
|
inoremap <Esc>[63~ <C-X><C-Y>
|
||||||
|
nnoremap <Esc>[62~ <C-E>
|
||||||
|
nnoremap <Esc>[63~ <C-Y>
|
||||||
|
endif
|
||||||
17
setup.bat
17
setup.bat
@@ -5,10 +5,13 @@ cd /d %0\..
|
|||||||
|
|
||||||
ver | find "XP" > nul
|
ver | find "XP" > nul
|
||||||
if %ERRORLEVEL% == 0 goto vXp
|
if %ERRORLEVEL% == 0 goto vXp
|
||||||
|
ver | find "Version 10." > nul
|
||||||
|
if %ERRORLEVEL% == 0 goto vTen
|
||||||
|
|
||||||
goto vOver
|
goto done
|
||||||
|
|
||||||
:vXp
|
:vXp
|
||||||
|
echo "Windows XP"
|
||||||
set target=%UserProfile%\vimfiles
|
set target=%UserProfile%\vimfiles
|
||||||
set cmd=junction "%target%" "%cd%"
|
set cmd=junction "%target%" "%cd%"
|
||||||
start /I %cmd%
|
start /I %cmd%
|
||||||
@@ -16,9 +19,17 @@ set cmd=fsutil hardlink create "%UserProfile%\_vimrc" "%cd%\vimrc"
|
|||||||
start /I %cmd%
|
start /I %cmd%
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
|
:vTen
|
||||||
:vOver
|
echo "Windows 10"
|
||||||
|
set target=%UserProfile%\vimfiles
|
||||||
|
set cmd=mklink /D "%target%" "%cd%"
|
||||||
|
start /I %cmd%
|
||||||
|
set target=%UserProfile%\_vimrc
|
||||||
|
set cmd=mklink "%target%" "%cd%"\vimrc
|
||||||
|
start /I %cmd%
|
||||||
|
|
||||||
goto done
|
goto done
|
||||||
|
|
||||||
|
echo "Done"
|
||||||
|
|
||||||
:done
|
:done
|
||||||
|
|||||||
17
vimrc
17
vimrc
@@ -1,16 +1,9 @@
|
|||||||
set encoding=utf-8
|
set encoding=utf-8
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
|
|
||||||
let g:vim_files=fnamemodify(resolve(expand('$MYVIMRC')), ':p:h')
|
if &runtimepath ==# ''
|
||||||
|
throw 'Empty ''runtimepath'''
|
||||||
|
endif
|
||||||
|
let $MYVIM = resolve(option#Split(&runtimepath)[0])
|
||||||
|
|
||||||
function! SourceConfig(name)
|
runtime! config/**/*.vim
|
||||||
" exec "echo 'Loading " . a:name . "'"
|
|
||||||
exec 'source ' . expand(g:vim_files . '/config/' . a:name)
|
|
||||||
endfunction
|
|
||||||
|
|
||||||
call SourceConfig('01-plugins.vim')
|
|
||||||
call SourceConfig('02-general.vim')
|
|
||||||
call SourceConfig('03-mappings.vim')
|
|
||||||
call SourceConfig('04-autocmds.vim')
|
|
||||||
|
|
||||||
unlet g:vim_files
|
|
||||||
|
|||||||
Reference in New Issue
Block a user