vim插件

0. vim版本信息

vim插件_第1张图片

1. 插件管理器 vim-plug

获取主要的脚本进行安装

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs  https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

整个项目可用下面指令获取

$ git clone https://github.com/junegunn/vim-plug.git

2. 插件配置

在"~/.vimrc"中加入 "source ~/.vim/plug.conf.vim",加载插件配置。

$ cat ~/.vim/plug.conf.vim
set nocompatible              " 去除VI一致性,必须
filetype off                  " 必须
let mapleader=";"
let maplocalleader = ";"

call plug#begin('~/.vim/plugged')

" vim documents for chinese
Plug 'yianwillis/vimcdoc'
" 确保你使用单引号
" 简化符号; 获取 https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" 语法检查
Plug 'w0rp/ale'
" 翻译
Plug 'iamcco/dict.vim'
" 美化命令行
Plug 'vim-airline/vim-airline'
" java补全
Plug 'artur-shaik/vim-javacomplete2'
" 版本控制显示
Plug 'mhinz/vim-signify'
" 异步任务
Plug 'tpope/vim-dispatch'
" 快速插入, 绝对是个改善生活的插件!,给快速插入 [] {} "" '' 将文本包裹起来。
Plug 'tpope/vim-surround'
" ag
Plug 'rking/ag.vim'
" 重构
"Plug 'apalmer1377/factorus'
" 按需加载
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" 关灯
Plug 'junegunn/limelight.vim'
" 自动补全引号(单引号/双引号/反引号), 括号(()[]{})
"Plug 'Raimondi/delimitMate'
" 使用从分支
"Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
"Plug 'Valloric/YouCompleteMe'
" 使用一个标记释放;
"Plug 'fatih/vim-go', { 'tag': '*' }
" 插件选项
"Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" 增强fF查找功能
Plug 'justinmk/vim-sneak'
" 增强?/查找功能
Plug 'haya14busa/incsearch.vim'
" vim中的平滑滚动
Plug 'terryma/vim-smooth-scroll' 
" python
"Plug 'davidhalter/jedi'
"Plug 'eclipse/eclipse.jdt.ls'
Plug 'majutsushi/tagbar'
" 注释
Plug 'scrooloose/nerdcommenter'
" 颜色呈现
"Plug 'gorodinskiy/vim-coloresque'
Plug 'ap/vim-css-color'

call plug#end()

source ~/.vim/ag.conf.vim
source ~/.vim/ale.conf.vim
source ~/.vim/dict.conf.vim
source ~/.vim/factorus.conf.vim
source ~/.vim/javacomplete2.conf.vim
source ~/.vim/limelight.conf.vim
source ~/.vim/nerdtree.conf.vim
source ~/.vim/smooth.conf.vim
source ~/.vim/tagbar.conf.vim
source ~/.vim/ultisnips.conf.vim
"source ~/.vim/ycm.conf.vim
filetype plugin indent on 
" ------ javacomplete2 ------
autocmd FileType c setlocal omnifunc=ccomplete#Complete
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html setlocal omnifunc=htmlcomplete#CompleteTags
"autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
"autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType sql setlocal omnifunc=sqlcomplete#Complete
autocmd FileType java,jsp setlocal omnifunc=javacomplete#Complete
autocmd FileType java inoremap . .
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
$ cat ~/.vim/ag.conf.vim
let g:ag_prg="/usr/bin/ag --vimgrep"
let g:ag_working_path_mode="r"
$ cat ~/.vim/ale.conf.vim
" 保持侧边栏可见
let g:ale_sign_column_always = 1
"let g:ale_java_javac_classpath=
$ cat ~/.vim/dict.conf.vim
set dictionary+=/usr/share/dict/words
"nmap tr ;;rvbyuea(p
autocmd FileType text,markdown setlocal complete+=k
$ cat ~/.vim/factorus.conf.vim
" 重构
"let g:factorus_project_dir=g:JavaComplete_SourcesPath
autocmd VimEnter * let g:factorus_project_dir=getcwd() . '/src/main'
$ cat ~/.vim/javacomplete2.conf.vim
" javacomplete2 setting
" 禁用maven存储库:
let g:JavaComplete_MavenRepositoryDisable = 0
" 使用完全限定名称描述:
let g:JavaComplete_UseFQN = 1
" 显式地设置pom.xml路径: 默认
"let g:JavaComplete_PomPath = expand("~/.vim/plugged/vim-javacomplete2/libs/javavi/pom.xml")
" 在方法声明完成时闭合括号:
let g:JavaComplete_ClosingBrace = 1
" javacomplete2基础缓存目录(缺省为 ~/.cache):
let g:JavaComplete_JavaviLogLevel = 'debug'
let g:JavaComplete_JavaviLogDirectory = expand("~/tmp")
let g:JavaComplete_BaseDir = expand("~/tmp")
" 只弹出菜单 不进行选择
let g:JavaComplete_ImportDefault = 0
" 使用自己的gradle可执行文件:
let g:JavaComplete_GradleExecutable = '/usr/bin/gradle'
" 'import'排序类型:
"let g:JavaComplete_ImportSortType = 'jarName'
"let g:JavaComplete_ImportOrder = ['java.', 'javax.', 'com.', 'org.', 'net.']
" 常规类名时,将使用自动插入导入:
let g:JavaComplete_RegularClasses = ['java.lang.String', 'java.lang.Object']
" 构造javacomplete2使用python3解释器而不是python2:
let g:JavaComplete_UsePython3 = 1
let g:JavaComplete_ShowExternalCommandsOutput = 1
" 静态在顶部引入
let g:JavaComplete_StaticImportAtTop = 1
" 禁用自动启动服务器
let g:JaveComplete_AutoStartServer = 1
" 按字母顺序排序完成结果。
let g:JavaComplete_CompletionResultSort = 1
let g:JavaComplete_JavaviDebug = 1
$ cat ~/.vim/limelight.conf.vim
" Color name (:help cterm-colors) or ANSI code
let g:limelight_conceal_ctermfg = 'gray'
let g:limelight_conceal_ctermfg = 240
$ cat ~/.vim/nerdtree.conf.vim
noremap    :NERDTreeToggle
"autocmd VimEnter * NERDTree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" tree 宽度尺寸
let NERDTreeWinSize=26
$ cat ~/.vim/smooth.conf.vim
noremap   :call smooth_scroll#up(&scroll, 0, 2)
noremap   :call smooth_scroll#down(&scroll, 0, 2)
noremap   :call smooth_scroll#up(&scroll*2, 0, 4)
noremap   :call smooth_scroll#down(&scroll*2, 0, 4)
$ cat ~/.vim/tagbar.conf.vim
let g:tagbar_ctags_bin='/usr/bin/ctags'
let g:tagbar_width=30
let g:tagbar_iconchars = ['▸', '▾']
noremap ta :TagbarToggle
let shell='/bin/bash'
$ cat ~/.vim/ultisnips.conf.vim
let g:UltiSnipsExpandTrigger=""
let g:UltiSnipsJumpForwardTrigger=""
let g:UltiSnipsJumpBackwardTrigger=""
$ cat ~/.vim/ycm.conf.vim
" null

