NeoVim
hyperextensible Vim-based text editor. 基于 vim 的超扩展的文本编辑器. 搭配各种扩展的话, 甚至可以做个IDE. 最后附一份SpaceVIM
的配置(尝试了下, 个人用得不舒服).
启动效果图
markdown编写
安装
# Arch
pacman -S neovim
# windows
scoop install neovim
# Linux Config Path: ~/.config/nvim/init.vim
# Windows Config Path: ~/AppData/Local/nvim/init.vim
安装 vim-plug
# Unix
curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Windows powershell
iwr -useb https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim |`
ni "$(@($env:XDG_DATA_HOME, $env:LOCALAPPDATA)[$null -eq $env:XDG_DATA_HOME])/nvim/autoload/plug.vim" -Force
配置插件
# 安装插件环境支持
# python
pip install neovim
# node.js
npm install -g neovim
# ruby
gem install neovim
配置 init.vim
" rtp is vim's runtime path
" set rtp+=~/AppData/Local/nvim/plug-config/coc.vim
" Automatic installation
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/AppData/Local/nvim/plugins')
" Treesitter 语法树更新插件, 要求 neovim > 0.5 版本
Plug 'nvim-treesitter/nvim-treesitter'
" Stable version of coc https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions 补全插件
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Rainbow https://github.com/luochen1990/rainbow 括号高亮
Plug 'luochen1990/rainbow'
" Schemes 主题
Plug 'christianchiarulli/nvcode-color-schemes.vim'
" Markdiwn Preview md文件预览(通过浏览器
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" Provides a start screen for Vim and Neovim 启动界面
Plug 'mhinz/vim-startify'
call plug#end()
" configure nvcode-color-schemes
let g:nvcode_termcolors=256
let g:rainbow_active = 1 " set to 0 if you want to enable it later via :RainbowToggle
colorscheme nvcode " Or whatever colorscheme you make
" checks if your terminal has 24-bit color support
if (has("termguicolors"))
set termguicolors
hi LineNr ctermbg=NONE guibg=NONE
endif
source ~/AppData/Local/nvim/plug-config/coc.vim
luafile ~/AppData/Local/nvim/lua/treesitter.lua
" Custom header and footer
let g:startify_custom_header = [
\ '+------------------------------+',
\ '| |',
\ '| Hello DevLGQ~ |',
\ '| |',
\ '+--------------+---------------+',
\]
let g:startify_custom_footer = [
\ '+--------------------------------------------------+',
\ '| All problems in computer science |',
\ '| can be solved by another level of indirection. |',
\ '+--------------------------------------------------+',
\]
coc.vim
配置文件
" Set internal encoding of vim, not needed on neovim, since coc.nvim using some
" unicode characters in the file autoload/float.vim
set encoding=utf-8
" TextEdit might fail if hidden is not set.
set hidden
" Some servers have issues with backup files, see #649.
set nobackup
set nowritebackup
" Give more space for displaying messages.
set cmdheight=2
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
set number
syntax on
treesitter.lua
配置文件
require 'nvim-treesitter.configs'.setup {
ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages
highlight = {
enable = true, -- false will disable the whole extension
},
}
配置完成之后, 进入nvim
, 运行:PlugInstall
进行插件的安装.
一些常用的指令
- Check plugins
:PlugStatus
- Remove undeclared plugins
:PlugClean
- Update plugins
:PlugUpdate
- Check coc
:checkhealth
Coc-Extensions
Conquer of Completion. 一款补全插件.
# list all of the extension commands
:CocList commands
# uninstall an extension
:CocUninstall coc-html
# manage your extension
:CocList extensions
# install extension
:CocInstall coc-json coc-python coc-sh coc-vimlsp coc-java coc-markdownlint coc-snippets coc-spell-checker
# Get useful info
:CocInfo
Coc 配置
# windows ~/AppData/Local/nvim/coc-settings.json
:CocConfig
coc-java extensions. 基于vscode-java
的coc
插件, 要求至少要 JDK11.
{
"java.configuration.runtimes": [
{
"name": "OpenJDK-11",
"path": "D:/Program Files/Java/jdk-11.0.10+9"
},
{
"name": "OpenJDK-16",
"path": "D:/Program Files/Java/jdk-16",
"default": true
}
],
// codelens
"codeLens.enable": true,
"java.referencesCodeLens.enabled": true,
"java.implementationsCodeLens.enabled": true,
"coc.preferences.formatOnSaveFiletypes": ["css", "markdown", "javascript",
"graphql", "html", "yaml", "json", "python", "java"]
}
SpaceVIM
init.toml
配置文件
# All SpaceVim option below [option] section
[options]
# 自动更新
automatic_update = false
# set spacevim theme. by default colorscheme layer is not loaded,
# if you want to use more colorscheme, please load the colorscheme layer
colorscheme = "gruvbox"
colorscheme_bg = "dark"
# Disable guicolors in basic mode, many terminal do not support 24bit
# true colors 禁用终端真彩
enable_guicolors = true
# Disable statusline separator, if you want to use other value, please
# install nerd fonts
statusline_separator = "nil"
statusline_iseparator = "bar"
# 顶部标签类型
# 0: 1 ➛ ➊
# 1: 1 ➛ ➀
# 2: 1 ➛ ⓵
# 3: 1 ➛ ¹
# 4: 1 ➛ 1
buffer_index_type = 1
windows_index_type = 3
# 显示/隐藏顶部标签栏上的文件类型图标
enable_tabline_filetype_icon = true
# 是否在状态栏上显示当前模式
enable_statusline_mode = true
statusline_unicode_symbols = false
# 分隔符 arrow curve nil fire
statusline_separator = 'curve'
# Enable vim compatible mode, avoid changing origin vim key bindings
vimcompatible = true
# 文件树位置
filetree_direction = "left"
# 缩进
default_indent = 4
# Enable autocomplete layer 模块设置 https://spacevim.org/cn/layers/
[[layers]]
name = 'autocomplete'
auto_completion_return_key_behavior = "complete"
auto_completion_tab_key_behavior = "cycle"
[[layers]]
name = 'shell'
default_position = 'top'
default_height = 30
[[layers]]
name = 'lang#java'
[[layers]]
name = 'lang#markdown'
# 添加自定义插件
# [[custom_plugins]]