# TNeoVim **Repository Path**: moieo/tneovim ## Basic Information - **Project Name**: TNeoVim - **Description**: NeoVim 常用开发环境的配置,已配置实现包括软件界面、语法高亮、语法纠正、语法补全、文件树、后台任务等功能,功能的实现均引用第三方插件实现,本项目将不同功能的插件配置成一套完整的开发编辑器。 - **Primary Language**: Lua - **License**: MulanPSL-2.0 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 4 - **Forks**: 1 - **Created**: 2023-06-21 - **Last Updated**: 2025-03-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 安装过程 ## 准备工作 想要使该配置正常工作,需要有 Nodejs v16 以上 及 Python3.7 以上的支持 安装所需的 Nodejs 包 prettier 用于格式化代码,eslint 用于 Nodejs 类项目的语法检查 ```bash npm install --global neovim prettier eslint ``` 安装所需的 Python 包 ```bash pip3 install pynvim ``` NeoVim 所有插件下载完成后在 NeoVim 执行 `:checkhealth` 检查是否缺失需要的软件包,缺失的软件包请自行安装 ## 安装 NeoVim Debian/Ubuntu ```bash sudo apt-get install neovim ``` RHEL/Fedora/CentOS ```bash sudo yum install neovim ``` Arch Linux ```bash sudo pacman -S neovim ``` ## 克隆项目 ```bash mkdir -p $HOME/.config git clone https://moieo@bitbucket.org/moieo/tneovim.git $HOME/.config/nvim ``` ## 首次启动 NeoVim ```bash nvim ``` 首次启动将下载需要的插件以及语法补全所需文件,请保持网络通畅 默认情况下,所有需要的文件都从 Github 克隆/下载 ## 更新/安装 LSP 环境 可以通过 Mason 来手动管理 LSP 环境,也可以打开指定语言的文件,然后执行 `:LspInstall` # 该配置支持的开发环境 根据自己目前的需求,配置完成后可以支持以下开发 | Python | C/C++ | Nodejs | | ------ | ----- | -------- | | Vue | React | Lua | | Golang | Shell | Java | | JSON | TOML | MarkDown | # 特别感谢 ## UI 相关插件 - [tokyonight](https://github.com/folke/tokyonight.nvim) - 现代化的暗色主题 - [nvim-web-devicons](https://github.com/kyazdani42/nvim-web-devicons) - 为文件提供图标支持 - [lualine.nvim](https://github.com/nvim-lualine/lualine.nvim) - 美观的状态栏 - [tabline.nvim](https://github.com/kdheepak/tabline.nvim) - 美观的标签页栏 - [indentLine](https://github.com/Yggdroot/indentLine) - 显示缩进对齐线 ## 工具类插件 - [overseer.nvim](https://github.com/stevearc/overseer.nvim) - 任务运行器,支持 VSCode tasks.json - [bufexplorer](https://github.com/jlanzarotta/bufexplorer) - 缓冲区管理器 - [fzf-lua](https://github.com/ibhagwan/fzf-lua) - 模糊查找器,用于快速搜索文件 - [nvim-terminal](https://github.com/s1n7ax/nvim-terminal) - 集成终端 - [nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua) - 文件树浏览器 - [vista.vim](https://github.com/liuchengxu/vista.vim) - 标签浏览器,显示代码结构 - [auto-pairs](https://github.com/jiangmiao/auto-pairs) - 自动配对括号和引号 ## LSP 语法补全插件 - [mason.nvim](https://github.com/williamboman/mason.nvim) - LSP 管理器 - [mason-lspconfig.nvim](https://github.com/williamboman/mason-lspconfig.nvim) - mason 和 lspconfig 的桥接 - [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) - LSP 配置工具 - [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) - 代码补全引擎 - [cmp-nvim-lsp](https://github.com/hrsh7th/cmp-nvim-lsp) - LSP 补全源 - [lspkind-nvim](https://github.com/onsails/lspkind-nvim) - 为补全添加 VSCode 风格图标 - [cmp-buffer](https://github.com/hrsh7th/cmp-buffer) - 从缓冲区补全 - [cmp-nvim-lua](https://github.com/hrsh7th/cmp-nvim-lua) - Lua API 补全 - [cmp-path](https://github.com/hrsh7th/cmp-path) - 文件路径补全 - [cmp-emoji](https://github.com/hrsh7th/cmp-emoji) - emoji 表情补全 - [cmp-cmdline](https://github.com/hrsh7th/cmp-cmdline) - 命令行补全 - [LuaSnip](https://github.com/L3MON4D3/LuaSnip) - 代码片段引擎 - [cmp_luasnip](https://github.com/saadparwaiz1/cmp_luasnip) - LuaSnip 补全源 - [friendly-snippets](https://github.com/rafamadriz/friendly-snippets) - 代码片段集合 - [trouble.nvim](https://github.com/folke/trouble.nvim) - 诊断列表 - [typescript-vim](https://github.com/leafgarland/typescript-vim) - TypeScript 语法支持 - [vim-json](https://github.com/leshill/vim-json) - JSON 语法支持 - [python-syntax](https://github.com/vim-python/python-syntax) - Python 语法高亮增强 - [vim-vue](https://github.com/posva/vim-vue) - Vue 语法支持 - [kotlin-vim](https://github.com/udalov/kotlin-vim) - Kotlin 语法支持 - [nvim-navic](https://github.com/SmiteshP/nvim-navic) - 代码导航栏 - [null-ls.nvim](https://github.com/jose-elias-alvarez/null-ls.nvim) - 代码格式化和诊断 - [plenary.nvim](https://github.com/nvim-lua/plenary.nvim) - Neovim Lua 工具库 - [vim-fish-syntax](https://github.com/khaveesh/vim-fish-syntax) - Fish shell 语法支持 - [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) - 语法高亮和代码分析 所有功能均为第三方开源插件,本项目只将功能组合。除以上例举外,还引用了许多其他开源项目 # 快捷键 ## 基础操作 | 按键 | 功能 | |------------|-------------------| | f | 打开/关闭文件树 | | z\ | 切换到下一个标签页 | | ztn | 创建新标签页 | | zs | 文件搜索 | | zb | 打开缓冲区浏览器 | | zfm | 格式化代码 | | \ | 终端模式退出 | ## 窗格操作 | 按键 | 功能 | |------------|-----------------| | z\ | 切换到下方窗格 | | z\ | 切换到上方窗格 | | z\ | 切换到左侧窗格 | | z\ | 切换到右侧窗格 | ## 任务管理 | 按键 | 功能 | |------------|-----------------| | ztt | 打开任务管理器 | | zto | 执行任务 | | ztc | 执行命令 | | zv | 显示语法树 | ## LSP 功能 | 按键 | 功能 | |-------------|------------------------| | gD | 跳转到声明 | | gd | 跳转到定义 | | K 或 gh | 显示悬浮文档 | | \D | 跳转到类型定义 | | \rn | 重命名变量 | | gr | 查看引用 | | \ca | 代码操作 | | gi | 跳转到实现 | | go | 显示诊断信息 | | gp | 跳转到上一个问题 | | gn | 跳转到下一个问题 | | gq | 显示位置列表 | # 关于 tasks.json 兼容 本配置,使用 `overseer.nvim` 来实现 兼容 `.vscode/tasks.json` 文件 具体文档请查看: # 已知问题解决方案 ## C/C++ 开发配置 ### 基础配置 请在 `$HOME/.clangd` 文件编辑如下内容: ```yaml CompileFlags: Add: ["-I/usr/include"] CompilationDatabase: build # 指定 compile_commands.json 所在目录 Diagnostics: UnusedIncludes: None InlayHints: BlockEnd: No Designators: No Enabled: Yes ParameterNames: No DeducedTypes: Yes TypeNameLimit: 20 ``` ### CMake 项目配置 1. 在项目根目录创建 build 目录: ```bash mkdir build && cd build ``` 2. 生成 compile_commands.json: ```bash cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. ``` 3. 返回项目根目录: ```bash cd .. ``` ### Makefile 项目配置 使用 Bear 工具生成 compile_commands.json: 1. 安装 Bear: ```bash # Debian/Ubuntu sudo apt install bear # Fedora sudo dnf install bear # Arch Linux sudo pacman -S bear ``` 2. 在项目根目录执行: ```bash mkdir build bear -- make -C build ``` 以上配置已在以下系统测试: - Fedora 41 - Ubuntu 22.04 - Arch Linux # 添加新的语言支持 1. 在 `lua/lsp/servers/init.lua` 中的 `ensure_installed` 和 `servers` 表中添加新的语言服务器 2. 如果需要特殊配置,在 `lua/lsp/servers` 目录下创建与语言服务器同名的配置文件 3. 配置文件示例: ```lua -- lua/lsp/servers/rust_analyzer.lua return { settings = { ["rust-analyzer"] = { diagnostics = { enable = true, }, }, }, } ``` # 支持的编程语言 | 语言 | LSP Server | 备注 | |-------------|-------------------------------|------------------------| | Lua | lua_ls | NeoVim 配置开发 | | Python | pyright | Python 开发 | | C/C++ | clangd | 需要 compile_commands.json | | Java | jdtls | Java 开发 | | TypeScript | ts_ls | TypeScript/JavaScript | | JSON | jsonls | JSON 文件编辑 | | YAML | yamlls | YAML 文件编辑 | | Bash | bashls | Shell 脚本开发 | | Go | gopls | Go 开发 | | Kotlin | kotlin_language_server | Kotlin 开发 | | Vue | volar | Vue 开发 | | HTML | html | HTML 开发 | | Perl | perlnavigator | Perl 开发 | | Rust | rust_analyzer | Rust 开发 | | CSS | cssls | CSS 开发 | | Docker | dockerls | Dockerfile | | GraphQL | graphql | GraphQL 开发 | | Markdown | marksman | Markdown 编辑 |