1
0

move compat stuff to old vimrc

probably remove vimrc in the future
This commit is contained in:
valeth 2015-11-18 10:46:27 +01:00
parent 0dc49f0a87
commit 4112cd6cf1
2 changed files with 198 additions and 282 deletions

222
init.vim
View File

@ -1,7 +1,7 @@
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" "
" Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com> "
" VIM Version: 7.4 "
" VIM Version: NVIM 0.1.0
" "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@ -23,88 +23,13 @@ else
let g:vim_data_home = expand('$HOME/.local/share/') . v:progname
endif
" reload config
" automatically reload config
augroup myvimrc
au!
au BufWritePost $MYVIMRC source $MYVIMRC
augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""
" Compat: Just for compatability with legacy vim "
""""""""""""""""""""""""""""""""""""""""""""""""""
if ! has('nvim')
set ttimeoutlen=-1
" default options in neovim
set autoindent
set autoread
set backspace=indent,eol,start
set complete-=i
set display=lastline
"if has('multi_byte')
" set encoding=utf-8
"endif
if v:version >= 704
set formatoptions=tcqj
endif
if &history < 10000
set history=10000
endif
if has('extra_search')
set hlsearch
set incsearch
endif
if has('langmap')
set langnoremap
endif
set laststatus=2
set listchars="tab:> ,trail:-,nbsp:+"
if has('mouse')
set mouse=a
endif
"set nocompatible
set nrformats=hex
if has('mksession')
set sessionoptions+=options
endif
set smarttab
if has('windows')
set tabpagemax=50
endif
set tags="./tags;,tags"
set ttyfast
if has('viminfo')
set viminfo+=!
endif
if has('wildmenu')
set wildmenu
endif
" options that have been removed from neovim
if v:version >= 704
set cryptmethod=blowfish
au BufReadPost * if &key != "" | set noswapfile nowritebackup viminfo= nobackup noshelltemp history=0 secure | endif
endif
endif
if v:version >= 704
set undofile
aug LineNumbers
au!
au VimEnter,WinEnter,InsertLeave * setlocal relativenumber
au WinLeave,InsertEnter * setlocal norelativenumber
aug END
endif
if has('xterm_clipboard')
set clipboard=unnamed,unnamedplus,autoselect
endif
"""""""""""""""""""""""""""""""""""
" Settings: All kinds of settings "
"""""""""""""""""""""""""""""""""""
@ -122,53 +47,30 @@ set smartcase
set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp
set showmatch
set shortmess=aoOtTI
if has('smartindent')
set smartindent
endif
set clipboard+=unnamedplus
set smartindent
set undofile
set splitbelow
set splitright
set breakindent
set breakindentopt=sbr
let &showbreak = '↳ '
set ruler
set showcmd
set wildmode=list:longest,full
set wildignore=.bak,.old,.swp,~
set virtualedit=block
" enable filetype plugins
if has('autocmd')
filetype indent on
filetype plugin on
endif
filetype indent on
filetype plugin on
syntax enable
"if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# ''
"runtime! macros/matchit.vim
"endif
if has('windows')
set splitbelow
set splitright
endif
if has('linebreak')
let &showbreak = '↳ '
if v:version >=704
set breakindent
set breakindentopt=sbr
endif
endif
if has('cmdline_info')
set ruler
set showcmd
endif
if has('wildmenu')
set wildmode=list:longest,full
set wildignore=.bak,.old,.swp,~
endif
if has('virtualedit')
set virtualedit=block
endif
if has('syntax')
syntax enable
endif
aug LineNumbers
au!
au VimEnter,WinEnter,InsertLeave * setlocal relativenumber
au WinLeave,InsertEnter * setlocal norelativenumber
aug END
aug CursorLineColumn
au!
@ -179,15 +81,13 @@ aug END
"set visualbell
"set t_vb=
if has('folding')
set foldcolumn=1
set foldlevel=99
set foldmethod=syntax
set foldtext=MyFoldText()
set foldcolumn=1
set foldlevel=99
set foldmethod=syntax
set foldtext=MyFoldText()
let g:sh_fold_enabled=1
let g:sh_fold_enabled=1
function! MyFoldText()
function! MyFoldText()
" get actual numberwidth of the current document
let nw_add = (len(line('$')) - (&numberwidth - 1))
if nw_add > 0
@ -211,8 +111,7 @@ if has('folding')
let foldtxt_mid = repeat(' ', foldtxt_mid_w + 2)
return foldtxt_start . foldtxt_mid . foldtxt_end
endfunction
endif
endfunction
"""""""""""""""""""""""""""""""
@ -226,63 +125,48 @@ command! WQ wq
command! Q q
command! W w
nnoremap U :redo<CR>
nnoremap <C-R> <NOP>
" allow explicit writing of read-only files with sudo
cnoremap sudow w !sudo tee % >/dev/null
" unset search highlighting
noremap <silent> <Leader><CR> :noh<CR>
nnoremap <F1> <NOP>
nnoremap U :redo<CR>
nnoremap <C-R> <NOP>
nnoremap <Leader>vl :setlocal cursorline!<CR>
nnoremap <Leader>vc :setlocal cursorcolumn!<CR>
nnoremap <Leader>ve :setlocal colorcolumn=80<CR>
nnoremap <Leader>vn :setlocal colorcolumn=0<CR>
nnoremap Y y$
nnoremap j gj
nnoremap k gk
" unset default help shortcut
nnoremap <F1> <NOP>
inoremap <F1> <NOP>
inoremap jk <ESC>
inoremap JK <ESC>
inoremap Jk <ESC>
vnoremap < <gv
vnoremap > >gv
" fix indentation of an entire file
nnoremap <leader>fmt gg=G<CR>``
" local replace
nnoremap gr gd[{V%::s/<C-R>///g<left><left>
nnoremap gR gD:%s/<C-R>///g<left><left>
if v:progname == 'nvim'
tnoremap <ESC> <C-\><C-n>
endif
" highlight searches and search while typing
if has('extra_search')
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent><C-L> :nohlsearch<CR><C-L>
endif
endif
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tn :tabnew<CR>
nnoremap tq :tabclose<CR>
nnoremap <silent> <leader>il :set invlist<CR>
inoremap <F1> <NOP>
inoremap jk <ESC>
inoremap JK <ESC>
inoremap Jk <ESC>
vnoremap < <gv
vnoremap > >gv
vnoremap <silent> <leader>il :<C-W>set invlist<CR>
cnoremap sudow w !sudo tee % >/dev/null
tnoremap <ESC> <C-\><C-n>
" highlight searches and search while typing
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent><C-L> :nohlsearch<CR><C-L>
endif
if exists('$TMUX')
function! TmuxOrSplitSwitch(wincmd, tmuxdir)
let previous_winnr = winnr()
@ -320,5 +204,5 @@ call plug#end()
""""""""""""""""
" Colorscheme: "
""""""""""""""""
colorscheme seoul256
"colorscheme molokai
"colorscheme seoul256
colorscheme molokai

150
vimrc
View File

@ -5,93 +5,125 @@
" "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
if ! exists('g:my_vim')
let g:my_vim=1
"###################################
"# XDG config and data directories #
"###################################
"""""""""""""""""""""""""
" Core: XDG Directories "
"""""""""""""""""""""""""
if exists('$XDG_CONFIG_HOME')
let g:vim_config_home = expand('$XDG_CONFIG_HOME/vim')
else
let g:vim_config_home = expand('$HOME/.config/vim')
endif
if exists('$XDG_CONFIG_HOME')
let g:vim_config_home = expand('$XDG_CONFIG_HOME/') . v:progname
else
let g:vim_config_home = expand('$HOME/.config/') . v:progname
endif
if !isdirectory(g:vim_config_home)
if !isdirectory(g:vim_config_home)
call mkdir( g:vim_config_home, 'p', 0700 )
endif
endif
if exists('$XDG_CACHE_HOME')
let g:vim_cache_home = expand('$XDG_CACHE_HOME/') . v:progname
else
let g:vim_cache_home = expand('$HOME/.local/cache/') . v:progname
endif
if exists('$XDG_CACHE_HOME')
let g:vim_cache_home = expand('$XDG_CACHE_HOME/vim')
else
let g:vim_cache_home = expand('$HOME/.local/cache/vim')
endif
if !isdirectory(g:vim_cache_home)
if !isdirectory(g:vim_cache_home)
call mkdir( g:vim_cache_home, 'p', 0700 )
endif
endif
if exists('$XDG_DATA_HOME')
let g:vim_data_home = expand('$XDG_DATA_HOME/') . v:progname
else
let g:vim_data_home = expand('$HOME/.local/share/') . v:progname
endif
if exists('$XDG_DATA_HOME')
let g:vim_data_home = expand('$XDG_DATA_HOME/vim')
else
let g:vim_data_home = expand('$HOME/.local/share/vim')
endif
if !isdirectory(g:vim_data_home)
if !isdirectory(g:vim_data_home)
call mkdir( g:vim_data_home, 'p', 0700 )
endif
endif
let g:user_rtp = g:vim_config_home
let g:runtimepath_old = &runtimepath
let &runtimepath .= ',' . expand(g:user_rtp)
let &runtimepath .= ',' . expand(g:user_rtp) . '/after'
let &runtimepath .= ',' . expand(g:runtimepath_old)
" reload config
augroup myvimrc
au!
au BufWritePost $MYVIMRC source $MYVIMRC
augroup END
let g:user_rtp = g:vim_config_home
let g:runtimepath_old = &runtimepath
let &runtimepath .= ',' . expand(g:user_rtp)
let &runtimepath .= ',' . expand(g:user_rtp) . '/after'
let &runtimepath .= ',' . expand(g:runtimepath_old)
""""""""""""""""""""""""""""""""""""""""""""""""""
" Compat: Just for compatability with legacy vim "
""""""""""""""""""""""""""""""""""""""""""""""""""
set ttimeoutlen=-1
" default options in neovim
set autoindent
set autoread
set backspace=indent,eol,start
set complete-=i
set display=lastline
"if has('multi_byte')
" set encoding=utf-8
"endif
if v:version >= 704
set formatoptions=tcqj
endif
if &history < 10000
set history=10000
endif
if has('extra_search')
set hlsearch
set incsearch
endif
if has('langmap')
set langnoremap
endif
set laststatus=2
set listchars="tab:> ,trail:-,nbsp:+"
if has('mouse')
set mouse=a
endif
"set nocompatible
set nrformats=hex
if has('mksession')
set sessionoptions+=options
endif
set smarttab
if has('windows')
set tabpagemax=50
endif
set tags="./tags;,tags"
set ttyfast
if has('viminfo')
set viminfo+=!
endif
if has('wildmenu')
set wildmenu
endif
if $USER == 'root'
set nobackup
else
let &backupdir = g:vim_data_home . '/backup'
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), 'p', 0700)
endif
endif
if $USER == 'root'
set noswapfile
else
let &directory = g:vim_data_home . '/swap'
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), 'p', 0700)
endif
endif
if has('mksession')
if has('mksession')
let &viewdir = g:vim_data_home . '/views'
if !isdirectory(expand(&viewdir))
call mkdir(expand(&viewdir), 'p', 0700)
endif
endif
endif
if has('persistent_undo')
if has('persistent_undo')
let &undodir = g:vim_data_home . '/undo'
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), 'p', 0700)
endif
endif
endif
if has('viminfo')
if has('viminfo')
set nocompatible
let &viminfo = "'1000,<50,s10,n" . g:vim_cache_home . '/viminfo'
endif
endif
" source additional config files