From e36184bfb107a592ad46902d92a4293500e2c900 Mon Sep 17 00:00:00 2001 From: himkt Date: Sat, 16 Feb 2019 15:31:19 +0900 Subject: [PATCH 1/2] Simplify and cleanup .vimrc --- config/config.vim | 153 ++++++++++++++++++++++++++++++---------------- 1 file changed, 101 insertions(+), 52 deletions(-) diff --git a/config/config.vim b/config/config.vim index 6728219c..de2f2b1d 100644 --- a/config/config.vim +++ b/config/config.vim @@ -1,84 +1,133 @@ " -" @author = himkt +" --------------------- +" +" Vim configuration +" +" @author = 'himkt' +" +" --------------------- " +if &compatible + set nocompatible +endif -" ----------- " -" base config " -" ----------- " - -" enable syntax support filetype plugin indent on - -" enable hilighting syntax on -" color scheme -colorscheme desert +if exists('$SHELL') + set shell=$SHELL +else + set shell=/bin/sh +endif -" omni completion -set completeopt=menuone,longest,preview +" open with the cursor in previous session +augroup vimrcEx + au BufRead * if line("'\"") > 0 && line("'\"") <= line("$") | + \ exe "normal g`\"" | endif +augroup END -" file encoding +"" File encodings set encoding=utf-8 -set fileencodings=utf-8,iso-2user_jp,euc-jp,ascii - +set fileencodings=utf-8,iso-2022-jp,euc-jp,ascii set fileformats=unix,mac,dos -set wrap visualbell -set nocompatible showcmd -set autoindent smartindent expandtab -set numberwidth=5 shiftwidth=2 tabstop=2 -set nowritebackup nobackup noswapfile -set incsearch hlsearch -set showmatch matchtime=1 + +"" Japanese input (TODO check whether if I can remove them) +set ttimeout +set ttimeoutlen=50 + +"" Enable cursor highlighting +set cursorline +set cursorcolumn + +"" Indent and tab +set expandtab +set nowrap +set autoindent +set smartindent +set smarttab + +"" Show vim title for a window +set title + +"" Show command in status line +set showcmd + +"" shift and tab stop +set tabstop=2 +set shiftwidth=2 +autocmd FileType python setl tabstop=8 shiftwidth=4 softtabstop=4 +autocmd FileType cpp setl tabstop=4 shiftwidth=4 softtabstop=4 + +"" Do not create backup and swap files +set noswapfile +set nobackup + +"" Enable incremental and hilighting search +set incsearch +set hlsearch + +"" Hilight a matched bracket +set showmatch +set matchtime=1 + +"" Enable status line (it seems this does not have any effect) +"" because vim-airline overwrite this config set laststatus=2 + set backspace=indent,eol,start -set clipboard+=unnamed mouse=a -set splitbelow splitright -set foldmethod=marker foldlevel=99 -set list listchars=trail:-,extends:»,precedes:«,nbsp:%,tab:\ \ -" basic shortcuts +"" Enable mouse +set mouse=a + +"" If vertical split -> open a new pane to right, +"" and if horizontal split -> open a new pane to below +set splitbelow +set splitright + +"" Folding config +set foldmethod=marker +set foldlevel=0 + map ; : -map / (incsearch-forward) +nnoremap x "_x +vnoremap x "_x -" rich hilighting -map (quickhl-manual-this) -map (quickhl-manual-reset) - +" indent +inoremap +inoremap " tab shortcuts -nnoremap : tabnew -nnoremap gt +nnoremap : tabnew nnoremap gT +nnoremap gt " window splitting -nnoremap > > -nnoremap < < nnoremap vp : vs nnoremap sp : sp -" paste mode -nnoremap np : set paste -nnoremap nn : set nopaste - -" folding +" folding configuration nnoremap zx : set foldlevel=99 nnoremap zc : set foldlevel=0 -" completion +" completion configuration +set completeopt=menuone,longest,preview autocmd CompleteDone * pclose autocmd FileType * setlocal omnifunc=syntaxcomplete#Complete -autocmd FileType python setlocal omnifunc=python3complete#Complete -autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete -" python tab config -autocmd FileType python setl autoindent tabstop=8 expandtab shiftwidth=4 softtabstop=4 " tag hilighting -autocmd Syntax * call matchadd('Todo', '\W\zs\(TODO\|FIXME\|IMPORTANT\|CHANGED\|XXX\|BUG\|HACK\)') -autocmd Syntax * call matchadd('Debug', '\W\zs\(NOTE\|INFO\|IDEA\)') - -" indent guide feature -autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=235 -autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=234 +autocmd Syntax * call matchadd('Todo', '\W\zs\(TODO\|FIXME\|IMPORTANT\|CHANGED\|XXX\)') +autocmd Syntax * call matchadd('Todo', '\W\zs\(BUG\|HACK\|NOTE\|INFO\|IDEA\)') + +" executing script in vim +autocmd FileType cpp nnoremap :exec ':term g++ --std=c++11 % && ./a.out && rm a.out' +autocmd FileType rust nnoremap :exec ':term rustc % -o a && ./a && rm ./a' +autocmd FileType ruby nnoremap :exec ':term ruby %' +autocmd FileType python nnoremap :exec ':term python %' +autocmd FileType python nnoremap :call Autopep8() + +" templates +autocmd BufNewFile *.cpp 0r $HOME/.dotfiles/template/cc/template.cc +autocmd BufNewFile *.cc 0r $HOME/.dotfiles/template/cc/template.cc +autocmd BufNewFile *.rs 0r $HOME/.dotfiles/template/rs/template.rs From c38fd8738df56ce456897d7c5b27a1d74ff3199b Mon Sep 17 00:00:00 2001 From: himkt Date: Sat, 16 Feb 2019 15:35:26 +0900 Subject: [PATCH 2/2] Remove general configs and load them from .vimrc --- config/confign.vim | 106 ++++----------------------------------------- 1 file changed, 9 insertions(+), 97 deletions(-) diff --git a/config/confign.vim b/config/confign.vim index 5c9db9ae..3d1a1109 100644 --- a/config/confign.vim +++ b/config/confign.vim @@ -1,8 +1,15 @@ " -" author = 'himkt' -" desc = 'My neovim configuration' +" --------------------- +" +" NeoVim configuration +" +" @author = 'himkt' +" +" --------------------- " +"" load basic vim configuration +source $HOME/.dotfiles/config/config.vim " ------------- " " vim-plug conf " @@ -134,98 +141,3 @@ endfunction function! Autopep8() call Preserve(':silent %!autopep8 -') endfunction - - - -" ----------- " -" base config " -" ----------- " - -" If you have an error, `cd $HOME/.dotfiles && make requirements` may solve it. -let g:python3_host_prog = $PYENV_ROOT . '/versions/3.6.3/bin/python' - -if &compatible - set nocompatible -endif - -filetype plugin indent on -syntax on - -if exists('$SHELL') - set shell=$SHELL -else - set shell=/bin/sh -endif - -" open with the cursor in previous session -augroup vimrcEx - au BufRead * if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | endif -augroup END - -" file encoding -set encoding=utf-8 -set fileencodings=utf-8,iso-2user_jp,euc-jp,ascii - -" for japanese input -set ttimeout -set ttimeoutlen=50 - -set fileformats=unix,mac,dos -set wrap visualbell ruler -set showcmd -set autoindent smartindent expandtab -set numberwidth=5 shiftwidth=2 tabstop=2 -set nowritebackup nobackup noswapfile -set incsearch hlsearch -set showmatch matchtime=1 -set laststatus=2 -set backspace=indent,eol,start -set mouse=a -set splitbelow splitright -set foldmethod=marker foldlevel=0 -map ; : -nnoremap x "_x -vnoremap x "_x - -" indent -inoremap -inoremap - -" tab shortcuts -nnoremap : tabnew -nnoremap gT -nnoremap gt - -" window splitting -nnoremap vp : vs -nnoremap sp : sp - -" folding configuration -nnoremap zx : set foldlevel=99 -nnoremap zc : set foldlevel=0 - -" completion configuration -set completeopt=menuone,longest,preview -autocmd CompleteDone * pclose -autocmd FileType * setlocal omnifunc=syntaxcomplete#Complete - -" tabstop configuraton -autocmd FileType python setl autoindent tabstop=8 expandtab shiftwidth=4 softtabstop=4 -autocmd FileType cpp setl autoindent tabstop=4 expandtab shiftwidth=4 softtabstop=4 - -" tag hilighting -autocmd Syntax * call matchadd('Todo', '\W\zs\(TODO\|FIXME\|IMPORTANT\|CHANGED\|XXX\)') -autocmd Syntax * call matchadd('Todo', '\W\zs\(BUG\|HACK\|NOTE\|INFO\|IDEA\)') - -" executing script in vim -autocmd FileType cpp nnoremap :exec ':term g++ --std=c++11 % && ./a.out && rm a.out' -autocmd FileType rust nnoremap :exec ':term rustc % -o a && ./a && rm ./a' -autocmd FileType ruby nnoremap :exec ':term ruby %' -autocmd FileType python nnoremap :exec ':term python %' -autocmd FileType python nnoremap :call Autopep8() - -" templates -autocmd BufNewFile *.cpp 0r $HOME/.dotfiles/template/cc/template.cc -autocmd BufNewFile *.cc 0r $HOME/.dotfiles/template/cc/template.cc -autocmd BufNewFile *.rs 0r $HOME/.dotfiles/template/rs/template.rs