当前位置: 首页 > news >正文

【Ubuntu】neovim Lazyvim安装与卸载

安装neovim

# 下载 AppImage
wget https://github.com/neovim/neovim/releases/latest/download/nvim-linux-x86_64.appimage# 添加执行权限
chmod u+x nvim-linux-x86_64.appimage# 移动到系统路径,重命名为 nvim
sudo mv nvim-linux-x86_64.appimage /usr/local/bin/nvim# 安装相关需要的软件
sudo apt install curl xclip git clang-format-19 fzf make

code

/home/louis/.config/nvim/init.lua

-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")-- 基本显示与缩进配置
vim.opt.number = true           -- 显示行号
vim.opt.smartindent = true      -- 智能自动缩进
vim.opt.shiftwidth = 4          -- 自动缩进时,每一级缩进 4 个空格
vim.opt.tabstop = 4             -- 设置 tab 字符显示为 4 个空格宽度
vim.opt.expandtab = true         -- 将 tab 转换为空格
vim.opt.softtabstop = 4         -- 按退格键时一次删除 4 个空格-- 禁用在 C、C++、Java、Python 等语言中换行后,自动添加注释符号
vim.api.nvim_create_autocmd("FileType", {pattern = {"c", "cpp", "java", "python", "javascript"},command = "setlocal formatoptions-=c formatoptions-=r formatoptions-=o"
})vim.o.encoding = "utf-8"
vim.o.fileencoding = "utf-8"
vim.o.fileencodings = "utf-8,ucs-bom,gbk,cp936"

clang-format

/home/louis/.config/nvim/lua/plugins/conform.lua

return {{"stevearc/conform.nvim",optional = true,opts = {formatters_by_ft = {["c"] = { "clang_format" },["cpp"] = { "clang_format" },["c++"] = { "clang_format" },},formatters = {clang_format = {command = "clang-format-19", -- 强制系统的-- prepend_args = { "--style=google" },-- args = { "--assume-filename", "$FILENAME" },env = { PATH = "/usr/bin:/usr/local/bin" }, -- 👈 这里彻底断掉 Mason路径影响},},},},
}

/home/louis/.config/nvim/lua/config/autocmds.lua

-- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
--
-- Add any additional autocmds here
-- with `vim.api.nvim_create_autocmd`
--
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
vim.api.nvim_create_autocmd({"FileType"}, {pattern = {"c", "cpp", "md", "txt", "c.snippets", "cpp.snippets"},callback = function()vim.b.autoformat = truevim.opt_local.expandtab = truevim.opt_local.tabstop = 4vim.opt_local.shiftwidth = 4vim.opt_local.softtabstop = 4end,
})

/home/louis/.clang-format

# SPDX-License-Identifier: GPL-2.0
# clang-format 配置,适用于 clang-format >= 11
---
# 与内核风格保持一致的基本设置
IndentWidth:                8     # 缩进宽度为 8 空格 :contentReference[oaicite:1]{index=1}
TabWidth:                   8     # Tab 宽度为 8 空格 :contentReference[oaicite:2]{index=2}
UseTab:                     Always # 永远使用 Tab 进行缩进 :contentReference[oaicite:3]{index=3}
ColumnLimit:                96    # 最大行宽 80 字符 :contentReference[oaicite:4]{index=4}
ContinuationIndentWidth:    8     # 换行缩进同样为 8 空格 :contentReference[oaicite:5]{index=5}# 括号和大括号的换行
BreakBeforeBraces:         Allman 
BraceWrapping:AfterFunction:            true  # 函数定义之后换行并缩进大括号 :contentReference[oaicite:6]{index=6}AfterControlStatement:    false # if/for/while 等语句不另起一行 :contentReference[oaicite:7]{index=7}# 空格和对齐
SpaceBeforeParens:          ControlStatementsExceptForEachMacros
PointerAlignment:           Right # 指针符号靠右,如 `int *ptr` :contentReference[oaicite:8]{index=8}
IndentCaseLabels:           false # switch 中的 case 与 switch 同级缩进 :contentReference[oaicite:9]{index=9}
IndentGotoLabels:           false # goto 标签与代码同级 :contentReference[oaicite:10]{index=10}
SpaceBeforeCpp11BracedList: true   # <-- 新增
SpacesInContainerLiterals:   true   # <-- 新增# 针对 for_each 宏的特殊处理
ForEachMacros:- 'for_each%'- '__for_each_%'- '__hlist_for_each_%'- '__map__for_each_%'- '__rq_for_each_%'
# 可根据子目录需要自行增加或删减 :contentReference[oaicite:11]{index=11}# include 排序与格式
SortIncludes:              false # 内核不自动排序 include :contentReference[oaicite:12]{index=12}# 注释与空行保留
MaxEmptyLinesToKeep:       1     # 最多保留 1 个空行 :contentReference[oaicite:13]{index=13}
ReflowComments:            false # 不自动折行注释 :contentReference[oaicite:14]{index=14}
AlignTrailingComments:Kind: AlwaysOverEmptyLines: 5
AlignConsecutiveAssignments: true
SpacesBeforeTrailingComments: 2

