update my_vim.vim configuration
This commit is contained in:
parent
e80ab90348
commit
1fe348750d
@ -1,75 +1,111 @@
|
|||||||
"
|
"########################################################################
|
||||||
" this only gets executed if not using the own vim installation
|
"# Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com> #
|
||||||
"
|
"# VIM Version: 7.4 #
|
||||||
|
"########################################################################
|
||||||
|
|
||||||
|
if exists('g:my_vim')
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let g:my_vim=1
|
||||||
|
|
||||||
|
|
||||||
|
"###################################
|
||||||
|
"# XDG config and data directories #
|
||||||
|
"###################################
|
||||||
|
|
||||||
function! CheckXDGVars()
|
function! CheckXDGVars()
|
||||||
if empty($XDG_CONFIG_HOME)
|
if exists( "$XDG_CONFIG_HOME" )
|
||||||
let $vim_config_home=expand("$HOME/.config/vim")
|
let g:vim_config_home = expand( "$XDG_CONFIG_HOME/vim" )
|
||||||
else
|
else
|
||||||
let $vim_config_home=expand("$XDG_CONFIG_HOME/vim")
|
let g:vim_config_home = expand( "$HOME/.config/vim" )
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if empty($XDG_CACHE_HOME)
|
if exists( "$XDG_CACHE_HOME" )
|
||||||
let $vim_cache_home=expand("$HOME/.local/cache/vim")
|
let g:vim_cache_home = expand( "$XDG_CACHE_HOME/vim" )
|
||||||
else
|
else
|
||||||
let $vim_cache_home=expand("$XDG_CACHE_HOME/vim")
|
let g:vim_cache_home = expand( "$HOME/.local/cache/vim" )
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if empty($XDG_DATA_HOME)
|
if exists( "$XDG_DATA_HOME" )
|
||||||
let $vim_data_home=expand("$HOME/.local/share/vim")
|
let g:vim_data_home = expand( "$XDG_DATA_HOME/vim" )
|
||||||
else
|
else
|
||||||
let $vim_data_home=expand("$XDG_DATA_HOME/vim")
|
let g:vim_data_home = expand( "$HOME/.local/share/vim" )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserRuntimePath(dir)
|
function! SetUserRuntimePath( dir )
|
||||||
let $user_rtp=a:dir
|
let l:user_rtp = a:dir
|
||||||
let $runtimepath_old=&runtimepath
|
let l:runtimepath_old = &runtimepath
|
||||||
set runtimepath=$user_rtp,$user_rtp/after,$runtimepath_old
|
let &runtimepath .= ',' . expand(l:user_rtp)
|
||||||
|
let &runtimepath .= ',' . expand(l:user_rtp) . '/after'
|
||||||
|
let &runtimepath .= ',' . expand(l:runtimepath_old)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserBackupdir(dir)
|
function! SetUserBackupdir( dir )
|
||||||
let &backupdir=a:dir . "/backup"
|
if $USER == 'root'
|
||||||
if !isdirectory(expand(&backupdir))
|
set nobackup
|
||||||
call mkdir(expand(&backupdir), "p", 0700)
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &backupdir = a:dir . "/backup"
|
||||||
|
if !isdirectory( expand( &backupdir ) )
|
||||||
|
call mkdir( expand( &backupdir ), "p", 0700 )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserSwapdir(dir)
|
function! SetUserSwapdir( dir )
|
||||||
let &directory=a:dir . "/swap"
|
if $USER == 'root'
|
||||||
if !isdirectory(expand(&directory))
|
set noswapfile
|
||||||
call mkdir(expand(&directory), "p", 0700)
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let &directory = a:dir . "/swap"
|
||||||
|
if !isdirectory( expand( &directory ) )
|
||||||
|
call mkdir( expand( &directory ), "p", 0700 )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserViewdir(dir)
|
function! SetUserViewdir( dir )
|
||||||
if has('mksession')
|
if !has( 'mksession' )
|
||||||
let &viewdir=a:dir . "/views"
|
return
|
||||||
if !isdirectory(expand(&viewdir))
|
endif
|
||||||
call mkdir(expand(&viewdir), "p", 0700)
|
|
||||||
endif
|
let &viewdir = a:dir . "/views"
|
||||||
|
if !isdirectory( expand( &viewdir ) )
|
||||||
|
call mkdir( expand( &viewdir ), "p", 0700 )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserUndodir(dir)
|
function! SetUserUndodir( dir )
|
||||||
if has('persistent_undo')
|
if !has( 'persistent_undo' )
|
||||||
let &undodir=a:dir . "/undo"
|
return
|
||||||
if !isdirectory(expand(&undodir))
|
endif
|
||||||
call mkdir(expand(&undodir), "p", 0700)
|
|
||||||
endif
|
let &undodir = a:dir . "/undo"
|
||||||
|
if !isdirectory( expand( &undodir ) )
|
||||||
|
call mkdir( expand( &undodir ), "p", 0700 )
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! SetUserViminfo(dir)
|
function! SetUserViminfo( dir )
|
||||||
if has('viminfo')
|
if !has( 'viminfo' )
|
||||||
if !isdirectory(a:dir)
|
return
|
||||||
call mkdir(a:dir, "p", 0700)
|
|
||||||
endif
|
|
||||||
set nocompatible
|
|
||||||
let &viminfo="'1000,<50,s10,n" . a:dir . "/viminfo"
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !isdirectory( a:dir )
|
||||||
|
call mkdir( a:dir, "p", 0700 )
|
||||||
|
endif
|
||||||
|
|
||||||
|
set nocompatible
|
||||||
|
let &viminfo = "'1000,<50,s10,n" . a:dir . "/viminfo"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
"###########
|
||||||
|
"# Options #
|
||||||
|
"###########
|
||||||
|
|
||||||
function! SetOptions()
|
function! SetOptions()
|
||||||
set autoindent
|
set autoindent
|
||||||
set backspace=indent,eol,start
|
set backspace=indent,eol,start
|
||||||
@ -81,7 +117,7 @@ function! SetOptions()
|
|||||||
set ttimeoutlen=100
|
set ttimeoutlen=100
|
||||||
set laststatus=2
|
set laststatus=2
|
||||||
set number
|
set number
|
||||||
set autoread " does it even work?
|
set autoread
|
||||||
set fileformats=unix,dos,mac
|
set fileformats=unix,dos,mac
|
||||||
set display+=lastline
|
set display+=lastline
|
||||||
set noerrorbells
|
set noerrorbells
|
||||||
@ -89,10 +125,44 @@ function! SetOptions()
|
|||||||
set t_vb=
|
set t_vb=
|
||||||
set showmatch
|
set showmatch
|
||||||
|
|
||||||
"#################################
|
" set scroll offset slightly higher so that the next or previous line can be seen
|
||||||
"# Options depending on features #
|
if !&scrolloff
|
||||||
"#################################
|
set scrolloff=1
|
||||||
|
endif
|
||||||
|
|
||||||
|
" same as with scroll offset but for horizontal scrolling
|
||||||
|
if !&sidescrolloff
|
||||||
|
set sidescrolloff=5
|
||||||
|
endif
|
||||||
|
|
||||||
|
" set the history far higher (default 50)
|
||||||
|
if &history < 1000
|
||||||
|
set history=1000
|
||||||
|
endif
|
||||||
|
|
||||||
|
" increase the maximal number of tabpages (default 10)
|
||||||
|
if &tabpagemax < 50
|
||||||
|
set tabpagemax=50
|
||||||
|
endif
|
||||||
|
|
||||||
|
" set the terminal colors to 256 if not in a VT
|
||||||
|
if exists($TERM)
|
||||||
|
if &t_Co == 8 && $TERM !~# '^linux'
|
||||||
|
set t_Co=256
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
if &listchars ==# 'eol:$'
|
||||||
|
set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
|
||||||
|
endif
|
||||||
|
|
||||||
|
" load the matchit macros
|
||||||
|
if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# ''
|
||||||
|
runtime! macros/matchit.vim
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
function! SetFeatureDependentOptions()
|
||||||
" allow the cursor to be positioned where no characters are in virtual block mode
|
" allow the cursor to be positioned where no characters are in virtual block mode
|
||||||
if has('virtualedit')
|
if has('virtualedit')
|
||||||
set virtualedit=block
|
set virtualedit=block
|
||||||
@ -142,56 +212,19 @@ function! SetOptions()
|
|||||||
if has('mouse')
|
if has('mouse')
|
||||||
set mouse=a
|
set mouse=a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
"######################################
|
|
||||||
"# Options depending on set variables #
|
|
||||||
"######################################
|
|
||||||
|
|
||||||
" set scroll offset slightly higher so that the next or previous line can be seen
|
|
||||||
if !&scrolloff
|
|
||||||
set scrolloff=1
|
|
||||||
endif
|
|
||||||
|
|
||||||
" same as with scroll offset but for horizontal scrolling
|
|
||||||
if !&sidescrolloff
|
|
||||||
set sidescrolloff=5
|
|
||||||
endif
|
|
||||||
|
|
||||||
" set the history far higher (default 50)
|
|
||||||
if &history < 1000
|
|
||||||
set history=1000
|
|
||||||
endif
|
|
||||||
|
|
||||||
" increase the maximal number of tabpages (default 10)
|
|
||||||
if &tabpagemax < 50
|
|
||||||
set tabpagemax=50
|
|
||||||
endif
|
|
||||||
|
|
||||||
" set the terminal colors to 256 if not in a VT
|
|
||||||
if exists($TERM)
|
|
||||||
if &t_Co == 8 && $TERM !~# '^linux'
|
|
||||||
set t_Co=256
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
"#################
|
|
||||||
"# Plugins, etc. #
|
|
||||||
"#################
|
|
||||||
|
|
||||||
" load the matchit macros
|
|
||||||
if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# ''
|
|
||||||
runtime! macros/matchit.vim
|
|
||||||
endif
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
if empty($my_vim)
|
|
||||||
call CheckXDGVars()
|
"#########
|
||||||
call SetUserRuntimePath($vim_config_home)
|
"# Setup #
|
||||||
call SetUserSwapdir($vim_data_home)
|
"#########
|
||||||
call SetUserUndodir($vim_data_home)
|
|
||||||
call SetUserViewdir($vim_data_home)
|
call CheckXDGVars()
|
||||||
call SetUserBackupdir($vim_data_home)
|
call SetUserRuntimePath( g:vim_config_home )
|
||||||
call SetUserViminfo($vim_cache_home)
|
call SetUserSwapdir( g:vim_data_home )
|
||||||
call SetOptions()
|
call SetUserUndodir( g:vim_data_home )
|
||||||
endif " empty($my_vim)
|
call SetUserViewdir( g:vim_data_home )
|
||||||
|
call SetUserBackupdir( g:vim_data_home )
|
||||||
|
call SetUserViminfo( g:vim_cache_home )
|
||||||
|
call SetOptions()
|
||||||
|
call SetFeatureDependentOptions()
|
||||||
|
Loading…
Reference in New Issue
Block a user