3. 安装插件

$ vim
:PlugInstall

vim插件_第2张图片

4. 后配置

$ cat ~/.vim/after/plugin/user.vim
autocmd BufNewFile,BufRead *.sh   exec ":call AddHead_SH()"
autocmd BufNewFile,BufRead *.c    exec ":call AddHead_C()"
autocmd BufNewFile,BufRead *.java exec ":call AddHead_JAVA()"
function AddHead_SH()
    if getfsize(expand('%')) > 0
        return 0
    endif
    call setline(1,'#!/bin/bash')
    call append(line('$'),"# Filename: " . expand('%'))
    call append(line('$'),"# Date:     " . strftime("%Y/%m/%d %H:%M:%S"))
    call append(line('$'),"# Auther:")
    call append(line('$'),"# Email:")
    call append(line('$'),"")
    call cursor(line('$'),1)
endfunc
function AddHead_C()
    if getfsize(expand('%')) > 0
        return 0
    endif
    call setline(1,'#include')
    call append(line('$'),"/*")
    call append(line('$')," * Filename: " . expand('%'))
    call append(line('$')," * Date:     " . strftime("%Y/%m/%d %H:%M:%S"))
    call append(line('$')," * Auther:   ")
    call append(line('$')," * Email:    ")
    call append(line('$')," */")
    call append(line('$'),"")
    call cursor(line('$'),1)
endfunc
function AddHead_JAVA()
    if getfsize(expand('%')) > 0
        return 0
    endif
    let s:filepath = expand('%:p:h')
    if match(s:filepath,'/src/') != -1
        let s:xpath = substitute(s:filepath,'^/.*/src/\(main\|test\)\?\(/java/\)\?','','')
        let s:package=tr(s:xpath,'/','.')
        call setline(1, "package " . s:package . ";")
    else
        call setline(1, "// package com.test;")
    endif
    call append(line('$'), "")
    call append(line('$'), "public class ". expand('%:t:r') . " {")
    call append(line('$'), "    /*")
    call append(line('$'), "     * @author ")
    call append(line('$'), "     * @email  ")
    call append(line('$'), "     * @date " . strftime("%Y/%m/%d %H:%M:%S"))
    call append(line('$'), "     * @version 1.0")
    call append(line('$'), "     */")
    call append(line('$'), "    // Your Code")
    call append(line('$'), "}")
    call cursor(line('$')-1, strlen(getline('.')))
    " 进入选择模式
    exec "normal ^v$h\"
endfunc

4. 补充

以上新环境安装可能会缺少ag工具,ubuntu可以通过以下指令安装:

# apt install silversearcher-ag           # Ubuntu
# yum install the_silver_searcher.x86_64  # CentOS

 

转载于:https://my.oschina.net/apis/blog/3016873

你可能感兴趣的:(vim插件)