diff --git a/core/compat.vim b/core/compat.vim deleted file mode 100644 index b1410a1..0000000 --- a/core/compat.vim +++ /dev/null @@ -1,17 +0,0 @@ -if ! has('nvim') - set ttimeoutlen=-1 -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 diff --git a/core/legacy.vim b/core/legacy.vim deleted file mode 100644 index e1d66e6..0000000 --- a/core/legacy.vim +++ /dev/null @@ -1,53 +0,0 @@ -if ! has('nvim') - " 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 diff --git a/core/mappings.vim b/core/mappings.vim deleted file mode 100644 index be4fe2f..0000000 --- a/core/mappings.vim +++ /dev/null @@ -1,63 +0,0 @@ -let g:mapleader = "," - -command! Wq wq -command! WQ wq -command! Q q -command! W w - -nnoremap U :redo -nnoremap - -" allow explicit writing of read-only files with sudo -cnoremap sudow w !sudo tee % >/dev/null - -" unset search highlighting -noremap :noh - -nnoremap vl :setlocal cursorline! -nnoremap vc :setlocal cursorcolumn! -nnoremap ve :setlocal colorcolumn=80 -nnoremap vn :setlocal colorcolumn=0 - -nnoremap Y y$ -nnoremap j gj -nnoremap k gk - -" unset default help shortcut -nnoremap -inoremap - -inoremap jk -inoremap JK -inoremap Jk - -vnoremap < >gv - -" fix indentation of an entire file -nnoremap fmt gg=G`` - -" local replace -nnoremap gr gd[{V%::s////g -nnoremap gR gD:%s////g - -if v:progname == 'nvim' - tnoremap -endif - -" highlight searches and search while typing -if has('extra_search') - if maparg('', 'n') ==# '' - nnoremap :nohlsearch - endif -endif - -nnoremap th :tabfirst -nnoremap tj :tabnext -nnoremap tk :tabprev -nnoremap tl :tablast -nnoremap tn :tabnew -nnoremap tq :tabclose - -nnoremap il :set invlist -vnoremap il :set invlist diff --git a/core/plugins.vim b/core/plugins.vim deleted file mode 100644 index d0a98f5..0000000 --- a/core/plugins.vim +++ /dev/null @@ -1,37 +0,0 @@ -call plug#begin(g:vim_data_home . '/plugins') - -" always load -Plug 'scrooloose/nerdcommenter' - -Plug 'majutsushi/tagbar' -Plug 'kien/ctrlp.vim' -Plug 'vim-scripts/gnupg' -Plug 'tomasr/molokai' -Plug 'hoelzro/vim-polyglot' -Plug 'bling/vim-airline' "until powerline works in neovim -Plug 'junegunn/seoul256.vim' -"Plug 'godlygeek/csapprox' -"Plug 'jiangmiao/auto-pairs' -"Plug 'tpope/vim-commentary' - -" on demand loading -Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } -Plug 'scrooloose/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } - -"Plug 'Twinside/vim-hoogle', { 'for': 'haskell' } -"Plug 'Twinside/vim-haskellConceal', { 'for': 'haskell' } -"Plug 'lukerandall/haskellmode-vim', { 'for': 'haskell' } - -Plug 'scrooloose/syntastic', {'for': ['c', 'cpp', 'python', 'sh']} - -if v:version >= 704 - Plug 'vim-pandoc/vim-pandoc' - Plug 'vim-pandoc/vim-pandoc-syntax' - Plug 'Valloric/YouCompleteMe', {'do': 'python2 install.py --clang-completer' } -endif - -if v:version >= 703 - Plug 'vim-scripts/Gundo', { 'on': 'GundoToggle' } -endif - -call plug#end() diff --git a/core/settings.vim b/core/settings.vim deleted file mode 100644 index 96aa762..0000000 --- a/core/settings.vim +++ /dev/null @@ -1,104 +0,0 @@ -set confirm -set ttimeout -set timeoutlen=500 -set autochdir -set autowrite -set scrolloff=1 -set sidescrolloff=5 -set number -set ignorecase -set smartcase -set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· -set showmatch -set shortmess=aoOtTI - -if has('smartindent') - set smartindent -endif - -" enable filetype plugins -if has('autocmd') - filetype indent on - filetype plugin on -endif - - -"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 CursorLineColumn - au! - au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn - au WinLeave * setlocal nocursorline nocursorcolumn -aug END - -"set visualbell -"set t_vb= - -if has('folding') - set foldcolumn=1 - set foldlevel=99 - set foldmethod=syntax - set foldtext=MyFoldText() - - let g:sh_fold_enabled=1 - - function! MyFoldText() - " get actual numberwidth of the current document - let nw_add = (len(line('$')) - (&numberwidth - 1)) - if nw_add > 0 - let nw = &numberwidth + nw_add - else - let nw = &numberwidth - endif - - let numfold_w =(nw * &number) + &foldcolumn - let window_w = winwidth(0) - numfold_w - let onetab = strpart(' ', 0, &tabstop) - - let foldtxt_start = getline(v:foldstart) . ' …' - let foldtxt_start = substitute(foldtxt_start, '\t', onetab, 'g') - let foldtxt_start_w = len(foldtxt_start) - 2 - - let foldtxt_end = '+' . string(foldclosedend(v:foldend) - foldclosed(v:foldstart)) . '  ' - let foldtxt_end_w = len(foldtxt_end) - - let foldtxt_mid_w = window_w - (foldtxt_start_w + foldtxt_end_w) - let foldtxt_mid = repeat(' ', foldtxt_mid_w + 2) - - return foldtxt_start . foldtxt_mid . foldtxt_end - endfunction -endif diff --git a/core/tmux.vim b/core/tmux.vim deleted file mode 100644 index f2f400f..0000000 --- a/core/tmux.vim +++ /dev/null @@ -1,25 +0,0 @@ -if exists('$TMUX') - function! TmuxOrSplitSwitch(wincmd, tmuxdir) - let previous_winnr = winnr() - silent! execute "wincmd " . a:wincmd - if previous_winnr == winnr() - call system("tmux select-pane -" . a:tmuxdir) - redraw! - endif - endfunction - - let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') - let &t_ti = "\]2;vim\\\" . &t_ti - let &t_te = "\]2;". previous_title . "\\\" . &t_te - - noremap :call TmuxOrSplitSwitch('h', 'L') - noremap :call TmuxOrSplitSwitch('l', 'R') - noremap :call TmuxOrSplitSwitch('k', 'U') - noremap :call TmuxOrSplitSwitch('j', 'D') - noremap :call TmuxOrSplitSwitch('b', 'l') -else - noremap h - noremap j - noremap k - noremap l -endif diff --git a/init.vim b/init.vim index fefc8bd..adac3bf 100644 --- a/init.vim +++ b/init.vim @@ -5,6 +5,10 @@ " " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""""""""""""""""""""""""" +" Core: XDG Directories " +""""""""""""""""""""""""" + let g:vim_config_home = split(&rtp, ',', 0)[0] if exists('$XDG_CACHE_HOME') @@ -19,10 +23,302 @@ else let g:vim_data_home = expand('$HOME/.local/share/') . v:progname endif -" source additional config files -runtime! core/**/*.vim -runtime! plugins/**/*.vim +" reload config +augroup myvimrc + au! + au BufWritePost $MYVIMRC source $MYVIMRC +augroup END -"colorscheme molokai + +"""""""""""""""""""""""""""""""""""""""""""""""""" +" 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 " +""""""""""""""""""""""""""""""""""" + +set confirm +set ttimeout +set timeoutlen=500 +set autochdir +set autowrite +set scrolloff=1 +set sidescrolloff=5 +set number +set ignorecase +set smartcase +set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· +set showmatch +set shortmess=aoOtTI + +if has('smartindent') + set smartindent +endif + +" enable filetype plugins +if has('autocmd') + filetype indent on + filetype plugin on +endif + + +"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 CursorLineColumn + au! + au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn + au WinLeave * setlocal nocursorline nocursorcolumn +aug END + +"set visualbell +"set t_vb= + +if has('folding') + set foldcolumn=1 + set foldlevel=99 + set foldmethod=syntax + set foldtext=MyFoldText() + + let g:sh_fold_enabled=1 + + function! MyFoldText() + " get actual numberwidth of the current document + let nw_add = (len(line('$')) - (&numberwidth - 1)) + if nw_add > 0 + let nw = &numberwidth + nw_add + else + let nw = &numberwidth + endif + + let numfold_w =(nw * &number) + &foldcolumn + let window_w = winwidth(0) - numfold_w + let onetab = strpart(' ', 0, &tabstop) + + let foldtxt_start = getline(v:foldstart) . ' …' + let foldtxt_start = substitute(foldtxt_start, '\t', onetab, 'g') + let foldtxt_start_w = len(foldtxt_start) - 2 + + let foldtxt_end = '+' . string(foldclosedend(v:foldend) - foldclosed(v:foldstart)) . '  ' + let foldtxt_end_w = len(foldtxt_end) + + let foldtxt_mid_w = window_w - (foldtxt_start_w + foldtxt_end_w) + let foldtxt_mid = repeat(' ', foldtxt_mid_w + 2) + + return foldtxt_start . foldtxt_mid . foldtxt_end + endfunction +endif + + +""""""""""""""""""""""""""""""" +" Mappings: Keyboard mappings " +""""""""""""""""""""""""""""""" + +let g:mapleader = "," + +command! Wq wq +command! WQ wq +command! Q q +command! W w + +nnoremap U :redo +nnoremap + +" allow explicit writing of read-only files with sudo +cnoremap sudow w !sudo tee % >/dev/null + +" unset search highlighting +noremap :noh + +nnoremap vl :setlocal cursorline! +nnoremap vc :setlocal cursorcolumn! +nnoremap ve :setlocal colorcolumn=80 +nnoremap vn :setlocal colorcolumn=0 + +nnoremap Y y$ +nnoremap j gj +nnoremap k gk + +" unset default help shortcut +nnoremap +inoremap + +inoremap jk +inoremap JK +inoremap Jk + +vnoremap < >gv + +" fix indentation of an entire file +nnoremap fmt gg=G`` + +" local replace +nnoremap gr gd[{V%::s////g +nnoremap gR gD:%s////g + +if v:progname == 'nvim' + tnoremap +endif + +" highlight searches and search while typing +if has('extra_search') + if maparg('', 'n') ==# '' + nnoremap :nohlsearch + endif +endif + +nnoremap th :tabfirst +nnoremap tj :tabnext +nnoremap tk :tabprev +nnoremap tl :tablast +nnoremap tn :tabnew +nnoremap tq :tabclose + +nnoremap il :set invlist +vnoremap il :set invlist + +if exists('$TMUX') + function! TmuxOrSplitSwitch(wincmd, tmuxdir) + let previous_winnr = winnr() + silent! execute "wincmd " . a:wincmd + if previous_winnr == winnr() + call system("tmux select-pane -" . a:tmuxdir) + redraw! + endif + endfunction + + let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') + let &t_ti = "\]2;vim\\\" . &t_ti + let &t_te = "\]2;". previous_title . "\\\" . &t_te + + noremap :call TmuxOrSplitSwitch('h', 'L') + noremap :call TmuxOrSplitSwitch('l', 'R') + noremap :call TmuxOrSplitSwitch('k', 'U') + noremap :call TmuxOrSplitSwitch('j', 'D') + noremap :call TmuxOrSplitSwitch('b', 'l') +else + noremap h + noremap j + noremap k + noremap l +endif + + +""""""""""""""""""""""""""""""""""""""""" +" Plugins: Plugin loading with vim-plug " +""""""""""""""""""""""""""""""""""""""""" +call plug#begin(g:vim_data_home . '/plugins') +runtime! plugins/**/*.vim +call plug#end() + +"""""""""""""""" +" Colorscheme: " +"""""""""""""""" colorscheme seoul256 -"silent colorscheme +"colorscheme molokai