From 75ff908059588b462c0c39e85703173dd60a341d Mon Sep 17 00:00:00 2001 From: Root Date: Mon, 11 Jan 2021 18:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E4=BA=8E=E5=BC=80=E5=8F=91Python?= =?UTF-8?q?=E5=92=8CRuby=E4=BB=A3=E7=A0=81=E7=9A=84Vim=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 0 .gitmodules | 39 +++++++ autoload/pathogen.vim | 264 ++++++++++++++++++++++++++++++++++++++++++ bundle/airline | 1 + bundle/airline-themes | 1 + bundle/colorschemes | 1 + bundle/completor | 1 + bundle/crystal | 1 + bundle/fugitive | 1 + bundle/nerdtree | 1 + bundle/python-mode | 1 + bundle/ruby | 1 + bundle/sensible | 1 + bundle/syntastic | 1 + bundle/tagbar | 1 + bundle/virtualenv | 1 + configs/basic.vim | 80 +++++++++++++ configs/extended.vim | 4 + configs/filetypes.vim | 4 + configs/mapkeys.vim | 58 ++++++++++ configs/plugins.vim | 22 ++++ del_plugin.sh | 10 ++ update.sh | 5 + vimrc | 6 + 24 files changed, 505 insertions(+) create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 autoload/pathogen.vim create mode 160000 bundle/airline create mode 160000 bundle/airline-themes create mode 160000 bundle/colorschemes create mode 160000 bundle/completor create mode 160000 bundle/crystal create mode 160000 bundle/fugitive create mode 160000 bundle/nerdtree create mode 160000 bundle/python-mode create mode 160000 bundle/ruby create mode 160000 bundle/sensible create mode 160000 bundle/syntastic create mode 160000 bundle/tagbar create mode 160000 bundle/virtualenv create mode 100644 configs/basic.vim create mode 100644 configs/extended.vim create mode 100644 configs/filetypes.vim create mode 100644 configs/mapkeys.vim create mode 100644 configs/plugins.vim create mode 100755 del_plugin.sh create mode 100755 update.sh create mode 100644 vimrc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b9407cb --- /dev/null +++ b/.gitmodules @@ -0,0 +1,39 @@ +[submodule "bundle/colorschemes"] + path = bundle/colorschemes + url = https://github.com/flazz/vim-colorschemes.git +[submodule "bundle/python-mode"] + path = bundle/python-mode + url = https://github.com/python-mode/python-mode.git +[submodule "bundle/completor"] + path = bundle/completor + url = https://github.com/maralla/completor.vim.git +[submodule "bundle/syntastic"] + path = bundle/syntastic + url = https://github.com/vim-syntastic/syntastic.git +[submodule "bundle/nerdtree"] + path = bundle/nerdtree + url = https://github.com/preservim/nerdtree.git +[submodule "bundle/tagbar"] + path = bundle/tagbar + url = https://github.com/preservim/tagbar.git +[submodule "bundle/fugitive"] + path = bundle/fugitive + url = https://github.com/tpope/vim-fugitive.git +[submodule "bundle/airline"] + path = bundle/airline + url = https://github.com/vim-airline/vim-airline.git +[submodule "bundle/crystal"] + path = bundle/crystal + url = https://github.com/vim-crystal/vim-crystal.git +[submodule "bundle/virtualenv"] + path = bundle/virtualenv + url = https://github.com/jmcantrell/vim-virtualenv.git +[submodule "bundle/airline-themes"] + path = bundle/airline-themes + url = https://github.com/vim-airline/vim-airline-themes +[submodule "bundle/ruby"] + path = bundle/ruby + url = https://github.com/vim-ruby/vim-ruby.git +[submodule "bundle/sensible"] + path = bundle/sensible + url = https://github.com/tpope/vim-sensible.git diff --git a/autoload/pathogen.vim b/autoload/pathogen.vim new file mode 100644 index 0000000..b2891cd --- /dev/null +++ b/autoload/pathogen.vim @@ -0,0 +1,264 @@ +" pathogen.vim - path option manipulation +" Maintainer: Tim Pope +" Version: 2.4 + +" Install in ~/.vim/autoload (or ~\vimfiles\autoload). +" +" For management of individually installed plugins in ~/.vim/bundle (or +" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your +" .vimrc is the only other setup necessary. +" +" The API is documented inline below. + +if exists("g:loaded_pathogen") || &cp + finish +endif +let g:loaded_pathogen = 1 + +" Point of entry for basic default usage. Give a relative path to invoke +" pathogen#interpose() or an absolute path to invoke pathogen#surround(). +" Curly braces are expanded with pathogen#expand(): "bundle/{}" finds all +" subdirectories inside "bundle" inside all directories in the runtime path. +" If no arguments are given, defaults "bundle/{}", and also "pack/{}/start/{}" +" on versions of Vim without native package support. +function! pathogen#infect(...) abort + if a:0 + let paths = filter(reverse(copy(a:000)), 'type(v:val) == type("")') + else + let paths = ['bundle/{}', 'pack/{}/start/{}'] + endif + if has('packages') + call filter(paths, 'v:val !~# "^pack/[^/]*/start/[^/]*$"') + endif + let static = '^\%([$~\\/]\|\w:[\\/]\)[^{}*]*$' + for path in filter(copy(paths), 'v:val =~# static') + call pathogen#surround(path) + endfor + for path in filter(copy(paths), 'v:val !~# static') + if path =~# '^\%([$~\\/]\|\w:[\\/]\)' + call pathogen#surround(path) + else + call pathogen#interpose(path) + endif + endfor + call pathogen#cycle_filetype() + if pathogen#is_disabled($MYVIMRC) + return 'finish' + endif + return '' +endfunction + +" Split a path into a list. +function! pathogen#split(path) abort + if type(a:path) == type([]) | return a:path | endif + if empty(a:path) | return [] | endif + let split = split(a:path,'\\\@]','\\&','') + endif +endfunction + +" Like findfile(), but hardcoded to use the runtimepath. +function! pathogen#runtime_findfile(file,count) abort + let rtp = pathogen#join(1,pathogen#split(&rtp)) + let file = findfile(a:file,rtp,a:count) + if file ==# '' + return '' + else + return fnamemodify(file,':p') + endif +endfunction + +" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=': diff --git a/bundle/airline b/bundle/airline new file mode 160000 index 0000000..0ca9576 --- /dev/null +++ b/bundle/airline @@ -0,0 +1 @@ +Subproject commit 0ca9576331ba845e7bf29f5e092f5da04f4f3580 diff --git a/bundle/airline-themes b/bundle/airline-themes new file mode 160000 index 0000000..8f1aa2c --- /dev/null +++ b/bundle/airline-themes @@ -0,0 +1 @@ +Subproject commit 8f1aa2c7fa44bf33b1fd4678f9c7b40c126b0e2b diff --git a/bundle/colorschemes b/bundle/colorschemes new file mode 160000 index 0000000..fd8f122 --- /dev/null +++ b/bundle/colorschemes @@ -0,0 +1 @@ +Subproject commit fd8f122cef604330c96a6a6e434682dbdfb878c9 diff --git a/bundle/completor b/bundle/completor new file mode 160000 index 0000000..7af7d5b --- /dev/null +++ b/bundle/completor @@ -0,0 +1 @@ +Subproject commit 7af7d5b5cc9f2b9834a287cc832ae74dfd0ca83c diff --git a/bundle/crystal b/bundle/crystal new file mode 160000 index 0000000..0ddf577 --- /dev/null +++ b/bundle/crystal @@ -0,0 +1 @@ +Subproject commit 0ddf5777b5766e1c13b627a45c45e6dda2db8aa7 diff --git a/bundle/fugitive b/bundle/fugitive new file mode 160000 index 0000000..bebe504 --- /dev/null +++ b/bundle/fugitive @@ -0,0 +1 @@ +Subproject commit bebe504e38d0a20c30d6dd666c4c793b3cc66104 diff --git a/bundle/nerdtree b/bundle/nerdtree new file mode 160000 index 0000000..aaa946f --- /dev/null +++ b/bundle/nerdtree @@ -0,0 +1 @@ +Subproject commit aaa946fb6bd79b9af86fbaf4b6b63fd81d839bd9 diff --git a/bundle/python-mode b/bundle/python-mode new file mode 160000 index 0000000..76df35a --- /dev/null +++ b/bundle/python-mode @@ -0,0 +1 @@ +Subproject commit 76df35a8d307b65fb9b5962a678b67317a30b084 diff --git a/bundle/ruby b/bundle/ruby new file mode 160000 index 0000000..e367f7b --- /dev/null +++ b/bundle/ruby @@ -0,0 +1 @@ +Subproject commit e367f7b33fe9159c943963f3f839e4d08b74090e diff --git a/bundle/sensible b/bundle/sensible new file mode 160000 index 0000000..2d9f34c --- /dev/null +++ b/bundle/sensible @@ -0,0 +1 @@ +Subproject commit 2d9f34c09f548ed4df213389caa2882bfe56db58 diff --git a/bundle/syntastic b/bundle/syntastic new file mode 160000 index 0000000..d97a664 --- /dev/null +++ b/bundle/syntastic @@ -0,0 +1 @@ +Subproject commit d97a664b9adbd1a0a9cba6c1c3baf071a1059d1e diff --git a/bundle/tagbar b/bundle/tagbar new file mode 160000 index 0000000..978e1fe --- /dev/null +++ b/bundle/tagbar @@ -0,0 +1 @@ +Subproject commit 978e1fe761de8be1f4d6c8469deba74a3cc0872f diff --git a/bundle/virtualenv b/bundle/virtualenv new file mode 160000 index 0000000..e7bb5b1 --- /dev/null +++ b/bundle/virtualenv @@ -0,0 +1 @@ +Subproject commit e7bb5b1960603decf2975f052db672850c5a7de4 diff --git a/configs/basic.vim b/configs/basic.vim new file mode 100644 index 0000000..f44f54f --- /dev/null +++ b/configs/basic.vim @@ -0,0 +1,80 @@ +execute pathogen#infect() +execute pathogen#helptags() + +syntax enable +filetype plugin indent on + +set ruler +set magic +set mouse-=a +set showcmd +set showmatch +set smartcase +set incsearch +set hlsearch +set autoread +set wildmenu +set wildignore=*.o,*~,*.pyc +set backspace=eol,start,indent +set laststatus=2 +set cmdheight=1 +set lazyredraw +set encoding=utf8 +set ffs=unix,dos,mac +set pastetoggle= +set background=dark + +set noerrorbells +set novisualbell +set tm=500 +set t_vb= +set t_Co=256 + +set nobackup +set nowb +set noswapfile + +set expandtab +set smarttab +set shiftwidth=4 +set tabstop=4 + +set ai "Auto indent +set si "Smart indent +set wrap "Wrap lines + +" 快捷键映射 +let mapleader=',' +nmap w :w! + +map :noh + +" :W sudo saves the file +command! W execute 'w !sudo tee % > /dev/null' edit! + +" 记下最后的编辑位置 +autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif + +" Useful mappings for managing tabs +map tn :tabnew +map to :tabonly +map tc :tabclose +map tm :tabmove +map t :tabnext + +" Switch CWD to the directory of the open buffer +map cd :cd %:p:h:pwd + +" Delete trailing white space on save, useful for some filetypes ;) +fun! CleanExtraSpaces() + let save_cursor = getpos(".") + let old_query = getreg('/') + silent! %s/\s\+$//e + call setpos('.', save_cursor) + call setreg('/', old_query) +endfun + +if has("autocmd") + autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() +endif + diff --git a/configs/extended.vim b/configs/extended.vim new file mode 100644 index 0000000..1fee7cc --- /dev/null +++ b/configs/extended.vim @@ -0,0 +1,4 @@ +colorscheme molokai + +iab xdate =strftime("%d/%m/%y %H:%M:%S") + diff --git a/configs/filetypes.vim b/configs/filetypes.vim new file mode 100644 index 0000000..b101019 --- /dev/null +++ b/configs/filetypes.vim @@ -0,0 +1,4 @@ +autocmd BufNewFile,BufRead *.go set st=4 ts=4 + +autocmd FileType ruby compiler ruby + diff --git a/configs/mapkeys.vim b/configs/mapkeys.vim new file mode 100644 index 0000000..e3d4491 --- /dev/null +++ b/configs/mapkeys.vim @@ -0,0 +1,58 @@ + +" Bash like keys for the command line +cnoremap +cnoremap +cnoremap + +cnoremap +cnoremap + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Parenthesis/bracket +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +vnoremap $1 `>a)` +vnoremap $2 `>a]` +vnoremap $3 `>a}` +vnoremap $$ `>a"` +vnoremap $q `>a'` +vnoremap $e `>a`` + +" Map auto complete of (, ", ', [ +inoremap $1 ()i +inoremap $2 []i +inoremap $3 {}i +inoremap $4 {o}O +inoremap $q ''i +inoremap $e ""i + +map n :cn +map p :cp + +" ==> NERDTree +map :NERDTreeToggle +map :TagbarToggle + +" ==> vim-ruby +if !exists( "*RubyEndToken" ) + + function RubyEndToken() + let current_line = getline( '.' ) + let braces_at_end = '{\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' + let stuff_without_do = '^\s*\(class\|if\|unless\|begin\|case\|for\|module\|while\|until\|def\)' + let with_do = 'do\s*\(|\(,\|\s\|\w\)*|\s*\)\?$' + + if match(current_line, braces_at_end) >= 0 + return "\}\O" + elseif match(current_line, stuff_without_do) >= 0 + return "\end\O" + elseif match(current_line, with_do) >= 0 + return "\end\O" + else + return "\" + endif + endfunction + +endif + +imap =RubyEndToken() + diff --git a/configs/plugins.vim b/configs/plugins.vim new file mode 100644 index 0000000..fd1b337 --- /dev/null +++ b/configs/plugins.vim @@ -0,0 +1,22 @@ +" ==> NERDTree +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif +autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif + +" ==> Airline +let g:airline_theme = 'wombat' +let g:airline#extensions#tabline#enabled = 1 + +" ==> Syntastic +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 0 + +let g:syntastic_python_checkers = ['autopep8'] + diff --git a/del_plugin.sh b/del_plugin.sh new file mode 100755 index 0000000..98f1a97 --- /dev/null +++ b/del_plugin.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +bundle="$1" + +git submodule deinit -f "$bundle" + +git rm -rf "$bundle" + +git status + diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..9406372 --- /dev/null +++ b/update.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +git submodule update --recursive --init --force +git submodule sync --recursive + diff --git a/vimrc b/vimrc new file mode 100644 index 0000000..15787e9 --- /dev/null +++ b/vimrc @@ -0,0 +1,6 @@ +source ~/.vim/configs/basic.vim +source ~/.vim/configs/filetypes.vim +source ~/.vim/configs/plugins.vim +source ~/.vim/configs/mapkeys.vim +source ~/.vim/configs/extended.vim +