set number
set relativenumber
set shiftwidth=4
set tabstop=4
set softtabstop=4
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
set autoindent
set cursorline
set wildmenu
set showmatch
set showcmd
set list
set laststatus=2
set ruler
set magic
set mouse=a
set hlsearch
exec "nohlsearch"
set incsearch
set ignorecase
syntax on
call plug#begin('~/.config/nvim/plugged')
Plug 'vim-airline/vim-airline'
Plug 'connorholyday/vim-snazzy'
Plug 'neomake/neomake'
Plug 'scrooloose/nerdtree'
"语法检查
Plug 'neomake/neomake'
" 自动补全
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'zchee/deoplete-jedi'
" 括号匹配
Plug 'jiangmiao/auto-pairs'
Plug 'majutsushi/tagbar',{'on' : 'TagbarOpenAutoClose'}
Plug 'w0rp/ale'
Plug 'Valloric/YouCompleteMe'
Plug 'scrooloose/nerdtree',{'on' : 'NERDTreeToggle'}
Plug 'Xuyuanp/nerdtree-git-plugin'
call plug#end()
color snazzy
let g:SnazzyTransparent = 1
let &t_ut = ''
"当新建.hpp .cpp .mk .sh等文件时自动调用SetTitle 函数
autocmd BufNewFile *.[ch],*.hpp,*.cpp,Makefile,*.mk,*.sh exec ":call SetTitle()"
" 加入注释
func SetComment()
call setline(1,"/*****************************************************************")
call append(line("."), "* Copyright (C) ".strftime("%Y")." FBI WARNING. All rights reserved.")
call append(line(".")+1, "* ")
call append(line(".")+2, "* 文件名称:".expand("%:t"))
call append(line(".")+3, "* 创 建 者:Sole")
call append(line(".")+4, "* 创建日期:".strftime("%Y年%m月%d日"))
call append(line(".")+5, "* 描 述:")
call append(line(".")+6, "*")
call append(line(".")+7, "*****************************************************************/")
call append(line(".")+8, "")
call append(line(".")+9, "")
endfunc
" 加入shell,Makefile注释
func SetComment_sh()
call setline(3, "#================================================================")
call setline(4, "# Copyright (C) ".strftime("%Y")." FBI WARNING. All rights reserved.")
call setline(5, "# ")
call setline(6, "# 文件名称:".expand("%:t"))
call setline(7, "# 创 建 者:Sole")
call setline(8, "# 创建日期:".strftime("%Y年%m月%d日"))
call setline(9, "# 描 述:")
call setline(10, "#")
call setline(11, "#================================================================")
call setline(12, "")
call setline(13, "")
endfunc
" 定义函数SetTitle,自动插入文件头
func SetTitle()
if &filetype == 'make'
call setline(1,"")
call setline(2,"")
call SetComment_sh()
elseif &filetype == 'sh'
call setline(1,"#!/system/bin/sh")
call setline(2,"")
call SetComment_sh()
else
call SetComment()
if expand("%:e") == 'hpp'
call append(line(".")+10, "#define _".toupper(expand("%:t:r"))."_H")
call append(line(".")+11, "#ifdef __cplusplus")
call append(line(".")+12, "extern \"C\"")
call append(line(".")+13, "{")
call append(line(".")+14, "#endif")
call append(line(".")+15, "")
call append(line(".")+16, "#ifdef __cplusplus")
call append(line(".")+17, "}")
call append(line(".")+18, "#endif")
call append(line(".")+19, "#endif //".toupper(expand("%:t:r"))."_H")
elseif expand("%:e") == 'h'
call append(line(".")+10, "#pragma once")
elseif &filetype == 'c'
call append(line(".")+10,"#include <stdio.h>")
call append(line(".")+11,"")
call append(line(".")+12,"int main(int argc,char *argv[])")
call append(line(".")+13,"{")
call append(line(".")+14,"\treturn 0;")
call append(line(".")+15,"}")
elseif &filetype == 'cpp'
call append(line(".")+10, "#include \"".expand("%:t:r").".h\"")
endif
endif
endfunc