NeoVim 使用
NeoVim
安装
macOS
brew install neovim
Ubuntu
-
使用 APT 安装 neovim(版本可能较旧):
sudo apt install neovim -
从 PPA 安装:
sudo add-apt-repository ppa:neovim-ppa/stable sudo apt install neovim
Windows
-
使用
winget:winget install Neovim.Neovim -
或者使用
scoop:scoop install neovim
使用
编辑文件:
nvim file
:set ma:使缓冲区可修改:set noma:使缓冲区不可修改
参见:Vim 学习笔记
LazyVim
刚安装的 NeoVim 看起来和传统 Vim 并无两样。可以安装 LazyVim 插件来美化 NeoVim。(需要 Neovim >= 0.9.0)
安装
在安裝前确保你的系统已经安装了 GCC 或 Clang 等 C 编译器。关于 Windows 上 GCC 的安装,参见安装 MinGW-w64。
Linux / macOS
git clone https://github.com/LazyVim/starter ~/.config/nvim
Windows
git clone https://github.com/LazyVim/starter $env:LOCALAPPDATA\nvim
配置
在 ~/.config/nvim/lua/config/options.lua 文件下可以进行一些个性化设置:
vim.opt.expandtab = true -- 使用空格代替 Tab
vim.opt.tabstop = 4 -- Tab 键的宽度
vim.opt.shiftwidth = 4 -- 缩进时的宽度
vim.opt.softtabstop = 4 -- 按退格键时可以删除的空格数量
vim.g.lazyvim_plugin_notifications = false -- 禁用插件通知
设置 Tab 键为自动补全按键
创建 ~/.config/nvim/lua/plugins/autocompleate.lua:
return {
-- Use <tab> for completion and snippets (supertab)
-- first: disable default <tab> and <s-tab> behavior in LuaSnip
{
"L3MON4D3/LuaSnip",
keys = function()
return {}
end,
},
-- then: setup supertab in cmp
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-emoji",
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
local cmp = require("cmp")
opts.mapping = vim.tbl_extend("force", opts.mapping, {
["<CR>"] = cmp.config.disable,
["<Tab>"] = cmp.mapping.confirm({ select = true }),
["<C-j>"] = cmp.mapping(function(fallback) end, { "i", "s" }),
})
end,
},
}
参考:HELP, How do I Auto complete with <TAB> in LazyVim? | Reddit
Lazygit
安装
macOS
brew install lazygit
Ubuntu
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | \grep -Po '"tag_name": *"v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/download/v${LAZYGIT_VERSION}/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar -xf lazygit.tar.gz lazygit
sudo install lazygit -Dt /usr/local/bin
检查 Lazygit 版本:
lazygit --version

浙公网安备 33010602011771号