安装Lazyvim

git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git

清除

有时候配置neovim错误, 不知道哪里出错,可以先全部删除清空再重新配置。

sudo apt remove --purge neovim
sudo apt autoremove --purge
sudo rm -rf /opt/nvimxxxx    //自己从github上下载的nvim 源码rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
rm -rf ~/.cache/nvim
rm -rf ~/.config/lazyvim
rm -rf ~/.local/state/nvim
rm -rf ~/.vim
rm -rf ~/.vimrc
rm -rf ~/.nvim
rm -rf ~/.nvimrc
find ~/.local -type d -name '*nvim*' -exec rm -rf {} +
find ~/.cache -type d -name '*nvim*' -exec rm -rf {} +
http://www.xdnf.cn/news/418537.html

相关文章:

  • coze平台实现文生视频和图生视频(阿里云版)工作流
  • OpenCV进阶操作:风格迁移以及DNN模块解析
  • 【计算机视觉】OpenCV实战项目:基于OpenCV的车牌识别系统深度解析
  • Kafka、RabbitMQ、RocketMQ的区别
  • 加速AI在k8s上使用GPU卡
  • WPS一旦打开,就会修改默认打开方式,怎么解?
  • 【OpenCV】网络模型推理的简单流程分析(readNetFromONNX、setInput和forward等)
  • React+Webpack 脚手架、前端组件库搭建
  • Ansys 计算刚柔耦合矩阵系数
  • Linux之初见进程
  • 使用光标测量,使用 TDR 测量 pH 和 fF
  • day 24
  • 智能手表整机装配作业指导书(SOP)
  • Vue.js---分支切换与cleanup
  • 第六章 GPIO输入——按键检测
  • 工业4G路由器IR5000公交站台物联网应用解决方案
  • 游戏引擎学习第275天:将旋转和剪切传递给渲染器
  • 【Linux】简单设计libc库
  • Spring Boot之Web服务器的启动流程分析
  • Antd中Form详解:
  • Mapreduce初使用
  • 第四章 部件篇之按钮矩阵部件
  • 在Linux中使用 times函数 和 close函数 两种方式 打印进程时间。
  • 线代第二章矩阵第八节逆矩阵、解矩阵方程
  • 【计算机视觉】OpenCV项目实战:基于face_recognition库的实时人脸识别系统深度解析
  • 光谱相机的光电信号转换
  • 基于Java的家政服务平台设计与实现(代码+数据库+LW)
  • 游戏引擎学习第277天:稀疏实体系统
  • GNU Screen 曝多漏洞:本地提权与终端劫持风险浮现
  • 前端如何应对精确数字运算?用BigNumber.js解决JavaScript原生Number类型在处理大数或高精度计算时的局限性