IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> vim 配置 -> 正文阅读

[开发工具]vim 配置

先分别讲各个部分,最后给完整的~/.vimrc文件

~/.vimrc 配置基础

自动补全

补全工具有YouCompleteMe / deoplete 等。
本文使用deoplete,支持异步搜索补全内容。使用不同的插件补全不同的语言内容

配置

if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1

安装 python3 的插件工具

pip3 install --user pynvim

语法检查[lint]

语法检查工具有 ale / vim-polyglot等。
在github上查询,ale的start及fork 数量远多于vim-polyglot。因而选前者。

Plug 'w0rp/ale'

let g:ale_linters = {
    'javascript': ['eslint'],
    'css': ['stylelint'],
}
let g:ale_fixers = {
    'javascript': ['eslint'],
    'css': ['stylelint'],
}
let g:ale_fix_on_save = 1

let g:ale_sign_column_always = 1
let g:ale_sign_error = '●'
let g:ale_sign_warning = '?'

nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)

全局搜索

常用的插件有 ctrlp / the_silver_searcher / ag.vim / mru.vim 等。
其中,the_silver_searcher在的github的star 最多,使用这个插件。

代码注释

使用NerdCommenter

Plug 'scrooloose/nerdcommenter'

# <leader>c<space> 注释/取消注释
# <leader>cc // 注释
# <leader>cm 只用一组符号注释
# <leader>cA 在行尾添加注释
# <leader>c$ /* 注释 */
# <leader>cs /* 块注释 */
# <leader>cy 注释并复制
# <leader>ca 切换 // 和 /* */
# <leader>cu 取消注释

let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCustomDelimiters = {
             'javascript': { 'left': '//', 'leftAlt': '/**', 'rightAlt': '*/' },
             'less': { 'left': '/**', 'right': '*/' }
         }

let g:NERDAltDelims_javascript = 1
let g:NERDDefaultNesting = 0

Git 集成

vim-gitgutter
vim-fugitive
后者start更多一些

完整配置(.vimrc)

" show line number
set nu
" enable syntax
syntax on

filetype plugin on

colorscheme github-light

" highlight current line
set cursorline

" replace tab with blank-space
set ts=4
set expandtab
set shiftwidth=4

call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
" On-demand loading
Plug 'scrooloose/nerdtree'|
            \ Plug 'Xuyuanp/nerdtree-git-plugin' |
            \ Plug 'ryanoasis/vim-devicons' 
Plug 'scrooloose/nerdcommenter'

" Plugin for syntax checking, refactoring
Plug 'dense-analysis/ale'

" vim interface for ag (the siler-searcher)
Plug 'mileszs/ack.vim'

" git integration
Plug 'tpope/vim-fugitive'

"Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-default branch
"Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }

" Initialize plugin system
call plug#end()




" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif

" NERDTree Config
" automatically run NERDTree
autocmd vimenter * NERDTree
let g:NERDTreeMinimalUI = 1
" default: 0
let g:NERDTreeGitStatusShowClean = 1 
" default: 0
let g:NERDTreeGitStatusConcealBrackets = 1 
let g:NERDTreeGitStatusIndicatorMapCustom = {
                \ 'Modified'  :'?',
                \ 'Staged'    :'?',
                \ 'Untracked' :'?',
                \ 'Renamed'   :'?',
                \ 'Unmerged'  :'═',
                \ 'Deleted'   :'?',
                \ 'Dirty'     :'?',
                \ 'Ignored'   :'?',
                \ 'Clean'     :'??',
                \ 'Unknown'   :'?',
                \ }
nnoremap <leader>nc :NERDTreeFocus<CR>
nnoremap <leader>nn :NERDTree<CR>
nnoremap <leader>nt :NERDTreeToggle<CR>
nnoremap <leader>nr :NERDTreeRefreshRoot<CR>
" o : open / close directory
" e : open directory by way of file-manager
" t : open in tab
" T : open in tab, not cursor in NERDTree
" r : refresh current directory
" R : refresh root directory
" X : unfold all directory
" p : go father directory
" P : to to root directory
" J : go to first node
" K : go to last node
" I : hide/show hiddne file
" m : show file menu
" C : set current directory as root directory
" u : set father directory as root directory


" [autocompletion] / [deoplete]
"
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
let g:deoplete#enable_at_startup = 1



" [autocompletion] / [ale]
" 
" Use ALE and also some plugin 'foobar' as completion sources for all code.
call deoplete#custom#option('sources', { '_': ['ale', 'foobar'],})

" set this variable to 1 to fix files when you save them.
let g:ale_fix_on_save = 1

" triggering completion manually with <C-x><C-o>.
set omnifunc=ale#completion#OmniFunc

let g:ale_completion_autoimport = 1

" use statusbar (by 'Airline') to show error msgs
let g:airline#extensions#ale#enabled = 1

let g:ale_sign_column_always = 1
let g:ale_sign_error = '●'
let g:ale_sign_warning = '?'

" use 'Ctrl+j' and 'Ctrl+k' to moving between errors for example
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)

" use 'quickfix' instead of 'loclist'
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
" open quickfix list
let g:ale_open_list = 1
" Useful if you are combining ALE with
" some other plugin which sets quickfix errors, etc.
let g:ale_keep_list_window_open = 1
" Show 5 lines of errors (default: 10)
"   let g:ale_list_window_size = 5

" To save power
"   let g:ale_lint_on_text_changed = 'never'
"   let g:ale_lint_on_insert_leave = 0
" You can disable this option too
" if you don't want linters to run on opening a file
"   let g:ale_lint_on_enter = 0

nnoremap gD:ALEGoToDefinition<CR>
nnoremap gR:ALEFindReferences<CR>
nnoremap gS:ALESymbolSearch<CR>

" [ searcher ] / [the silver searcher]
if executable('ag')
  let g:ackprg = 'ag --vimgrep'
endif
"?    a quick summary of these keys, repeat to close
"o    to open (same as Enter)
"O    to open and close the quickfix window
"go   to preview file, open but maintain focus on ack.vim results
"t    to open in new tab
"T    to open in new tab without moving to it
"h    to open in horizontal split
"H    to open in horizontal split, keeping focus on the results
"v    to open in vertical split
"gv   to open in vertical split, keeping focus on the results
"q    to close the quickfix window


" <leader>c<space> 注释/取消注释
" <leader>cc // 注释
" <leader>cm 只用一组符号注释
" <leader>cA 在行尾添加注释
" <leader>c$ /* 注释 */
" <leader>cs /* 块注释 */
" <leader>cy 注释并复制
" <leader>ca 切换 // 和 /* */
" <leader>cu 取消注释

let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCustomDelimiters = {
        \ 'javascript': { 'left': '//', 'leftAlt': '/**', 'rightAlt': '*/' },
        \ 'less': { 'left': '/**', 'right': '*/' }
        \}

let g:NERDAltDelims_javascript = 1
let g:NERDDefaultNesting = 0

参考
网页1

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-03-04 15:48:03  更:2022-03-04 15:49:22 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 6:32:38-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码