sudo apt install neovim
yay -S neovim
sudo ln -s /usr/bin/nvim /usr/bin/vi
sudo ln -s /usr/bin/nvim /usr/local/bin/vi
sudo ln -s /usr/bin/nvim /bin/vi
mkdir -p $HOME/.config/nvim
touch $HOME/.config/nvim/init.vim
cat <<FOE | tee $HOME/.config/nvim/init.vim
" 定义快捷键的前缀,即<Leader>
let mapleader=";"
" 开启文件类型侦测
filetype on
" 根据侦测到的不同类型加载对应的插件
filetype plugin on
" 让配置变更立即生效
autocmd BufWritePost $MYVIMRC source $MYVIMRC
" 开启语法高亮功能
syntax enable
" 允许用指定语法高亮配色方案替换默认方案
syntax on
set backspace=indent,eol,start
set hidden
:nnoremap <F2> :setl noai nocin nosi inde=<CR>
set encoding=utf-8
set t_Co=256
" 自适应不同语言的智能缩进
filetype indent on
" 将制表符扩展为空格
set expandtab
" 设置编辑时制表符占用空格数
set tabstop=4
" 设置格式化时制表符占用空格数
set shiftwidth=4
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4
set autoindent
set relativenumber
set cursorline
set textwidth=80
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" 禁止折行
set nowrap
set linebreak
set showmatch
" 总是显示状态栏
set laststatus=2
" 显示光标当前位置
set ruler
" 开启行号显示
set number
" 高亮显示当前行/列
set cursorline
set cursorcolumn
" 高亮显示搜索结果
set hlsearch
" 开启实时搜索功能
set incsearch
" 搜索时大小写不敏感
set ignorecase
" 关闭兼容模式
" set nocompatibles
" vim 自身命令行模式智能补全
" set wildmenu
set history=1000
set autoread
set listchars=tab:»■,trail:■
set list
" 禁止光标闪烁
set gcr=a:block-blinkon0
" 禁止显示滚动条
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
" 禁止显示菜单和工具条
set guioptions-=m
set guioptions-=T
" 基于缩进或语法进行代码折叠
"set foldmethod=indent
set foldmethod=syntax
" 启动 vim 时关闭折叠代码
set nofoldenable
call plug#begin('~/.local/share/nvim/plugged')
Plug 'joshdick/onedark.vim'
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
let g:onedark_termcolors=256
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
let g:deoplete#enable_at_startup = 1
Plug 'zchee/deoplete-jedi'
autocmd InsertLeave,CompleteDone * if pumvisible() == 0 | pclose | endif
inoremap <expr><tab> pumvisible() ? "\<c-n>" : "\<tab>"
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
let g:airline_theme='dark'
Plug 'jiangmiao/auto-pairs'
Plug 'scrooloose/nerdcommenter'
Plug 'sbdchd/neoformat'
Plug 'davidhalter/jedi-vim'
" disable autocompletion, cause we use deoplete for completion
let g:jedi#completions_enabled = 0
"
" " open the go-to function in split, not another buffer
let g:jedi#use_splits_not_buffers = "right"
Plug 'scrooloose/nerdtree'
Plug 'dense-analysis/ale'
" ale settings
" let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
let g:ale_open_list = 1
" python checker
let g:ale_fixers = {
\ 'javascript': ['standard'],
\ 'python': ['pylint'],
\ 'bash': ['shfmt']
\}
" shellcheck
let g:ale_linters = {
\ 'csh': ['shell'],
\ 'bash': ['shell'],
\ 'rust': ['cargo'],
\ 'text': [],
\ 'zsh': ['shell'],
\}
Plug 'pearofducks/ansible-vim'
let g:ansible_unindent_after_newline = 1
let g:ansible_attribute_highlight = "ob"
let g:ansible_extra_keywords_highlight = 1
Plug 'terryma/vim-multiple-cursors'
Plug 'machakann/vim-highlightedyank'
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Trigger configuration. Do not use <tab> if you use
" https://github.com/Valloric/YouCompleteMe.
" UltiSnips 的 tab 键与 YCM 冲突,重新设定
let g:UltiSnipsExpandTrigger="<leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<leader><tab>"
let g:UltiSnipsJumpBackwardTrigger="<leader><s-tab>"
" shortcut to go to next position
let g:UltiSnipsJumpForwardTrigger='<c-j>'
" shortcut to go to previous position
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
let g:UltiSnipsSnippetDirectories=["UltiSnips", "mycoolsnippets"]
Plug 'nathanaelkane/vim-indent-guides'
" 随 vim 自启动
let g:indent_guides_enable_on_vim_startup=1
" 从第二层开始可视化显示缩进
let g:indent_guides_start_level=2
" 色块宽度
let g:indent_guides_guide_size=1
" 快捷键 i 开/关缩进可视化
:nmap <silent> <Leader>i <Plug>IndentGuidesToggle
" Make sure you use single quotes
Plug 'Valloric/YouCompleteMe'
" git submodule update --init --recursive && ./install.py --clang-completer
" YCM 补全菜单配色
" 菜单
highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
" 选中项
highlight PmenuSel ctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
" 补全功能在注释中同样有效
let g:ycm_complete_in_comments=1
" 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_confirm_extra_conf=0
" 开启 YCM 标签补全引擎
let g:ycm_collect_identifiers_from_tags_files=1
" 引入 C++ 标准库tags
" set tags+=/data/misc/software/misc./vim/stdcpp.tags
" YCM 集成 OmniCppComplete 补全引擎,设置其快捷键
inoremap <leader>; <C-x><C-o>
" 补全内容不以分割子窗口形式出现,只显示补全列表
set completeopt-=preview
" 从第一个键入字符就开始罗列匹配项
let g:ycm_min_num_of_chars_for_completion=1
" 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_cache_omnifunc=0
" 语法关键字补全
let g:ycm_seed_identifiers_with_syntax=1
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'
call plug#end()
colorscheme onedark
FOE
nvim +plugInstall +qall
mkdir -p $HOME/.config/nvim/mycoolsnippets
cat <<EOF | tee $HOME/.config/nvim/mycoolsnippets/markdown.snippets
snippet head "head for my blog"
---
title = ${1:Title String} # 文章标题
date = `!v strftime('%a, %d %b %Y %X %z')` # 自动添加日期信息
draft = false # 设为false可被编译为HTML,true供本地修改
tags = ["${8:Tag1}, ${9:Tag2}"] # 文章标签,可设置多个,用逗号隔开。Hugo会自动生成标签
的子URL
---
$0
endsnippet
EOF
cat <<EOF | tee $HOME/.config/nvim/mycoolsnippets/sh.snippets
snippet author "paste my name and email"
#!/bin/bash
# By Sandylaw <[email protected]>
# `!v strftime('%a, %d %b %Y %X %z')`
endsnippet
snippet debsig "debian change log signature" w
-- SandyLaw <waytoarcher@gmail> `!v strftime('%a, %d %b %Y %X %z')`
endsnippet
EOF