Vim 插件管理器

需求

  • 安装 Vim 补全插件
  • 安装 Kubernetes YAML补全插件

基础准备

系统版本

[root@m1 ~]# cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)

首先安装

# 安装
[root@m1 ~]# yum -y install git
[root@m1 ~]# yum -y install vim

# 创建目录
mkdir -p ~/.vim/doc
mkdir -p ~/.vim/plugin
mkdir -p ~/.vim/plugged
mkdir -p ~/.vim/syntax
mkdir -p ~/.vim/autoload

Vim 插件管理器

vim-plug 下载

# Github
https://github.com/junegunn/vim-plug

# 存放vim-plug路径
cd ~/.vim/autoload/

# 拉取 plug.vim 插件
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

编写插件管理

# 路径
[root@m1 ~]# vim ~/.vimrc 

# 实际插件-------start#
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

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

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

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

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

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

" Unmanaged plugin (manually installed and updated)
" Plug '~/my-prototype-plugin'

Plug 'andrewstuart/vim-kubernetes'

"Plug 'Valloric/YouCompleteMe'

" Initialize plugin system
call plug#end()

set backspace=indent,eol,start
# 实际插件-------end#


# 查看和安装插件
vim
:PlugStatus
:PlugInstall

# 其余的操作
:PlugClean
:PlugUpdate

PlugInstall.png

Kubernetes

k8s代码块补全

# 拉取 vim-kubernetes
[root@m1 ~]# git clone https://github.com/andrewstuart/vim-kubernetes.git

# 复制到 ~/.vim/ 下
[root@m1 ~]# cp -R vim-kubernetes/UltiSnips/ ~/.vim/

# 查看是否存在 yaml.snippets
[root@m1 ~]# ls -la ~/.vim/UltiSnips/
total 12
drwxr-xr-x 2 root root    27 Apr 22 14:00 .
drwxr-xr-x 8 root root    93 Apr 22 13:56 ..
-rw-r--r-- 1 root root 11256 Apr 22 14:00 yaml.snippets

缩写大全

snippet全拼描述
rcReplication Controller-
depDeployment-
svcService-
depsvcDeployment and service-
depsvcingDeployment, service, and ingress-
pvPersistentVolume-
pvcPersistentVolumeClaim-
ingIngress-
nsNamespace-
saServiceAccount-
ingtlsIngress TLS section-
cfgConfigMap-
secSecret-
envEnvironment template-
secrefenv SecretRef-
pvolPod Volume Object-
jobKubernetes Job-
cronKubernetes Cronjob-
skrSecretKeyRef-
certcert-manager certificate-
netpNetworkPolicy-
probeLiveness/Readiness Probes-
ssStatefulSet-
resResources-
initInit Container-
stratDeployment Strategy-
atlstls-acme annotations-
vtlstls-vault annotations-
cmtlscert-manager tls annotations-
ednsexternal dns-
roleRole-
rbRoleBinding-
rbacRole and Binding-
hpaHorizontalPodAutoscaler-
pvolmVolume Mount and spec-
volmVolume Mount-
promPrometheus annotations-
affAffinitiy/Anti-Affinity-
hpaHorizontal Pod Autoscaler-

TIPS

1、使用 vim --version | grep python 查看 vim是否开启支持ptyhon
[root@m1 bin]# vim a.yaml
YouCompleteMe unavailable: unable to load Python.
Press ENTER or type command to continue

相关地址

  • Github
    • https://github.com/junegunn/vim-plug
    • https://github.com/andrewstuart/vim-kubernetes
  • Kubernetes的vim补全插件
    • https://www.jianshu.com/p/0cb5c9227f66
  • vim插件YouCompleteMe安装(vim-plug不推荐)
    • https://zhuanlan.zhihu.com/p/54074345
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

eddie_k2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值