Last active
May 25, 2021 15:19
-
-
Save liyu001989/17811808295dfb2f5e5d2533c96d62da to your computer and use it in GitHub Desktop.
Laravel-vimrc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"建议插件的加载放在最开始,否则可能有加载问题例theme | |
"可以单独写个文件进行加载例如: | |
"so ~/.vim/plugins.vim | |
"--------插件-------- | |
call plug#begin('~/.vim/plugged') | |
Plug '907th/vim-auto-save' | |
"Plug 'StanAngeloff/php.vim' | |
"中文帮助 | |
Plug 'yianwillis/vimcdoc' | |
"goyo 模式 | |
Plug 'junegunn/goyo.vim' | |
"phpdoc | |
Plug 'rican7/php-doc-modded' | |
"去除方法注释的多余部分 | |
let g:pdv_cfg_autoEndFunction=0 | |
"去除多余的空白 | |
Plug 'ntpeters/vim-better-whitespace' | |
let g:strip_whitespace_on_save=1 | |
let g:strip_whitespace_confirm=0 | |
"主题配色 | |
Plug 'skielbasa/vim-material-monokai' | |
"代码缩进提示 | |
Plug 'yggdroot/indentline' | |
"优化状态栏 | |
Plug 'vim-airline/vim-airline' | |
let g:airline_theme='materialmonokai' | |
"let g:airline#extensions#tabline#enabled = 1 | |
"let g:airline#extensions#tabline#buffer_nr_show = 0 | |
let g:airline_powerline_fonts = 1 | |
"文件目录 | |
Plug 'scrooloose/nerdtree' | |
"自动打开 nerdtree | |
"autocmd VimEnter * NERDTree | wincmd p | |
"使用 vim 直接打开某个目录 | |
autocmd StdinReadPre * let s:std_in=1 | |
"autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | wincmd p | ene | exe 'NERDTree' argv()[0] | endif | |
"自动退出nerdtree | |
Plug 'Xuyuanp/nerdtree-git-plugin' | |
autocmd BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
"fzf 文件查找 | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
let g:fzf_tags_command = 'ctags -R' | |
Plug 'lvht/phpcd.vim', { 'for': 'php', 'do': 'composer install' } | |
"let g:phpcd_autoload_path = '.autoload.php' | |
"let g:deoplete#ignore_sources = get(g:, 'deoplete#ignore_sources', {}) | |
"let g:deoplete#ignore_sources.php = ['phpcd', 'omni'] | |
"Plug 'roxma/nvim-completion-manager' | |
"if !has('nvim') | |
" Plug 'roxma/vim-hug-neovim-rpc' | |
"endif | |
"let g:deoplete#enable_at_startup = 1 | |
"Plug 'lvht/phpcd.vim', { 'for': 'php', 'do': 'composer install' } | |
Plug 'shawncplus/phpcomplete.vim' | |
"文件图标 | |
Plug 'ryanoasis/vim-devicons' | |
"自动补全括号引号 | |
Plug 'raimondi/delimitmate' | |
"自动关闭 html 标签 | |
Plug 'alvan/vim-closetag' | |
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.blade.php' | |
"快速注释与取消注释 | |
Plug 'scrooloose/nerdcommenter' | |
"启动页面 | |
Plug 'mhinz/vim-startify' | |
"不切换目录 | |
let g:startify_change_to_dir=0 | |
"其他目录打开,切换到项目根目录 | |
let g:startify_change_to_vcs_root=1 | |
"php-cs-fixer | |
Plug 'stephpy/vim-php-cs-fixer' | |
let g:php_cs_fixer_rules = "@PSR2" | |
"tagbar | |
Plug 'majutsushi/tagbar' | |
"Plug 'xolox/vim-easytags' | |
"Plug 'xolox/vim-misc' | |
"blade | |
Plug 'jwalton512/vim-blade' | |
Plug 'posva/vim-vue' | |
Plug 'groenewege/vim-less' | |
Plug 'othree/javascript-libraries-syntax.vim' | |
Plug 'pangloss/vim-javascript' | |
"let g:javascript_plugin_jsdoc = 1 | |
Plug 'tpope/vim-repeat' | |
Plug 'mattn/emmet-vim' | |
"Plug 'othree/html5.vim' | |
Plug 'plasticboy/vim-markdown' | |
"typescript | |
Plug 'leafgarland/typescript-vim' | |
Plug 'shmup/vim-sql-syntax' | |
"auto use namespace | |
Plug 'arnaud-lb/vim-php-namespace' | |
Plug 'craigemery/vim-autotag' | |
let g:autotagTagsFile=".tags" | |
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } | |
Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' } | |
Plug 'wakatime/vim-wakatime' | |
Plug 'zxqfl/tabnine-vim' | |
" rsync | |
"Plug 'kenn7/vim-arsync' | |
" ale 代码格式化 | |
Plug 'dense-analysis/ale' | |
" git | |
Plug 'tpope/vim-fugitive' | |
call plug#end() | |
" docker sync 问题 https://github.com/moby/moby/issues/15793 | |
set noswapfile | |
set backupcopy=yes | |
"配色 | |
set guifont=Hack\ Nerd\ Font "设置字体 | |
set background=dark "背景黑色 | |
set termguicolors | |
colorscheme material-monokai | |
syntax on "语法高亮 | |
set background=dark "背景黑色 | |
set number "显示行号 | |
set t_Co=256 "启用256色 | |
set cursorline "高亮当前行 | |
"基础配置 | |
set nocompatible "不与 Vi 兼容 | |
set showmode "显示左下角状态栏 | |
set showcmd "在底部显示当前输入的指令 | |
set showmatch "自动高亮对应的括号 | |
set autoindent "自动缩进 | |
set ruler "底部显示光标所在的行号 | |
set wildmenu "命令模式智能补全 | |
set wrap "自动折行 | |
set linebreak "不会在单词内部折行 | |
set autoread "打开文件监视 | |
set encoding=utf-8 "设置编码 | |
set mouse=a "鼠标可用 | |
"拼写检查 | |
"set spell spelllang=en_us,cjk "开启拼写检查 | |
"highlight clear SpellBad "清除拼写错误样式 | |
"highlight SpellBad cterm=underline "拼写错误的使用下划线 | |
"缩进 | |
set smartindent "智能缩进 | |
set expandtab "使用空格代替 Tab | |
set smarttab "智能 Tab,根据其他缩进确定 Tab | |
set backspace=indent,eol,start "让 backspace 正常工作 | |
set tabstop=4 "Tab 等于多少个空格 | |
set softtabstop=4 "Tab 转换为多少个空格 | |
set shiftwidth=4 "默认缩进 4 个空格 | |
" html, blade, js Tab 等于 2 个空格 | |
autocmd FileType html,blade,javascript setlocal tabstop=2 shiftwidth=2 softtabstop=2 | |
"搜索 | |
set hlsearch "高亮检索 | |
set incsearch "开启实时搜索功能 | |
set ignorecase "检索时忽略大小写 | |
set smartcase "智能匹配大小写 | |
"解决esc延迟问题 | |
set timeoutlen=1000 ttimeoutlen=0 | |
"自动加载配置 | |
if has("autocmd") | |
autocmd! BufWritePost $MYVIMRC source $MYVIMRC | |
endif | |
"--------按键映射-------- | |
let mapleader = "," | |
let g:mapleader = "," | |
"插入模式下移动 | |
imap <C-j> <down> | |
imap <C-k> <up> | |
imap <C-l> <right> | |
imap <C-h> <left> | |
"切换窗口 | |
nmap <C-j> <C-w>j | |
nmap <C-k> <C-w>k | |
nmap <C-l> <C-w>l | |
nmap <C-h> <C-w>h | |
"标签页快捷键 | |
nmap <C-t> :tabnew<cr> " 新tab | |
nmap <C-p> :tabp<cr> " 前一个tab | |
nmap <C-n> :tabn<cr> " 下一个tab | |
"buffer 快捷键 | |
"nmap <C-b><C-p> :bp<cr> | |
"nmap <C-b><C-n> :bn<cr> | |
nmap gn :bn<cr> " 前一个 buffer | |
nmap gp :bp<cr> " 下一个buffer | |
nmap gd :bd<cr> " 关闭buffer | |
"快速打开配置文件 | |
nmap <Leader>ev :tabedit $MYVIMRC<cr> | |
"toggle 目录 | |
map <C-d> :NERDTreeToggle<CR> | |
"文件模糊查询 | |
"nmap <C-p> :Files<CR> | |
nmap <Leader>p :Files<CR> | |
let g:fzf_commands_expect = 'alt-enter,ctrl-x' | |
"粘贴到剪切板 | |
vmap <Leader>y "+y | |
function! ToggleMouse() | |
if &mouse == 'a' | |
set mouse= nonumber | |
else | |
set mouse=a number | |
endif | |
endfunction | |
nmap <Leader>m :call ToggleMouse()<cr> | |
" 使用 Tab 代替 Ctrl + x + o | |
function! TabOrComplete() | |
if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w' | |
return "\<C-X>\<C-O>" | |
else | |
return "\<Tab>" | |
endif | |
endfunction | |
inoremap <tab> <c-r>=TabOrComplete()<CR> | |
set completeopt-=preview | |
nmap <silent><nowait> <leader>kk :call phpcd#JumpToDefinition('normal')<CR> | |
nmap <silent><nowait> <leader>jj :call phpcd#JumpBack()<CR> | |
filetype plugin on | |
autocmd FileType php set omnifunc=phpcomplete#CompletePHP | |
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags | |
imap <c-x><c-k> <plug>(fzf-complete-word) | |
imap <c-x><c-f> <plug>(fzf-complete-path) | |
imap <c-x><c-j> <plug>(fzf-complete-file-ag) | |
imap <c-x><c-l> <plug>(fzf-complete-line) | |
"生成phpdoc | |
imap <Leader>d <ESC>:call PhpDocSingle()<CR>i | |
nmap <Leader>d :call PhpDocSingle()<CR> | |
vmap <Leader>d :call PhpDocRange()<CR> | |
"php-cs-fixer | |
nmap <silent><leader>pf :call PhpCsFixerFixFile()<CR> | |
"tagbar | |
nmap <Leader>l :TagbarToggle<CR> | |
function! s:tags_sink(line) | |
let parts = split(a:line, '\t\zs') | |
let excmd = matchstr(parts[2:], '^.*\ze;"\t') | |
execute 'silent e' parts[1][:-2] | |
let [magic, &magic] = [&magic, 0] | |
execute excmd | |
let &magic = magic | |
endfunction | |
"command! -bang -nargs=? -complete=dir Files | |
"\ call fzf#vim#files(<q-args>, &columns > 80 ? fzf#vim#with_preview() : {}, <bang>0) | |
"command! -bang -nargs=? -complete=dir Fileskj | |
"\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0) | |
"command! -bang -nargs=? -complete=dir HFiles | |
"\ call fzf#vim#files(<q-args>, {'source': 'ag --hidden --ignore .git -g ""'}, <bang>0) | |
" 搜索某个目录下的文件 | |
nmap <Leader>b :Buffers<CR> | |
nmap <Leader>r :BTags<CR> | |
nmap <Leader>t :Tags<CR> | |
nmap <Leader>lc :Files config<CR> | |
nmap <Leader>lr :Files routes<CR> | |
nmap <Leader>lC :Files app/Http/Controllers/<CR> | |
nmap <Leader>lv :Files resources/views/<CR> | |
"快速保存退出 | |
nmap <Leader>q :q<cr> | |
"插入模式保存 | |
imap <Leader>w <C-o>:w<cr> | |
"普通模式保存 | |
nmap <Leader>w :w<cr> | |
"vim-php-namespace | |
function! IPhpInsertUse() | |
call PhpInsertUse() | |
call feedkeys('a', 'n') | |
endfunction | |
autocmd FileType php inoremap <Leader>u <Esc>:call IPhpInsertUse()<CR> | |
autocmd FileType php noremap <Leader>u :call PhpInsertUse()<CR> | |
autocmd FileType php inoremap <Leader>s <Esc>:call PhpSortUse()<CR> | |
autocmd FileType php noremap <Leader>s :call PhpSortUse()<CR> | |
let g:php_namespace_sort_after_insert = 1 | |
let g:php_namespace_sort = "'{,'}-1!awk '{print length, $0}' | sort -n -s | cut -d' ' -f2-" | |
"保存的时候自动对子 可以指定文件类型 *.scss | |
nmap <Leader> = :normal migg=G`i<CR> | |
"autocmd BufWritePre * :normal migg=G`i | |
" | |
let g:pdv_cfg_Author='liyu <[email protected]>' | |
let g:pdv_cfg_autoEndClass=0 | |
let g:pdv_cfg_annotation_Version=0 | |
let g:pdv_cfg_annotation_Copyright=0 | |
let g:pdv_cfg_annotation_License=0 | |
let g:pdv_cfg_annotation_Package=0 | |
" 同步本地代码 | |
nmap <Leader>ry :!ry<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment