├── .after └── syntax │ └── qf.vim ├── .gitignore ├── .luarc.json ├── README.md ├── a.cpp ├── compile.sh ├── cover.png ├── dotfiles ├── .bashrc ├── .clang-format ├── .config │ ├── clangd │ │ └── config.yaml │ └── picom.conf ├── .gdbinit ├── .inputrc ├── .p10k.zsh ├── .zsh_aliases └── .zshrc ├── init.vim ├── lua └── archvim │ ├── config │ ├── aerial.lua │ ├── asynctasks.lua │ ├── auto-session.lua │ ├── autoclose.lua │ ├── autosave.lua │ ├── bufferline.lua │ ├── cmake-tools.lua │ ├── diagflow.lua │ ├── genius.lua │ ├── gitsigns.lua │ ├── hop.lua │ ├── lsp-signature.lua │ ├── lspconfig.lua │ ├── lspsaga.lua │ ├── lualine.lua │ ├── luasnip.lua │ ├── marks.lua │ ├── mason.lua │ ├── neoconf.lua │ ├── neodev.lua │ ├── neoformat.lua │ ├── neoline.lua │ ├── neovim-session-manager.lua │ ├── noice.lua │ ├── notify.lua │ ├── nvim-autopairs.lua │ ├── nvim-cmp.lua │ ├── nvim-comment.lua │ ├── nvim-dap.lua │ ├── nvim-gpt.lua │ ├── nvim-lint.lua │ ├── nvim-spectre.lua │ ├── nvim-surround.lua │ ├── nvim-tree.lua │ ├── nvim-treesitter.lua │ ├── nvim_context_vt.lua │ ├── overseer.lua │ ├── refactoring.lua │ ├── surround.lua │ ├── telescope.lua │ ├── toggleterm.lua │ ├── trouble.lua │ ├── twilight.lua │ ├── undotree.lua │ ├── which-key.lua │ ├── windline.lua │ └── zfvimim.lua │ ├── custom.lua │ ├── icons.lua │ ├── init.lua │ ├── mappings.lua │ ├── options.lua │ └── plugins.lua ├── scripts ├── customize_settings.sh ├── install_deps.sh ├── install_nvim.sh └── key_details.md └── todo.txt /.after/syntax/qf.vim: -------------------------------------------------------------------------------- 1 | syn match NonText "^||" 2 | syn match DiagnosticOk "\" 8 | syn match DiagnosticError "\" 9 | syn match DiagnosticWarn "\" 10 | syn match DiagnosticHint "-- .*$" 11 | " syn match Special "[:()&|<>\-+*\/]" 12 | " syn match Special "[:()&|<>]" 13 | syn match Function "['`‘][^'’]\+['’]" 14 | syn match DiagnosticWarn "\[-W[^\]]\+\]$" 15 | syn match NonText "(message):$" 16 | syn match CmpItemMenu "\^\~*" 17 | syn match NonText "\ .\+$" 19 | " syn match DiagnosticHint "\[\d\+\/\d\+\] \(Building\|Linking\) [A-Z]\+ \(object\|executable\)\> .\+$" 20 | syn match DiagnosticHint "\[\d\+\/\d\+\] .\+$" 21 | syn match NonText "\" 35 | " syn match Keyword "\<\(struct\|class\|template\|typename\|friend\|static\|inline\|thread_local\|const\|volatile\|throw\|operator\|typedef\|using\|namespace\|decltype\|public\|protected\|private\|constexpr\)\>" 36 | " syn match Constant '\" 37 | " syn match qfFileName "\([a-zA-Z0-9\._\-+]\+\/\)*[a-zA-Z0-9\._\-+]*\.[a-zA-Z][a-zA-Z0-9\._\-+]*|" 38 | " syn match DiagnosticUnderlineOk "\<\d\+\s|\s.*$" 39 | " syn match NonText "^||\s\+|\?" 40 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /plugin 2 | /pack 3 | /.build_cache 4 | /a.out 5 | -------------------------------------------------------------------------------- /.luarc.json: -------------------------------------------------------------------------------- 1 | { 2 | "runtime.version": "LuaJIT", 3 | "diagnostics": { 4 | "enable": true, 5 | "globals": [ 6 | "vim", 7 | "describe", 8 | "pending", 9 | "it", 10 | "before_each", 11 | "after_each", 12 | "setup", 13 | "teardown", 14 | "finally", 15 | "lfs" 16 | ] 17 | }, 18 | "workspace": { 19 | "library": [ 20 | "/usr/share/nvim/runtime/lua/" 21 | ], 22 | "checkThirdParty": false, 23 | "maxPreload": 2000, 24 | "preloadFileSize": 1000 25 | }, 26 | "telemetry.enable": false 27 | } 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 小彭老师自用 NeoVim 整合包 2 | 3 | 本整合包内含大量实用插件,包括智能补全、语法高亮、错误提示、快速跳转、全局搜索、集成终端、文件浏览、Git 支持等。且安装方便,小彭老师自用同款,纯 Lua 配置,是您基于 NeoVim 的 IDE 不二之选。 4 | 5 | ![图片演示](cover.png) 6 | 7 | ## 一键安装(推荐) 8 | 9 | 无需克隆本仓库,直接在命令行中输入以下命令即可安装: 10 | 11 | ```bash 12 | curl -SLf https://142857.red/files/nvimrc-install.sh | bash 13 | ``` 14 | 15 | 如果安装遇到问题,欢迎通过 [GitHub issue](github.com/archibate/vimrc/issues) 反映,我会尽快帮您解决。 16 | 17 | * 目前只支持 Linux 和 MacOS 系统,暂不支持 Wendous 系统。 18 | * 请勿以 root 身份运行!否则会为 root 安装 nvim 插件而不是当前用户,插件安装后仅对当前用户有效。 19 | * 您的系统中无需事先安装有 nvim,本整合包内部已经自带了最新版 nvim 的 AppImage,可无依赖直接运行。 20 | * 无需连接 GitHub,所有插件全部已经预下载在整合包内部,无需 GitHub 加速器! 21 | * 过程中会通过您系统的包管理器安装一些工具,所以只需确保包管理器的设置是国内源即可。 22 | * 为了能够使用补全,会为您安装如 clangd 一类的包,但即使其中一个安装失败,也不影响其他语言和编辑器整体的使用。 23 | * 安装脚本运行中可能产生一些冗余错误信息,属于正常现象,不影响使用,请忽视他们。 24 | 25 | 安装完成后,输入 `nvim` 即可使用,按 `q` 或 `:wqa` 即可退出。 26 | 27 | 如需更新,重新执行上面的一键安装命令即可。 28 | 29 | 推荐为您的终端安装 [Nerd Fonts](https://www.nerdfonts.com/) 字体,并把终端设置为该字体。然后在 `nvim` 中输入 `:lua require'archvim.options'.nerd_fonts = true`,这样就可以显示文件类型图标了。 30 | 31 | > 小彭老师用的是 JetBrainsMono Nerd Font Regular,字号 16,这是一款专为程序员打造的等宽字体。 32 | 33 | 如需自己定制插件参数、移除不想要的插件或添加更多插件:可以编辑 `~/.config/nvim/lua/archvim/plugins.lua`,里面有全部的插件列表,删除或添加即可。 34 | 35 | > 注意:删除或添加了新插件后,需要运行 `:PackerSync` 和 `:PackerCompile` 命令才能生效。 36 | 37 | ### 常见问题 38 | 39 | - Q: 不想要部分插件,或想安装其他插件? 40 | - A: 修改 [`~/.config/nvim/lua/archvim/plugins.lua`](lua/archvim/plugins.lua) 中的 `plugins` 列表即可。 41 | 42 | - Q: 不想要部分 LSP 服务器? 43 | - A: 修改 [`~/.config/nvim/lua/archvim/config/mason.lua`](lua/archvim/config/mason.lua) 中的 `ensure_installed` 字段即可。 44 | 45 | - Q: 不想要部分语法高亮? 46 | - A: 修改 [`~/.config/nvim/lua/archvim/config/tree-sitter.lua`](lua/archvim/config/tree-sitter.lua) 中的 `ensure_installed` 字段即可。 47 | 48 | - Q: 出现乱码,无法正确显示符号? 49 | - A: 安装 [Nerd Font](https://www.cnblogs.com/zi-wang/p/12566898.html) 字体,并把终端设置为该字体。然后在 `nvim` 中输入 `:lua require'archvim.options'.nerd_fonts = true`,重启,这样以后就可以正确显示文件类型图标了。如果不喜欢,那就 `:lua require'archvim.options'.nerd_fonts = false` 关闭。 50 | 51 | - Q: 打开 C/C++ 源码时不识别头文件目录,“飙红线”,怎么办? 52 | - A: 请先在 NeoVim 中用 `:CMakeGenerate` 命令配置项目!否则无法识别你 CMake 里的编译选项。如果一定要命令行构建,请给 `cmake` 指定 `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` 参数,这样 C++ 补全才能正常工作,详见下方的 “C/C++/CMake 配置” 章节。 53 | 54 | - Q: Inlay Hint 太烦太挡视线了!能否关闭? 55 | - A: `:lua require'archvim.options'.enable_inlay_hint = false`,重启,即可永久关闭。如需暂时开启和关闭,可以用 `gsi` 快捷键。 56 | 57 | - Q: 支持(非 Neo 的)Vim 吗? 58 | - A: 本分支只有 NeoVim 配置,对于来自 BV1H44y1V7DW 视频想领取老版 Vim 插件的同学,请移步 [main 分支](https://github.com/archibate/vimrc/tree/main)。 59 | 60 | ### 支持的 Linux 发行版 61 | 62 | - Arch Linux(亲测可用) 63 | - Manjano Linux (群友测试可用) 64 | - Ubuntu (亲测 20.04 可用) 65 | - Debian (理论可行,没有测试过) 66 | - Kali Linux (理论可行,没有测试过) 67 | - Raspbian (理论可行,没有测试过) 68 | - Fedora (感谢 @justiceeem 大佬) 69 | - OpenSUSE (感谢 @sleeplessai 大佬) 70 | - CentOS (感谢 @xxy-im 大佬) 71 | - Deepin (感谢 @zhangasia 大佬) 72 | - MacOS (感谢 @YangZ2020 测试确认) 73 | 74 | ## 开始上手 75 | 76 | ### 常用键位映射 77 | 78 | `i` `j` `k` `c` `d` `w` 等 Vim 原生键位不再赘述,此处仅介绍本插件整合包额外增加或不同的。 79 | 80 | 以下默认读者知晓 Vim 的四大模式:普通模式(NORMAL)、插入模式(INSERT)、可视模式(VISUAL)、终端插入模式(TERMINAL)。 81 | 82 | 不同模式下有独立的键位映射,以下除非特殊说明,默认指的是普通模式下的映射。 83 | 84 | #### 太长不看(简略版) 85 | 86 | **基本** 87 | 88 | - `jk` / `kj` / `` 回到普通模式 89 | - `q` / `:wq` / `ZZ` 保存并退出 90 | - `Q` 记录宏 91 | 92 | - `gl` / `$` 移动到行末尾 93 | - `gh` / `^` 移动到行开头(不包括空格) 94 | - `3gl` / `$2l` 移动到行末尾倒数第 3 个字符 95 | - `3gh` / `^2h` 移动到行开头倒数第 3 个字符 96 | 97 | - `` 向左移动若干格 98 | - `` 向下移动若干格 99 | - `` 向上移动若干格 100 | - `` 向右移动若干格 101 | - `` 当前所在行居中 102 | - `` 跳转到上若干个单词的开头 103 | - `` 跳转到下若干个单词的末尾 104 | - `` 跳转到下若干个单词的开头 105 | 106 | **跳转** 107 | 108 | - `gd` 跳转到定义 109 | - `gD` 跳转到声明 110 | - `gy` 跳转到变量类型的定义 111 | - `gY` 跳转到虚函数实现 112 | - `go` 头文件和源文件来回跳转 113 | 114 | - `gr` 寻找符号引用 115 | - `gz` 罗列所有相关信息(定义、引用等) 116 | 117 | - `gf` 打开光标下的文件名 118 | - `gF` 打开光标下的文件名并跳到右侧指定的行号 119 | - `gx` 打开光标下的网页链接 120 | 121 | - `` 跳转回来 122 | 123 | **重构** 124 | 125 | - `gcc` 注释/取消注释当前选中的代码/行 126 | - `gn` 重命名变量 127 | - `gw` 尝试自动修复问题 128 | - `g=` 自动格式化当前代码 129 | 130 | **预览** 131 | 132 | - `K` 悬浮窗查看文档 133 | - `gsf` 预览函数定义 134 | - `gsc` 预览类定义 135 | - `gsd` 预览语法错误 136 | 137 | **开关** 138 | 139 | - `gso` 打开大纲 140 | - `gsg` 打开 Git 面板 141 | - `gsp` 打开项目文件树 142 | - `gss` 查看所有静态语法错误 143 | - `gsl` 查看所有编译器报错 144 | - `gsi` 开关 Inlay Hint 145 | 146 | **标签页** 147 | 148 | - `` 或 `:wa` 一键保存所有打开的文件 149 | 150 | - `` 或 `gt` 切换到下一个标签页 151 | - `` 或 `gb` 切换到上一个标签页 152 | - `` 或 `g` 将当前标签页固定在最前 153 | 154 | - `` 或 `gT` 将当前标签页右移一位 155 | - `` 或 `gB` 将当前标签页左移一位 156 | - `` 或 `g` 关闭当前标签页 157 | 158 | - `` 或 `g` 关闭右侧所有标签页 159 | - `` 或 `g` 关闭左侧所有标签页 160 | - `` 或 `g` 关闭除当前标签页外所有 161 | 162 | - `g` 选择跳转到一个标签页 163 | 164 | **文本查找** 165 | 166 | - `,.` 当前文件中模糊查找 167 | - `,k` 当前项目中正则表达式查找 168 | 169 | - `,l` 当前项目中的所有文件 170 | - `,b` 当前 Vim 已打开文件 171 | - `,o` 最近打开过的历史文件 172 | 173 | - `,i` 当前所有加入 Git 仓库的文件 174 | - `,p` 当前 Git 有未提交修改的文件 175 | - `,c` 所有 Git 提交历史 176 | - `,v` 所有 Git 分支 177 | 178 | - `,L` 当前项目所有加入 CMake 的 `.cpp` 源文件 179 | - `,O` 当前项目所有 `CMakeLists.txt` 和 `.cmake` 文件 180 | 181 | - `,x` 当前文件中所有符号 182 | - `,j` 当前 Vim 跳转历史 183 | - `,m` 所有 `m` 创建过的书签 184 | 185 | - `,/` 历史 `/` 搜索记录 186 | - `,:` 历史执行过的 Vim 命令 187 | - `,;` 所有可用的 Vim 命令 188 | - `,?` 所有 Vim 帮助文档 189 | 190 | - `,a` 所有静态检查错误 191 | - `,q` 所有编译器报错 192 | - `,,` 多功能模糊查找 193 | 194 | **选择** 195 | 196 | - `vac` 选中当前类 197 | - `vic` 选中当前类体内 198 | - `vaf` 选中当前函数 199 | - `vif` 选中当前函数体 200 | - `vab` 选中当前块 201 | - `vib` 选中当前块中内容 202 | - `vad` 选中当前分支 203 | - `vid` 选中当前分支块或条件 204 | - `vae` 选中当前循环 205 | - `vie` 选中当前循环体 206 | - `vai` 选中当前函数调用语句 207 | - `vii` 选中当前函数调用语句的参数列表 208 | - `vap` 选中当前参数(包括空格和逗号) 209 | - `vip` 选中当前参数(不包括空格和逗号) 210 | - `vah` 选中当前赋值语句 211 | - `vih` 选中当前赋值语句中的左侧值 212 | - `var` 选中当前返回语句 213 | - `vir` 选中当前返回语句返回值 214 | - `vin` 选中当前数字 215 | - `vat` 选中当前注释块 216 | 217 | - `+` 扩大选择 218 | - `-` 缩小选择 219 | 220 | 举一反三:`dat` 删除当前注释块,`cip` 修改当前参数 221 | 222 | **移动** 223 | 224 | - `]c` 下一个类开头 225 | - `[c` 上一个类开头 226 | - `]C` 下一个类结尾 227 | - `[C` 上一个类结尾 228 | 229 | - `]f` 下一个函数开头 230 | - `[f` 上一个函数开头 231 | - `]F` 下一个函数结尾 232 | - `[F` 上一个函数结尾 233 | 234 | ...以此类推,所有英文字母同上“选择”所述... 235 | 236 | - `` 全屏任意移动 237 | 238 | **换位** 239 | 240 | - `mh` 左移参数 241 | - `ml` 右移参数 242 | - `mj` 下移当前语句 243 | - `mk` 上移当前语句 244 | - `maf` 下移当前函数 245 | - `mif` 上移当前函数 246 | - `mac` 下移当前类 247 | - `mic` 上移当前类 248 | 249 | **括号** 250 | 251 | 可视(VISUAL)模式中: 252 | 253 | - `s)` 给当前选中内容包上 `(选中内容)` 括号 254 | - `s}` 给当前选中内容包上 `{选中内容}` 括号 255 | - `s]` 给当前选中内容包上 `[选中内容]` 括号 256 | - `s>` 给当前选中内容包上 `<选中内容>` 尖括号 257 | - `s'` 给当前选中内容包上 `'选中内容'` 单引号 258 | - `s"` 给当前选中内容包上 `"选中内容"` 双引号 259 | - `stspan` 给当前选中内容包上 `选中内容` 标签 260 | - `sta href="b.html"` 给当前选中内容包上 `选中内容` 标签 261 | 262 | 普通(NORMAL)模式中: 263 | 264 | - `ysi` 添加括号 265 | - `cs` 改变括号 266 | - `ds` 删除括号 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | **窗口** 293 | 294 | - `` 关闭当前窗口 295 | 296 | - `` 移动到当前左侧的窗口 297 | - `` 移动到当前下方的窗口 298 | - `` 移动到当前上方的窗口 299 | - `` 移动到当前右侧的窗口 300 | 301 | - `` 将当前窗口向左移动 302 | - `` 将当前窗口向下移动 303 | - `` 将当前窗口向上移动 304 | - `` 将当前窗口向右移动 305 | 306 | - `` 横向切割当前窗口,变为上下两个 307 | - `` 纵向切割当前窗口,变为左右两个 308 | 309 | - `` 将当前窗口高度增加 1 格 310 | - `` 将当前窗口高度减少 1 格 311 | - `` 将当前窗口宽度增加 1 格 312 | - `` 将当前窗口宽度减少 1 格 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | **CMake 项目** 326 | 327 | - `cmc` 或 `:CMakeGenerate` 配置当前项目 328 | - `cmb` 或 `:CMakeBuild` 构建当前项目 329 | 330 | - `cmr` 或 `:CMakeRun` 运行当前项目 331 | - `cms` 或 `:CMakeStopRunner` 杀死当前终端中的正在运行的程序 332 | 333 | - `:CMakeSelectBuildDir` 选择构建目录 334 | - `:CMakeSelectBuildType` 选择构建类型(`Release` 或 `Debug`) 335 | - `:CMakeSelectLaunchTarget` 选择以后 `:CMakeRun` 要运行的目标 336 | 337 | **内置终端** 338 | 339 | - `` 或 `` 打开/关闭终端 340 | - `` 从终端模式(TERMINAL)中回到普通模式(NORMAL) 341 | - `p` 粘贴剪贴板中的命令 342 | - `i` 或 `a` 从普通模式回到终端模式 343 | 344 | - `1` 或 `1` 打开 1 号终端 345 | - `2` 或 `2` 打开 2 号终端 346 | - 以此类推 347 | 348 | - `` 将当前行的文本或选中的部分作为命令执行 349 | 350 | **文件树** 351 | 352 | - `y` 拷贝 353 | - `x` 剪切 354 | - `d` 删除 355 | - `p` 粘贴 356 | - `a` 创建 357 | 358 | ### C/C++/CMake 配置 359 | 360 | 建议使用本插件自带的 `cmake-tools` 插件的 `:CMakeGenerate` 和 `:CMakeBuild` 命令来构建项目。 361 | 362 | 这样是无需任何配置,所有 `CMakeLists.txt` 中配置的头文件都能找得到,语法高亮和代码提示就是正确的。 363 | 364 | 如果你想要手动命令行调用 `cmake`,那么也请指定 `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` 参数: 365 | 366 | ```bash 367 | cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON 368 | ``` 369 | 370 | 这会生成对 C++ 代码补全必不可少的 `build/compile_commands.json` 文件。 371 | 372 | 否则,本插件的语法高亮和代码提示插件将无法确定头文件目录,语法检测可能无法正常工作(俗称“飙红线”)。 373 | 374 | > `:CMakeGenerate` 实际上就是默认自带了 `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` 这个参数,建议始终通过 `:CMakeGenerate` 和 `:CMakeBuild` 来构建项目。 375 | 376 | 如果你用的是其他构建系统,可能需要自己在项目根目录下生成 `compile_commands.json` 文件。 377 | 378 | 如需指定没有 `compile_commands.json` 时默认的 Clangd 选项(单文件编译的情况),编辑文件 [`~/.config/clangd/config.yaml`](dotfiles/.config-clangd-config.yaml),内容为: 379 | 380 | ```yaml 381 | CompileFlags: 382 | Add: 383 | - --no-cuda-version-check 384 | - -D__clangd__ # 添加你的自定义选项 385 | Remove: 386 | - -forward-unknown-to-host-compiler 387 | - --expt-* 388 | - -gencode* 389 | - --generate-code* 390 | - -Xfatbin* 391 | - -arch=* 392 | - -rdc=* 393 | ``` 394 | 395 | ## 内含插件列表 396 | 397 | 完整插件列表,请查看 [`lua/archvim/plugins.lua`](lua/archvim/plugins.lua),你可以编辑该文件,从而修改配置或添加新的插件。 398 | 399 | ### 语法高亮支持 400 | 401 | ``` 402 | c,cpp,cuda,cmake,lua,python,html,javascript,css,json,bash,regex,markdown,glsl,vim,vimdoc 403 | ``` 404 | 405 | 你可以输入 `:TSInstall ` 来安装更多语言的语义高亮支持。 406 | 407 | ### 用于代码补全的 LSP 服务器 408 | 409 | ``` 410 | clangd,pyright,lua_ls 411 | ``` 412 | 413 | 可以通过执行 `:Mason` 或修改 [`lua/archvim/config/lspconfig.lua`](lua/archvim/config/lspconfig.lua) 来安装更多语言的 LSP 补全支持。 414 | 415 | ### 脚本会创建或修改的文件 416 | 417 | ``` 418 | /usr/bin/nvim 419 | /usr/bin/.nvim.appimage.noextract 420 | ~/.config/nvim 421 | ~/.local/share/nvim 422 | ~/.config/clangd 423 | ~/.clang-format 424 | ``` 425 | 426 | * 如果脚本发现您已经存在 `~/.config/nvim` 目录,则会将其备份至 `~/.config/.nvim.backup.随机数字`。 427 | * 如果脚本发现您已经存在 `/usr/bin/nvim` 可执行文件,但版本不足 v0.10.0,则会用本整合包内置的 nvim.AppImage 替换他。 428 | * 请勿以 sudo 模式运行本脚本,本脚本内部自动会在需要时采取 sudo。 429 | 430 | > 欲了解本整合包安装与打包原理,请看 [`.compile.sh`](.compile.sh)。 431 | 432 | ## 手动安装(不推荐) 433 | 434 | 如果你有稳定的 GitHub 外网连接,并且已经自己安装好了 NeoVim 版本 v0.10.0 以上,也可以尝试运行以下命令手动安装: 435 | 436 | ```bash 437 | test -f ~/.config/nvim && mv ~/.config/nvim{,.backup} 438 | git clone https://github.com/archibate/vimrc ~/.config/nvim 439 | git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim 440 | bash ~/.config/nvim/install_deps.sh 441 | ``` 442 | 443 | > 手动安装的好处是你以后只需 `git pull` 就可以更新上小彭老师最新改动,缺点是他不会自动为你安装依赖项,也不会帮你升级 NeoVim 版本,不建议使用。 444 | 445 | 初次进入会有一些报错,若提示你包缺失,输入 `:PackerInstall` 即可自动安装全部所需的包(需要连接 GitHub),重启后稍等片刻,即可开始使用 nvim。 446 | 447 | ## 其他软件的配置文件参考 448 | 449 | [`dotfiles/`](dotfiles/) 文件夹下有其他小彭老师自用的配置文件,欢迎参考。 450 | 451 | ```bash 452 | $ ls -A dotfiles 453 | .bashrc .clang-format .gdbinit .inputrc .zshrc .config/ 454 | ``` 455 | 456 | 其中 `.clang-format` 是我推荐的 C/C++ 代码格式化方案,如果你是一键安装脚本那已经自动帮你拷贝到 `~` 了。 457 | 458 | 安装以后,当你在一个 C++ 源码中运行 `:Neoformat` 命令时,会采用其中的方案。但如果当前项目根目录下有 `.clang-format` 文件,则优先采用当前项目的。 459 | 460 | ## 旧版本 Vimrc 461 | 462 | 本分支为最新 NeoVim 版插件整合包,对于来自 BV1H44y1V7DW 视频想领取老版 Vim 插件的同学,请移步 [main 分支](https://github.com/archibate/vimrc/tree/main)。 463 | 464 | 另外,NeoVim(`~/.config/nvim`)和 Vim(`~/.vim`)的配置完全独立,互不干扰,所以你可以同时拥有两个配置,取决于你启动的是 `nvim` 还是 `vim`。 465 | 466 | ## 配色方案 467 | 468 | ```vim 469 | :colorscheme zephyr " 默认 470 | :colorscheme gruvbox 471 | :colorscheme nord 472 | ``` 473 | 474 | ## 以下为写给小彭老师自己看的 475 | 476 | 通过运行 `./.compile.sh` 生成 `.build_cache/nvimrc-install.sh` 这个一键安装脚本(约 25 MiB)后,我会把他发布到 142857.red。 477 | 478 | 我会运行 `docker run -v $PWD/.build_cache:/mnt -it --rm ubuntu:20.04` 来测试兼容性。 479 | 480 | 在 Ubuntu 容器中,我会用 `NODEP=1 bash nvimrc-install.sh` 避免使用包管理器,加速安装,方便测试。 481 | 482 | TODO: 适配 nvim v0.10.0? 483 | -------------------------------------------------------------------------------- /a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | void quickSort(int arr[], int low, int high); 5 | 6 | int main() { 7 | // Test code 8 | int arr[] = {10, 7, 8, 9, 1, 5}; 9 | int n = sizeof(arr)/sizeof(arr[0]); 10 | quickSort(arr, 0, n-1); 11 | for (int i=0; i < n; i++) 12 | cout << arr[i] << " "; 13 | cout << endl; 14 | return 0; 15 | } 16 | 17 | int partition(int arr[], int low, int high); 18 | 19 | void quickSort(int arr[], int low, int high) { 20 | if (low < high) { 21 | int pi = partition(arr, low, high); 22 | quickSort(arr, low, pi - 1); 23 | quickSort(arr, pi + 1, high); 24 | } 25 | } 26 | 27 | int partition(int arr[], int low, int high) { 28 | int pivot = arr[high]; 29 | int i = (low - 1); 30 | for (int j = low; j <= high - 1; j++) { 31 | if (arr[j] < pivot) { 32 | i++; 33 | std::swap(arr[i], arr[j]); 34 | } 35 | } 36 | std::swap(arr[i + 1], arr[high]); 37 | return (i + 1); 38 | } 39 | 40 | -------------------------------------------------------------------------------- /compile.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | cd "$(dirname "$0")" 3 | if [ "x$ARCHIBATE_COMPUTER" = "x" ]; then 4 | echo "-- WARNING: This script is used for compiling bundle, not for end-users!" 5 | echo "-- WARNING: End users should use this command to install:" 6 | echo "-- 警告: 此脚本仅用于编译插件包,而非末端用户!" 7 | echo "-- 警告: 末端用户请使用此命令安装:" 8 | echo "curl -SLf https://142857.red/files/nvimrc-install.sh | bash" 9 | exit 1 10 | fi 11 | unset ARCHIBATE_COMPUTER 12 | export ARCHIBATE_COMPUTER 13 | compress=z 14 | version_min=090 15 | treesitters=(c cpp cuda cmake lua python html javascript css json bash regex markdown diff glsl vim vimdoc) 16 | commands=(sudo base64 tar mktemp cat tee rm mkdir test cp mv stat grep echo uname) 17 | 18 | cache="$PWD/.build_cache" 19 | payload="$cache"/archvim-release.tar.gz 20 | script="$cache"/nvimrc-install.sh 21 | 22 | mkdir -p "$cache" 23 | nvim --headless --cmd "let g:archvim_predownload=2 | let g:archvim_predownload_cachedir='$cache/archvim-build'" -c 'q' 24 | git --version > /dev/null 25 | rm -rf "$cache"/archvim-release 26 | mkdir -p "$cache"/archvim-release 27 | cp -r ./lua ./init.vim ./scripts ./dotfiles "$cache"/archvim-release 28 | sed -i "s/\"let g:archvim_predownload=1/let g:archvim_predownload=1/" "$cache"/archvim-release/init.vim 29 | rm -rf "$cache"/archvim-release/lua/archvim/predownload 30 | cp -r "$cache"/archvim-build/predownload "$cache"/archvim-release/lua/archvim 31 | rm -rf "$payload" 32 | cd "$cache"/archvim-release 33 | mkdir -p "$cache"/archvim-release/nvim-treesitter-parser 34 | for x in ${treesitters[@]}; do 35 | cp ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/parser/"$x".so "$cache"/archvim-release/nvim-treesitter-parser 36 | done 37 | for x in "$cache"/archvim-release/nvim-treesitter-parser/*.so; do 38 | strip -s "$x" 39 | done 40 | cp -r ~/.local/share/nvim/mason/registries/github/mason-org/mason-registry "$cache"/archvim-release 41 | test -f "$cache"/archvim-nvim.appimage || curl -L https://github.com/neovim/neovim/releases/latest/download/nvim.appimage -o "$cache"/archvim-nvim.appimage 42 | cp "$cache"/archvim-nvim.appimage "$cache"/archvim-release/nvim.appimage 43 | chmod u+x nvim.appimage 44 | tar -${compress}cf "$payload" . 45 | cd "$(dirname "$0")" 46 | rm -rf "$cache"/archvim-release 47 | 48 | # https://stackoverflow.com/questions/29418050/package-tar-gz-into-a-shell-script 49 | printf "#!/bin/bash 50 | set -e 51 | echo '-- Welcome to the ArchVim installation script' 52 | echo '-- 欢迎使用小彭老师 ArchVim 一键安装脚本' 53 | which ${commands[*]} > /dev/null || (echo \"ERROR: One of the following command(s) not found: ${commands[*]}\" && exit 1) 54 | tmpdir=\"\$(mktemp -d)\" 55 | tmpzip=\"\$(mktemp)\" 56 | rm -rf \$tmpdir 57 | mkdir -p \$tmpdir 58 | echo '-- Fetching bundled data...' 59 | echo '-- 正在下载插件包,请稍等...' 60 | cat > \$tmpzip << __ARCHVIM_PAYLOAD_EOF__\n" > "$script" 61 | 62 | base64 "$payload" >> "$script" 63 | 64 | printf "\n__ARCHVIM_PAYLOAD_EOF__ 65 | cd \$tmpdir 66 | echo '-- Extracting bundled data...' 67 | base64 -d < \$tmpzip | tar -${compress}x 68 | test -f ./scripts/install_deps.sh || echo \"ERROR: cannot extract file, make sure you have base64 and tar working\" 69 | echo '-- Checking NeoVim version...' 70 | if which nvim; then 71 | stat \"\$(which nvim)\" || true 72 | sudo chmod +x \"\$(which nvim)\" || true 73 | version=\"1\$(nvim --version | head -n1 | cut -f2 -dv | sed s/\\\\.//g)\" 74 | else 75 | version=0 76 | fi 77 | (which nvim >/dev/null 2>/dev/null && [ \"\$version\" -ge 1$version_min ]) || bash ./scripts/install_nvim.sh || echo -e \"\\n\\nERROR: cannot install NeoVim >= 0.9.1! Consider install it manually...\\n错误:无法自动安装 NeoVim 0.9.1 以上的版本!您可能需要手动安装一下……\\n\\n\" 78 | nvim --version 79 | if [ -d ~/.config/nvim ]; then 80 | echo \"-- Backup existing config to ~/.config/.nvim.backup.\$\$...\" 81 | mv ~/.config/nvim ~/.config/.nvim.backup.\$\$ 82 | fi 83 | echo '-- Copying to ~/.config/nvim...' 84 | mkdir -p ~/.config 85 | rm -rf ~/.config/nvim 86 | cp -r . ~/.config/nvim 87 | if [ \"x\$NODEP\" = \"x\" ]; then 88 | echo '-- Installing dependencies...' 89 | bash ~/.config/nvim/scripts/install_deps.sh || echo -e \"\\n\\n--\\n--\\n-- WARNING: some dependency installation failed, please check your internet connection.\n-- If you see this message, please report the full terminal output to archibate by opening GitHub issues.\\n-- ArchVim can still run without those dependencies, though.\\n-- You can always try re-run dependency installation by running: bash ~/.config/nvim/scripts/install_deps.sh\\n\\n--\\n--\\n-- 警告: 某些依赖项安装失败,请检查包管理器是否配置为国内源并有网络连接。\\n-- ArchVim 仍然可以正常运行,但是可能会缺少某些功能。\\n-- 如果你看到本消息,请通过 GitHub 向小彭老师反馈并贴上终端的完整输出。\\n-- 修复网络问题后,你也可以手动再次尝试安装依赖项:bash ~/.config/nvim/scripts/install_deps.sh\\n--\\n--\\n\\n\" 90 | fi 91 | echo '-- Synchronizing packer.nvim...' 92 | # rm -rf ~/.local/share/nvim/site/pack/packer 93 | nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerSync' 94 | nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerClean' 95 | # nvim --headless -c 'autocmd User PackerComplete quitall' -c 'PackerCompile' 96 | echo '-- Copying language supports...' 97 | mkdir -p ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/parser 98 | mv ~/.config/nvim/nvim-treesitter-parser/*.so ~/.local/share/nvim/site/pack/packer/start/nvim-treesitter/parser/ 99 | if [ \"x\$(uname -sm)\" != \"xLinux x86_64\" ]; then 100 | echo 'WARNING: Not x86_64 linux, may need manually run :TSInstall cpp later!' 101 | fi 102 | rm -rf ~/.config/nvim/nvim-treesitter-parser 103 | echo '-- Copying mason registries...' 104 | mkdir -p ~/.local/share/nvim/mason/github/mason-org/mason-registry 105 | mv ~/.config/nvim/mason-registry/* ~/.local/share/nvim/mason/github/mason-org/mason-registry/ 106 | rmdir ~/.config/nvim/mason-registry 107 | echo '-- Copying clangd configurations...' 108 | if [ ! -f ~/.config/clangd/config.yaml ]; then 109 | mkdir -p ~/.config/clangd/ 110 | ln -sf ~/.config/nvim/dotfiles/.config/clangd/config.yaml ~/.config/clangd/config.yaml 111 | fi 112 | if [ ! -f ~/.clang-format ]; then 113 | ln -sf ~/.config/nvim/dotfiles/.clang-format ~/.clang-format 114 | fi 115 | echo '-- Verifying treesitters...' 116 | (nvim --headless -c \"TSInstallInfo\" -c 'sleep 1 | q!' 2>&1 | grep -v 'not installed') || echo 'no installed treesitters?' 117 | if [ \"x\$(uname -sm)\" != \"xLinux x86_64\" ]; then 118 | for x in ${treesitters[*]}; do 119 | nvim --headless -c \"TSUpdateSync \$x\" -c 'sleep 1 | q!' 120 | done 121 | nvim --headless -c \"TSInstallInfo\" -c 'sleep 1 | q!' 122 | fi 123 | echo '-- Finishing installation...' 124 | rm -rf \$tmpdir \$tmpzip 125 | cd ~/.config/nvim 126 | bash ~/.config/nvim/scripts/customize_settings.sh || true 127 | 128 | echo 129 | echo \"--\" 130 | echo \"--\" 131 | echo \"-- There might be some errors or warnings generated above, that doesn't effect use!\" 132 | echo \"-- Ignore these messages, as long as you can start nvim, your installation is done.\" 133 | echo \"-- All OK, ArchVim plugins installed into ~/.config/nvim, now run 'nvim' to play.\" 134 | echo \"-- run into any trouble? Feel free to contact me via the GitHub link below.\" 135 | echo \"-- https://github.com/archibate/vimrc/issues\" 136 | echo \"--\" 137 | echo \"-- To update, just download this script again and run.\" 138 | echo \"-- If you manually added any plugins, run :PackerSync and :PackerCompile to apply.\" 139 | echo \"-- To uninstall, just remove the ~/.config/nvim directory.\" 140 | if [ -f ~/.config/.nvim.backup.\$\$ ]; then 141 | echo \"-- Need your old nvim config back? We've backup that: ~/.config/nvim.backup.\$\$.\" 142 | fi 143 | echo \"--\" 144 | echo \"-- You may run :checkhealth to check if Neovim is working well.\" 145 | echo \"-- You may run :Mason or :TSInstallInfo to check for installed language supports.\" 146 | echo \"--\" 147 | echo \"--\" 148 | echo \"-- 上面有时可能会有一些报错和警告,请忽略,这对正常使用没有任何影响!\" 149 | echo \"-- 只要你能启动 'nvim' 且无报错弹窗,就说明你的 NeoVim 就已经安装成功。\" 150 | echo \"-- 欢迎向我反馈各种问题和建议:https://github.com/archibate/vimrc/issues\" 151 | echo \"--\" 152 | echo \"-- 如需更新,只需重新下载这个脚本并运行即可,会自动覆盖老的版本。\" 153 | echo \"-- 如果手动添加了新插件,记得 :PackerSync 和 :PackerCompile 才能生效。\" 154 | echo \"-- 如需卸载本插件包,只需删除 ~/.config/nvim 文件夹。\" 155 | if [ -f ~/.config/.nvim.backup.\$\$ ]; then 156 | echo \"-- 想恢复旧配置?把本脚本自动备份的 ~/.config/.nvim.backup.\$\$ 移动回 ~/.config/nvim 即可。\" 157 | fi 158 | echo \"--\" 159 | echo \"-- 你可以运行 :checkhealth 来检查 NeoVim 是否工作正常。\" 160 | echo \"-- 也可以运行 :Mason 和 :TSInstallInfo 检查本脚本为您安装了哪些语言支持。\" 161 | \n" >> "$script" 162 | 163 | rm "$payload" 164 | chmod +x "$script" 165 | 166 | echo -- finished with "$script" 167 | if [ "x$1" != "x" ]; then 168 | echo -- deploying to https://142857.red/nvimrc-install.sh 169 | scp "$cache"/nvimrc-install.sh root@142857.red:/var/www/html/files/nvimrc-install.sh 170 | fi 171 | -------------------------------------------------------------------------------- /cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/archibate/vimrc/2cf70d83ee26e6e2a0e07f87118b7b861e218f8f/cover.png -------------------------------------------------------------------------------- /dotfiles/.bashrc: -------------------------------------------------------------------------------- 1 | export PATH="$PATH:$HOME/.local/bin" 2 | [[ -f ~/.bashenv ]] && source ~/.bashenv 3 | [[ $- == *i* ]] || return 4 | 5 | export LANG=C.UTF-8 6 | 7 | alias grep='grep --color=auto' 8 | alias ls='ls --color=auto' 9 | alias la='ls -la' 10 | alias l='ls -lt' 11 | alias s='ls' 12 | alias gs='git status' 13 | alias ga='git add --all' 14 | alias gad='git add' 15 | alias gc='git commit -m' 16 | alias gco='git checkout' 17 | alias gcm='git commit' 18 | alias gca='git commit --amend' 19 | alias gq='git pull' 20 | alias gk='git reset' 21 | alias gkh='git reset --hard' 22 | alias gkha='git reset --hard HEAD^' 23 | alias gp='git push' 24 | alias gg='git switch' 25 | alias ggo='git switch -c' 26 | alias grs='git restore --staged' 27 | alias grc='git rm --cached' 28 | alias gr='git restore' 29 | alias gd='git diff' 30 | alias gdc='git diff --cached' 31 | alias gda='git diff HEAD^' 32 | alias gm='git merge' 33 | alias gl='git log' 34 | alias gll='git log --graph --oneline --decorate' 35 | alias gt='git stash' 36 | alias gtp='git stash pop' 37 | alias gcl='git clone' 38 | alias gcl1='git clone --depth=1' 39 | alias gsmu='git submodule update --init --recursive' 40 | alias g='git' 41 | alias p='python' 42 | alias b='nvim' 43 | alias sup='sudo pacman' 44 | 45 | if [[ -f /usr/share/git/completion/git-prompt.sh ]]; then 46 | source /usr/share/git/completion/git-prompt.sh 47 | else 48 | __git_ps1() { 49 | true 50 | } 51 | fi 52 | 53 | __exit_status() { 54 | local x="$?" 55 | if [[ "x$x" != "x0" ]]; then 56 | printf "$1" "$x" 57 | fi 58 | } 59 | __afb1="$(tput bold)$(tput setaf 1)" 60 | __afb4="$(tput bold)$(tput setaf 4)" 61 | __af7="$(tput setaf 7)" 62 | __cuf999="$(tput cuf 999)" 63 | __cub999="$(tput cub 999)" 64 | __cub1="$(tput cub 1)" 65 | __af6="$(tput setaf 6)" 66 | __af5="$(tput setaf 5)" 67 | __af4="$(tput setaf 4)" 68 | __af3="$(tput setaf 3)" 69 | __af2="$(tput setaf 2)" 70 | __af1="$(tput setaf 1)" 71 | __rst="$(tput sgr0)" 72 | 73 | __bash_root_pid="${BASHPID}" 74 | __cmd_start() { 75 | date +%s.%N > "/dev/shm/${USER}.bashtime.${__bash_root_pid}" 76 | } 77 | __cmd_end() { 78 | file="/dev/shm/${USER}.bashtime.${__bash_root_pid}" 79 | if [[ -f "${file}" ]]; then 80 | endtime="$(date +%s.%N)" 81 | starttime="$(< "${file}")" 82 | rm "${file}" 83 | x="$(echo "m=$endtime-$starttime;s=2;if(m>=10)s=1;h=0.5;scale=s+1;t=1000;if(m<0)h=-0.5;a=m*t+h;scale=s;a=a/t;if(a>0.1)a;" | bc)" 84 | if [[ "$x" == .* ]]; then 85 | x="0$x" 86 | fi 87 | if [ "x$x" != "x" ]; then 88 | printf "$1" "$x" 89 | fi 90 | fi 91 | } 92 | 93 | __mem_usage() { 94 | echo "$[100 - $(awk '/MemFree/{print $2}' /proc/meminfo) * 100 / $(awk '/MemTotal/{print $2}' /proc/meminfo)]%" 95 | } 96 | 97 | export PS1='\[${__rst}\]$(__exit_status "\[${__afb1}\]%s\[${__rst}\] ")$(__cmd_end "\[${__af6}\]%ss\[${__rst}\] ")\[${__afb4}\]\W\[${__rst}\]$(__git_ps1 " \[${__af2}\](%s)\[${__rst}\]") \[${__af3}\]\$\[${__rst}\] ' 98 | export PS0='$(__cmd_start)\[${__rst}\]' 99 | 100 | eval "$(fzf --bash)" 101 | 102 | # export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix' 103 | # export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" 104 | export FZF_DEFAULT_OPTS='--bind "tab:down" --bind "btab:up" --cycle --reverse --walker=file,dir,follow --scheme=path' 105 | export FZF_COMPLETION_TRIGGER="**" 106 | export FZF_COMPLETION_AUTO_COMMON_PREFIX=true 107 | export FZF_COMPLETION_AUTO_COMMON_PREFIX_PART=true 108 | 109 | # _fzf_compgen_path() { 110 | # fd "$1" --hidden --type f --strip-cwd-prefix --follow 111 | # } 112 | # 113 | # _fzf_compgen_dir() { 114 | # fd "$1" --hidden --type d --strip-cwd-prefix --follow 115 | # } 116 | 117 | # _fzf_compgen_history() { 118 | # local output opts script 119 | # script='BEGIN { getc; $/ = "\n\t"; $HISTCOUNT = $ENV{last_hist} + 1 } s/^[ *]//; print $HISTCOUNT - $. . "\t$_" if !$seen{$_}++' 120 | # output=$(set +o pipefail; builtin fc -lnr -2147483648 | last_hist=$(HISTTIMEFORMAT='' builtin history 1) command perl -n -e "$script") || return 121 | # echo "${output#*$'\t'}" 122 | # } 123 | 124 | _fzf_comprun() { 125 | local command=$1 126 | shift 127 | case "$command" in 128 | export|unset) fzf --preview "eval 'echo \$'{}" "$@" ;; 129 | ssh|telnet) fzf --preview 'ping -c3 {}' "$@" ;; 130 | *) fzf --preview '([[ -f {} ]] && bat --style=changes --color=always {}) || ([[ -d {} ]] && ls --color=always -lA {})' "$@" ;; 131 | esac 132 | } 133 | 134 | # __fzf_compfile() { 135 | # if [[ "x$1" == "x_EmptycmD_" ]]; then 136 | # COMP_WORDS=() 137 | # else 138 | # _fzf_complete --reverse -- "$@" < <(_fzf_compgen_path) 139 | # fi 140 | # } 141 | 142 | # __fzf_comphist() { 143 | # COMP_WORDS=() 144 | # # if [[ "x$1" == "x_EmptycmD_" ]]; then 145 | # # echo ".[$COMP_WORDS]" >&2 146 | # # fi 147 | # # _fzf_complete --reverse -- "" < <(builtin history | tac | command sed '/^[[:space:]]*$/d' | command sed 's/^\s\s[0-9]\+\s\s//' | command sed '/^\s/d' | uniq) 148 | # # echo ".[$COMP_WORDS]" >&2 149 | # } 150 | 151 | complete -D -F _fzf_path_completion -o default -o bashdefault _fzf_path_completion 152 | # complete -I -F __fzf_compcomd -o default -o bashdefault __fzf_compcomd 153 | # complete -E -F __fzf_comphist -o default -o bashdefault __fzf_comphist 154 | 155 | __j_cd() { 156 | builtin cd "$@" || return 157 | if [[ "$OLDPWD" != "$PWD" ]]; then 158 | [[ -f ~/.bash_history_cd ]] && sed -i "/^$(printf '%s\n' "$PWD" | sed -e 's/[]\/$*.^[]/\\&/g')$/d" ~/.bash_history_cd 159 | echo "$PWD" >> ~/.bash_history_cd 160 | [[ -f .bash_localrc ]] && source .bash_localrc 161 | [[ -f venv/bin/activate ]] && source venv/bin/activate 162 | true 163 | fi 164 | } 165 | 166 | __j_fzf() { 167 | file="/dev/shm/${USER}.fzf-${RANDOM}.${__bash_root_pid}" 168 | if [[ "$(tee $file | wc -l)" -le 1 ]]; then 169 | cat $file 170 | else 171 | fzf --reverse < $file 172 | fi 173 | } 174 | 175 | j() { 176 | [[ "$#" -ne 0 ]] && __j_cd "$@" 2> /dev/null && return 177 | if [[ -f ~/.bash_history_cd ]]; then 178 | local dir="$(cat ~/.bash_history_cd | grep -Gv "^$(printf '%s\n' "$PWD" | sed -e 's/[]$*.^[]/\\&/g')$" | grep -G -- "$1[^/]*$" | __j_fzf)" 179 | if [[ -n "$dir" ]]; then 180 | __j_cd "$dir" 181 | fi 182 | fi 183 | } 184 | 185 | cd() { 186 | __j_cd "$@" 187 | } 188 | 189 | if (( BASH_VERSINFO[0] >= 4 )); then 190 | 191 | __toggle_sudo() { 192 | if [[ -z $READLINE_LINE ]]; then 193 | READLINE_LINE="$(fc -ln -1 | command sed 's/^[[:space:]]\{1,\}//')" 194 | READLINE_POINT=${#READLINE_LINE} 195 | [[ "$READLINE_LINE" = 'sudo '* ]] && return 196 | fi 197 | if [[ "$READLINE_LINE" = 'sudo '* ]]; then 198 | READLINE_LINE="${READLINE_LINE#sudo }" 199 | ((READLINE_POINT -= 5)) 200 | else 201 | READLINE_LINE="sudo $READLINE_LINE" 202 | ((READLINE_POINT += 5)) 203 | fi 204 | ((READLINE_POINT < 0)) && READLINE_POINT=0 205 | } 206 | 207 | bind -m vi-insert -x '"\C-x": __toggle_sudo' 208 | 209 | __toggle_complete() { 210 | if [[ -z $READLINE_LINE ]] || [[ "$READLINE_LINE" != *" "* ]] || [[ "$READLINE_LINE" == *'$'* ]]; then 211 | __dismiss_complete 212 | return 213 | fi 214 | # if [[ -z $READLINE_LINE ]]; then 215 | # READLINE_LINE="$(fc -ln -1 | command sed 's/^[[:space:]]\{1,\}//')" 216 | # READLINE_POINT=${#READLINE_LINE} 217 | # return 218 | # fi 219 | if [[ "$READLINE_LINE" = *"$FZF_COMPLETION_TRIGGER" ]]; then 220 | READLINE_LINE="${READLINE_LINE%"$FZF_COMPLETION_TRIGGER"}" 221 | READLINE_POINT=${#READLINE_LINE} 222 | elif [[ "$READLINE_LINE" = *"$FZF_COMPLETION_TRIGGER"\ ]]; then 223 | READLINE_LINE="${READLINE_LINE%"$FZF_COMPLETION_TRIGGER "}" 224 | READLINE_POINT=${#READLINE_LINE} 225 | else 226 | READLINE_LINE="$READLINE_LINE$FZF_COMPLETION_TRIGGER" 227 | READLINE_POINT=${#READLINE_LINE} 228 | fi 229 | } 230 | 231 | __dismiss_complete() { 232 | if [[ "$READLINE_LINE" = *\ ]]; then 233 | READLINE_LINE="${READLINE_LINE%\ }" 234 | READLINE_POINT=${#READLINE_LINE} 235 | fi 236 | if [[ "$READLINE_LINE" = *"$FZF_COMPLETION_TRIGGER" ]]; then 237 | READLINE_LINE="${READLINE_LINE%"$FZF_COMPLETION_TRIGGER"}" 238 | READLINE_POINT=${#READLINE_LINE} 239 | fi 240 | } 241 | 242 | bind -m vi-insert '"\e[1T": complete' 243 | bind -m vi-insert -x '"\e[2T": __toggle_complete' 244 | bind -m vi-insert '"\e[3T": redraw-current-line' 245 | bind -m vi-insert -x '"\e[4T": __dismiss_complete' 246 | bind -m vi-insert 'Tab: "\e[2T\e[1T"' 247 | bind -m vi-insert '"\e[0n": "\e[3T\e[4T"' 248 | 249 | else 250 | # bind -m vi-insert '"\e[Z": complete' 251 | # bind -m vi-insert 'Tab: "'$FZF_COMPLETION_TRIGGER'\e[Z"' 252 | bind -m vi-insert 'Tab: complete' 253 | bind -m vi-insert '"\e[0n": redraw-current-line' 254 | fi 255 | 256 | set -o vi 257 | bind -m vi-command '"\e": "\C-k\C-u\C-k\C-u\C-d"' 258 | bind -m vi-command 'q: "\C-d"' 259 | bind -m vi-command 'K: history-search-backward' 260 | bind -m vi-command 'J: history-search-forward' 261 | bind -m vi-command 'H: beginning-of-line' 262 | bind -m vi-command 'L: end-of-line' 263 | bind -m vi-command '"\C-r": vi-redo' 264 | bind -m vi-insert '"\C-l": clear-screen' 265 | bind -m vi-insert '"\M-[A": previous-history' 266 | bind -m vi-insert '"\M-[B": next-history' 267 | bind -m vi-insert '"\M-[D": backward-char' 268 | bind -m vi-insert '"\M-[C": forward-char' 269 | bind -m vi-insert '"\e[1;5A": history-search-backward' 270 | bind -m vi-insert '"\e[1;5B": history-search-forward' 271 | bind -m vi-insert '"\e[1;5D": backward-word' 272 | bind -m vi-insert '"\e[1;5C": forward-word' 273 | bind -m vi-insert '"\C-a": beginning-of-line' 274 | bind -m vi-insert '"\C-e": end-of-line' 275 | bind -m vi-insert '"\C-k": kill-line' 276 | bind -m vi-insert '"\C-u": backward-kill-line' 277 | # bind -m vi-insert '"\C-q": kill-word' 278 | # bind -m vi-insert '"\C-w": backward-kill-word' 279 | bind -m vi-insert '"\C-w": " \edBxi"' 280 | bind -m vi-insert '"\C-p": history-search-backward' 281 | bind -m vi-insert '"\C-n": history-search-forward' 282 | bind -m vi-insert '"\C-b": backward-word' 283 | bind -m vi-insert '"\C-f": forward-word' 284 | bind 'set completion-ignore-case on' 285 | bind 'set show-mode-in-prompt on' 286 | bind 'set vi-ins-mode-string \1\e[6 q\2' 287 | bind 'set vi-cmd-mode-string \1\e[2 q'"$__cuf999$__cub1$__af7:)$__rst$__cub999"'\2' 288 | bind 'set keyseq-timeout 10' 289 | bind 'set match-hidden-files off' 290 | bind 'set bell-style visible' 291 | bind 'set colored-completion-prefix on' 292 | bind 'set show-all-if-unmodified on' 293 | 294 | [[ -f .bash_localrc ]] && source .bash_localrc 295 | true 296 | -------------------------------------------------------------------------------- /dotfiles/.clang-format: -------------------------------------------------------------------------------- 1 | # https://clang.llvm.org/docs/ClangFormatStyleOptions.html 2 | BasedOnStyle: LLVM 3 | Standard: c++20 4 | IndentWidth: 4 5 | AccessModifierOffset: -4 6 | ColumnLimit: 80 7 | DeriveLineEnding: false 8 | UseCRLF: false 9 | LineEnding: LF 10 | InsertNewlineAtEOF: true 11 | UseTab: Never 12 | TabWidth: 4 13 | ContinuationIndentWidth: 4 14 | Cpp11BracedListStyle: true 15 | IndentCaseLabels: false 16 | IndentCaseBlocks: false 17 | IndentRequiresClause: true 18 | RequiresExpressionIndentation: OuterScope 19 | IntegerLiteralSeparator: 20 | Binary: 4 21 | BinaryMinDigits: 6 22 | Decimal: 3 23 | DecimalMinDigits: 7 24 | Hex: 4 25 | HexMinDigits: 9 26 | AlignConsecutiveAssignments: 27 | Enabled: false 28 | AcrossEmptyLines: false 29 | AcrossComments: false 30 | AlignCompound: true 31 | PadOperators: false 32 | AlignConsecutiveDeclarations: 33 | Enabled: false 34 | AcrossEmptyLines: false 35 | AcrossComments: false 36 | AlignCompound: true 37 | AlignConsecutiveMacros: 38 | Enabled: true 39 | AcrossEmptyLines: false 40 | AcrossComments: false 41 | AlignConsecutiveShortCaseStatements: 42 | Enabled: true 43 | AcrossEmptyLines: false 44 | AcrossComments: false 45 | AlignCaseColons: false 46 | AlignEscapedNewlines: DontAlign 47 | RequiresClausePosition: OwnLine 48 | BreakBeforeConceptDeclarations: Always 49 | IndentAccessModifiers: false 50 | AllowShortIfStatementsOnASingleLine: false 51 | AllowShortEnumsOnASingleLine: false 52 | AllowAllParametersOfDeclarationOnNextLine: true 53 | AllowShortBlocksOnASingleLine: Empty 54 | AllowShortCaseLabelsOnASingleLine: true 55 | AllowShortLambdasOnASingleLine: Inline 56 | AllowAllArgumentsOnNextLine: true 57 | AllowShortFunctionsOnASingleLine: Empty 58 | AlignOperands: true 59 | LambdaBodyIndentation: Signature 60 | NamespaceIndentation: None 61 | PackConstructorInitializers: CurrentLine 62 | EmptyLineBeforeAccessModifier: LogicalBlock 63 | EmptyLineAfterAccessModifier: Never 64 | IndentWrappedFunctionNames: false 65 | InsertBraces: true 66 | FixNamespaceComments: true 67 | SpaceAfterTemplateKeyword: true 68 | SpaceBeforeAssignmentOperators: true 69 | SpaceBeforeCaseColon: false 70 | SpaceBeforeCpp11BracedList: false 71 | SpaceBeforeRangeBasedForLoopColon: false 72 | SpaceBeforeInheritanceColon: true 73 | SpaceBeforeCtorInitializerColon: true 74 | SpaceBeforeParens: ControlStatements 75 | SpaceInEmptyBlock: false 76 | AlwaysBreakTemplateDeclarations: true 77 | # BreakTemplateDeclarations: Yes 78 | SeparateDefinitionBlocks: Always 79 | BreakBeforeBraces: Custom 80 | BraceWrapping: 81 | AfterEnum: false 82 | AfterClass: false 83 | AfterStruct: false 84 | AfterUnion: false 85 | AfterFunction: false 86 | AfterControlStatement: false 87 | AfterCaseLabel: false 88 | AfterNamespace: false 89 | AfterExternBlock: false 90 | BeforeLambdaBody: false 91 | BeforeWhile: false 92 | IndentBraces: false 93 | SplitEmptyFunction: false 94 | SplitEmptyRecord: false 95 | SplitEmptyNamespace: false 96 | BeforeCatch: false 97 | BeforeElse: false 98 | CompactNamespaces: false 99 | BreakAfterAttributes: Never 100 | IndentPPDirectives: AfterHash 101 | PPIndentWidth: 1 102 | AlignTrailingComments: 103 | Kind: Always 104 | OverEmptyLines: 1 105 | KeepEmptyLinesAtTheStartOfBlocks: false 106 | KeepEmptyLinesAtEOF: false 107 | MaxEmptyLinesToKeep: 1 108 | SortIncludes: CaseInsensitive 109 | IncludeBlocks: Merge 110 | SortUsingDeclarations: LexicographicNumeric 111 | DerivePointerAlignment: false 112 | PointerAlignment: Right 113 | ReferenceAlignment: Pointer 114 | SpaceAroundPointerQualifiers: After 115 | ReflowComments: true 116 | QualifierAlignment: Custom 117 | QualifierOrder: ['static', 'inline', 'friend', 'constexpr', 'type', 'const', 'volatile'] 118 | IncludeCategories: 119 | - Regex: 'std\.hpp>$' 120 | Priority: 1 121 | - Regex: '.*' 122 | Priority: 2 123 | -------------------------------------------------------------------------------- /dotfiles/.config/clangd/config.yaml: -------------------------------------------------------------------------------- 1 | # 把本文件放到 ~/.config/clangd/config.yaml 2 | CompileFlags: 3 | Add: 4 | - --no-cuda-version-check 5 | - -Wno-unknown-warning-option 6 | - -D__clangd__ # 添加你的自定义选项 7 | # - -fgnuc-version=12.3.1 8 | Remove: 9 | - -mlongcalls 10 | - -fno-shrink-wrap 11 | - -fno-tree-switch-conversion 12 | - -fstrict-volatile-bitfields 13 | - -forward-unknown-to-host-compiler 14 | - -expt-* 15 | - --expt-* 16 | - -gencode* 17 | - --generate-code* 18 | - -Xfatbin* 19 | - -arch=* 20 | - -rdc=* 21 | - -mno-* 22 | InlayHints: 23 | ParameterNames: Yes 24 | DeducedTypes: Yes 25 | -------------------------------------------------------------------------------- /dotfiles/.config/picom.conf: -------------------------------------------------------------------------------- 1 | ################################# 2 | # Shadows # 3 | ################################# 4 | 5 | 6 | # Enabled client-side shadows on windows. Note desktop windows 7 | # (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, 8 | # unless explicitly requested using the wintypes option. 9 | # 10 | # shadow = false 11 | shadow = true; 12 | 13 | # The blur radius for shadows, in pixels. (defaults to 12) 14 | # shadow-radius = 12 15 | shadow-radius = 7; 16 | shadow-radius = 14; #4k 17 | 18 | # The opacity of shadows. (0.0 - 1.0, defaults to 0.75) 19 | # shadow-opacity = .75 20 | 21 | # The left offset for shadows, in pixels. (defaults to -15) 22 | # shadow-offset-x = -15 23 | shadow-offset-x = -7; 24 | shadow-offset-x = -14; #4k 25 | 26 | # The top offset for shadows, in pixels. (defaults to -15) 27 | # shadow-offset-y = -15 28 | shadow-offset-y = -7; 29 | shadow-offset-y = -14; #4k 30 | 31 | # Red color value of shadow (0.0 - 1.0, defaults to 0). 32 | # shadow-red = 0 33 | 34 | # Green color value of shadow (0.0 - 1.0, defaults to 0). 35 | # shadow-green = 0 36 | 37 | # Blue color value of shadow (0.0 - 1.0, defaults to 0). 38 | # shadow-blue = 0 39 | 40 | # Hex string color value of shadow (#000000 - #FFFFFF, defaults to #000000). This option will override options set shadow-(red/green/blue) 41 | # shadow-color = "#000000" 42 | 43 | # Specify a list of conditions of windows that should have no shadow. 44 | # 45 | # examples: 46 | # shadow-exclude = "n:e:Notification"; 47 | # 48 | # shadow-exclude = [] 49 | shadow-exclude = [ 50 | "name = 'Notification'", 51 | "window_type = 'popup_menu'", 52 | "class_g = 'Conky'", 53 | "class_g ?= 'Notify-osd'", 54 | "class_g = 'Cairo-clock'", 55 | "class_g ?= 'xfce4-screenshooter'", 56 | "_GTK_FRAME_EXTENTS@:c", 57 | ]; 58 | 59 | # Specify a list of conditions of windows that should have no shadow painted over, such as a dock window. 60 | # clip-shadow-above = [] 61 | 62 | # Specify a X geometry that describes the region in which shadow should not 63 | # be painted in, such as a dock window region. Use 64 | # shadow-exclude-reg = "x10+0+0" 65 | # for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. 66 | # 67 | # shadow-exclude-reg = "" 68 | 69 | # Crop shadow of a window fully on a particular monitor to that monitor. This is 70 | # currently implemented using the X RandR extension. 71 | # crop-shadow-to-monitor = false 72 | 73 | 74 | ################################# 75 | # Fading # 76 | ################################# 77 | 78 | 79 | # Fade windows in/out when opening/closing and when opacity changes, 80 | # unless no-fading-openclose is used. 81 | # fading = false 82 | fading = true; 83 | 84 | # Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) 85 | # fade-in-step = 0.028 86 | fade-in-step = 0.08; 87 | 88 | # Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) 89 | # fade-out-step = 0.03 90 | fade-out-step = 0.025; 91 | 92 | # The time between steps in fade step, in milliseconds. (> 0, defaults to 10) 93 | # fade-delta = 10 94 | fade-delta = 5 95 | 96 | # Specify a list of conditions of windows that should not be faded. 97 | # fade-exclude = [] 98 | fade-exclude = [] 99 | 100 | # Do not fade on window open/close. 101 | # no-fading-openclose = false 102 | 103 | # Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc. 104 | # no-fading-destroyed-argb = false 105 | 106 | 107 | ################################# 108 | # Transparency / Opacity # 109 | ################################# 110 | 111 | 112 | # Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) 113 | # inactive-opacity = 1 114 | # inactive-opacity = 0.9; 115 | 116 | # Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) 117 | # frame-opacity = 1.0 118 | # frame-opacity = 0.9; 119 | frame-opacity = 1.0; 120 | 121 | # Let inactive opacity set by -i override the '_NET_WM_WINDOW_OPACITY' values of windows. 122 | # inactive-opacity-override = true 123 | inactive-opacity-override = false; 124 | 125 | # Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) 126 | # active-opacity = 1.0 127 | 128 | # Dim inactive windows. (0.0 - 1.0, defaults to 0.0) 129 | # inactive-dim = 0.0 130 | 131 | # Specify a list of conditions of windows that should never be considered focused. 132 | # focus-exclude = [] 133 | focus-exclude = [ "class_g = 'Cairo-clock'" ]; 134 | 135 | # Use fixed inactive dim value, instead of adjusting according to window opacity. 136 | # inactive-dim-fixed = 1.0 137 | 138 | # Specify a list of opacity rules, in the format `PERCENT:PATTERN`, 139 | # like `50:name *= "Firefox"`. picom-trans is recommended over this. 140 | # Note we don't make any guarantee about possible conflicts with other 141 | # programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. 142 | # example: 143 | # opacity-rule = [ "80:class_g = 'URxvt'" ]; 144 | # 145 | # opacity-rule = [] 146 | 147 | 148 | ################################# 149 | # Corners # 150 | ################################# 151 | 152 | # Sets the radius of rounded window corners. When > 0, the compositor will 153 | # round the corners of windows. Does not interact well with 154 | # `transparent-clipping`. 155 | corner-radius = 12 156 | corner-radius = 24 #4k 157 | 158 | # Exclude conditions for rounded corners. 159 | rounded-corners-exclude = [ 160 | "window_type = 'dock'", 161 | "window_type = 'desktop'", 162 | "window_type = 'popup_menu'", 163 | ]; 164 | 165 | 166 | ################################# 167 | # Background-Blurring # 168 | ################################# 169 | 170 | 171 | # Parameters for background blurring, see the *BLUR* section for more information. 172 | # blur-method = 173 | # blur-size = 12 174 | # 175 | # blur-deviation = false 176 | # 177 | # blur-strength = 5 178 | 179 | # Blur background of semi-transparent / ARGB windows. 180 | # Bad in performance, with driver-dependent behavior. 181 | # The name of the switch may change without prior notifications. 182 | # 183 | # blur-background = false 184 | blur-background = true 185 | 186 | # Blur background of windows when the window frame is not opaque. 187 | # Implies: 188 | # blur-background 189 | # Bad in performance, with driver-dependent behavior. The name may change. 190 | # 191 | # blur-background-frame = false 192 | 193 | 194 | # Use fixed blur strength rather than adjusting according to window opacity. 195 | # blur-background-fixed = false 196 | 197 | 198 | # Specify the blur convolution kernel, with the following format: 199 | # example: 200 | # blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; 201 | # 202 | # blur-kern = "" 203 | # blur-kern = "3x3box"; 204 | 205 | 206 | # Exclude conditions for background blur. 207 | # blur-background-exclude = [] 208 | blur-background-exclude = [ 209 | "window_type = 'desktop'", 210 | "window_type = 'popup_menu'", 211 | "_GTK_FRAME_EXTENTS@:c", 212 | "class_g ?= 'xfce4-screenshooter'", 213 | "class_g ?= 'screenkey'", 214 | ]; 215 | 216 | ################################# 217 | # General Settings # 218 | ################################# 219 | 220 | # Enable remote control via D-Bus. See the man page for more details. 221 | # dbus = true 222 | 223 | # Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers. 224 | # daemon = false 225 | 226 | # Specify the backend to use: `xrender`, `glx`, `egl` or `xr_glx_hybrid`. 227 | # `xrender` is the default one. 228 | # 229 | backend = "glx"; 230 | # backend = "xrender"; 231 | 232 | # Use higher precision during rendering, and apply dither when presenting the 233 | # rendered screen. Reduces banding artifacts, but might cause performance 234 | # degradation. Only works with OpenGL. 235 | dithered-present = false; 236 | 237 | # Enable/disable VSync. 238 | # vsync = false 239 | vsync = false; 240 | 241 | # Try to detect WM windows (a non-override-redirect window with no 242 | # child that has 'WM_STATE') and mark them as active. 243 | # 244 | # mark-wmwin-focused = false 245 | mark-wmwin-focused = true; 246 | 247 | # Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused. 248 | # mark-ovredir-focused = false 249 | mark-ovredir-focused = true; 250 | 251 | # Try to detect windows with rounded corners and don't consider them 252 | # shaped windows. The accuracy is not very high, unfortunately. 253 | # 254 | # detect-rounded-corners = false 255 | detect-rounded-corners = true; 256 | 257 | # Detect '_NET_WM_WINDOW_OPACITY' on client windows, useful for window managers 258 | # not passing '_NET_WM_WINDOW_OPACITY' of client windows to frame windows. 259 | # 260 | # detect-client-opacity = false 261 | detect-client-opacity = true; 262 | 263 | # Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window, 264 | # rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy, 265 | # provided that the WM supports it. 266 | # 267 | # use-ewmh-active-win = false 268 | 269 | # Unredirect all windows if a full-screen opaque window is detected, 270 | # to maximize performance for full-screen windows. Known to cause flickering 271 | # when redirecting/unredirecting windows. 272 | # 273 | # unredir-if-possible = false 274 | 275 | # Delay before unredirecting the window, in milliseconds. Defaults to 0. 276 | # unredir-if-possible-delay = 0 277 | 278 | # Conditions of windows that shouldn't be considered full-screen for unredirecting screen. 279 | # unredir-if-possible-exclude = [] 280 | 281 | # Use 'WM_TRANSIENT_FOR' to group windows, and consider windows 282 | # in the same group focused at the same time. 283 | # 284 | # detect-transient = false 285 | detect-transient = true; 286 | 287 | # Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same 288 | # group focused at the same time. This usually means windows from the same application 289 | # will be considered focused or unfocused at the same time. 290 | # 'WM_TRANSIENT_FOR' has higher priority if detect-transient is enabled, too. 291 | # 292 | # detect-client-leader = false 293 | 294 | # Resize damaged region by a specific number of pixels. 295 | # A positive value enlarges it while a negative one shrinks it. 296 | # If the value is positive, those additional pixels will not be actually painted 297 | # to screen, only used in blur calculation, and such. (Due to technical limitations, 298 | # with use-damage, those pixels will still be incorrectly painted to screen.) 299 | # Primarily used to fix the line corruption issues of blur, 300 | # in which case you should use the blur radius value here 301 | # (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, 302 | # with a 5x5 one you use `--resize-damage 2`, and so on). 303 | # May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly. 304 | # 305 | # resize-damage = 1 306 | 307 | # Specify a list of conditions of windows that should be painted with inverted color. 308 | # Resource-hogging, and is not well tested. 309 | # 310 | # invert-color-include = [] 311 | 312 | # GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. 313 | # Might cause incorrect opacity when rendering transparent content (but never 314 | # practically happened) and may not work with blur-background. 315 | # My tests show a 15% performance boost. Recommended. 316 | # 317 | glx-no-stencil = true; 318 | 319 | # GLX backend: Avoid rebinding pixmap on window damage. 320 | # Probably could improve performance on rapid window content changes, 321 | # but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). 322 | # Recommended if it works. 323 | # 324 | # glx-no-rebind-pixmap = false 325 | 326 | # Disable the use of damage information. 327 | # This cause the whole screen to be redrawn every time, instead of the part of the screen 328 | # has actually changed. Potentially degrades the performance, but might fix some artifacts. 329 | # The opposing option is use-damage 330 | # 331 | # no-use-damage = false 332 | use-damage = true; 333 | 334 | # Use X Sync fence to sync clients' draw calls, to make sure all draw 335 | # calls are finished before picom starts drawing. Needed on nvidia-drivers 336 | # with GLX backend for some users. 337 | # 338 | # xrender-sync-fence = false 339 | 340 | # GLX backend: Use specified GLSL fragment shader for rendering window 341 | # contents. Read the man page for a detailed explanation of the interface. 342 | # 343 | # window-shader-fg = "default" 344 | 345 | # Use rules to set per-window shaders. Syntax is SHADER_PATH:PATTERN, similar 346 | # to opacity-rule. SHADER_PATH can be "default". This overrides window-shader-fg. 347 | # 348 | # window-shader-fg-rule = [ 349 | # "my_shader.frag:window_type != 'dock'" 350 | # ] 351 | 352 | # Force all windows to be painted with blending. Useful if you 353 | # have a glx-fshader-win that could turn opaque pixels transparent. 354 | # 355 | # force-win-blend = false 356 | 357 | # Do not use EWMH to detect fullscreen windows. 358 | # Reverts to checking if a window is fullscreen based only on its size and coordinates. 359 | # 360 | # no-ewmh-fullscreen = false 361 | 362 | # Dimming bright windows so their brightness doesn't exceed this set value. 363 | # Brightness of a window is estimated by averaging all pixels in the window, 364 | # so this could comes with a performance hit. 365 | # Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0) 366 | # 367 | # max-brightness = 1.0 368 | 369 | # Make transparent windows clip other windows like non-transparent windows do, 370 | # instead of blending on top of them. 371 | # 372 | # transparent-clipping = false 373 | 374 | # Specify a list of conditions of windows that should never have transparent 375 | # clipping applied. Useful for screenshot tools, where you need to be able to 376 | # see through transparent parts of the window. 377 | # 378 | # transparent-clipping-exclude = [] 379 | 380 | # Set the log level. Possible values are: 381 | # "trace", "debug", "info", "warn", "error" 382 | # in increasing level of importance. Case doesn't matter. 383 | # If using the "TRACE" log level, it's better to log into a file 384 | # using *--log-file*, since it can generate a huge stream of logs. 385 | # 386 | # log-level = "debug" 387 | log-level = "warn"; 388 | 389 | # Set the log file. 390 | # If *--log-file* is never specified, logs will be written to stderr. 391 | # Otherwise, logs will to written to the given file, though some of the early 392 | # logs might still be written to the stderr. 393 | # When setting this option from the config file, it is recommended to use an absolute path. 394 | # 395 | # log-file = "/path/to/your/log/file" 396 | 397 | # Show all X errors (for debugging) 398 | # show-all-xerrors = false 399 | 400 | # Write process ID to a file. 401 | # write-pid-path = "/path/to/your/log/file" 402 | 403 | # Window type settings 404 | # 405 | # 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: 406 | # "unknown", "desktop", "dock", "toolbar", "menu", "utility", 407 | # "splash", "dialog", "normal", "dropdown_menu", "popup_menu", 408 | # "tooltip", "notification", "combo", and "dnd". 409 | # 410 | # Following per window-type options are available: :: 411 | # 412 | # fade, shadow::: 413 | # Controls window-type-specific shadow and fade settings. 414 | # 415 | # opacity::: 416 | # Controls default opacity of the window type. 417 | # 418 | # focus::: 419 | # Controls whether the window of this type is to be always considered focused. 420 | # (By default, all window types except "normal" and "dialog" has this on.) 421 | # 422 | # full-shadow::: 423 | # Controls whether shadow is drawn under the parts of the window that you 424 | # normally won't be able to see. Useful when the window has parts of it 425 | # transparent, and you want shadows in those areas. 426 | # 427 | # clip-shadow-above::: 428 | # Controls whether shadows that would have been drawn above the window should 429 | # be clipped. Useful for dock windows that should have no shadow painted on top. 430 | # 431 | # redir-ignore::: 432 | # Controls whether this type of windows should cause screen to become 433 | # redirected again after been unredirected. If you have unredir-if-possible 434 | # set, and doesn't want certain window to cause unnecessary screen redirection, 435 | # you can set this to `true`. 436 | # 437 | wintypes: 438 | { 439 | tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; }; 440 | dock = { shadow = false; clip-shadow-above = true; } 441 | dnd = { shadow = false; } 442 | popup_menu = { opacity = 1.0; } 443 | dropdown_menu = { opacity = 1.0; } 444 | }; 445 | 446 | blur: 447 | { 448 | method = "gaussian"; 449 | size = 17; 450 | size = 34; #4k 451 | # size = 0; # none 452 | deviation = 9.0; 453 | deviation = 18.0; #4k 454 | }; 455 | -------------------------------------------------------------------------------- /dotfiles/.gdbinit: -------------------------------------------------------------------------------- 1 | set confirm off 2 | # set debuginfod enabled off 3 | set auto-load safe-path / 4 | set pagination off 5 | -------------------------------------------------------------------------------- /dotfiles/.inputrc: -------------------------------------------------------------------------------- 1 | # set editing-mode vi 2 | # $if mode=vi 3 | # set keymap vi-command 4 | # K: history-search-backward 5 | # J: history-search-forward 6 | # H: beginning-of-line 7 | # L: end-of-line 8 | # "\C-r": vi-redo 9 | # set keymap vi-insert 10 | # # these are for vi-insert mode 11 | # Tab: complete 12 | # "\e[Z": "**\t" 13 | # "\C-l": clear-screen 14 | # "\M-[A": previous-history 15 | # "\M-[B": next-history 16 | # "\M-[D": backward-char 17 | # "\M-[C": forward-char 18 | # "\C-a": beginning-of-line 19 | # "\C-e": end-of-line 20 | # "\C-k": kill-line 21 | # "\C-u": backward-kill-line 22 | # "\C-q": kill-word 23 | # "\C-w": backward-kill-word 24 | # "\C-p": history-search-backward 25 | # "\C-n": history-search-forward 26 | # "\C-b": backward-word 27 | # "\C-f": forward-word 28 | # $endif 29 | # set completion-ignore-case on 30 | # set show-mode-in-prompt on 31 | # set vi-ins-mode-string \1\e[6 q\2 32 | # set vi-cmd-mode-string \1\e[2 q\2 33 | # set keyseq-timeout 10 34 | # set match-hidden-files off 35 | # set bell-style visible 36 | # set colored-completion-prefix on 37 | # set show-all-if-unmodified on 38 | -------------------------------------------------------------------------------- /dotfiles/.zsh_aliases: -------------------------------------------------------------------------------- 1 | [[ -f ~/.zshenv ]] && source ~/.zshenv 2 | [[ $- == *i* ]] || exit 3 | 4 | export LANG=C.UTF-8 5 | 6 | alias grep='grep --color=auto' 7 | alias ls='ls --color=auto' 8 | alias la='ls -la' 9 | alias l='ls -lt' 10 | alias s='ls' 11 | alias gs='git status' 12 | alias ga='git add --all' 13 | alias gad='git add' 14 | alias gc='git commit -m' 15 | alias gco='git checkout' 16 | alias gcm='git commit' 17 | alias gca='git commit --amend' 18 | alias gq='git pull' 19 | alias gk='git reset' 20 | alias gkh='git reset --hard' 21 | alias gkha='git reset --hard HEAD^' 22 | alias gp='git push' 23 | alias gg='git switch' 24 | alias ggo='git switch -c' 25 | alias grs='git restore --staged' 26 | alias grc='git rm --cached' 27 | alias gr='git restore' 28 | alias gd='git diff' 29 | alias gdc='git diff --cached' 30 | alias gda='git diff HEAD^' 31 | alias gm='git merge' 32 | alias gl='git log' 33 | alias gll='git log --graph --oneline --decorate' 34 | alias gt='git stash' 35 | alias gtp='git stash pop' 36 | alias gcl='git clone' 37 | alias gcl1='git clone --depth=1' 38 | alias gsmu='git submodule update --init --recursive' 39 | alias g='git' 40 | alias p='python' 41 | alias b='nvim' 42 | alias sup='sudo pacman' 43 | alias h='history | tail' 44 | 45 | function extract { 46 | if [ -z "$1" ]; then 47 | echo "Usage: extract ." 48 | else 49 | if [ -f $1 ]; then 50 | case $1 in 51 | *.tar.bz2) tar xvjf $1 ;; 52 | *.tar.gz) tar xvzf $1 ;; 53 | *.tar.xz) tar xvJf $1 ;; 54 | *.lzma) unlzma $1 ;; 55 | *.bz2) bunzip2 $1 ;; 56 | *.rar) unrar x -ad $1 ;; 57 | *.gz) gunzip $1 ;; 58 | *.tar) tar xvf $1 ;; 59 | *.tbz2) tar xvjf $1 ;; 60 | *.tgz) tar xvzf $1 ;; 61 | *.zip) unzip $1 ;; 62 | *.Z) uncompress $1 ;; 63 | *.7z) 7z x $1 ;; 64 | *.xz) unxz $1 ;; 65 | *.exe) cabextract $1 ;; 66 | *) echo "extract: '$1' - unknown archive method" ;; 67 | esac 68 | else 69 | echo "$1 - file does not exist" 70 | fi 71 | fi 72 | } 73 | 74 | function abspath() { 75 | if [ -d "$1" ]; then 76 | echo "$(cd $1; pwd)" 77 | elif [ -f "$1" ]; then 78 | if [[ $1 == */* ]]; then 79 | echo "$(cd ${1%/*}; pwd)/${1##*/}" 80 | else 81 | echo "$(pwd)/$1" 82 | fi 83 | fi 84 | } 85 | -------------------------------------------------------------------------------- /dotfiles/.zshrc: -------------------------------------------------------------------------------- 1 | [[ $- == *i* ]] || return 2 | 3 | P10K=1 4 | 5 | if [[ "x$P10K" != "x" ]] && [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then 6 | source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" 7 | fi 8 | 9 | # Znap packages manager 10 | [[ -r ~/Codes/repos/znap/znap.zsh ]] || 11 | git clone --depth 1 -- \ 12 | https://github.com/marlonrichert/zsh-snap.git ~/Codes/repos/znap 13 | source ~/Codes/repos/znap/znap.zsh # Start Znap 14 | 15 | # Path to your oh-my-zsh installation. 16 | # export ZSH="/home/bate/.oh-my-zsh" 17 | 18 | # Set name of the theme to load --- if set to "random", it will 19 | # load a random theme each time oh-my-zsh is loaded, in which case, 20 | # to know which specific one was loaded, run: echo $RANDOM_THEME 21 | # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 22 | ZSH_THEME="robbyrussell" 23 | 24 | # Set list of themes to pick from when loading at random 25 | # Setting this variable when ZSH_THEME=random will cause zsh to load 26 | # a theme from this variable instead of looking in $ZSH/themes/ 27 | # If set to an empty array, this variable will have no effect. 28 | # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) 29 | 30 | # Uncomment the following line to use case-sensitive completion. 31 | # CASE_SENSITIVE="true" 32 | 33 | # Uncomment the following line to use hyphen-insensitive completion. 34 | # Case-sensitive completion must be off. _ and - will be interchangeable. 35 | # HYPHEN_INSENSITIVE="true" 36 | 37 | # Uncomment one of the following lines to change the auto-update behavior 38 | # zstyle ':omz:update' mode disabled # disable automatic updates 39 | # zstyle ':omz:update' mode auto # update automatically without asking 40 | # zstyle ':omz:update' mode reminder # just remind me to update when it's time 41 | 42 | # Uncomment the following line to change how often to auto-update (in days). 43 | # zstyle ':omz:update' frequency 13 44 | 45 | # Uncomment the following line if pasting URLs and other text is messed up. 46 | # DISABLE_MAGIC_FUNCTIONS="true" 47 | 48 | # Uncomment the following line to disable colors in ls. 49 | # DISABLE_LS_COLORS="true" 50 | 51 | # Uncomment the following line to disable auto-setting terminal title. 52 | # DISABLE_AUTO_TITLE="true" 53 | 54 | # Uncomment the following line to enable command auto-correction. 55 | # ENABLE_CORRECTION="true" 56 | 57 | # Uncomment the following line to display red dots whilst waiting for completion. 58 | # You can also set it to another string to have that shown instead of the default red dots. 59 | # e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f" 60 | # Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765) 61 | # COMPLETION_WAITING_DOTS="true" 62 | 63 | # Uncomment the following line if you want to disable marking untracked files 64 | # under VCS as dirty. This makes repository status check for large repositories 65 | # much, much faster. 66 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 67 | 68 | # Uncomment the following line if you want to change the command execution time 69 | # stamp shown in the history command output. 70 | # You can set one of the optional three formats: 71 | # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 72 | # or set a custom format using the strftime function format specifications, 73 | # see 'man strftime' for details. 74 | # HIST_STAMPS="mm/dd/yyyy" 75 | 76 | # Would you like to use another custom folder than $ZSH/custom? 77 | # ZSH_CUSTOM=/path/to/new-custom-folder 78 | 79 | # FUCK UPDATE! 80 | DISABLE_AUTO_UPDATE="true" 81 | 82 | # Which plugins would you like to load? 83 | # Standard plugins can be found in $ZSH/plugins/ 84 | # Custom plugins may be added to $ZSH_CUSTOM/plugins/ 85 | # Example format: plugins=(rails git textmate ruby lighthouse) 86 | # Add wisely, as too many plugins slow down shell startup. 87 | plugins=( 88 | sudo 89 | # git 90 | # autojump 91 | # zsh-syntax-highlighting 92 | # zsh-autosuggestions 93 | # fzf-zsh-plugin 94 | # fzf-tab 95 | fzf 96 | copypath 97 | archlinux 98 | # ripgrep 99 | # zsh-navigation-tools 100 | ) 101 | 102 | znap source zsh-users/zsh-syntax-highlighting 103 | znap source zsh-users/zsh-autosuggestions 104 | znap source zsh-users/zsh-history-substring-search 105 | # znap source zdharma-continuum/history-search-multi-word 106 | # znap source marlonrichert/zsh-autocomplete 107 | if [[ "x$P10K" != "x" ]]; then 108 | znap source romkatv/powerlevel10k 109 | fi 110 | 111 | znap source ohmyzsh/ohmyzsh 112 | 113 | # User configuration 114 | 115 | # export MANPATH="/usr/local/man:$MANPATH" 116 | 117 | # You may need to manually set your language environment 118 | # export LANG=en_US.UTF-8 119 | 120 | # Preferred editor for local and remote sessions 121 | # if [[ -n $SSH_CONNECTION ]]; then 122 | # export EDITOR='vim' 123 | # else 124 | # export EDITOR='nvim' 125 | # fi 126 | 127 | # Compilation flags 128 | # export ARCHFLAGS="-arch x86_64" 129 | 130 | if [[ ! -o interactive ]]; then 131 | return 132 | fi 133 | 134 | export FZF_COMPLETION_TRIGGER='**' 135 | 136 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 137 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 138 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 139 | # For a full list of active aliases, run `alias`. 140 | # 141 | # Example aliases 142 | alias zshconfig="mate ~/.zshrc" 143 | alias ohmyzsh="mate ~/.oh-my-zsh" 144 | 145 | # bindkey '^I' menu-select 146 | # bindkey "$terminfo[kcbt]" menu-select 147 | # bindkey -M menuselect '^I' menu-complete 148 | # bindkey -M menuselect "$terminfo[kcbt]" reverse-menu-complete 149 | # bindkey "$terminfo[kcuu1]" up-line-or-history 150 | # bindkey "$terminfo[kcud1]" down-line-or-history 151 | 152 | [[ -s /etc/profile.d/autojump.sh ]] && source /etc/profile.d/autojump.sh 153 | [[ -f ~/.zsh_aliases ]] && . ~/.zsh_aliases 154 | 155 | if [[ -n $P10K ]]; then 156 | [[ -f ~/.p10k.zsh ]] && source ~/.p10k.zsh 157 | fi 158 | 159 | bloop() { 160 | export LOOPCOMMAND=1 161 | while ! nvim $@; do; done; 162 | unset LOOPCOMMAND 163 | export LOOPCOMMAND 164 | } 165 | 166 | clangdpioesp() { 167 | > .clangd << EOF 168 | CompileFlags: 169 | Remove: 170 | - -mlongcalls 171 | - -fno-shrink-wrap 172 | - -fno-tree-switch-conversion 173 | - -fstrict-volatile-bitfields 174 | Add: 175 | - -fgnuc-version=12.3.1 176 | EOF 177 | for x in $(ls -d ~/.platformio/packages/framework-arduinoespressif32/libraries/*/); do 178 | echo " - -I${x}src" >> .clangd 179 | done 180 | } 181 | 182 | happypio() { 183 | pio project init --board ${1-nanoatmega328} 184 | > src/main.cpp << EOF 185 | #include 186 | 187 | void setup() { 188 | Serial.begin(115200); 189 | } 190 | 191 | void loop() { 192 | } 193 | EOF 194 | > compiledb_flags.py << EOF 195 | Import("env") 196 | 197 | env.Replace(COMPILATIONDB_INCLUDE_TOOLCHAIN=True) 198 | EOF 199 | >> .gitignore << EOF 200 | .cache/ 201 | src/secrets.h 202 | EOF 203 | >> platformio.ini << EOF 204 | extra_scripts = pre:compiledb_flags.py 205 | build_unflags = 206 | -std=gnu++11 207 | build_flags = 208 | -std=c++17 209 | monitor_speed = 115200 210 | lib_deps = 211 | EOF 212 | pio run --target compiledb 213 | } 214 | 215 | happyidf() { 216 | . ~/esp/esp-idf/export.sh 217 | } 218 | -------------------------------------------------------------------------------- /init.vim: -------------------------------------------------------------------------------- 1 | if has('nvim') 2 | "let g:archvim_predownload=1 3 | lua require('archvim') 4 | else 5 | echoerr "You are using Vim, not NeoVim" 6 | endif 7 | 8 | if filereadable('.vim_localrc') 9 | source .vim_localrc 10 | endif 11 | -------------------------------------------------------------------------------- /lua/archvim/config/aerial.lua: -------------------------------------------------------------------------------- 1 | require("aerial").setup({ 2 | -- optionally use on_attach to set keymaps when aerial has attached to a buffer 3 | -- on_attach = function(bufnr) 4 | -- -- Jump forwards/backwards with '{' and '}' 5 | -- -- vim.keymap.set("n", "{", "AerialPrev", { buffer = bufnr }) 6 | -- -- vim.keymap.set("n", "}", "AerialNext", { buffer = bufnr }) 7 | -- end, 8 | nerd_font = require'archvim.options'.nerd_fonts and "auto" or false, 9 | use_icon_provider = require'archvim.options'.nerd_fonts, 10 | dense = not require'archvim.options'.nerd_fonts, 11 | layout = { 12 | max_width = { 40, 0.25 }, 13 | min_width = 16, 14 | resize_to_content = true, 15 | preserve_equality = true, 16 | }, 17 | keymaps = { 18 | ["q"] = { 19 | callback = function() vim.cmd [[ :AerialClose ]] end, 20 | desc = "Close the aerial window", 21 | nowait = true, 22 | }, 23 | }, 24 | }) 25 | -- You probably also want to set a keymap to toggle aerial 26 | vim.keymap.set("n", "", "AerialToggle!") 27 | local found_telescope, telescope = pcall(require, "telescope") 28 | if found_telescope then 29 | telescope.load_extension("aerial") 30 | end 31 | -------------------------------------------------------------------------------- /lua/archvim/config/asynctasks.lua: -------------------------------------------------------------------------------- 1 | vim.cmd [[ 2 | let g:asyncrun_open = 6 3 | let g:asynctasks_term_pos = 'bottom' 4 | let g:asynctasks_term_rows = 6 5 | let g:asynctasks_term_cols = 50 6 | let g:asynctasks_term_reuse = 1 7 | let g:asynctasks_term_focus = 0 8 | let g:asyncrun_rootmarks = ['.tasks', '.git/'] 9 | 10 | function! AsyncTaskMultiple(first, ...) 11 | if len(a:000) >= 1 12 | if a:first == 0 13 | cclose 14 | endif 15 | let l:tmp = "" 16 | for task in a:000[1:] 17 | let l:tmp .= "'".l:task."'," 18 | endfor 19 | let l:tmp = l:tmp[:-1] 20 | let g:asyncrun_exit = "if g:asyncrun_code == 0 | call AsyncTaskMultiple(0, ".l:tmp.") | else | call AsyncTaskMultiple(0) | endif" 21 | exec "AsyncTask ".a:000[0] 22 | else 23 | let g:asyncrun_exit = "" 24 | endif 25 | endfunction 26 | command! -nargs=+ AsyncTasks :call AsyncTaskMultiple(1, ) 27 | ]] 28 | 29 | local map = require'archvim/mappings' 30 | map("n", "", "AsyncTasks project-build project-run") 31 | map("n", "", "AsyncStop") 32 | map("n", "", "AsyncTask project-build") 33 | map("n", "", "AsyncTasks file-build file-run") 34 | -------------------------------------------------------------------------------- /lua/archvim/config/auto-session.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/rmagatti/auto-session 2 | 3 | -- 推荐设置 4 | vim.o.sessionoptions = "buffers,curdir,folds,help,tabpages,winsize,winpos,terminal" -- ,globals,options,localoptions 5 | 6 | -- local function restore_nvim_tree() 7 | -- local nvim_tree = require('nvim-tree') 8 | -- nvim_tree.change_dir(vim.fn.getcwd()) 9 | -- -- nvim_tree.refresh() 10 | -- end 11 | 12 | require("auto-session").setup { 13 | auto_session_root_dir = vim.fn.stdpath('data').."/sessions/", 14 | auto_session_enable_last_session = false, 15 | auto_session_enabled = true, 16 | auto_session_create_enabled = true, 17 | -- 保存会话时自动关闭 nvim-tree 18 | -- 这是因为 nvim-tree 如果处于开启 19 | -- 状态,会破坏会话的保存 20 | pre_save_cmds = { 21 | -- [[tabdo GPTClose]], 22 | [[tabdo NvimTreeClose]], 23 | [[tabdo cclose]], 24 | -- [[tabdo noautocmd bufdo exec "if &bt == 'terminal' | bdelete | endif"]], 25 | }, 26 | post_restore_cmds = { 27 | -- [[tabdo noautocmd bufdo exists("b:accessedtime") ? b:accessedtime : 0]] 28 | -- function () 29 | -- local bufs = vim.api.nvim_list_bufs() 30 | -- local mrubuf = -1 31 | -- local mrutime = 0 32 | -- for _, buf in ipairs(bufs) do 33 | -- local btime = vim.b[buf].accessedtime0 or 0 34 | -- -- vim.b[buf].accessedtime0 = nil 35 | -- vim.b[buf].accessedtime = btime 36 | -- if btime > mrutime then 37 | -- mrutime = btime 38 | -- mrubuf = buf 39 | -- end 40 | -- end 41 | -- vim.g_print(mrubuf) 42 | -- if mrubuf ~= -1 then 43 | -- vim.cmd.buffer(mrubuf) 44 | -- end 45 | -- end, 46 | }, 47 | } 48 | 49 | -- 在每次退出 neovim 时自动保存会话 50 | -- 其实该插件不加这个自动命令也能 51 | -- 自动保存会话,但总是感觉效果不理想 52 | -- 所以这里我就自己加了个自动命令 53 | -- vim.cmd [[ 54 | -- augroup save_session_on_exit 55 | -- autocmd! 56 | -- autocmd VimLeavePre * silent! :SaveSession 57 | -- augroup end 58 | -- ]] 59 | -------------------------------------------------------------------------------- /lua/archvim/config/autoclose.lua: -------------------------------------------------------------------------------- 1 | require'autoclose'.setup{ 2 | keys = { 3 | ["'"] = { escape = false, close = false, pair = "``" }, 4 | ["\""] = { escape = false, close = false, pair = "\"\"" }, 5 | ["`"] = { escape = false, close = false, pair = "``" }, 6 | }, 7 | options = { 8 | disable_when_touch = true, 9 | touch_regex = "[%w(%[{`]", 10 | pair_spaces = true, 11 | }, 12 | } 13 | -------------------------------------------------------------------------------- /lua/archvim/config/autosave.lua: -------------------------------------------------------------------------------- 1 | require("autosave").setup { 2 | enabled = true, 3 | execution_message = function () 4 | return "saved at " .. vim.fn.strftime("%H:%M:%S") 5 | end, 6 | -- execution_message = "Saved", 7 | events = {"InsertLeave", "TextChanged"}, 8 | conditions = { 9 | exists = true, 10 | filename_is_not = {}, 11 | filetype_is_not = {}, 12 | modifiable = true, 13 | }, 14 | write_all_buffers = false, 15 | on_off_commands = false, 16 | clean_command_line_interval = 0, 17 | debounce_delay = 335, 18 | } 19 | -------------------------------------------------------------------------------- /lua/archvim/config/bufferline.lua: -------------------------------------------------------------------------------- 1 | local plain = not require'archvim.options'.nerd_fonts 2 | 3 | require'bufferline'.setup { 4 | options = { 5 | -- indicator = { 6 | -- style = 'underline', 7 | -- }, 8 | -- separator_style = "slant", 9 | -- show_buffer_icons = false, 10 | buffer_close_icon = plain and 'x' or nil, 11 | modified_icon = plain and '*' or nil, 12 | -- close_icon = plain and 'x' or nil, 13 | left_trunc_marker = plain and '<' or nil, 14 | right_trunc_marker = plain and '>' or nil, 15 | offsets = { 16 | { 17 | filetype = "NvimTree", 18 | text = "File Explorer", 19 | highlight = "Directory", 20 | text_align = "left", 21 | }, 22 | }, 23 | close_command = function(bufnum) 24 | require('bufdelete').bufdelete(bufnum, true) 25 | end, 26 | diagnostics = "nvim_lsp", 27 | diagnostics_indicator = function(count, level, diagnostics_dict, context) 28 | return "("..count..")" 29 | end, 30 | sort_by = 'insert_after_current', 31 | custom_filter = function(buf_number, buf_numbers) 32 | -- filter out filetypes you don't want to see 33 | if vim.bo[buf_number].filetype == "qf" then 34 | return false 35 | end 36 | if vim.bo[buf_number].buftype == "terminal" then 37 | return false 38 | end 39 | if vim.bo[buf_number].buftype == "nofile" then 40 | return false 41 | end 42 | if vim.bo[buf_number].filetype == "Trouble" then 43 | return false 44 | end 45 | -- if string.find(vim.fn.bufname(buf_number), 'term://') == 1 then 46 | -- return false 47 | -- end 48 | return true 49 | end, 50 | } 51 | } 52 | 53 | -- Function to close empty and unnamed buffers 54 | local function close_empty_unnamed_buffers() 55 | -- Get a list of all buffers 56 | local buffers = vim.api.nvim_list_bufs() 57 | 58 | -- Iterate over each buffer 59 | for _, bufnr in ipairs(buffers) do 60 | -- Check if the buffer is empty and doesn't have a name 61 | if vim.api.nvim_buf_is_loaded(bufnr) and vim.api.nvim_buf_get_name(bufnr) == '' and 62 | -- vim.api.nvim_buf_get_option(bufnr, 'buftype') == '' 63 | vim.bo[bufnr].buftype == '' then 64 | 65 | -- Close the buffer if it's empty: 66 | if vim.api.nvim_buf_line_count(bufnr) == 1 then 67 | local lines = vim.api.nvim_buf_get_lines(bufnr, 0, 1, false) 68 | if #lines == 0 or lines[0] == nil or #lines[0] == 0 then 69 | vim.api.nvim_buf_delete(bufnr, { 70 | force = true, 71 | }) 72 | end 73 | end 74 | end 75 | end 76 | end 77 | 78 | -- Clear the mandatory, empty, unnamed buffer when a real file is opened: 79 | -- vim.api.nvim_command('autocmd BufReadPost * lua require("config.bufferline_setup").close_empty_unnamed_buffers()') 80 | vim.api.nvim_create_autocmd({"BufReadPost"}, { 81 | callback = function (data) 82 | close_empty_unnamed_buffers() 83 | end, 84 | }) 85 | 86 | 87 | vim.keymap.set({"v", "n"}, "g", "BufferLineTogglePin", { silent = true }) 88 | vim.keymap.set({"v", "n"}, "gb", "BufferLineCyclePrev", { silent = true }) 89 | vim.keymap.set({"v", "n"}, "gt", "BufferLineCycleNext", { silent = true }) 90 | vim.keymap.set({"v", "n"}, "g", "BufferLinePick", { silent = true }) 91 | vim.keymap.set({"v", "n"}, "g", "bdelete", { silent = true }) 92 | -- vim.keymap.set({"v", "n"}, "go", "blast", { silent = true }) 93 | -- vim.keymap.set({"v", "n"}, "gO", "bfirst", { silent = true }) 94 | vim.keymap.set({"v", "n"}, "gB", "BufferLineMovePrev", { silent = true }) 95 | vim.keymap.set({"v", "n"}, "gT", "BufferLineMoveNext", { silent = true }) 96 | vim.keymap.set({"v", "n"}, "g", "BufferLineCloseOthers", { silent = true }) 97 | vim.keymap.set({"v", "n"}, "g", "BufferLineCloseLeft", { silent = true }) 98 | vim.keymap.set({"v", "n"}, "g", "BufferLineCloseRight", { silent = true }) 99 | 100 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineTogglePin", { silent = true }) 101 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineCyclePrev", { silent = true }) 102 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineCycleNext", { silent = true }) 103 | vim.keymap.set({"v", "n", "i"}, "", "bdelete", { silent = true }) 104 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineMovePrev", { silent = true }) 105 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineMoveNext", { silent = true }) 106 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineCloseOthers", { silent = true }) 107 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineCloseLeft", { silent = true }) 108 | vim.keymap.set({"v", "n", "i"}, "", "BufferLineCloseRight", { silent = true }) 109 | 110 | -- vim.cmd [[ 111 | -- aug buffer_accessed_time 112 | -- au! 113 | -- au BufEnter,BufWinEnter * let b:accessedtime = localtime() 114 | -- aug END 115 | -- 116 | -- function! BufferLineSortByMRU() 117 | -- lua require'bufferline'.sort_buffers_by(function(a, b) return (vim.b[a.id].accessedtime or 0) > (vim.b[b.id].accessedtime or 0) end) 118 | -- endfunction 119 | -- 120 | -- command -nargs=0 BufferLineSortByMRU call BufferLineSortByMRU() 121 | -- ]] 122 | 123 | 124 | if not require'archvim.options'.nerd_fonts then 125 | require'bufferline.groups'.builtin.pinned.icon = '-' 126 | end 127 | -------------------------------------------------------------------------------- /lua/archvim/config/diagflow.lua: -------------------------------------------------------------------------------- 1 | require('diagflow').setup({ 2 | enable = true, 3 | max_width = 60, -- The maximum width of the diagnostic messages 4 | max_height = 10, -- the maximum height per diagnostics 5 | severity_colors = { -- The highlight groups to use for each diagnostic severity level 6 | error = "DiagnosticFloatingError", 7 | warning = "DiagnosticFloatingWarn", 8 | info = "DiagnosticFloatingInfo", 9 | hint = "DiagnosticFloatingHint", 10 | }, 11 | format = function(diagnostic) 12 | if vim.fn.mode() == "i" then 13 | return '' 14 | end 15 | local severity = vim.diagnostic.severity[diagnostic.severity] 16 | local status, sign = pcall(function() 17 | return vim.trim( 18 | vim.fn.sign_getdefined( 19 | "DiagnosticSign" .. severity:lower():gsub("^%l", string.upper) 20 | )[1].text 21 | ) 22 | end) 23 | if not status then 24 | sign = severity:sub(1, 1) 25 | end 26 | return sign .. ' ' .. diagnostic.message 27 | end, 28 | gap_size = 1, 29 | scope = 'line', -- 'cursor', 'line' this changes the scope, so instead of showing errors under the cursor, it shows errors on the entire line. 30 | padding_top = 0, 31 | padding_right = 0, 32 | text_align = 'right', -- 'left', 'right' 33 | placement = 'inline', -- 'top', 'inline' 34 | inline_padding_left = 0, -- the padding left when the placement is inline 35 | update_event = { 'DiagnosticChanged', 'BufReadPost', 'BufEnter' }, -- the event that updates the diagnostics cache 36 | toggle_event = { 'InsertEnter', 'InsertLeave' }, -- if InsertEnter, can toggle the diagnostics on inserts 37 | show_sign = false, -- set to true if you want to render the diagnostic sign before the diagnostic message 38 | render_event = { 'DiagnosticChanged', 'CursorMoved' }, 39 | border_chars = { 40 | top_left = "┌", 41 | top_right = "┐", 42 | bottom_left = "└", 43 | bottom_right = "┘", 44 | horizontal = "─", 45 | vertical = "│" 46 | }, 47 | show_borders = false, 48 | }) 49 | 50 | if require'archvim.options'.nerd_fonts then 51 | vim.diagnostic.config{ 52 | signs = { 53 | text = { 54 | [vim.diagnostic.severity.ERROR] = "", 55 | [vim.diagnostic.severity.WARN] = "", 56 | [vim.diagnostic.severity.INFO] = "", 57 | [vim.diagnostic.severity.HINT] = "", 58 | }, 59 | texthl = { 60 | [vim.diagnostic.severity.ERROR] = "DiagnosticSignError", 61 | [vim.diagnostic.severity.WARN] = "DiagnosticSignWarn", 62 | [vim.diagnostic.severity.INFO] = "DiagnosticSignInfo", 63 | [vim.diagnostic.severity.HINT] = "DiagnosticSignHint", 64 | }, 65 | }, 66 | } 67 | end 68 | -------------------------------------------------------------------------------- /lua/archvim/config/genius.lua: -------------------------------------------------------------------------------- 1 | require'genius'.setup { 2 | default_bot = 'openai', 3 | completion_delay_ms = -1, 4 | config_openai = os.getenv('ARCHIBATE_COMPUTER') and { 5 | base_url = "https://api.deepseek.com/beta", 6 | api_key = os.getenv("DEEPSEEK_API_KEY"), 7 | infill_options = { 8 | max_tokens = 120, 9 | model = "deepseek-coder", 10 | temperature = 0.6, 11 | }, 12 | -- base_url = "https://api.openai.com", 13 | -- base_url = "http://127.0.0.1:8080/https://api.openai.com\nhttps://api.openai.com", 14 | -- api_key = os.getenv("OPENAI_API_KEY"), 15 | } or nil, 16 | } 17 | 18 | -- vim.cmd [[ 19 | -- inoremap GeniusComplete 20 | -- ]] 21 | -------------------------------------------------------------------------------- /lua/archvim/config/gitsigns.lua: -------------------------------------------------------------------------------- 1 | require'gitsigns'.setup { 2 | current_line_blame = false, 3 | current_line_blame_opts = { 4 | virt_text = true, 5 | virt_text_pos = 'eol', 6 | delay = 2000, 7 | }, 8 | } 9 | local success, handler = pcall(require, "scrollbar.handlers.gitsigns") 10 | if success then 11 | handler.setup() 12 | end 13 | -------------------------------------------------------------------------------- /lua/archvim/config/hop.lua: -------------------------------------------------------------------------------- 1 | local hop = require('hop') 2 | hop.setup() 3 | 4 | -- local directions = require('hop.hint').HintDirection 5 | -- vim.keymap.set('', 'f', function() 6 | -- hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true }) 7 | -- end, {remap=true}) 8 | -- vim.keymap.set('', 'F', function() 9 | -- hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true }) 10 | -- end, {remap=true}) 11 | -- vim.keymap.set('', 't', function() 12 | -- hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true, hint_offset = -1 }) 13 | -- end, {remap=true}) 14 | -- vim.keymap.set('', 'T', function() 15 | -- hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true, hint_offset = 1 }) 16 | -- end, {remap=true}) 17 | vim.keymap.set('', '', function() 18 | hop.hint_char1({ current_line_only = false }) 19 | end, {remap=true}) 20 | -------------------------------------------------------------------------------- /lua/archvim/config/lsp-signature.lua: -------------------------------------------------------------------------------- 1 | require "lsp_signature".setup({ 2 | bind = true, 3 | doc_lines = 0, 4 | handler_opts = { 5 | border = "none", 6 | }, 7 | floating_window = false, 8 | floating_window_above_cur_line = true, 9 | floating_window_off_x = 1, 10 | floating_window_off_y = 0, 11 | fix_pos = false, 12 | hint_enable = true, 13 | hint_prefix = require'archvim.options'.nerd_fonts and " " or "", 14 | hint_scheme = "Comment", 15 | hi_parameter = "LspSignatureActiveParameter", 16 | debug = false, 17 | toggle_key = '', 18 | toggle_key_flip_floatwin_setting = true, 19 | select_signature_key = '', 20 | timer_interval = 80, 21 | -- transparency = 1, 22 | }) 23 | -------------------------------------------------------------------------------- /lua/archvim/config/lspconfig.lua: -------------------------------------------------------------------------------- 1 | local function pyright_on_attach(client, bufnr) 2 | local function organize_imports() 3 | local params = { 4 | command = 'pyright.organizeimports', 5 | arguments = { vim.uri_from_bufnr(0) }, 6 | } 7 | vim.lsp.buf.execute_command(params) 8 | end 9 | 10 | if client.name == "pyright" then 11 | vim.api.nvim_create_user_command("PyrightOrganizeImports", 12 | organize_imports, {desc = 'Organize Imports'}) 13 | end 14 | end 15 | 16 | (function() 17 | local old_notify = rawget(vim, 'notify') 18 | rawset(vim, 'notify', function(msg, ...) 19 | -- if msg:match([[clangd: -32602]]) then 20 | -- return 21 | -- end 22 | -- 23 | if msg:match([[{ "Corresponding file cannot be determined" }]]) then 24 | vim.cmd[[Ouroboros]] 25 | return 26 | end 27 | 28 | old_notify(msg, ...) 29 | end) 30 | end)() 31 | 32 | local function clangd_on_attach(client, bufnr) 33 | if vim.api.nvim_buf_get_name(bufnr):match "^%a+://" then 34 | return 35 | end 36 | 37 | local function switch_source_header() 38 | local params = { 39 | command = 'textDocument/switchSourceHeader', 40 | arguments = { vim.uri_from_bufnr(0) }, 41 | } 42 | vim.lsp.buf.execute_command(params) 43 | end 44 | 45 | if client.name == "clangd" then 46 | vim.api.nvim_create_user_command("ClangdSwitchSourceHeader", 47 | switch_source_header, {desc = 'Switch Source Header'}) 48 | end 49 | end 50 | 51 | require'lspconfig'.pyright.setup{ 52 | on_attach = pyright_on_attach, 53 | } 54 | -- require'lspconfig'.pylyzer.setup{} 55 | require'lspconfig'.lua_ls.setup{} 56 | require'lspconfig'.cmake.setup{} 57 | -- require'lspconfig'.rust_analyzer.setup{} 58 | 59 | require('lspconfig').clangd.setup{ 60 | on_attach = clangd_on_attach, 61 | on_new_config = function(new_config, new_cwd) 62 | local status, cmake = pcall(require, "cmake-tools") 63 | if status then 64 | cmake.clangd_on_new_config(new_config) 65 | end 66 | end, 67 | } 68 | 69 | -- vim.api.nvim_set_hl(0, 'LspReferenceRead', {link = 'Search'}) 70 | -- vim.api.nvim_set_hl(0, 'LspReferenceText', {link = 'Search'}) 71 | -- vim.api.nvim_set_hl(0, 'LspReferenceWrite', {link = 'Search'}) 72 | 73 | local function setup_lsp(event) 74 | local id = vim.tbl_get(event, 'data', 'client_id') 75 | local client = id and vim.lsp.get_client_by_id(id) 76 | if client == nil then 77 | return 78 | end 79 | 80 | if client.server_capabilities.inlayHintProvider then 81 | if vim.lsp.inlay_hint ~= nil and require'archvim.options'.enable_inlay_hint then 82 | vim.lsp.inlay_hint.enable(true) 83 | end 84 | end 85 | 86 | if client.supports_method('textDocument/documentHighlight') then 87 | local group = vim.api.nvim_create_augroup('highlight_symbol', {clear = false}) 88 | 89 | vim.api.nvim_clear_autocmds({buffer = event.buf, group = group}) 90 | 91 | vim.api.nvim_create_autocmd({'CursorHold', 'CursorHoldI'}, { 92 | group = group, 93 | buffer = event.buf, 94 | -- callback = vim.lsp.buf.document_highlight, 95 | callback = function() 96 | vim.cmd [[ 97 | hi LspReferenceText guibg=none "gui=bold "guisp=#a3e697 98 | hi LspReferenceRead guibg=none "gui=bold "guisp=#87c2e6 99 | hi LspReferenceWrite guibg=none "gui=bold "guisp=#e8a475 100 | ]] 101 | vim.lsp.buf.document_highlight() 102 | end, 103 | }) 104 | 105 | vim.api.nvim_create_autocmd({'CursorMoved', 'CursorMovedI'}, { 106 | group = group, 107 | buffer = event.buf, 108 | callback = vim.lsp.buf.clear_references, 109 | }) 110 | end 111 | 112 | -- vim.api.nvim_create_autocmd({"CursorHold"}, { 113 | -- callback = function() 114 | -- for _, winid in pairs(vim.api.nvim_tabpage_list_wins(0)) do 115 | -- if vim.api.nvim_win_get_config(winid).zindex then 116 | -- return 117 | -- end 118 | -- end 119 | -- vim.diagnostic.open_float({ 120 | -- scope = "cursor", 121 | -- focusable = false, 122 | -- close_events = { 123 | -- "CursorMoved", 124 | -- "CursorMovedI", 125 | -- "BufHidden", 126 | -- "InsertCharPre", 127 | -- "WinLeave", 128 | -- "BufEnter", 129 | -- "BufLeave", 130 | -- }, 131 | -- }) 132 | -- end, 133 | -- }) 134 | 135 | if client.supports_method('textDocument/signatureHelp') then 136 | if vim.lsp.buf.signature_help ~= nil and require'archvim.options'.enable_signature_help then 137 | local group = vim.api.nvim_create_augroup('signature_help', {clear = false}) 138 | 139 | vim.api.nvim_clear_autocmds({buffer = event.buf, group = group}) 140 | 141 | vim.api.nvim_create_autocmd({'CursorHoldI'}, { 142 | group = group, 143 | buffer = event.buf, 144 | callback = function() 145 | vim.lsp.buf.signature_help() 146 | end 147 | }) 148 | end 149 | end 150 | end 151 | 152 | vim.api.nvim_create_autocmd('LspAttach', { 153 | desc = 'Setup LSP', 154 | callback = setup_lsp, 155 | }) 156 | 157 | vim.api.nvim_create_user_command("LspInlayHintToggle", function () 158 | if vim.lsp.inlay_hint.is_enabled() then 159 | vim.lsp.inlay_hint.enable(false) 160 | else 161 | vim.lsp.inlay_hint.enable(true) 162 | end 163 | end, {desc = 'Toggle inlay hints'}) 164 | 165 | vim.api.nvim_create_user_command("LspDiagnosticsToggle", function () 166 | if vim.diagnostic.is_enabled() then 167 | vim.diagnostic.enable(false) 168 | else 169 | vim.diagnostic.enable(true) 170 | end 171 | end, {desc = 'Toggle diagnostics'}) 172 | -------------------------------------------------------------------------------- /lua/archvim/config/lspsaga.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/tami5/lspsaga.nvim 2 | 3 | require("lspsaga").setup { 4 | -- 提示边框样式:round、single、double 5 | border_style = "round", 6 | error_sign = " ", 7 | warn_sign = " ", 8 | hint_sign = " ", 9 | infor_sign = " ", 10 | diagnostic_header_icon = " ", 11 | -- 正在写入的行提示 12 | code_action_icon = " ", 13 | code_action_prompt = { 14 | -- 显示写入行提示 15 | -- 如果为 true ,则写代码时会在左侧行号栏中显示你所定义的图标 16 | enable = false, 17 | sign = true, 18 | sign_priority = 40, 19 | virtual_text = true, 20 | }, 21 | -- 快捷键配置 22 | code_action_keys = { 23 | quit = "", 24 | exec = "", 25 | }, 26 | rename_action_keys = { 27 | quit = "", 28 | exec = "", 29 | }, 30 | } 31 | 32 | vim.cmd [[ 33 | " code action 34 | nnoremap gA lua require('lspsaga.codeaction').code_action() 35 | vnoremap gA :lua require('lspsaga.codeaction').range_code_action() 36 | 37 | " rename, close rename win use in insert mode or `q` in noremal mode or `:q` 38 | nnoremap gR lua require('lspsaga.rename').rename() 39 | 40 | " preview definition 41 | nnoremap gK lua require('lspsaga.provider').preview_definition() 42 | 43 | " show hover doc 44 | nnoremap K lua require('lspsaga.hover').render_hover_doc() 45 | " scroll down hover doc or scroll in definition preview 46 | nnoremap lua require('lspsaga.action').smart_scroll_with_saga(1) 47 | " scroll up hover doc 48 | nnoremap lua require('lspsaga.action').smart_scroll_with_saga(-1) 49 | " show signature help 50 | nnoremap gsK lua require('lspsaga.signaturehelp').signature_help() 51 | 52 | " show diagnostic on current line 53 | nnoremap ga lua require('lspsaga.diagnostic').show_line_diagnostics() 54 | 55 | ]] 56 | 57 | -- Diagnostic jump 58 | -- You can use to jump back to your previous location 59 | vim.keymap.set("n", "[a", "Lspsaga diagnostic_jump_prev") 60 | vim.keymap.set("n", "]a", "Lspsaga diagnostic_jump_next") 61 | -- -- Diagnostic jump with filters such as only jumping to an error 62 | -- vim.keymap.set("n", "[E", function() 63 | -- require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR }) 64 | -- end) 65 | -- vim.keymap.set("n", "]E", function() 66 | -- require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR }) 67 | -- end) 68 | -------------------------------------------------------------------------------- /lua/archvim/config/luasnip.lua: -------------------------------------------------------------------------------- 1 | local function lazy_load_snippets() 2 | require("luasnip.loaders.from_vscode").lazy_load() 3 | end 4 | vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = lazy_load_snippets }) 5 | 6 | -- vim.cmd [[ 7 | -- " press to expand or jump in a snippet. These can also be mapped separately 8 | -- " via luasnip-expand-snippet and luasnip-jump-next. 9 | -- imap luasnip#jumpable(1) ? 'luasnip-expand-or-jump' : '' 10 | -- " -1 for jumping backwards. 11 | -- inoremap lua require('luasnip').jump(-1) 12 | -- 13 | -- snoremap lua require('luasnip').jump(1) 14 | -- snoremap lua require('luasnip').jump(-1) 15 | -- 16 | -- "" For changing choices in choiceNodes (not strictly necessary for a basic setup). 17 | -- "imap luasnip#choice_active() ? 'luasnip-next-choice' : '' 18 | -- "smap luasnip#choice_active() ? 'luasnip-next-choice' : '' 19 | -- ]] 20 | -------------------------------------------------------------------------------- /lua/archvim/config/marks.lua: -------------------------------------------------------------------------------- 1 | require'marks'.setup{ 2 | sign_priority = { lower=10, upper=15, builtin=8, bookmark=20 }, 3 | -- builtin_marks = { "'", "." }, 4 | -- bookmark_0 = { 5 | -- sign = "⚑", 6 | -- virt_text = "hello world", 7 | -- -- explicitly prompt for a virtual line annotation when setting a bookmark from this group. 8 | -- -- defaults to false. 9 | -- annotate = false, 10 | -- }, 11 | refresh_interval = 200, 12 | } 13 | -------------------------------------------------------------------------------- /lua/archvim/config/mason.lua: -------------------------------------------------------------------------------- 1 | require("mason").setup({ 2 | ui = { 3 | icons = { 4 | package_installed = "✓", 5 | package_pending = "➜", 6 | package_uninstalled = "✗" 7 | } 8 | } 9 | }) 10 | 11 | require("mason-lspconfig").setup { 12 | -- ensure_installed = { "clangd", "pyright", "lua_ls" }, 13 | -- automatic_installation = true, 14 | } 15 | -------------------------------------------------------------------------------- /lua/archvim/config/neoconf.lua: -------------------------------------------------------------------------------- 1 | require'neoconf'.setup() 2 | -------------------------------------------------------------------------------- /lua/archvim/config/neodev.lua: -------------------------------------------------------------------------------- 1 | require("neodev").setup({ 2 | library = { plugins = { "nvim-dap-ui" }, types = true }, 3 | }) 4 | 5 | -- then setup your lsp server as usual 6 | local lspconfig = require('lspconfig') 7 | 8 | -- example to setup lua_ls and enable call snippets 9 | lspconfig.lua_ls.setup({ 10 | settings = { 11 | Lua = { 12 | completion = { 13 | callSnippet = "Replace" 14 | } 15 | } 16 | } 17 | }) 18 | -------------------------------------------------------------------------------- /lua/archvim/config/neoformat.lua: -------------------------------------------------------------------------------- 1 | -- 1.自动对齐 2 | vim.g.neoformat_basic_format_align = 1 3 | -- 2.自动删除行尾空格 4 | vim.g.neoformat_basic_format_trim = 1 5 | -- 3.将制表符替换为空格 6 | vim.g.neoformat_basic_format_retab = 1 7 | -- 只提示错误消息 8 | vim.g.neoformat_only_msg_on_error = 1 9 | 10 | -- vim.cmd [[ 11 | -- augroup fmt 12 | -- autocmd! 13 | -- autocmd BufWritePre * if index(['c', 'cpp', 'cuda'], &filetype) != -1 && filereadable(".clang-format") | undojoin | Neoformat | endif 14 | -- augroup END 15 | -- ]] 16 | -------------------------------------------------------------------------------- /lua/archvim/config/neoline.lua: -------------------------------------------------------------------------------- 1 | vim.cmd [[ 2 | set noshowmode 3 | " lightline 4 | let g:lightline = { 5 | \ 'active': { 6 | \ 'left': [ 7 | \ [ 'mode', 'paste', ], 8 | \ [ 'readonly', 'filename', 'modified', ], 9 | \ [ 'branch', ], 10 | \ ] 11 | \ }, 12 | \ } 13 | ]] 14 | -------------------------------------------------------------------------------- /lua/archvim/config/neovim-session-manager.lua: -------------------------------------------------------------------------------- 1 | local Path = require('plenary.path') 2 | local config = require('session_manager.config') 3 | require('session_manager').setup({ 4 | sessions_dir = Path:new(vim.fn.stdpath('data'), 'sessions'), -- The directory where the session files will be saved. 5 | -- session_filename_to_dir = session_filename_to_dir, -- Function that replaces symbols into separators and colons to transform filename into a session directory. 6 | -- dir_to_session_filename = dir_to_session_filename, -- Function that replaces separators and colons into special symbols to transform session directory into a filename. Should use `vim.loop.cwd()` if the passed `dir` is `nil`. 7 | autoload_mode = config.AutoloadMode.CurrentDir, -- Define what to do when Neovim is started without arguments. Possible values: Disabled, CurrentDir, LastSession 8 | autosave_last_session = true, -- Automatically save last session on exit and on session switch. 9 | autosave_ignore_not_normal = true, -- Plugin will not save a session when no buffers are opened, or all of them aren't writable or listed. 10 | autosave_ignore_dirs = {}, -- A list of directories where the session will not be autosaved. 11 | autosave_ignore_filetypes = { -- All buffers of these file types will be closed before the session is saved. 12 | 'gitcommit', 13 | 'gitrebase', 14 | 'toggleterm', 15 | 'qf', 16 | }, 17 | autosave_ignore_buftypes = { 18 | 'terminal', 19 | }, -- All buffers of these bufer types will be closed before the session is saved. 20 | autosave_only_in_session = false, -- Always autosaves session. If true, only autosaves after a session is active. 21 | max_path_length = 80, -- Shorten the display path if length exceeds this threshold. Use 0 if don't want to shorten the path at all. 22 | }) 23 | -------------------------------------------------------------------------------- /lua/archvim/config/noice.lua: -------------------------------------------------------------------------------- 1 | require("noice").setup { 2 | lsp = { 3 | -- override markdown rendering so that **cmp** and other plugins use **Treesitter** 4 | override = { 5 | ["vim.lsp.util.convert_input_to_markdown_lines"] = true, 6 | ["vim.lsp.util.stylize_markdown"] = true, 7 | ["cmp.entry.get_documentation"] = true, -- requires hrsh7th/nvim-cmp 8 | }, 9 | signature = { 10 | enabled = false, 11 | }, 12 | }, 13 | presets = { 14 | bottom_search = false, -- use a classic bottom cmdline for search 15 | command_palette = true, -- position the cmdline and popupmenu together 16 | long_message_to_split = true, -- long messages will be sent to a split 17 | inc_rename = true, -- enables an input dialog for inc-rename.nvim 18 | lsp_doc_border = false, -- add a border to hover docs and signature help 19 | }, 20 | cmdline = { 21 | enabled = true, -- enables the Noice cmdline UI 22 | view = "cmdline_popup", -- view for rendering the cmdline. Change to `cmdline` to get a classic cmdline at the bottom 23 | opts = {}, -- global options for the cmdline. See section on views 24 | format = { 25 | -- conceal: (default=true) This will hide the text in the cmdline that matches the pattern. 26 | -- view: (default is cmdline view) 27 | -- opts: any options passed to the view 28 | -- icon_hl_group: optional hl_group for the icon 29 | -- title: set to anything or empty string to hide 30 | cmdline = { pattern = "^:", icon = require'archvim.options'.nerd_fonts and "" or ':', lang = "vim" }, 31 | search_down = { kind = "search", pattern = "^/", icon = require'archvim.options'.nerd_fonts and " " or '/', lang = "regex" }, 32 | search_up = { kind = "search", pattern = "^%?", icon = require'archvim.options'.nerd_fonts and " " or '?', lang = "regex" }, 33 | filter = { pattern = "^:%s*!", icon = require'archvim.options'.nerd_fonts and "" or '$', lang = "bash" }, 34 | lua = { pattern = { "^:%s*lua%s+", "^:%s*lua%s*=%s*", "^:%s*=%s*" }, icon = require'archvim.options'.nerd_fonts and "" or 'l', lang = "lua" }, 35 | inc_rename = { pattern = { "^:%s*IncRename%s+" }, icon = require'archvim.options'.nerd_fonts and "" or '>' }, 36 | help = { pattern = "^:%s*he?l?p?%s+", icon = require'archvim.options'.nerd_fonts and "󰋗" or 'h' }, 37 | input = {}, -- Used by input() 38 | -- lua = false, -- to disable a format, set to `false` 39 | }, 40 | }, 41 | } 42 | -------------------------------------------------------------------------------- /lua/archvim/config/notify.lua: -------------------------------------------------------------------------------- 1 | if not require'archvim.options'.disable_notify then 2 | vim.notify = require('notify') 3 | vim.notify.setup { 4 | background_colour = "#000000", 5 | render = 'minimal', 6 | minimum_width = 50, 7 | max_width = 100, 8 | timeout = 1000, 9 | } 10 | end 11 | 12 | local old_notify = vim.notify 13 | vim.notify = function(msg, ...) 14 | if msg:match("clangd: %-32602: failed to decode textDocument/documentHighlight request") then 15 | return 16 | end 17 | if msg:match("warning: multiple different client offset_encodings") then 18 | return 19 | end 20 | if msg:match("clipboard: error: Error: target STRING not available") then 21 | return 22 | end 23 | if msg:match("You cannot close the last tab! This will exit neovim") then 24 | return 25 | end 26 | if msg:match("message = \"trying to get preamble for non-added document\"") then 27 | return 28 | end 29 | if msg:match("\"lsp_signatur handler\",") then 30 | return 31 | end 32 | if msg:match("No results for %*%*") then 33 | -- transform "No results for **qflist**\nBuffer: /home/bate/Codes/cppguidebook/examples/error_code.cpp" 34 | -- into "No results for **qflist**" 35 | msg = msg:gsub("No results for %*%*([%w_]+)%*%*\nBuffer: .+", "No results for %1") 36 | end 37 | 38 | old_notify(msg, ...) 39 | end 40 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-autopairs.lua: -------------------------------------------------------------------------------- 1 | 2 | 3 | local npairs = require("nvim-autopairs") 4 | -- local Rule = require('nvim-autopairs.rule') 5 | 6 | npairs.setup({ 7 | check_ts = true, 8 | break_undo = false, 9 | fast_wrap = { 10 | map = '', 11 | chars = { '{', '[', '(', '"', "'" }, 12 | pattern = [=[[%'%"%>%]%)%}%,]]=], 13 | end_key = '$', 14 | before_key = 'h', 15 | after_key = 'l', 16 | cursor_pos_before = true, 17 | keys = 'qwertyuiopzxcvbnmasdfghjkl', 18 | manual_position = true, 19 | highlight = 'Search', 20 | highlight_grey = 'Comment', 21 | }, 22 | }) 23 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-cmp.lua: -------------------------------------------------------------------------------- 1 | local has_lspkind, lspkind = pcall(require, 'lspkind') 2 | local cmp = require'cmp' 3 | 4 | local function has_words_before() 5 | local cursor = vim.api.nvim_win_get_cursor(0) 6 | local line = cursor[1] 7 | local col = cursor[2] 8 | return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil 9 | end 10 | 11 | cmp.setup { 12 | -- view = 'custom', 13 | preselect = 'none', 14 | completion = { 15 | completeopt = 'menu,menuone,noinsert,noselect' 16 | -- completeopt = 'menu,menuone' 17 | }, 18 | -- experimental = { ghost_text = true }, 19 | 20 | -- 指定 snippet 引擎 21 | snippet = { 22 | expand = function(args) 23 | -- -- For `vsnip` users. 24 | -- vim.fn["vsnip#anonymous"](args.body) 25 | -- For `luasnip` users. 26 | require('luasnip').lsp_expand(args.body) 27 | -- For `ultisnips` users. 28 | -- vim.fn["UltiSnips#Anon"](args.body) 29 | -- For `snippy` users. 30 | -- require'snippy'.expand_snippet(args.body) 31 | end, 32 | }, 33 | 34 | -- 来源 35 | sources = cmp.config.sources { 36 | -- {name = "lazydev", group_index = 0}, 37 | {name = "nvim_lsp", max_item_count = 10}, 38 | -- {name = "nvim_lsp_signature_help", max_item_count = 1}, 39 | {name = "buffer", max_item_count = 8, keyword_length = 2}, 40 | {name = "rg", max_item_count = 5, keyword_length = 4}, 41 | -- {name = "git", max_item_count = 5, keyword_length = 2}, 42 | -- { 43 | -- name = 'rime', 44 | -- option = { 45 | -- }, 46 | -- }, 47 | -- { 48 | -- name = 'rime_punct', 49 | -- option = { 50 | -- }, 51 | -- }, 52 | {name = "luasnip", max_item_count = 8}, 53 | {name = "path"}, 54 | -- {name = "codeium"}, -- INFO: uncomment this for AI completion 55 | -- {name = "spell", max_item_count = 4}, 56 | -- {name = "cmp_yanky", max_item_count = 2}, 57 | {name = "calc", max_item_count = 3}, 58 | -- {name = "cmdline"}, 59 | -- {name = "git"}, 60 | -- {name = "emoji", max_item_count = 3}, 61 | -- {name = "copilot"}, -- INFO: uncomment this for AI completion 62 | -- {name = "cmp_tabnine"}, -- INFO: uncomment this for AI completion 63 | }, 64 | 65 | -- 对补全建议排序 66 | sorting = { 67 | comparators = { 68 | cmp.config.compare.offset, 69 | cmp.config.compare.exact, 70 | cmp.config.compare.score, 71 | cmp.config.compare.recently_used, 72 | require("cmp-under-comparator").under, 73 | -- require("cmp_tabnine.compare"), -- INFO: uncomment this for AI completion 74 | cmp.config.compare.kind, 75 | cmp.config.compare.sort_text, 76 | cmp.config.compare.length, 77 | cmp.config.compare.order, 78 | } 79 | }, 80 | 81 | 82 | -- 快捷键 83 | mapping = { 84 | -- 上一个 85 | [''] = cmp.mapping.select_prev_item(), 86 | -- 下一个 87 | [''] = cmp.mapping.select_next_item(), 88 | [""] = cmp.mapping(function(fallback) 89 | if cmp.visible() then 90 | cmp.select_next_item() 91 | elseif require("luasnip").expand_or_jumpable() then 92 | require("luasnip").expand_or_jump() 93 | elseif has_words_before() then 94 | cmp.complete() 95 | else 96 | fallback() 97 | end 98 | end, { "i", "s" }), 99 | [""] = cmp.mapping(function(fallback) 100 | if cmp.visible() then 101 | cmp.select_prev_item() 102 | elseif require("luasnip").jumpable(-1) then 103 | require("luasnip").jump(-1) 104 | else 105 | fallback() 106 | end 107 | end, { "i", "s" }), 108 | -- 出现补全 109 | [''] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }), 110 | -- 取消 111 | [''] = cmp.mapping({ 112 | i = cmp.mapping.abort(), 113 | c = cmp.mapping.close(), 114 | }), 115 | -- RIME 专用确认 116 | -- [''] = cmp.mapping(function(fallback) 117 | -- if cmp.visible() then 118 | -- cmp.mapping.confirm({ 119 | -- select = true, 120 | -- behavior = cmp.ConfirmBehavior.Replace, 121 | -- }) 122 | -- else 123 | -- fallback() 124 | -- end 125 | -- end, { 'i', 's' }), 126 | -- 确认 127 | -- Accept currently selected item. If none selected, `select` first item. 128 | -- Set `select` to `false` to only confirm explicitly selected items. 129 | [''] = cmp.mapping.confirm({ 130 | select = false, 131 | behavior = cmp.ConfirmBehavior.Insert, 132 | }), 133 | 134 | -- [''] = cmp.mapping.confirm({ 135 | -- select = false, 136 | -- behavior = cmp.ConfirmBehavior.Insert, 137 | -- }), 138 | -- [''] = cmp.mapping.disable, 139 | -- [''] = cmp.mapping({ 140 | -- i = cmp.mapping.abort(), 141 | -- c = cmp.mapping.close(), 142 | -- }), 143 | 144 | -- ['1'] = cmp.mapping(function(fallback) 145 | -- if cmp.visible() then 146 | -- cmp.mapping.confirm({ 147 | -- select = true, 148 | -- behavior = cmp.ConfirmBehavior.Replace, 149 | -- }) 150 | -- else 151 | -- fallback() 152 | -- end 153 | -- end), 154 | -- ['2'] = cmp.mapping(function(fallback) 155 | -- if cmp.visible() then 156 | -- cmp.select_next_item() 157 | -- else 158 | -- fallback() 159 | -- end 160 | -- end, { "i", "s" }), 161 | -- ['3'] = cmp.mapping(function(fallback) 162 | -- if cmp.visible() then 163 | -- cmp.select_next_item() 164 | -- cmp.select_next_item() 165 | -- else 166 | -- fallback() 167 | -- end 168 | -- end, { "i", "s" }), 169 | -- [''] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `` mapping. 170 | [''] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }), 171 | [''] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }), 172 | }, 173 | 174 | -- 使用 lspkind-nvim 显示类型图标 175 | formatting = { 176 | format = require'archvim.options'.nerd_fonts and has_lspkind and lspkind.cmp_format { 177 | mode = 'symbol', 178 | maxwidth = 50, 179 | before = function(entry, vim_item) 180 | vim_item.menu = "["..string.upper(entry.source.name).."]" 181 | 182 | if entry.source.name == "calc" then 183 | vim_item.kind = "Calc" 184 | end 185 | 186 | if entry.source.name == "git" then 187 | vim_item.kind = "Git" 188 | end 189 | 190 | if entry.source.name == "rg" then 191 | vim_item.kind = "Search" 192 | end 193 | 194 | if entry.source.name == "rime" then 195 | vim_item.kind = "Rime" 196 | end 197 | 198 | if entry.source.name == "cmp_yanky" then 199 | vim_item.kind = "Clipboard" 200 | end 201 | 202 | -- if entry.source.name == "nvim_lsp_signature_help" then 203 | -- vim_item.kind = "Call" 204 | -- end 205 | 206 | -- vim_item = require("tailwindcss-colorizer-cmp").formatter(entry, vim_item) 207 | return vim_item 208 | end, 209 | ellipsis_char = '...', 210 | symbol_map = { 211 | Text = "󰉿", 212 | Method = "󰆧", 213 | Function = "󰊕", 214 | Constructor = "", 215 | Field = "󰜢", 216 | Variable = "󰀫", 217 | Class = "󰠱", 218 | Interface = "", 219 | Module = "", 220 | Property = "󰜢", 221 | Unit = "󰑭", 222 | Value = "󰎠", 223 | Enum = "", 224 | Keyword = "󰌋", 225 | Snippet = "", 226 | Color = "󰏘", 227 | File = "󰈙", 228 | Reference = "󰈇", 229 | Folder = "󰉋", 230 | EnumMember = "", 231 | Constant = "󰏿", 232 | Struct = "󰙅", 233 | Event = "", 234 | Operator = "󰆕", 235 | TypeParameter = "", 236 | Calc = "", 237 | Git = "", 238 | Search = "", 239 | Rime = "", 240 | Clipboard = "", 241 | Call = "", 242 | }, 243 | }, 244 | }, 245 | } 246 | 247 | -- Use buffer source for `/`. 248 | -- cmp.setup.cmdline({'/', '?'}, { 249 | -- mapping = cmp.mapping.preset.cmdline({ 250 | -- -- Use default nvim history scrolling 251 | -- [""] = { 252 | -- c = false, 253 | -- }, 254 | -- [""] = { 255 | -- c = false, 256 | -- }, 257 | -- [''] = cmp.mapping.select_prev_item(), 258 | -- [''] = cmp.mapping.select_next_item(), 259 | -- }), 260 | -- sources = { 261 | -- { name = 'buffer' }, 262 | -- } 263 | -- }) 264 | -- 265 | -- -- -- Use cmdline & path source for ':'. 266 | -- cmp.setup.cmdline(':', { 267 | -- mapping = cmp.mapping.preset.cmdline({ 268 | -- -- Use default nvim history scrolling 269 | -- [""] = { 270 | -- c = false, 271 | -- }, 272 | -- [""] = { 273 | -- c = false, 274 | -- }, 275 | -- [''] = cmp.mapping.select_prev_item(), 276 | -- [''] = cmp.mapping.select_next_item(), 277 | -- }), 278 | -- sources = cmp.config.sources { 279 | -- { name = 'path' }, 280 | -- { name = 'cmdline' }, 281 | -- } 282 | -- }) 283 | 284 | -- vim.opt.spell = true 285 | -- vim.opt.spelllang = { 'en_us' } 286 | 287 | -- require("tailwindcss-colorizer-cmp").setup({ 288 | -- color_square_width = 2, 289 | -- }) 290 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-comment.lua: -------------------------------------------------------------------------------- 1 | local function update_commentstring() 2 | require("ts_context_commentstring.internal").update_commentstring() 3 | if vim.bo.commentstring == '' then 4 | if vim.bo.filetype == 'glsl' or vim.bo.filetype == 'cuda' then 5 | vim.bo.commentstring = '//%s' 6 | else 7 | vim.bo.commentstring = '#%s' 8 | end 9 | end 10 | end 11 | 12 | -- vim.api.nvim_create_autocmd("BufEnter", { 13 | -- callback = function() 14 | -- update_commentstring() 15 | -- end 16 | -- }) 17 | 18 | require('nvim_comment').setup { 19 | -- Linters prefer comment and line to have a space in between markers 20 | marker_padding = true, 21 | -- should comment out empty or whitespace only lines 22 | comment_empty = true, 23 | -- trim empty comment whitespace 24 | comment_empty_trim_whitespace = true, 25 | -- Should key mappings be created 26 | create_mappings = true, 27 | -- Normal mode mapping left hand side 28 | line_mapping = "gcc", 29 | -- Visual/Operator mapping left hand side 30 | operator_mapping = "gc", 31 | -- text object mapping, comment chunk,, 32 | comment_chunk_text_object = "ic", 33 | -- Hook function to call before commenting takes place 34 | hook = update_commentstring, 35 | } 36 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-dap.lua: -------------------------------------------------------------------------------- 1 | local function os_capture(cmd, raw) 2 | local f = assert(io.popen(cmd, 'r')) 3 | local s = assert(f:read('*a')) 4 | f:close() 5 | if raw then return s end 6 | s = string.gsub(s, '^%s+', '') 7 | s = string.gsub(s, '%s+$', '') 8 | s = string.gsub(s, '[\n\r]+', ' ') 9 | return s 10 | end 11 | 12 | local function file_exists(name) 13 | local f=io.open(name,"r") 14 | if f~=nil then io.close(f) return true else return false end 15 | end 16 | 17 | local dap = require('dap') 18 | 19 | dap.defaults.fallback.switchbuf = 'useopen,uselast' 20 | 21 | dap.adapters.codelldb = { 22 | type = 'server', 23 | port = "${port}", 24 | executable = { 25 | command = vim.fn.stdpath("data") .. '/mason/packages/codelldb/codelldb', 26 | args = {"--port", "${port}"}, 27 | -- command = os_capture('which sh'), 28 | -- args = {"-c", "codelldb --port ${port}"}, 29 | -- On windows you may have to uncomment this: 30 | -- detached = false, 31 | } 32 | } 33 | 34 | dap.configurations.cpp = { 35 | { 36 | name = "Launch file", 37 | type = "codelldb", 38 | request = "launch", 39 | program = function() 40 | local ok, xmakepath = pcall(function() 41 | return require("xmake.project_config").info.target.exec_path 42 | end) 43 | if ok then 44 | return xmakepath 45 | end 46 | -- TODO: cmake path? 47 | local exepath = 'a.out' 48 | if file_exists(exepath) then 49 | return exepath 50 | end 51 | return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') 52 | end, 53 | cwd = '${workspaceFolder}', 54 | stopOnEntry = false, 55 | }, 56 | { 57 | name = "Attach to process", 58 | type = "codelldb", 59 | request = "launch", 60 | program = function() 61 | return vim.fn.input('Process PID: ', vim.fn.getcwd() .. '/', 'file') 62 | end, 63 | cwd = '${workspaceFolder}', 64 | stopOnEntry = false, 65 | }, 66 | } 67 | dap.configurations.c = dap.configurations.cpp 68 | dap.configurations.rust = dap.configurations.cpp 69 | 70 | dap.adapters.python = function(cb, config) 71 | if config.request == 'attach' then 72 | ---@diagnostic disable-next-line: undefined-field 73 | local port = (config.connect or config).port 74 | ---@diagnostic disable-next-line: undefined-field 75 | local host = (config.connect or config).host or '127.0.0.1' 76 | cb({ 77 | type = 'server', 78 | port = assert(port, '`connect.port` is required for a python `attach` configuration'), 79 | host = host, 80 | options = { 81 | source_filetype = 'python', 82 | }, 83 | }) 84 | else 85 | cb({ 86 | type = 'executable', 87 | command = vim.fn.stdpath("data") .. '/mason/packages/debugpy/bin/python', 88 | args = { '-m', 'debugpy.adapter' }, 89 | options = { 90 | source_filetype = 'python', 91 | }, 92 | }) 93 | end 94 | end 95 | 96 | dap.configurations.python = { 97 | { 98 | type = 'python'; 99 | request = 'launch'; 100 | name = "Launch file"; 101 | program = "${file}"; 102 | pythonPath = function() 103 | return os_capture('which python') 104 | end; 105 | }, 106 | } 107 | 108 | dap.adapters.bashdb = { 109 | type = 'executable'; 110 | command = vim.fn.stdpath("data") .. '/mason/packages/bash-debug-adapter/bash-debug-adapter'; 111 | name = 'bashdb'; 112 | } 113 | 114 | dap.configurations.sh = { 115 | { 116 | type = 'bashdb'; 117 | request = 'launch'; 118 | name = "Launch file"; 119 | showDebugOutput = true; 120 | pathBashdb = vim.fn.stdpath("data") .. '/mason/packages/bash-debug-adapter/extension/bashdb_dir/bashdb'; 121 | pathBashdbLib = vim.fn.stdpath("data") .. '/mason/packages/bash-debug-adapter/extension/bashdb_dir'; 122 | trace = true; 123 | file = "${file}"; 124 | program = "${file}"; 125 | cwd = '${workspaceFolder}'; 126 | pathCat = "cat"; 127 | pathBash = "/bin/bash"; 128 | pathMkfifo = "mkfifo"; 129 | pathPkill = "pkill"; 130 | args = {}; 131 | env = {}; 132 | terminalKind = "integrated"; 133 | } 134 | } 135 | 136 | dap.adapters.node2 = { 137 | type = 'executable', 138 | command = 'node', 139 | args = {vim.fn.stdpath("data") .. '/mason/packages/node-debug2-adapter/out/src/nodeDebug.js'}, 140 | } 141 | 142 | dap.configurations.javascript = { 143 | { 144 | name = 'Launch file', 145 | type = 'node2', 146 | request = 'launch', 147 | program = '${file}', 148 | cwd = vim.fn.getcwd(), 149 | sourceMaps = true, 150 | protocol = 'inspector', 151 | console = 'integratedTerminal', 152 | }, 153 | { 154 | -- For this to work you need to make sure the node process is started with the `--inspect` flag. 155 | name = 'Attach to process', 156 | type = 'node2', 157 | request = 'attach', 158 | processId = require'dap.utils'.pick_process, 159 | }, 160 | } 161 | dap.configurations.typescript = dap.configurations.javascript 162 | dap.configurations.javascriptreact = dap.configurations.javascript 163 | dap.configurations.typescriptreact = dap.configurations.typescript 164 | 165 | local dapui = require('dapui') 166 | 167 | dapui.setup() 168 | 169 | dap.listeners.after.event_initialized["dapui_config"] = function() 170 | dapui.open() 171 | end 172 | dap.listeners.before.event_terminated["dapui_config"] = function() 173 | dapui.close() 174 | end 175 | dap.listeners.before.event_exited["dapui_config"] = function() 176 | dapui.close() 177 | end 178 | 179 | -- vim.cmd [[vnoremap gsK lua require("dapui").eval()]] 180 | -- vim.cmd [[nnoremap gsK lua require("dapui").eval()]] 181 | 182 | vim.fn.sign_define('DapBreakpoint', {text='🔴', texthl='', linehl='', numhl=''}) 183 | vim.fn.sign_define('DapBreakpointCondition', {text='⭕', texthl='', linehl='', numhl=''}) 184 | vim.fn.sign_define('DapBreakpointRejected', {text='🚫', texthl='', linehl='', numhl=''}) 185 | vim.fn.sign_define('DapLogPoint', {text='📔', texthl='', linehl='', numhl=''}) 186 | vim.fn.sign_define('DapStopped', {text='👉', texthl='', linehl='', numhl=''}) 187 | 188 | require("nvim-dap-virtual-text").setup() 189 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-gpt.lua: -------------------------------------------------------------------------------- 1 | require'nvim-gpt'.setup { 2 | -- which backend to use: gpt-3.5-turbo, gpt-4, gpt-4-32k, creative, balanced, percise, google-search 3 | model = 'gpt-3.5-turbo', 4 | -- model = 'deepseek-ai/deepseek-llm-7b-chat', 5 | -- model = 'balanced', 6 | -- model = 'dummy', 7 | -- may provide specific parameters like temperature depends on models 8 | params = { 9 | ['gpt-3.5-turbo'] = { 10 | -- see https://platform.openai.com/docs/api-reference/chat/create 11 | temperature = 0.85, 12 | top_p = 1, 13 | n = 1, 14 | presence_penalty = 0, 15 | frequency_penalty = 0, 16 | }, 17 | ['google-search'] = { 18 | -- see https://pypi.org/project/googlesearch-python 19 | num_results = 10, 20 | sleep_interval = 0, 21 | timeout = 5, 22 | lang = 'en', 23 | format = '\n# {title}\n- {url}\n\n{desc}\n', 24 | }, 25 | }, 26 | -- '|/_\\' = rotating loading symbol, '_ ' = blinking on and off, '' = disable 27 | -- cursors = '|/_\\', 28 | cursors = '🌑🌒🌓🌔🌕🌖🌗🌘', 29 | -- cursors = '▙▛▜▟', 30 | -- cursors = '', 31 | -- this is how we quote code when :'<,'>GPTCode 32 | code_quote = '{question}\n```{filetype}\n{code}\n```', 33 | -- this is how we ask for code insertion when :GPTWrite 34 | code_insertion = { 35 | '### File: {file}\n', 36 | '### ', 37 | '\n### Instruction\nDo code insertion at the mark. Note that you only need to output the text to be inserted, with no additional text.', 38 | }, 39 | -- title indicating human question in GPT window 40 | question_title = '\n🙂:', 41 | -- title indicating bot answer in GPT window 42 | answer_title = '\n🤖:', 43 | -- marker use when human requests to regenerate 44 | regenerate_title = '🔄', 45 | -- whether to show bot's welcome messages on start up: 'fancy', '🤖 {}', 'none' 46 | welcome_messages = '🤖 {}', 47 | -- GPT window width 48 | window_width = 45, 49 | -- GPT window specific options 50 | window_options = { 51 | wrap = true, 52 | signcolumn = 'no', 53 | list = false, 54 | cursorline = true, 55 | number = false, 56 | relativenumber = false, 57 | }, 58 | -- whether we lock to last line when answer: none, last-char, last-line, force 59 | lock_last_line = 'force', 60 | -- GPT window update interval (ms) when streaming the answer 61 | update_interval = 100, 62 | -- automatically add default keymaps (see 'Keymaps' section below) 63 | no_default_keymaps = false, 64 | question_templates = [[ 65 | Note that you shall only output the plain answer, with no additional text like 'Sure' or 'Here is the result'. 66 | Please wrap the final answer with triple quotes like ```answer```. 67 | The answer is wrong, please try again. 68 | Write a test for this code. 69 | Write an documentation or API reference for this code. 70 | Could you find any possible BUGs in this code? 71 | Write a benchmark for this code. You may want to use the Google Benchmark as framework. 72 | Rewrite to simplify this. 73 | Edit the code to fix the problem. 74 | How to fix this error? 75 | Explain the purpose of this code, step by step. 76 | Rename the variable and function names to make them more readable. 77 | Rewrite to make this code more readable and maintainable. 78 | This line is too long and complex. Could you split it for readability? 79 | Please reduce duplication by following the Don't Repeat Yourself principle. 80 | Complete the missing part of code with given context. 81 | Implement the function based on its calling signature. 82 | Here is a markdown file that have several links in the format [name](link), please fill the links according to given name. You may want to search the web if you are not sure about the link. 83 | Make this expression longer and fullfilling. 84 | Let's think step by step. 85 | Could you verify this? 86 | You may want to search the web. 87 | Since the output length is limited. Please omit the unchanged part with ellipses. Only output the changed or newly-added part. 88 | Please provide multiple different versions of answer for reference. 89 | Fix possible grammar issues or typos in my writing. 90 | Rewrite with better choices of words. 91 | Translate from Chinese to English, or English to Chinese. 92 | 请给出如何解决问题的bash指令,确保你给出的指令是可以直接正常执行的。不要输出伪代码,不要含有placeholder。我会回复你命令执行的结果。你总是以可执行的bash命令来告诉我下一步怎么做,你的回答总是应该包含一个bash命令块。如果问题太大,你可以一步一步来,把问题分解成若干个可实操的步骤,现在你只需要告诉我第一步该怎么用bash命令来做。如果我的问题中包含你不知道的信息,你可以输出ls命令来查看我的文件系统,或用cat来查看文件内容。如果我的问题需要创建或修改文件,请你用这种格式: cat > somefile.txt < EOF 来创建或修改文件内容。如果只需往文件里追加内容,可以用>>。如果只需查找替换部分内容,可以用sed。 93 | ]], 94 | } 95 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-lint.lua: -------------------------------------------------------------------------------- 1 | require("lint").linters_by_ft = { 2 | python = {"pylint"}, 3 | c = {"clangtidy"}, 4 | cpp = {"cpplint"}, 5 | cmake = {"cmakelint"}, 6 | javascript = {"eslint"}, 7 | typescript = {"eslint"}, 8 | go = {"golangcilint"}, 9 | markdown = {"vale"}, 10 | yaml = {"yamllint"}, 11 | bash = {"shellcheck"}, 12 | lua = {"luacheck"}, 13 | -- INFO: add your language here 14 | } 15 | -- vim.cmd [[ 16 | -- augroup nvim_lint_try_lint_ont_write 17 | -- autocmd! 18 | -- autocmd BufEnter,BufWritePost * lua require('lint').try_lint() 19 | -- augroup end 20 | -- ]] 21 | vim.keymap.set({"n", "v"}, "gq", function () require('lint').try_lint() end) 22 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-spectre.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/nvim-pack/nvim-spectre 2 | -- WARN: spectre 手动安装依赖项 sed 和 ripgrep 3 | -- sed 命令(自行安装,如果已有则忽略) 4 | -- ripgrep: https://github.com/BurntSushi/ripgrep 5 | 6 | require("spectre").setup { 7 | mapping = { 8 | -- 删除选中 9 | ["toggle_line"] = { 10 | map = "dd", 11 | cmd = "lua require('spectre').toggle_line()", 12 | desc = "toggle current item" 13 | }, 14 | -- 前往文件 15 | ["enter_file"] = { 16 | map = "", 17 | cmd = "lua require('spectre.actions').select_entry()", 18 | desc = "goto current file" 19 | }, 20 | -- 查看菜单(忽略大小写、忽略隐藏文件) 21 | ["show_option_menu"] = { 22 | map = "go", 23 | cmd = "lua require('spectre').show_options()", 24 | desc = "show option" 25 | }, 26 | -- 开始替换 27 | ["run_replace"] = { 28 | map = "gr", 29 | cmd = "lua require('spectre.actions').run_replace()", 30 | desc = "replace all" 31 | }, 32 | -- 显示差异 33 | ["change_view_mode"] = { 34 | map = "gv", 35 | cmd = "lua require('spectre').change_view()", 36 | desc = "change result view mode" 37 | } 38 | } 39 | } 40 | 41 | local map = require'archvim/mappings' 42 | -- 全项目替换 43 | map("n", "sp", "lua require('spectre').open()") 44 | -- 只替换当前文件 45 | map("n", "sf", "lua require('spectre').open_file_search()") 46 | -- 全项目中搜索当前单词 47 | map("n", "sw", "lua require('spectre').open_visual({select_word=true})") 48 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-surround.lua: -------------------------------------------------------------------------------- 1 | require'nvim-surround'.setup { 2 | keymaps = { 3 | insert = "", 4 | insert_line = "", 5 | normal = "ys", 6 | normal_cur = "yss", 7 | normal_line = "yS", 8 | normal_cur_line = "ySS", 9 | visual = "s", 10 | visual_line = "S", 11 | delete = "ds", 12 | change = "cs", 13 | }, 14 | } 15 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-tree.lua: -------------------------------------------------------------------------------- 1 | require'nvim-tree'.setup { 2 | auto_reload_on_write = true, 3 | hijack_cursor = false, 4 | -- open_on_setup = false, 5 | -- open_on_setup_file = true, 6 | hijack_unnamed_buffer_when_opening = false, 7 | sort_by = "name", 8 | view = { 9 | width = 30, 10 | -- height = 30, 11 | side = "right", 12 | --color = "#3f0af0", 13 | preserve_window_proportions = true, -- cmake-tools say that they need this 14 | }, 15 | filters = { 16 | custom = { "^.git$" }, 17 | }, 18 | renderer = { 19 | icons = { 20 | web_devicons = { 21 | file = { 22 | enable = true, 23 | color = true, 24 | }, 25 | folder = { 26 | enable = false, 27 | color = true, 28 | }, 29 | }, 30 | show = { 31 | file = true, 32 | folder = true, 33 | folder_arrow = true, 34 | git = true, 35 | modified = true, 36 | hidden = false, 37 | diagnostics = true, 38 | bookmarks = true, 39 | }, 40 | }, 41 | }, 42 | } 43 | 44 | -- vim.cmd [[ 45 | -- augroup exit_if_nvim_tree_only_tab 46 | -- autocmd! 47 | -- autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | wqa | endif 48 | -- augroup end 49 | -- ]] 50 | 51 | local function open_nvim_tree(data) 52 | -- -- buffer is a real file on the disk 53 | -- local real_file = vim.fn.filereadable(data.file) == 1 54 | -- 55 | -- -- buffer is a [No Name] 56 | -- local no_name = data.file == "" and vim.bo[data.buf].buftype == "" 57 | 58 | -- buffer is a directory 59 | local directory = vim.fn.isdirectory(data.file) == 1 60 | 61 | -- if not real_file and not no_name and not directory then 62 | -- return 63 | -- end 64 | 65 | if not directory then 66 | -- open the tree, find the file but don't focus it 67 | -- require("nvim-tree.api").tree.toggle({ focus = false, find_file = true, }) 68 | else 69 | -- create a new, empty buffer 70 | -- vim.cmd.enew() 71 | -- wipe the directory buffer 72 | vim.cmd.bw(data.buf) 73 | -- change to the directory 74 | vim.cmd.cd(data.file) 75 | -- open the tree 76 | require("nvim-tree.api").tree.open() 77 | end 78 | end 79 | 80 | vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) 81 | 82 | -- vim.api.nvim_create_autocmd("BufEnter", { 83 | -- nested = true, 84 | -- callback = function() 85 | -- if #vim.api.nvim_list_wins() == 1 and require("nvim-tree.utils").is_nvim_tree_buf() then 86 | -- vim.cmd "quit" 87 | -- end 88 | -- end 89 | -- }) 90 | 91 | -- local map = require'archvim/mappings' 92 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim-treesitter.lua: -------------------------------------------------------------------------------- 1 | ------------------------------- 2 | require'nvim-treesitter.configs'.setup { 3 | -- ensure_installed = {"c", "cpp", "cuda", "cmake", "lua", "python", "html", "javascript", "css", "json", "bash", "regex", "markdown", "diff", "glsl", "vim", "vimdoc"}, 4 | sync_install = false, 5 | highlight = { 6 | enable = true, 7 | additional_vim_regex_highlighting = false, 8 | }, 9 | incremental_selection = { 10 | enable = true, 11 | keymaps = { 12 | init_selection = '+', 13 | node_incremental = '+', 14 | node_decremental = '-', 15 | -- scope_incremental = '+', 16 | } 17 | }, 18 | indent = { 19 | enable = true, 20 | }, 21 | rainbow = { 22 | enable = false, 23 | extended_mode = true, 24 | }, 25 | matchup = { 26 | enable = true, 27 | }, 28 | context_commentstring = { 29 | enable = true, 30 | }, 31 | textobjects = { 32 | select = { 33 | enable = true, 34 | 35 | -- Automatically jump forward to textobj, similar to targets.vim 36 | lookahead = true, 37 | 38 | keymaps = { 39 | -- You can use the capture groups defined in textobjects.scm 40 | ["af"] = "@function.outer", 41 | ["if"] = "@function.inner", 42 | ["ac"] = "@class.outer", 43 | ["ic"] = "@class.inner", 44 | ["as"] = { query = "@scope", query_group = "locals" }, 45 | ["az"] = { query = "@fold", query_group = "folds" }, 46 | ["ai"] = "@call.outer", 47 | ["ii"] = "@call.inner", 48 | ["ad"] = "@conditional.outer", 49 | ["id"] = "@conditional.inner", 50 | ["ae"] = "@loop.outer", 51 | ["ie"] = "@loop.inner", 52 | ["ap"] = "@parameter.outer", 53 | ["ip"] = "@parameter.inner", 54 | ["ab"] = "@block.outer", 55 | ["ib"] = "@block.inner", 56 | ["at"] = "@comment.outer", 57 | ["it"] = "@comment.inner", 58 | ["ar"] = "@return.outer", 59 | ["ir"] = "@return.inner", 60 | ["al"] = "@statement.outer", 61 | ["il"] = "@statement.inner", 62 | ["an"] = "@number.outer", 63 | ["in"] = "@number.inner", 64 | ["ah"] = "@assignment.outer", 65 | ["ih"] = "@assignment.inner", 66 | }, 67 | -- You can choose the select mode (default is charwise 'v') 68 | -- 69 | -- Can also be a function which gets passed a table with the keys 70 | -- * query_string: eg '@function.inner' 71 | -- * method: eg 'v' or 'o' 72 | -- and should return the mode ('v', 'V', or '') or a table 73 | -- mapping query_strings to modes. 74 | selection_modes = { 75 | ['@parameter.outer'] = 'v', -- charwise 76 | ['@function.outer'] = 'V', -- linewise 77 | ['@statement.outer'] = 'V', -- linewise 78 | ['@assignment.outer'] = 'V', -- linewise 79 | ['@block.outer'] = 'V', -- linewise 80 | ['@loop.outer'] = 'V', -- linewise 81 | ['@conditional.outer'] = 'V', -- linewise 82 | ['@class.outer'] = 'V', -- linewise 83 | }, 84 | -- If you set this to `true` (default is `false`) then any textobject is 85 | -- extended to include preceding or succeeding whitespace. Succeeding 86 | -- whitespace has priority in order to act similarly to eg the built-in 87 | -- `ap`. 88 | -- 89 | -- Can also be a function which gets passed a table with the keys 90 | -- * query_string: eg '@function.inner' 91 | -- * selection_mode: eg 'v' 92 | -- and should return true of false 93 | include_surrounding_whitespace = false, 94 | }, 95 | swap = { 96 | enable = true, 97 | swap_next = { 98 | ["ml"] = "@parameter.inner", 99 | ["mj"] = "@statement.outer", 100 | ["mip"] = "@parameter.inner", 101 | ["mib"] = "@block.outer", 102 | ["mil"] = "@statement.outer", 103 | ["mif"] = "@function.outer", 104 | ["mic"] = "@class.outer", 105 | ["min"] = "@number.inner", 106 | }, 107 | swap_previous = { 108 | ["mh"] = "@parameter.inner", 109 | ["mk"] = "@statement.outer", 110 | ["map"] = "@parameter.inner", 111 | ["mab"] = "@block.outer", 112 | ["mal"] = "@statement.outer", 113 | ["maf"] = "@function.outer", 114 | ["mac"] = "@class.outer", 115 | ["man"] = "@number.inner", 116 | }, 117 | }, 118 | move = { 119 | enable = true, 120 | set_jumps = true, -- whether to set jumps in the jumplist 121 | goto_next_start = { 122 | ["]f"] = "@function.outer", 123 | ["]c"] = "@class.outer", 124 | ["]s"] = { query_group = "locals", query = "@scope" }, 125 | ["]z"] = { query = "@fold", query_group = "folds" }, 126 | ["]i"] = "@call.*", 127 | ["]d"] = "@conditional.*", 128 | ["]o"] = "@loop.*", 129 | ["]p"] = "@parameter.inner", 130 | ["]b"] = "@block.outer", 131 | ["]t"] = "@comment.*", 132 | ["]r"] = "@return.inner", 133 | ["]l"] = "@statement.*", 134 | ["]n"] = "@number.*", 135 | ["]h"] = "@assignment.outer", 136 | }, 137 | goto_next_end = { 138 | ["]F"] = "@function.outer", 139 | ["]C"] = "@class.outer", 140 | ["]S"] = { query = "@scope", query_group = "locals" }, 141 | ["]Z"] = { query = "@fold", query_group = "folds" }, 142 | ["]I"] = "@call.*", 143 | ["]D"] = "@conditional.*", 144 | ["]E"] = "@loop.*", 145 | ["]P"] = "@parameter.inner", 146 | ["]B"] = "@block.outer", 147 | ["]T"] = "@comment.*", 148 | ["]R"] = "@return.inner", 149 | ["]L"] = "@statement.*", 150 | ["]N"] = "@number.*", 151 | ["]H"] = "@assignment.outer", 152 | }, 153 | goto_previous_start = { 154 | ["[f"] = "@function.outer", 155 | ["[c"] = "@class.outer", 156 | ["[s"] = { query = "@scope", query_group = "locals" }, 157 | ["[z"] = { query = "@fold", query_group = "folds" }, 158 | ["[i"] = "@call.*", 159 | ["[d"] = "@conditional.*", 160 | ["[e"] = "@loop.*", 161 | ["[p"] = "@parameter.inner", 162 | ["[b"] = "@block.outer", 163 | ["[t"] = "@comment.*", 164 | ["[r"] = "@return.inner", 165 | ["[l"] = "@statement.*", 166 | ["[n"] = "@number.*", 167 | ["[h"] = "@assignment.outer", 168 | }, 169 | goto_previous_end = { 170 | ["[F"] = "@function.outer", 171 | ["[C"] = "@class.outer", 172 | ["[S"] = { query = "@scope", query_group = "locals" }, 173 | ["[Z"] = { query = "@fold", query_group = "folds" }, 174 | ["[I"] = "@call.*", 175 | ["[D"] = "@conditional.*", 176 | ["[E"] = "@loop.*", 177 | ["[P"] = "@parameter.*", 178 | ["[B"] = "@block.outer", 179 | ["[T"] = "@comment.*", 180 | ["[R"] = "@return.inner", 181 | ["[L"] = "@statement.*", 182 | ["[N"] = "@number.*", 183 | ["[H"] = "@assignment.outer", 184 | }, 185 | -- Below will go to either the start or the end, whichever is closer. 186 | -- Use if you want more granular movements 187 | -- Make it even more gradual by adding multiple queries and regex. 188 | -- goto_next = { 189 | -- ["]d"] = "@conditional.outer", 190 | -- }, 191 | -- goto_previous = { 192 | -- ["[d"] = "@conditional.outer", 193 | -- } 194 | }, 195 | lsp_interop = { 196 | enable = true, 197 | border = 'none', 198 | floating_preview_opts = {}, 199 | peek_definition_code = { 200 | ["gsf"] = "@function.outer", 201 | ["gsc"] = "@class.outer", 202 | }, 203 | }, 204 | }, 205 | autotag = { 206 | enable = true, 207 | }, 208 | -- refactor = { 209 | -- highlight_definitions = { 210 | -- enable = false, 211 | -- -- Set to false if you have an `updatetime` of ~100. 212 | -- clear_on_cursor_move = true, 213 | -- }, 214 | -- highlight_current_scope = { 215 | -- enable = false, 216 | -- }, 217 | -- smart_rename = { 218 | -- enable = true, 219 | -- -- Assign keymaps to false to disable them, e.g. `smart_rename = false`. 220 | -- keymaps = { 221 | -- smart_rename = "gnr", 222 | -- }, 223 | -- }, 224 | -- navigation = { 225 | -- enable = true, 226 | -- -- Assign keymaps to false to disable them, e.g. `goto_definition = false`. 227 | -- keymaps = { 228 | -- goto_definition = "gnd", 229 | -- list_definitions = "gnl", 230 | -- list_definitions_toc = "gno", 231 | -- goto_next_usage = "gn]", 232 | -- goto_previous_usage = "gn[", 233 | -- }, 234 | -- }, 235 | -- }, 236 | } 237 | 238 | require('ts_context_commentstring').setup{} 239 | vim.g.skip_ts_context_commentstring_module = true 240 | 241 | vim.g.matchup_matchparen_offscreen = { method = "status" } 242 | vim.g.matchup_surround_enabled = 1 243 | vim.g.matchup_delim_noskips = 2 244 | 245 | -- vim.wo.foldmethod = 'expr' 246 | -- vim.wo.foldexpr = 'nvim_#foldexpr()' 247 | -- vim.wo.foldlevel = 99 248 | 249 | -- require'treesitter-context'.setup { 250 | -- enable = false, -- Enable this plugin (Can be enabled/disabled later via commands) 251 | -- max_lines = 0, -- How many lines the window should span. Values <= 0 mean no limit. 252 | -- min_window_height = 0, -- Minimum editor window height to enable context. Values <= 0 mean no limit. 253 | -- line_numbers = true, 254 | -- multiline_threshold = 20, -- Maximum number of lines to show for a single context 255 | -- trim_scope = 'inner', -- Which context lines to discard if `max_lines` is exceeded. Choices: 'inner', 'outer' 256 | -- mode = 'cursor', -- Line used to calculate context. Choices: 'cursor', 'topline' 257 | -- -- Separator between context and content. Should be a single character string, like '-'. 258 | -- -- When separator is set, the context will only show up when there are at least 2 lines above cursorline. 259 | -- separator = nil, 260 | -- zindex = 20, -- The Z-index of the context window 261 | -- on_attach = nil, -- (fun(buf: integer): boolean) return false to disable attaching 262 | -- } 263 | 264 | -- vim.keymap.set("n", "[.", function() 265 | -- require("treesitter-context").go_to_context() 266 | -- end, { silent = true }) 267 | 268 | -- -- use 'vm' to visual select any block like hop.nvim does 269 | -- vim.cmd [[ 270 | -- omap m :lua pcall(require('tsht').nodes) 271 | -- xnoremap m :lua pcall(require('tsht').nodes) 272 | -- ]] 273 | 274 | -- require 'nt-cpp-tools'.setup { 275 | -- preview = { 276 | -- quit = 'q', -- optional keymapping for quit preview 277 | -- accept = '' -- optional keymapping for accept preview 278 | -- }, 279 | -- header_extension = 'hpp', -- optional 280 | -- source_extension = 'cpp', -- optional 281 | -- custom_define_class_function_commands = { -- optional 282 | -- TSCppImplWrite = { 283 | -- output_handle = require'nt-cpp-tools.output_handlers'.get_add_to_cpp() 284 | -- } 285 | -- --[[ 286 | -- = { 287 | -- output_handle = function (str, context) 288 | -- -- string contains the class implementation 289 | -- -- do whatever you want to do with it 290 | -- end 291 | -- } 292 | -- ]] 293 | -- } 294 | -- } 295 | -------------------------------------------------------------------------------- /lua/archvim/config/nvim_context_vt.lua: -------------------------------------------------------------------------------- 1 | require('nvim_context_vt').setup({ 2 | enabled = true, 3 | prefix = '#', 4 | }) 5 | 6 | local utils = require('nvim_context_vt.utils') 7 | utils.default_parser = function(node, _, opts) 8 | local text = utils.get_node_text(node, 0)[1] 9 | if vim.bo.filetype == 'c' or vim.bo.filetype == 'cpp' or vim.bo.filetype == 'cuda' or vim.bo.filetype == 'glsl' then 10 | return string.format('// %s', text) 11 | end 12 | if vim.bo.commentstring == '' then 13 | return opts.prefix .. ' ' .. text 14 | end 15 | if vim.bo.commentstring:find('%s') then 16 | text = string.format(vim.bo.commentstring, text) 17 | else 18 | text = vim.trim(string.format(vim.bo.commentstring, ' ' .. text .. ' ')) 19 | end 20 | return text 21 | end 22 | -------------------------------------------------------------------------------- /lua/archvim/config/overseer.lua: -------------------------------------------------------------------------------- 1 | local overseer = require("overseer") 2 | 3 | overseer.setup{ 4 | templates = { "builtin", "user.cpp_build", "user.run_script" }, 5 | strategy = { 6 | "toggleterm", 7 | -- load your default shell before starting the task 8 | use_shell = false, 9 | -- overwrite the default toggleterm "direction" parameter 10 | direction = nil, 11 | -- overwrite the default toggleterm "highlights" parameter 12 | highlights = nil, 13 | -- overwrite the default toggleterm "auto_scroll" parameter 14 | auto_scroll = nil, 15 | -- have the toggleterm window close and delete the terminal buffer 16 | -- automatically after the task exits 17 | close_on_exit = false, 18 | -- have the toggleterm window close without deleting the terminal buffer 19 | -- automatically after the task exits 20 | -- can be "never, "success", or "always". "success" will close the window 21 | -- only if the exit code is 0. 22 | quit_on_exit = "never", 23 | -- open the toggleterm window when a task starts 24 | open_on_start = true, 25 | -- mirrors the toggleterm "hidden" parameter, and keeps the task from 26 | -- being rendered in the toggleable window 27 | hidden = false, 28 | -- command to run when the terminal is created. Combine with `use_shell` 29 | -- to run a terminal command before starting the task 30 | on_create = nil, 31 | } 32 | } 33 | 34 | vim.api.nvim_create_user_command("WatchRun", function() 35 | overseer.run_template({ name = "run script" }, function(task) 36 | if task then 37 | task:add_component({ "restart_on_save", paths = {vim.fn.expand("%:p")} }) 38 | local main_win = vim.api.nvim_get_current_win() 39 | overseer.run_action(task, "open") 40 | vim.api.nvim_set_current_win(main_win) 41 | else 42 | vim.notify("WatchRun not supported for filetype " .. vim.bo.filetype, vim.log.levels.ERROR) 43 | end 44 | end) 45 | end, {}) 46 | 47 | vim.api.nvim_create_user_command("Grep", function(params) 48 | -- Insert args at the '$*' in the grepprg 49 | local cmd, num_subs = vim.o.grepprg:gsub("%$%*", params.args) 50 | if num_subs == 0 then 51 | cmd = cmd .. " " .. params.args 52 | end 53 | local task = overseer.new_task({ 54 | cmd = vim.fn.expandcmd(cmd), 55 | components = { 56 | { 57 | "on_output_quickfix", 58 | errorformat = vim.o.grepformat, 59 | open = not params.bang, 60 | open_height = 8, 61 | items_only = true, 62 | }, 63 | -- We don't care to keep this around as long as most tasks 64 | { "on_complete_dispose", timeout = 30 }, 65 | "default", 66 | }, 67 | }) 68 | task:start() 69 | end, { nargs = "*", bang = true, complete = "file" }) 70 | 71 | vim.api.nvim_create_user_command("Make", function(params) 72 | -- Insert args at the '$*' in the makeprg 73 | local cmd, num_subs = vim.o.makeprg:gsub("%$%*", params.args) 74 | if num_subs == 0 then 75 | cmd = cmd .. " " .. params.args 76 | end 77 | local task = require("overseer").new_task({ 78 | cmd = vim.fn.expandcmd(cmd), 79 | components = { 80 | { "on_output_quickfix", open = not params.bang, open_height = 8 }, 81 | "default", 82 | }, 83 | }) 84 | task:start() 85 | end, { 86 | desc = "Run your makeprg as an Overseer task", 87 | nargs = "*", 88 | bang = true, 89 | }) 90 | 91 | vim.api.nvim_create_user_command("OverseerRestartLast", function() 92 | local tasks = overseer.list_tasks({ recent_first = true }) 93 | if vim.tbl_isempty(tasks) then 94 | vim.notify("No tasks found", vim.log.levels.WARN) 95 | else 96 | overseer.run_action(tasks[1], "restart") 97 | end 98 | end, {}) 99 | -------------------------------------------------------------------------------- /lua/archvim/config/refactoring.lua: -------------------------------------------------------------------------------- 1 | require'refactoring'.setup{} 2 | 3 | vim.keymap.set({ "n", "x" }, "ref", function() require('refactoring').refactor('Extract Function') end) 4 | vim.keymap.set({ "n", "x" }, "rff", function() require('refactoring').refactor('Extract Function To File') end) 5 | -- Extract function supports only visual mode 6 | vim.keymap.set({ "n", "x" }, "rev", function() require('refactoring').refactor('Extract Variable') end) 7 | -- Extract variable supports only visual mode 8 | vim.keymap.set({ "n", "x" }, "rif", function() require('refactoring').refactor('Inline Function') end) 9 | -- Inline func supports only normal 10 | vim.keymap.set({ "n", "x" }, "riv", function() require('refactoring').refactor('Inline Variable') end) 11 | -- Inline var supports both normal and visual mode 12 | vim.keymap.set({ "n", "x" }, "reb", function() require('refactoring').refactor('Extract Block') end) 13 | vim.keymap.set({ "n", "x" }, "rfb", function() require('refactoring').refactor('Extract Block To File') end) 14 | -- Extract block supports only normal mode 15 | -- prompt for a refactor to apply when the remap is triggered 16 | vim.keymap.set( 17 | {"n", "x"}, 18 | "r?", 19 | function() require('refactoring').select_refactor() end 20 | ) 21 | -- Note that not all refactor support both normal and visual mode 22 | -------------------------------------------------------------------------------- /lua/archvim/config/surround.lua: -------------------------------------------------------------------------------- 1 | require"surround".setup { 2 | context_offset = 100, 3 | load_autogroups = false, 4 | mappings_style = "surround", 5 | map_insert_mode = true, 6 | quotes = {"'", '"'}, 7 | brackets = {"(", '{', '['}, 8 | space_on_closing_char = true, 9 | pairs = { 10 | nestable = { 11 | b = { "(", ")" }, 12 | s = { "[", "]" }, 13 | B = { "{", "}" }, 14 | a = { "<", ">" }, 15 | }, 16 | linear = { 17 | q = { "'", "'" }, 18 | t = { "`", "`" }, 19 | d = { '"', '"' }, 20 | }, 21 | prefix = "s", 22 | }, 23 | } 24 | -------------------------------------------------------------------------------- /lua/archvim/config/telescope.lua: -------------------------------------------------------------------------------- 1 | require("telescope").setup{ 2 | defaults = { 3 | initial_mode = 'normal', 4 | }, 5 | mappings = { 6 | n = { 7 | [""] = require('telescope.actions').close, 8 | }, 9 | }, 10 | extensions = { 11 | aerial = { 12 | -- How to format the symbols 13 | format_symbol = function(symbol_path, filetype) 14 | -- if filetype == "json" or filetype == "yaml" then 15 | return table.concat(symbol_path, ".") 16 | -- else 17 | -- return symbol_path[#symbol_path] 18 | -- end 19 | end, 20 | -- Available modes: symbols, lines, both 21 | show_columns = "both", 22 | }, 23 | }, 24 | } 25 | 26 | -- 查找文件 27 | vim.keymap.set("n", "l", "Telescope find_files initial_mode=insert") 28 | -- 查找文件(仅包含 CMake 目标所直接包含的源和头文件) 29 | vim.keymap.set("n", "L", "Telescope cmake_tools sources initial_mode=insert") 30 | -- 查找文件(仅包含 CMakeLists.txt 和 *.cmake 类文件) 31 | vim.keymap.set("n", "O", "Telescope cmake_tools cmake_files initial_mode=insert") 32 | -- 查找 git 仓库中的文件 33 | vim.keymap.set("n", "i", "Telescope git_files initial_mode=insert") 34 | -- 查找最近打开过的文件 35 | vim.keymap.set("n", "o", "Telescope oldfiles initial_mode=insert") 36 | -- 查找 git status 中的文件 37 | vim.keymap.set("n", "p", "Telescope git_status initial_mode=insert") 38 | -- 查找当前项目文件中的文字 39 | vim.keymap.set("n", "k", "Telescope live_grep initial_mode=insert") 40 | -- 模糊查找当前文件中的文字 41 | vim.keymap.set("n", ".", "Telescope current_buffer_fuzzy_find initial_mode=insert") 42 | -- 查找所有已打开文件 43 | vim.keymap.set("n", "b", "Telescope buffers") 44 | -- 查找当前 Tab 中所有已打开文件 45 | vim.keymap.set("n", "B", "Telescope scope buffers") 46 | -- 查找 vim 的跳转记录 47 | vim.keymap.set("n", "j", "Telescope jumplist initial_mode=insert") 48 | -- 查找 vim 的标记 49 | vim.keymap.set("n", "m", "Telescope marks initial_mode=insert") 50 | -- 查找 / 的搜索记录 51 | vim.keymap.set("n", "/", "Telescope search_history initial_mode=insert") 52 | -- 查找 vim 命令历史记录 53 | vim.keymap.set("n", ":", "Telescope command_history initial_mode=insert") 54 | -- 查找所有 vim 命令 55 | vim.keymap.set("n", ";", "Telescope commands initial_mode=insert") 56 | -- 查找帮助文档 57 | vim.keymap.set("n", "?", "Telescope help_tags initial_mode=insert") 58 | if pcall(require, "todo-comments") then 59 | -- 查找 todo 等事项 60 | vim.keymap.set("n", "t", "TodoTelescope initial_mode=insert") 61 | end 62 | -- 查找本文件中所有文本对象 63 | vim.keymap.set("n", "z", "Telescope treesitter initial_mode=insert") 64 | -- 查找本文件中所有符号 65 | vim.keymap.set("n", "x", "Telescope lsp_document_symbols initial_mode=insert") 66 | -- 查找 git 仓库的 commit 历史 67 | vim.keymap.set("n", "c", "Telescope git_commits") 68 | -- 查找 git 仓库的所有分支 69 | vim.keymap.set("n", "v", "Telescope git_branches") 70 | -- 查找本文件中所有静态分析报错 71 | vim.keymap.set("n", "a", "Telescope diagnostics") 72 | -- 查找本文件中所有动态编译报错 73 | vim.keymap.set("n", "q", "Telescope quickfix") 74 | -- 查看所有 Vim 通知 75 | vim.keymap.set("n", "n", "Telescope notify") 76 | -- 模糊查询 77 | vim.keymap.set({"v", "n"}, "", "FzfLua", { silent = true, desc = "Fuzzy Find" }) 78 | -------------------------------------------------------------------------------- /lua/archvim/config/toggleterm.lua: -------------------------------------------------------------------------------- 1 | require("toggleterm").setup{ 2 | -- size can be a number or function which is passed the current terminal 3 | size = function(term) 4 | if term.direction == "horizontal" then 5 | return 10 6 | elseif term.direction == "vertical" then 7 | return vim.o.columns * 0.4 8 | end 9 | end, 10 | open_mapping = [[]], 11 | hide_numbers = true, -- hide the number column in toggleterm buffers 12 | -- shade_filetypes = {}, 13 | autochdir = true, 14 | shade_terminals = false, 15 | -- shading_factor = '1', -- the degree by which to darken to terminal colour, default: 1 for dark backgrounds, 3 for light 16 | start_in_insert = true, 17 | insert_mappings = true, -- whether or not the open mapping applies in insert mode 18 | terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals 19 | persist_size = true, 20 | persist_mode = true, 21 | -- direction = 'vertical', 22 | direction = 'tab', 23 | -- direction = 'vertical', 24 | close_on_exit = true, -- close the terminal window when the process exits 25 | auto_scroll = false, -- automatically scroll to the bottom on terminal output 26 | -- This field is only relevant if direction is set to 'float' 27 | float_opts = { 28 | -- The border key is *almost* the same as 'nvim_open_win' 29 | -- see :h nvim_open_win for details on borders however 30 | -- the 'curved' border is a custom border type 31 | -- not natively supported but implemented in this plugin. 32 | border = 'curved', 33 | width = 70, 34 | height = 18, 35 | winblend = 3, 36 | }, 37 | highlights = { 38 | -- highlights which map to a highlight group name and a table of it's values 39 | -- NOTE: this is only a subset of values, any group placed here will be set for the terminal window split 40 | Normal = { 41 | guibg = "none", 42 | }, 43 | NormalFloat = { 44 | link = 'Normal', 45 | }, 46 | FloatBorder = { 47 | guibg = "none", 48 | }, 49 | }, 50 | winbar = { 51 | enabled = false, 52 | name_formatter = function(term) -- term: Terminal 53 | return term.name 54 | end 55 | }, 56 | } 57 | 58 | -- local Terminal = require('toggleterm.terminal').Terminal 59 | 60 | function _G.set_terminal_keymaps() 61 | local opts = {buffer = 0} 62 | vim.keymap.set('n', '', [[quit]], opts) 63 | -- vim.keymap.set('n', '', [[quit]], opts) 64 | vim.keymap.set('n', 'q', [[quit]], opts) 65 | vim.keymap.set('n', '', [[startinsert]], opts) 66 | vim.keymap.set('n', '', [[startinsert]], opts) 67 | vim.keymap.set('n', '', [[startinsert]], opts) 68 | vim.keymap.set('n', '', [[startinsert]], opts) 69 | vim.keymap.set('n', '', [[startinsert]], opts) 70 | vim.keymap.set('n', '', [[startinsert]], opts) 71 | vim.keymap.set('t', '', [[]], opts) 72 | vim.keymap.set('t', '', [["+pi]], opts) 73 | -- vim.opt_local.switchbuf = 'split' 74 | -- vim.keymap.set('t', '', [['"'.nr2char(getchar()).'pi']], {expr=true,buffer=0}) 75 | -- vim.keymap.set('t', 'jk', [[]], opts) 76 | -- vim.keymap.set('t', 'kj', [[]], opts) 77 | -- vim.keymap.set('t', '', [[wincmd h]], opts) 78 | -- vim.keymap.set('t', '', [[wincmd j]], opts) 79 | -- vim.keymap.set('t', '', [[wincmd k]], opts) 80 | -- vim.keymap.set('t', '', [[wincmd l]], opts) 81 | end 82 | 83 | -- if you only want these mappings for toggle term use term://*toggleterm#* instead 84 | vim.cmd('autocmd! TermOpen term://* lua set_terminal_keymaps()') 85 | -------------------------------------------------------------------------------- /lua/archvim/config/trouble.lua: -------------------------------------------------------------------------------- 1 | require'trouble'.setup { 2 | icons = require'archvim.options'.nerd_fonts and { 3 | indent = { 4 | top = "│ ", 5 | middle = "├╴", 6 | -- last = "└╴", 7 | last = "╰╴", 8 | fold_open = " ", 9 | fold_closed = " ", 10 | ws = " ", 11 | }, 12 | folder_closed = " ", 13 | folder_open = " ", 14 | kinds = { 15 | Array = " ", 16 | Boolean = "󰨙 ", 17 | Class = " ", 18 | Constant = "󰏿 ", 19 | Constructor = " ", 20 | Enum = " ", 21 | EnumMember = " ", 22 | Event = " ", 23 | Field = " ", 24 | File = " ", 25 | Function = "󰊕 ", 26 | Interface = " ", 27 | Key = " ", 28 | Method = "󰊕 ", 29 | Module = " ", 30 | Namespace = "󰦮 ", 31 | Null = " ", 32 | Number = "󰎠 ", 33 | Object = " ", 34 | Operator = " ", 35 | Package = " ", 36 | Property = " ", 37 | String = " ", 38 | Struct = "󰆼 ", 39 | TypeParameter = " ", 40 | Variable = "󰀫 ", 41 | }, 42 | } or nil, 43 | } 44 | 45 | vim.cmd [[ 46 | augroup trouble_setlocal 47 | autocmd! 48 | autocmd FileType trouble setlocal wrap 49 | augroup END 50 | ]] 51 | -------------------------------------------------------------------------------- /lua/archvim/config/twilight.lua: -------------------------------------------------------------------------------- 1 | require'twilight'.setup{ 2 | dimming = { 3 | alpha = 0.25, -- amount of dimming 4 | -- we try to get the foreground from the highlight groups or fallback color 5 | color = { "Normal", "#ffffff" }, 6 | term_bg = "#000000", -- if guibg=NONE, this will be used to calculate text color 7 | inactive = true, -- when true, other windows will be fully dimmed (unless they contain the same buffer) 8 | }, 9 | context = 10, -- amount of lines we will try to show around the current line 10 | treesitter = true, -- use treesitter when available for the filetype 11 | -- treesitter is used to automatically expand the visible text, 12 | -- but you can further control the types of nodes that should always be fully expanded 13 | expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types 14 | "function", 15 | "method", 16 | "table", 17 | "if_statement", 18 | }, 19 | exclude = {}, -- exclude these filetypes 20 | } 21 | -------------------------------------------------------------------------------- /lua/archvim/config/undotree.lua: -------------------------------------------------------------------------------- 1 | vim.o.undofile = true 2 | 3 | -- local map = require'archvim/mappings' 4 | -- map("n", "", "UndotreeToggle", { silent = true }) 5 | -- map("i", "", "UndotreeToggle", { silent = true }) 6 | -------------------------------------------------------------------------------- /lua/archvim/config/which-key.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/folke/which-key.nvim 2 | 3 | require("which-key").setup { 4 | plugins = { 5 | marks = true, -- shows a list of your marks on ' and ` 6 | registers = true, -- shows your registers on " in NORMAL or in INSERT mode 7 | spelling = { 8 | -- 是否接管默认 z= 的行为 9 | enabled = true, 10 | suggestions = 24, 11 | }, 12 | }, 13 | } 14 | -------------------------------------------------------------------------------- /lua/archvim/config/windline.lua: -------------------------------------------------------------------------------- 1 | local windline = require('windline') 2 | local helper = require('windline.helpers') 3 | local sep = helper.separators 4 | local b_components = require('windline.components.basic') 5 | local state = _G.WindLine.state 6 | local vim_components = require('windline.components.vim') 7 | local HSL = require('wlanimation.utils') 8 | 9 | local lsp_comps = require('windline.components.lsp') 10 | local git_comps = require('windline.components.git') 11 | 12 | local hl_list = { 13 | Black = { 'white', 'black' }, 14 | White = { 'black', 'white' }, 15 | Normal = { 'NormalFg', 'NormalBg' }, 16 | Inactive = { 'InactiveFg', 'InactiveBg' }, 17 | Active = { 'ActiveFg', 'ActiveBg' }, 18 | } 19 | local basic = {} 20 | 21 | local airline_colors = {} 22 | 23 | airline_colors.a = { 24 | NormalSep = { 'magenta_a', 'magenta_b' }, 25 | InsertSep = { 'green_a', 'green_b' }, 26 | VisualSep = { 'yellow_a', 'yellow_b' }, 27 | ReplaceSep = { 'blue_a', 'blue_b' }, 28 | CommandSep = { 'red_a', 'red_b' }, 29 | Normal = { 'black', 'magenta_a' }, 30 | Insert = { 'black', 'green_a' }, 31 | Visual = { 'black', 'yellow_a' }, 32 | Replace = { 'black', 'blue_a' }, 33 | Command = { 'black', 'red_a' }, 34 | } 35 | 36 | airline_colors.b = { 37 | NormalSep = { 'magenta_b', 'magenta_c' }, 38 | InsertSep = { 'green_b', 'green_c' }, 39 | VisualSep = { 'yellow_b', 'yellow_c' }, 40 | ReplaceSep = { 'blue_b', 'blue_c' }, 41 | CommandSep = { 'red_b', 'red_c' }, 42 | Normal = { 'white', 'magenta_b' }, 43 | Insert = { 'white', 'green_b' }, 44 | Visual = { 'white', 'yellow_b' }, 45 | Replace = { 'white', 'blue_b' }, 46 | Command = { 'white', 'red_b' }, 47 | } 48 | 49 | airline_colors.c = { 50 | NormalSep = { 'magenta_c', 'NormalBg' }, 51 | InsertSep = { 'green_c', 'NormalBg' }, 52 | VisualSep = { 'yellow_c', 'NormalBg' }, 53 | ReplaceSep = { 'blue_c', 'NormalBg' }, 54 | CommandSep = { 'red_c', 'NormalBg' }, 55 | Normal = { 'white', 'magenta_c' }, 56 | Insert = { 'white', 'green_c' }, 57 | Visual = { 'white', 'yellow_c' }, 58 | Replace = { 'white', 'blue_c' }, 59 | Command = { 'white', 'red_c' }, 60 | } 61 | 62 | basic.divider = { b_components.divider, hl_list.Normal } 63 | 64 | local width_breakpoint = 100 65 | 66 | basic.section_a = { 67 | hl_colors = airline_colors.a, 68 | text = function(_,_,width) 69 | if width > width_breakpoint then 70 | return { 71 | { ' ' .. state.mode[1] .. ' ', state.mode[2] }, 72 | { sep.right_filled, state.mode[2] .. 'Sep' }, 73 | } 74 | end 75 | return { 76 | { ' ' .. state.mode[1]:sub(1, 1) .. ' ', state.mode[2] }, 77 | { sep.right_filled, state.mode[2] .. 'Sep' }, 78 | } 79 | end, 80 | } 81 | 82 | 83 | basic.section_b = { 84 | hl_colors = airline_colors.b, 85 | text = function(bufnr,_, width) 86 | if width > width_breakpoint and git_comps.is_git(bufnr) then 87 | return { 88 | { git_comps.git_branch() , state.mode[2] }, 89 | { ' ', '' }, 90 | { sep.right_filled, state.mode[2] .. 'Sep' }, 91 | } 92 | end 93 | return { { sep.right_filled, state.mode[2] .. 'Sep' } } 94 | end, 95 | } 96 | 97 | 98 | basic.section_c = { 99 | hl_colors = airline_colors.c, 100 | text = function() 101 | return { 102 | { ' ', state.mode[2] }, 103 | { b_components.cache_file_name('[No Name]', 'unique')}, 104 | { ' '}, 105 | { sep.right_filled, state.mode[2] .. 'Sep' }, 106 | } 107 | end, 108 | } 109 | 110 | basic.section_x = { 111 | hl_colors = airline_colors.c, 112 | text = function(_,_,width) 113 | if width > width_breakpoint then 114 | return { 115 | { sep.left_filled, state.mode[2] .. 'Sep' }, 116 | { ' ', state.mode[2] }, 117 | { b_components.file_encoding()}, 118 | { ' ' }, 119 | { b_components.file_format({ icon = true }) }, 120 | { ' ' }, 121 | } 122 | end 123 | return { 124 | { sep.left_filled, state.mode[2] .. 'Sep' }, 125 | } 126 | end, 127 | } 128 | 129 | basic.section_y = { 130 | hl_colors = airline_colors.b, 131 | text = function(_,_,width) 132 | if width > width_breakpoint then 133 | return { 134 | { sep.left_filled, state.mode[2] .. 'Sep' }, 135 | { b_components.cache_file_type({ icon = true }), state.mode[2] }, 136 | { ' ' }, 137 | } 138 | end 139 | return { { sep.left_filled, state.mode[2] .. 'Sep' } } 140 | end, 141 | } 142 | 143 | basic.section_z = { 144 | hl_colors = airline_colors.a, 145 | text = function(_,_,width) 146 | if width > width_breakpoint then 147 | return { 148 | { sep.left_filled, state.mode[2] .. 'Sep' }, 149 | { '', state.mode[2] }, 150 | { b_components.progress_lua}, 151 | { ' '}, 152 | { b_components.line_col_lua}, 153 | } 154 | end 155 | return { 156 | { sep.left_filled, state.mode[2] .. 'Sep' }, 157 | { ' ', state.mode[2] }, 158 | { b_components.line_col_lua, state.mode[2] }, 159 | } 160 | end, 161 | } 162 | 163 | basic.lsp_diagnos = { 164 | name = 'diagnostic', 165 | hl_colors = { 166 | red = { 'red', 'NormalBg' }, 167 | yellow = { 'yellow', 'NormalBg' }, 168 | blue = { 'blue', 'NormalBg' }, 169 | }, 170 | text = function(bufnr) 171 | if lsp_comps.check_lsp(bufnr) then 172 | return { 173 | { lsp_comps.lsp_error({ format = '  %s', show_zero = true }), 'red' }, 174 | { lsp_comps.lsp_warning({ format = '  %s', show_zero = true }), 'yellow' }, 175 | { lsp_comps.lsp_hint({ format = '  %s', show_zero = true }), 'blue' }, 176 | } 177 | end 178 | return { ' ', 'red' } 179 | end, 180 | } 181 | 182 | basic.git = { 183 | name = 'git', 184 | width = width_breakpoint, 185 | hl_colors = { 186 | green = { 'green', 'NormalBg' }, 187 | red = { 'red', 'NormalBg' }, 188 | blue = { 'blue', 'NormalBg' }, 189 | }, 190 | text = function(bufnr) 191 | if git_comps.is_git(bufnr) then 192 | return { 193 | -- { git_comps.diff_added({ format = '  %s' }), 'green' }, 194 | -- { git_comps.diff_removed({ format = '  %s' }), 'red' }, 195 | -- { git_comps.diff_changed({ format = '  %s' }), 'blue' }, 196 | { git_comps.diff_added({ format = '  %s' }), 'green' }, 197 | { git_comps.diff_removed({ format = '  %s' }), 'red' }, 198 | { git_comps.diff_changed({ format = '  %s' }), 'blue' }, 199 | } 200 | end 201 | return '' 202 | end, 203 | } 204 | local quickfix = { 205 | filetypes = { 'qf', 'Trouble' }, 206 | active = { 207 | { '🚦 Quickfix ', { 'white', 'black' } }, 208 | { helper.separators.slant_right, { 'black', 'black_light' } }, 209 | { 210 | function() 211 | return vim.fn.getqflist({ title = 0 }).title 212 | end, 213 | { 'cyan', 'black_light' }, 214 | }, 215 | { ' Total : %L ', { 'cyan', 'black_light' } }, 216 | { helper.separators.slant_right, { 'black_light', 'InactiveBg' } }, 217 | { ' ', { 'InactiveFg', 'InactiveBg' } }, 218 | basic.divider, 219 | { helper.separators.slant_right, { 'InactiveBg', 'black' } }, 220 | { '🧛 ', { 'white', 'black' } }, 221 | }, 222 | always_active = true, 223 | show_last_status = true 224 | } 225 | 226 | local explorer = { 227 | filetypes = { 'fern', 'NvimTree', 'lir' }, 228 | active = { 229 | { '  ', { 'white', 'magenta_b' } }, 230 | { helper.separators.slant_right, { 'magenta_b', 'NormalBg' } }, 231 | { b_components.divider, '' }, 232 | { b_components.file_name(''), { 'NormalFg', 'NormalBg' } }, 233 | }, 234 | always_active = true, 235 | show_last_status = true 236 | } 237 | 238 | local default = { 239 | filetypes = { 'default' }, 240 | active = { 241 | basic.section_a, 242 | basic.section_b, 243 | basic.section_c, 244 | basic.lsp_diagnos, 245 | { vim_components.search_count(), { 'cyan', 'NormalBg' } }, 246 | basic.divider, 247 | basic.git, 248 | basic.section_x, 249 | basic.section_y, 250 | basic.section_z, 251 | }, 252 | inactive = { 253 | { b_components.full_file_name, hl_list.Inactive }, 254 | { b_components.divider, hl_list.Inactive }, 255 | { b_components.line_col, hl_list.Inactive }, 256 | { b_components.progress, hl_list.Inactive }, 257 | }, 258 | } 259 | 260 | windline.setup({ 261 | colors_name = function(colors) 262 | local mod = function (c, value) 263 | if vim.o.background == 'light' then 264 | return HSL.rgb_to_hsl(c):tint(value):to_rgb() 265 | end 266 | return HSL.rgb_to_hsl(c):shade(value):to_rgb() 267 | end 268 | 269 | colors.magenta_a = colors.magenta 270 | colors.magenta_b = mod(colors.magenta,0.5) 271 | colors.magenta_c = mod(colors.magenta,0.7) 272 | 273 | colors.yellow_a = colors.yellow 274 | colors.yellow_b = mod(colors.yellow,0.5) 275 | colors.yellow_c = mod(colors.yellow,0.7) 276 | 277 | colors.blue_a = colors.blue 278 | colors.blue_b = mod(colors.blue,0.5) 279 | colors.blue_c = mod(colors.blue,0.7) 280 | 281 | colors.green_a = colors.green 282 | colors.green_b = mod(colors.green,0.5) 283 | colors.green_c = mod(colors.green,0.7) 284 | 285 | colors.red_a = colors.red 286 | colors.red_b = mod(colors.red,0.5) 287 | colors.red_c = mod(colors.red,0.7) 288 | 289 | return colors 290 | end, 291 | statuslines = { 292 | default, 293 | quickfix, 294 | explorer, 295 | }, 296 | }) 297 | -------------------------------------------------------------------------------- /lua/archvim/config/zfvimim.lua: -------------------------------------------------------------------------------- 1 | vim.cmd [[ 2 | function! s:myLocalDb() 3 | let db = ZFVimIM_dbInit({ 4 | \ 'name' : 'LocalDb', 5 | \ }) 6 | call ZFVimIM_cloudRegister({ 7 | \ 'mode' : 'local', 8 | \ 'dbId' : db['dbId'], 9 | \ 'repoPath' : '/home/bate/.ZFVimIM_localdb', 10 | \ 'dbFile' : '/dbFile.txt', 11 | \ 'dbCountFile' : '/dbCountFile.txt', 12 | \ }) 13 | endfunction 14 | autocmd User ZFVimIM_event_OnDbInit call s:myLocalDb() 15 | let g:ZFVimIM_cloudSync_enable = 0 16 | ]] 17 | 18 | vim.cmd [[ 19 | let g:ZFVimIM_symbolMap = { 20 | \ ' ' : [''], 21 | \ '`' : ['·'], 22 | \ '!' : ['!'], 23 | \ '$' : ['¥'], 24 | \ '^' : ['……'], 25 | \ '-' : [''], 26 | \ '_' : ['——'], 27 | \ '(' : ['('], 28 | \ ')' : [')'], 29 | \ '[' : ['【'], 30 | \ ']' : ['】'], 31 | \ '<' : ['《'], 32 | \ '>' : ['》'], 33 | \ '\' : ['、'], 34 | \ '/' : ['、'], 35 | \ ';' : [';'], 36 | \ ':' : [':'], 37 | \ ',' : [','], 38 | \ '.' : ['。'], 39 | \ '?' : ['?'], 40 | \ "'" : ['‘', '’'], 41 | \ '"' : ['“', '”'], 42 | \ '0' : [''], 43 | \ '1' : [''], 44 | \ '2' : [''], 45 | \ '3' : [''], 46 | \ '4' : [''], 47 | \ '5' : [''], 48 | \ '6' : [''], 49 | \ '7' : [''], 50 | \ '8' : [''], 51 | \ '9' : [''], 52 | \ } 53 | ]] 54 | 55 | vim.cmd [[ 56 | let g:ZFVimIM_keymap = 0 57 | 58 | " nnoremap ;; ZFVimIME_keymap_toggle_n() 59 | inoremap ;; ZFVimIME_keymap_toggle_i() 60 | " vnoremap ;; ZFVimIME_keymap_toggle_v() 61 | 62 | " nnoremap ;: ZFVimIME_keymap_next_n() 63 | inoremap ;: ZFVimIME_keymap_next_i() 64 | " vnoremap ;: ZFVimIME_keymap_next_v() 65 | 66 | " nnoremap ;, ZFVimIME_keymap_add_n() 67 | inoremap ;, ZFVimIME_keymap_add_i() 68 | " xnoremap ;, ZFVimIME_keymap_add_v() 69 | 70 | " nnoremap ;. ZFVimIME_keymap_remove_n() 71 | inoremap ;. ZFVimIME_keymap_remove_i() 72 | " xnoremap ;. ZFVimIME_keymap_remove_v() 73 | ]] 74 | -------------------------------------------------------------------------------- /lua/archvim/custom.lua: -------------------------------------------------------------------------------- 1 | if require'archvim.options'.more_cpp_ftdetect then 2 | vim.cmd [[ 3 | augroup archvim_set_filetype 4 | au! BufRead,BufNewFile *.cppm,*.ixx setfiletype cpp 5 | au! BufRead,BufNewFile *.vert,*.frag,*.comp,*.geom,*.tess setfiletype glsl 6 | augroup end 7 | ]] 8 | end 9 | if require'archvim.options'.transparent_color then 10 | vim.cmd [[ 11 | augroup colorscheme_mock 12 | autocmd! 13 | autocmd ColorScheme * hi Normal guibg=none | hi def link LspInlayHint Comment 14 | " \ | hi LspReferenceText guibg=none 15 | " \ | hi LspReferenceRead guibg=none 16 | " \ | hi LspReferenceWrite guibg=none 17 | " hi NormalFloat guifg=#928374 guibg=#282828 | 18 | " hi WinSeparator guibg=none | 19 | " hi TreesitterContext gui=NONE guibg=#282828 | 20 | " hi TreesitterContextBottom gui=underline guisp=Grey 21 | augroup END 22 | ]] 23 | end 24 | 25 | if not require'archvim.options'.enable_clipboard then 26 | vim.cmd [[ 27 | set clipboard-=unnamedplus 28 | ]] 29 | end 30 | 31 | vim.cmd [[ 32 | " silent! colorscheme zephyr 33 | silent! colorscheme gruvbox 34 | ]] 35 | 36 | -- More custom options goes here 37 | -------------------------------------------------------------------------------- /lua/archvim/icons.lua: -------------------------------------------------------------------------------- 1 | -- https://github.com/microsoft/vscode/blob/main/src/vs/base/common/codicons.ts 2 | -- go to the above and then enter u and the symbold should appear 3 | -- or go here and upload the font file: https://mathew-kurian.github.io/CharacterMap/ 4 | -- find more here: https://www.nerdfonts.com/cheat-sheet 5 | 6 | local icons = { 7 | kind = { 8 | Text = "󰦨 ", 9 | Method = " ", 10 | Function = " ", 11 | Constructor = " ", 12 | Field = " ", 13 | Variable = " ", 14 | Class = " ", 15 | Interface = " ", 16 | Module = " ", 17 | Property = " ", 18 | Unit = " ", 19 | Value = "󰾡 ", 20 | Enum = " ", 21 | Keyword = " ", 22 | Snippet = " ", 23 | Color = " ", 24 | File = " ", 25 | Reference = " ", 26 | Folder = " ", 27 | EnumMember = " ", 28 | Constant = " ", 29 | Struct = " ", 30 | Event = " ", 31 | Operator = " ", 32 | TypeParameter = " ", 33 | Specifier = " ", 34 | Statement = "", 35 | Recovery = " ", 36 | TranslationUnit = " ", 37 | PackExpansion = " " 38 | }, 39 | type = { 40 | Array = " ", 41 | Number = " ", 42 | String = " ", 43 | Boolean = " ", 44 | Object = " ", 45 | Template = " " 46 | }, 47 | documents = { 48 | File = "", 49 | Files = "", 50 | Folder = "", 51 | OpenFolder = "", 52 | EmptyFolder = "", 53 | EmptyOpenFolder = "", 54 | Unknown = "", 55 | Symlink = "", 56 | FolderSymlink = "" 57 | }, 58 | git = { 59 | Add = " ", 60 | Mod = " ", 61 | Remove = " ", 62 | Untrack = " ", 63 | Rename = " ", 64 | Diff = " ", 65 | Repo = " ", 66 | Branch = " ", 67 | Unmerged = " " 68 | }, 69 | ui = { 70 | Lock = "", 71 | TinyCircle = "", 72 | Circle = "", 73 | BigCircle = "", 74 | BigUnfilledCircle = "", 75 | CircleWithGap = "", 76 | LogPoint = "", 77 | Close = "", 78 | NewFile = "", 79 | Search = "", 80 | Lightbulb = "", 81 | Project = "", 82 | Dashboard = "", 83 | History = "", 84 | Comment = "", 85 | Bug = "", 86 | Code = "", 87 | Telescope = " ", 88 | Gear = "", 89 | Package = "", 90 | List = "", 91 | SignIn = "", 92 | Check = "", 93 | Fire = "", 94 | Note = "", 95 | BookMark = "", 96 | Pencil = "", 97 | ChevronRight = "", 98 | Table = "", 99 | Calendar = "", 100 | Line = "▊", 101 | Evil = "", 102 | Debug = "", 103 | Run = "", 104 | VirtualPrefix = "", 105 | Next = "", 106 | Previous = "", 107 | Clock = "", 108 | }, 109 | diagnostics = { 110 | Error = " ", 111 | Warning = " ", 112 | Information = " ", 113 | Question = " ", 114 | Hint = " ", 115 | }, 116 | misc = { 117 | Robot = "󰚩 ", 118 | Squirrel = " ", 119 | Tag = " ", 120 | Arch = "󰣇 ", 121 | }, 122 | cmake = { 123 | CMake = "", 124 | Build = "", 125 | Run = "", 126 | Debug = "", 127 | }, 128 | } 129 | 130 | if not require'archvim.options'.nerd_fonts then 131 | for k, v in pairs(icons) do 132 | for k1, v1 in pairs(v) do 133 | icons[k][k1] = k1 134 | end 135 | end 136 | end 137 | 138 | return icons 139 | -------------------------------------------------------------------------------- /lua/archvim/init.lua: -------------------------------------------------------------------------------- 1 | -- neovim 9.0+ required 2 | 3 | require('archvim.options') 4 | require('archvim.plugins') 5 | require('archvim.mappings') 6 | require('archvim.custom') 7 | 8 | function print(...) 9 | vim.notify(vim.inspect({...})) 10 | end 11 | -------------------------------------------------------------------------------- /lua/archvim/mappings.lua: -------------------------------------------------------------------------------- 1 | vim.api.nvim_create_user_command("Quit", function () 2 | vim.cmd [[ wall | if &buftype == 'quickfix' | cclose | elseif &buftype == 'prompt' | quit! | else | quit | endif ]] 3 | end, {desc = 'Quit current window'}) 4 | -- 讨厌 q 用作退出的“宏孝子”请删除这 3 行: 5 | vim.keymap.set("n", "q", "Quit", { silent = true }) 6 | vim.keymap.set("v", "q", "", { silent = true }) 7 | vim.keymap.set("n", "Q", "q", { silent = true, noremap = true }) 8 | 9 | -- 讨厌 jk 的同学请删除这 4 行: 10 | vim.keymap.set("i", "jk", "", { silent = true }) 11 | vim.keymap.set("i", "kj", "", { silent = true }) 12 | vim.keymap.set("t", "jk", "", { silent = true }) 13 | vim.keymap.set("t", "kj", "", { silent = true }) 14 | 15 | -- Ctrl+Insert 复制;Shift+Insert 粘贴 16 | vim.keymap.set({"n", "v"}, "", "\"+y", { silent = true }) 17 | vim.keymap.set("i", "", "\"+yya", { silent = true }) 18 | vim.keymap.set({"n", "v"}, "", "\"+p", { silent = true }) 19 | vim.keymap.set("i", "", "+", { silent = true }) 20 | 21 | -- Functional wrapper for mapping custom keybindings 22 | -- local function map(mode, lhs, rhs, opts) 23 | -- if type(mode) == 'table' then 24 | -- for i = 1, #mode do 25 | -- map(mode[i], lhs, rhs, opts) 26 | -- end 27 | -- return 28 | -- end 29 | -- local options = { noremap = true } 30 | -- if opts then 31 | -- options = vim.tbl_extend("force", options, opts) 32 | -- end 33 | -- vim.api.nvim_set_keymap(mode, lhs, rhs, options) 34 | -- end 35 | 36 | local function is_quickfix_open() 37 | for _, win in ipairs(vim.api.nvim_list_wins()) do 38 | if vim.bo[vim.api.nvim_win_get_buf(win)].buftype == 'quickfix' then 39 | return true 40 | end 41 | end 42 | return false 43 | end 44 | 45 | local function get_current_quickfix_entry() 46 | local qflist = vim.fn.getqflist({ idx = 0 }) 47 | local current_idx = qflist.idx 48 | local entry = vim.fn.getqflist({ id = qflist.id, items = 0 }).items[current_idx] 49 | return entry 50 | end 51 | 52 | vim.keymap.set({"v", "n"}, "_", "+", { noremap = true }) 53 | vim.keymap.set({"v", "n"}, "gh", "(v:count == 0 || v:count == 1 ? '^^' : '^^' . (v:count - 1) . 'l')", { silent = true, expr = true }) 54 | vim.keymap.set({"v", "n"}, "gl", "(v:count == 0 || v:count == 1 ? '^$' : '^$' . (v:count - 1) . 'h')", { silent = true, expr = true }) 55 | vim.keymap.set({"v", "n"}, "gm", "gM", { noremap = true }) 56 | vim.keymap.set({"v", "n"}, "gM", "gm", { noremap = true }) 57 | vim.keymap.set({"v", "n", "i"}, "", "wa") 58 | vim.keymap.set({"v", "n", "i"}, "", "cclose | Trouble qflist toggle") 59 | vim.keymap.set({"v", "n", "i"}, "", "copen") 60 | -- vim.keymap.set({"v", "n", "i"}, "", function () 61 | -- if is_quickfix_open() then 62 | -- return "cclose" 63 | -- -- if get_current_quickfix_entry() then 64 | -- -- return "cn" 65 | -- -- else 66 | -- -- return "cc" 67 | -- -- end 68 | -- else 69 | -- -- return "cc" 70 | -- return "copen" 71 | -- end 72 | -- end, { noremap = true, expr = true }) 73 | -- -- vim.keymap.set({"v", "n", "i"}, "", function () 74 | -- -- if is_quickfix_open() then 75 | -- -- return "cclose" 76 | -- -- -- if get_current_quickfix_entry() then 77 | -- -- -- return "cp" 78 | -- -- -- else 79 | -- -- -- return "cclose" 80 | -- -- -- end 81 | -- -- else 82 | -- -- -- return "cc" 83 | -- -- return "copen" 84 | -- -- end 85 | -- -- end, { noremap = true, expr = true }) 86 | vim.keymap.set({"v", "n", "i", "t"}, "", "NvimTreeFindFileToggle", { silent = true }) 87 | vim.keymap.set({"v", "n", "i", "t"}, "", "Trouble diagnostics toggle focus=false", { silent = true }) 88 | vim.keymap.set({"v", "n", "i", "t"}, "", "Trouble diagnostics toggle focus=false filter.buf=0", { silent = true }) 89 | if pcall(require, "cmake-tools") then 90 | vim.keymap.set({"v", "n", "i", "t"}, "", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeRun')|elseif filereadable('platformio.ini')|call execute('TermExec cmd=\\')|sleep 24m|call execute('TermExec cmd=''platformio -f -c vim run --target upload && platformio -f -c vim device monitor''')|elseif filereadable('run.sh')|call execute('TermExec cmd=./run.sh')|endif", { silent = true }) 91 | vim.keymap.set({"v", "n", "i", "t"}, "", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeStopRunner')|call execute('CMakeStopExecutor')|else|call execute('TermExec cmd=\\')|endif", { silent = true }) 92 | vim.keymap.set("n", "cmr", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeRun')|elseif filereadable('platformio.ini')|call execute('TermExec cmd=\\')|sleep 24m|call execute('TermExec cmd=''platformio -f -c vim run --target upload && platformio -f -c vim device monitor''')|elseif filereadable('run.sh')|call execute('TermExec cmd=./run.sh')|endif", { silent = true, desc = 'CMakeRun' }) 93 | vim.keymap.set("n", "cmb", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeBuild')|elseif filereadable('platformio.ini')|call execute('TermExec cmd=''platformio -f -c vim run''')|elseif filereadable('Makefile')|call execute('TermExec cmd=make')|elseif filereadable('build.sh')|call execute('TermExec cmd=./build.sh')|endif", { silent = true, desc = 'CMakeBuild' }) 94 | vim.keymap.set("n", "cmc", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeGenerate')|elseif filereadable('platformio.ini')|call execute('TermExec cmd=''platformio -f -c vim run --target compiledb''')|elseif filereadable('Makefile')|call execute('TermExec cmd=make configure')|elseif filereadable('configure')|call execute('TermExec cmd=./configure')|endif", { silent = true, desc = 'CMakeGenerate' }) 95 | vim.keymap.set("n", "cms", "waif luaeval('require\"cmake-tools\".is_cmake_project()')|call execute('CMakeStopRunner')|call execute('CMakeStopExecutor')|else|call execute('TermExec cmd=\\')|endif", { silent = true, desc = 'CMakeStopRunner' }) 96 | else 97 | vim.keymap.set({"v", "n", "i", "t"}, "", "wacall execute('TermExec cmd=make')", { silent = true }) 98 | vim.keymap.set({"v", "n", "i", "t"}, "", "wacall execute('TermExec cmd=\\')", { silent = true }) 99 | end 100 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "Neogitset foldtext='+'", { silent = true }) 101 | vim.keymap.set({"v", "n", "i", "t"}, "", function() 102 | require'neogit'.open{} 103 | end, { silent = true }) 104 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "NoiceAll", { silent = true }) 105 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapToggleBreakpoint", { silent = true }) 106 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapToggleRepl", { silent = true }) 107 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapStepOver", { silent = true }) 108 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapStepInto", { silent = true }) 109 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapStepOut", { silent = true }) 110 | -- if found_cmake then 111 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "if luaeval('require\"cmake-tools\".is_cmake_project() and require\"dap\".session()==nil')|call execute('CMakeDebug')|else|call execute('DapContinue')|endif", { silent = true }) 112 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "if luaeval('require\"cmake-tools\".is_cmake_project() and require\"dap\".session()==nil')|call execute('CMakeStop')|else|call execute('DapTerminate')|endif", { silent = true }) 113 | -- else 114 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapContinue", { silent = true }) 115 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "DapTerminate", { silent = true }) 116 | -- end 117 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[ZenMode]]) 118 | -- vim.keymap.set({"v", "n"}, "", "nohlsearch", { silent = true }) 119 | 120 | -- vim.keymap.set({"v", "n"}, "g=", "Neoformat", { silent = true }) 121 | -- vim.keymap.set({"v", "n"}, "go", "Ouroboros", { silent = true }) 122 | -- vim.keymap.set({"v", "n"}, "gO", "split | Ouroboros", { silent = true }) 123 | -- vim.keymap.set({"v", "n"}, "g", "vsplit | Ouroboros", { silent = true }) 124 | -- vim.keymap.set({"v", "n", "i"}, "", "Neoformat", { silent = true }) 125 | -- vim.keymap.set("n", "Q", "waqa!", { silent = true }) 126 | 127 | -- vim.cmd [[ 128 | -- command! -nargs=0 A :ClangdSwitchSourceHeader 129 | -- command! -nargs=? F :Neoformat 130 | -- ]] 131 | 132 | -- vim.api.nvim_create_autocmd({"VimEnter"}, { 133 | -- -- disable_n_more_files_to_edit 134 | -- callback = function (data) 135 | -- local no_name = data.file == "" and vim.bo[data.buf].buftype == "" 136 | -- if not no_name then 137 | -- -- vim.cmd [[ args % ]] 138 | -- end 139 | -- end, 140 | -- }) 141 | 142 | vim.keymap.set({'v', 'n'}, '', [[h8h]]) 143 | vim.keymap.set({'v', 'n'}, '', [[43]]) 144 | vim.keymap.set({'v', 'n'}, '', [[43]]) 145 | vim.keymap.set({'v', 'n'}, '', [[l8l]]) 146 | vim.keymap.set({'v', 'n'}, '', [[zz]]) 147 | vim.keymap.set({'v', 'n'}, '', [[b2b]]) 148 | vim.keymap.set({'v', 'n'}, '', [[e2e]]) 149 | vim.keymap.set({'v', 'n'}, '', [[w2w]]) 150 | vim.keymap.set({'i'}, '', [[h]]) 151 | vim.keymap.set({'i'}, '', [[j]]) 152 | vim.keymap.set({'i'}, '', [[k]]) 153 | vim.keymap.set({'i'}, '', [[l]]) 154 | vim.keymap.set({'i'}, '', [[zz]]) 155 | vim.keymap.set({'i'}, '', [[b]]) 156 | vim.keymap.set({'i'}, '', [[e]]) 157 | vim.keymap.set({'i'}, '', [[w]]) 158 | 159 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd h]]) 160 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd j]]) 161 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd k]]) 162 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd l]]) 163 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd H]]) 164 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd J]]) 165 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd K]]) 166 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd L]]) 167 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd r]]) 168 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd x]]) 169 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd s]]) 170 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd v]]) 171 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd +]]) 172 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd -]]) 173 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd ]]) 174 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd >]]) 175 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd q]]) 176 | vim.keymap.set({'v', 'n', 'i', 't'}, '', [[wincmd q]]) 177 | vim.keymap.set('n', '', [[nohls]], { noremap = true }) 178 | -- vim.keymap.set('t', [[]], [[]], { noremap = true }) 179 | vim.keymap.set('t', '', [[]], { noremap = true }) 180 | -- vim.keymap.set('t', [[]], [[]], { noremap = true }) 181 | -- vim.keymap.set('t', [[jk]], [[]], opts) 182 | 183 | -- 开关终端 184 | -- vim.keymap.set({"v", "n", "i", "t"}, "", "ToggleTerm", { silent = true }) 185 | vim.keymap.set({"v", "n", "i", "t"}, "", "ToggleTerm", { silent = true }) 186 | vim.keymap.set({"v"}, "", "ToggleTermSendVisualSelection", { silent = true }) 187 | vim.keymap.set({"n", "i"}, "", "ToggleTermSendCurrentLine", { silent = true }) 188 | vim.keymap.set({"t"}, "", "ToggleTermToggleAll", { silent = true }) 189 | -- 格式化代码 190 | vim.keymap.set({'v'}, 'g=', [[Neoformat]]) 191 | vim.keymap.set({'n'}, 'g=', function () 192 | vim.lsp.buf.format() 193 | end) 194 | vim.keymap.set({'v', 'n', 'i'}, '', function() 195 | vim.lsp.buf.format() 196 | end) 197 | -- 查看文档 198 | vim.keymap.set({'v', 'n'}, 'K', function () 199 | vim.lsp.buf.hover() 200 | end) 201 | -- 函数签名 202 | vim.keymap.set({'v', 'n'}, 'gK', function () 203 | vim.lsp.buf.signature_help() 204 | end) 205 | -- 代码修复 206 | vim.keymap.set({'v', 'n'}, 'gw', function () 207 | vim.lsp.buf.code_action({ 208 | apply = true, 209 | }) 210 | end) 211 | -- 重命名变量 212 | vim.keymap.set({'v', 'n'}, 'gn', function() 213 | return ":IncRename " .. vim.fn.expand("") 214 | end, { expr = true, desc = 'Rename symbol' }) 215 | vim.keymap.set({'v', 'n'}, 'gN', function() 216 | return ":IncRename " 217 | end, { expr = true, desc = 'Rename symbol' }) 218 | -- 查找符号定义 219 | vim.keymap.set("n", "gd", "Telescope lsp_definitions", { desc = 'Goto definition' }) 220 | -- 查找符号声明 221 | vim.keymap.set("n", "gD", function() 222 | vim.lsp.buf.declaration() 223 | end, { desc = 'Goto declaration' }) 224 | -- 开关静态分析错误列表 225 | vim.keymap.set("n", "gss", "Trouble diagnostics toggle") 226 | -- 开关编译器报错列表 227 | vim.keymap.set("n", "gsl", "cclose | Trouble qflist toggle") 228 | vim.keymap.set("n", "gsg", "Neogit") 229 | -- 当前光标下的静态分析错误 230 | vim.keymap.set("n", "gsd", function() 231 | vim.diagnostic.open_float({ 232 | scope = "cursor", 233 | focusable = false, 234 | close_events = { 235 | "CursorMoved", 236 | "CursorMovedI", 237 | "BufHidden", 238 | "InsertCharPre", 239 | "WinLeave", 240 | "BufEnter", 241 | "BufLeave", 242 | }, 243 | }) 244 | end, { desc = 'Diagnostics under cursor' }) 245 | -- 开关 Inlay Hint 246 | vim.keymap.set({"v", "n"}, "gsi", function() 247 | if vim.lsp.inlay_hint ~= nil then 248 | vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) 249 | end 250 | end, { desc = "Toggle inlay hint" }) 251 | -- 重启 LSP 252 | vim.keymap.set({"v", "n"}, "gsu", "LspStop | LspStart", { silent = true, desc = "Restart LSP" }) 253 | -- 开关项目文件树 254 | vim.keymap.set({"v", "n"}, "gsp", "NvimTreeFindFileToggle", { silent = true, desc = "Toggle Nvim Tree", }) 255 | -- 开关大纲视图 256 | vim.keymap.set({"v", "n"}, "gso", "AerialToggle!", { desc = "Toggle aerial outline" }) 257 | -- 查找类型定义 258 | vim.keymap.set({"v", "n"}, "gy", "Telescope lsp_type_definitions", { desc = 'Goto type definition' }) 259 | -- 查找所有引用 260 | vim.keymap.set({"v", "n"}, "gr", "Telescope lsp_references", { desc = 'Find references' }) 261 | -- 查找函数实现 262 | vim.keymap.set({"v", "n"}, "gY", "Telescope lsp_implementations", { desc = 'Find implementations' }) 263 | -- 查看全部 264 | vim.keymap.set({"v", "n"}, "gz", "Trouble lsp toggle") 265 | -- 查看类型继承图 266 | vim.keymap.set({"v", "n"}, "gst", function () 267 | vim.lsp.buf.typehierarchy("subtypes") 268 | end, { desc = 'List derived class hierarchy' }) 269 | vim.keymap.set({"v", "n"}, "gsT", function () 270 | vim.lsp.buf.typehierarchy("supertypes") 271 | end, { desc = 'List base class hierarchy' }) 272 | -- 头文件/源文件跳转 273 | vim.keymap.set({"v", "n"}, "go", "ClangdSwitchSourceHeader", { silent = true }) 274 | vim.keymap.set({"v", "n"}, "gO", "split | ClangdSwitchSourceHeader", { silent = true }) 275 | vim.keymap.set({"v", "n"}, "g", "vsplit | ClangdSwitchSourceHeader", { silent = true }) 276 | 277 | vim.keymap.set({'n'}, '', '') 278 | -- vim.keymap.set({'i'}, '', '') 279 | 280 | -- vim.keymap.set({'v', 'n'}, 'gp', ':GPT') 281 | -- vim.keymap.set({'v', 'n'}, 'gP', ':GPT!') 282 | -- vim.keymap.set({'i'}, '', 'GPT') 283 | -- vim.keymap.set({'i', 'n'}, '', '-8,+8GPT refactor this code') 284 | -- vim.keymap.set({'v'}, '', 'GPT refactor this code') 285 | 286 | vim.cmd [[ 287 | augroup quickfix_setlocal 288 | autocmd! 289 | autocmd FileType qf setlocal wrap 290 | \ | vnoremap cclose 291 | \ | nnoremap cclose 292 | \ | vnoremap cclose 293 | \ | nnoremap cclose 294 | \ | nnoremap cclose 295 | augroup END 296 | ]] 297 | 298 | vim.cmd [[ 299 | augroup neogit_setlocal 300 | autocmd! 301 | autocmd FileType NeogitStatus nnoremap :q 302 | autocmd FileType NeogitStatus vnoremap :q 303 | autocmd FileType NeogitStatus inoremap :q 304 | autocmd FileType NeogitStatus nnoremap gsg :q 305 | augroup END 306 | ]] 307 | 308 | -- if os.getenv('LOOPCOMMAND') then 309 | -- vim.keymap.set('n', 'R', 'R') 310 | -- vim.api.nvim_create_user_command("R", function () 311 | -- vim.cmd [[ 312 | -- sil! UpdateRemotePlugins 313 | -- wall! 314 | -- cquit! 315 | -- ]] 316 | -- end, { desc = 'Restart NeoVim' }) 317 | -- end 318 | 319 | return vim.keymap.set 320 | -------------------------------------------------------------------------------- /lua/archvim/options.lua: -------------------------------------------------------------------------------- 1 | vim.g.mapleader = ',' 2 | 3 | vim.cmd [[ 4 | set mouse=a 5 | set mousemodel=extend 6 | set updatetime=400 7 | set nu nornu ru ls=2 8 | set et sts=0 ts=4 sw=4 9 | set signcolumn=number 10 | set nohls 11 | set listchars=tab:▸\ ,trail:⋅,extends:❯,precedes:❮ 12 | set cinoptions=j1,(0,ws,Ws,g0,:0,=0,l1 13 | set cinwords=if,else,switch,case,for,while,do 14 | set showbreak=↪ 15 | set list 16 | set clipboard+=unnamedplus 17 | set switchbuf=useopen 18 | set exrc 19 | set foldtext='+--' 20 | set bri wrap 21 | " set cc=80 22 | set termguicolors 23 | ]] 24 | 25 | vim.cmd [[ 26 | augroup disable_formatoptions_cro 27 | autocmd! 28 | autocmd BufEnter * setlocal formatoptions-=cro 29 | augroup end 30 | ]] 31 | 32 | vim.cmd [[ 33 | augroup disable_swap_exists_warning 34 | autocmd! 35 | autocmd SwapExists * let v:swapchoice = "e" 36 | augroup end 37 | ]] 38 | 39 | -- vim.cmd [[ 40 | -- augroup neogit_setlocal 41 | -- autocmd! 42 | -- autocmd FileType NeogitStatus set foldtext='+--' 43 | -- augroup END 44 | -- ]] 45 | 46 | -- vim.g_printed = '' 47 | -- vim.g_print = function(msg) 48 | -- vim.g_printed = vim.g_printed .. tostring(msg) .. '\n' 49 | -- end 50 | -- vim.g_dump = function() 51 | -- print(vim.g_printed) 52 | -- end 53 | 54 | vim.lsp.set_log_level("warn") 55 | 56 | local default_opts = { 57 | nerd_fonts = true, 58 | disable_notify = true, 59 | transparent_color = true, 60 | more_cpp_ftdetect = true, 61 | enable_signature_help = true, 62 | enable_inlay_hint = true, 63 | enable_clipboard = true, 64 | } 65 | 66 | (function() 67 | local data_path = vim.fn.stdpath('data') .. '/archvim' 68 | local file_name = data_path .. '/opts.json' 69 | local file = io.open(file_name, 'r') 70 | if file then 71 | local content = file:read('*a') 72 | file:close() 73 | local result = vim.fn.json_decode(content) 74 | for k, v in pairs(result) do 75 | default_opts[k] = v 76 | end 77 | end 78 | end)() 79 | 80 | return setmetatable({}, { 81 | __newindex = function (_, k, v) 82 | rawset(default_opts, k, v) 83 | local data_path = vim.fn.stdpath('data') .. '/archvim' 84 | if vim.fn.isdirectory(data_path) ~= 1 then 85 | vim.fn.mkdir(data_path, 'p') 86 | end 87 | local file_name = data_path .. '/opts.json' 88 | local file = io.open(file_name, 'w') 89 | assert(file, string.format("cannot open file '%s' for write", file_name)) 90 | file:write(vim.fn.json_encode(default_opts)) 91 | file:close() 92 | end, 93 | __index = function (_, k) 94 | return rawget(default_opts, k) 95 | end, 96 | }) 97 | -------------------------------------------------------------------------------- /scripts/customize_settings.sh: -------------------------------------------------------------------------------- 1 | echo "-- Configuring ~/.local/share/nvim/archvim/opts.json" 2 | mkdir -p ~/.local/share/nvim/archvim 3 | 4 | YesOrNo() { 5 | if [ "x$2" = "xn" ]; then 6 | prompt="是或否,默认选否 [y/N] " 7 | else 8 | prompt="是或否,默认选是 [Y/n] " 9 | fi 10 | echo -n "$prompt" 11 | read -n1 answer < /dev/tty || read answer < /dev/tty || answer=$2 12 | if [ "x$2" = "xn" ]; then 13 | if [ "x$answer" != "xy" ]; then 14 | answer=0 15 | else 16 | answer=1 17 | fi 18 | else 19 | if [ "x$answer" != "xn" ]; then 20 | answer=1 21 | else 22 | answer=0 23 | fi 24 | fi 25 | return $answer 26 | } 27 | 28 | SetConfig() { 29 | echo "(设置中,请稍候...)" 30 | key=$1 31 | if [ $2 != 0 ]; then 32 | value=true 33 | else 34 | value=false 35 | fi 36 | nvim --headless -c "lua require'archvim.options'.$key = $value" -c 'sleep 1 | q!' 37 | echo 38 | return $2 39 | } 40 | 41 | cat << EOF 42 | ****************************************************** 43 | 现在开始为您的个性化定制,如果不确定,可以一路按 ENTER 下去 44 | ****************************************************** 45 | EOF 46 | 47 | cat << EOF 48 | ----------------------------------------------------------------------------------------- 49 | If the symbol ' ' is not showing correctly, you might want to install Nerd Fonts. 50 | 此字符 “ ” 若无法显示,可能是因为您没有安装 Nerd Fonts 字体。 51 | 52 | Nerd Fonts 官网下载:https://www.nerdfonts.com/ 53 | 推荐选择 “JetBrainMono Nerd Fonts” 字体。 54 | If you are using WSL or remote SSH, you'll have to manually download the font on Windows. 55 | 如果您使用的是 WSL 或者远程服务器连接,那么则需要为 Windows 客户端安装此字体。 56 | Windows 终端 Nerd Fonts 安装教程:https://medium.com/@vedantkadam541/beautify-your-windows-terminal-using-nerd-fonts-and-oh-my-posh-4f4393f097 57 | 58 | Worry not, without Nerd Fonts, you may still use NeoVim without the fancy icons. 59 | 别担心,即使没有安装此字体,您仍然可以正常使用 NeoVim,只不过没了一些花哨的图标。 60 | ----------------------------------------------------------------------------------------- 61 | EOF 62 | 63 | cat << EOF 64 | ================================================================== 65 | Did your terminal shows this symbols correctly?  (a clock symbol) 66 | 您的终端是否能正常显示此字符? (此处应为时钟符号) 67 | ================================================================== 68 | EOF 69 | YesOrNo n 70 | SetConfig nerd_fonts $? 71 | 72 | if [ $? != 0 ]; then 73 | cat << EOF 74 | ================================================================== 75 | Did your terminal shows this symbols correctly?  (a cross symbol) 76 | 您的终端是否能正常显示此字符?(此处应为叉号) 77 | ================================================================== 78 | EOF 79 | YesOrNo n 80 | SetConfig nerd_fonts $? 81 | fi 82 | 83 | cat << EOF 84 | ================================================================== 85 | Do you need to use this NeoVim in remote connection (SSH)?' 86 | 您是否需要在远程连接(SSH)中使用此 NeoVim?' 87 | ================================================================== 88 | EOF 89 | YesOrNo y 90 | SetConfig disable_notify $? 91 | 92 | cat << EOF 93 | ================================================================== 94 | Did you set any background image for the terminal? 95 | 您是否为终端设定了背景贴图(例如二次元壁纸)? 96 | ================================================================== 97 | EOF 98 | YesOrNo n 99 | SetConfig transparent_color $? 100 | 101 | cat << EOF 102 | ================================================================== 103 | Inlay Hint: add(a: 1, b: 2)" 104 | No Inlay Hint: add(1, 2)" 105 | Inlay Hint: auto i:int = 1;" 106 | No Inlay Hint: auto i = 1;" 107 | 108 | Would you like to enable inlay hints?' 109 | 您是否希望开启 Inlay Hint 提示?' 110 | ================================================================== 111 | EOF 112 | YesOrNo n 113 | SetConfig enable_inlay_hint $? 114 | 115 | cat << EOF 116 | ================================================================== 117 | Would you like to shared clipboard between NeoVim and system? 118 | 您是否希望 NeoVim 与系统共享剪贴板? 119 | ================================================================== 120 | EOF 121 | YesOrNo y 122 | SetConfig enable_clipboard $? 123 | 124 | cat << EOF 125 | -- 126 | -- You may always change these settings later by re-running this script. 127 | -- 您以后可以随时重新运行本脚本以修改这些上述设置。 128 | -- 脚本路径:~/.config/nvim/scripts/customize_settings.sh 129 | -- 130 | EOF 131 | -------------------------------------------------------------------------------- /scripts/install_deps.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | echo '-- Automatically installing ArchVim system dependencies...' 5 | 6 | cd "$(dirname $0)/.." 7 | 8 | get_linux_distro() { 9 | if grep -Eq "Ubuntu" /etc/*-release 2> /dev/null; then 10 | echo "Ubuntu" 11 | elif grep -Eq "Deepin" /etc/*-release 2> /dev/null; then 12 | echo "Deepin" 13 | elif grep -Eq "Raspbian" /etc/*-release 2> /dev/null; then 14 | echo "Raspbian" 15 | elif grep -Eq "uos" /etc/*-release 2> /dev/null; then 16 | echo "UOS" 17 | elif grep -Eq "LinuxMint" /etc/*-release 2> /dev/null; then 18 | echo "LinuxMint" 19 | elif grep -Eq "elementary" /etc/*-release 2> /dev/null; then 20 | echo "elementaryOS" 21 | elif grep -Eq "Debian" /etc/*-release 2> /dev/null; then 22 | echo "Debian" 23 | elif grep -Eq "Kali" /etc/*-release 2> /dev/null; then 24 | echo "Kali" 25 | elif grep -Eq "Parrot" /etc/*-release 2> /dev/null; then 26 | echo "Parrot" 27 | elif grep -Eq "CentOS" /etc/*-release 2> /dev/null; then 28 | echo "CentOS" 29 | elif grep -Eq "fedora" /etc/*-release 2> /dev/null; then 30 | echo "fedora" 31 | elif grep -Eq "openSUSE" /etc/*-release 2> /dev/null; then 32 | echo "openSUSE" 33 | elif grep -Eq "Arch Linux" /etc/*-release 2> /dev/null; then 34 | echo "ArchLinux" 35 | elif grep -Eq "ManjaroLinux" /etc/*-release 2> /dev/null; then 36 | echo "ManjaroLinux" 37 | elif grep -Eq "Gentoo" /etc/*-release 2> /dev/null; then 38 | echo "Gentoo" 39 | elif grep -Eq "alpine" /etc/*-release 2> /dev/null; then 40 | echo "Alpine" 41 | elif [ "x$(uname -s)" = "xDarwin" ]; then 42 | echo "MacOS" 43 | else 44 | echo "Unknown" 45 | fi 46 | } 47 | 48 | detect_platform() { 49 | local platform="$(uname -s | tr '[:upper:]' '[:lower:]')" 50 | 51 | # check for MUSL 52 | if [ "${platform}" = "linux" ]; then 53 | if ldd /bin/sh | grep -i musl >/dev/null; then 54 | platform=linux_musl 55 | fi 56 | fi 57 | 58 | # mingw is Git-Bash 59 | if echo "${platform}" | grep -i mingw >/dev/null; then 60 | platform=win 61 | fi 62 | 63 | echo "${platform}" 64 | } 65 | 66 | detect_arch() { 67 | local arch="$(uname -m | tr '[:upper:]' '[:lower:]')" 68 | 69 | if echo "${arch}" | grep -i arm >/dev/null; then 70 | # ARM is fine 71 | echo "${arch}" 72 | else 73 | if [ "${arch}" = "i386" ]; then 74 | arch=x86 75 | elif [ "${arch}" = "x86_64" ]; then 76 | arch=x64 77 | elif [ "${arch}" = "aarch64" ]; then 78 | arch=arm64 79 | fi 80 | 81 | # `uname -m` in some cases mis-reports 32-bit OS as 64-bit, so double check 82 | if [ "${arch}" = "x64" ] && [ "$(getconf LONG_BIT)" -eq 32 ]; then 83 | arch=x86 84 | fi 85 | 86 | echo "${arch}" 87 | fi 88 | } 89 | 90 | pcall() { 91 | "$@" 92 | echo -- ERROR: failed to install: "$@" 93 | } 94 | 95 | ensure_pip() { 96 | python="$(which python3 || which python)" 97 | if ! $python -m pip --version 2> /dev/null; then 98 | (curl --connect-timeout 8 https://bootstrap.pypa.io/get-pip.py | $python) || true 99 | fi 100 | if ! $python -m pip --version 2> /dev/null; then 101 | pcall $python -m ensurepip 102 | fi 103 | pcall $python -m pip --version 104 | } 105 | 106 | install_pip() { 107 | ensure_pip 108 | python="$(which python3 || which python)" 109 | if "$python" -m pip install --help | grep break-system-packages; then 110 | args="--break-system-packages" 111 | else 112 | args= 113 | fi 114 | index=(-i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple) 115 | 116 | packages=(pynvim openai tiktoken cmake_language_server) 117 | for package in "${packages[@]}"; do 118 | pcall "$python" -m pip install -U "${index[@]}" $package $break 119 | done 120 | } 121 | 122 | install_npm() { 123 | registry=--registry=https://registry.npmmirror.com 124 | pcall npm install -g pyright $registry 125 | } 126 | 127 | install_pacman() { 128 | sudo pacman -S --noconfirm ripgrep 129 | sudo pacman -S --noconfirm fzf 130 | sudo pacman -S --noconfirm cmake 131 | sudo pacman -S --noconfirm make 132 | sudo pacman -S --noconfirm git 133 | sudo pacman -S --noconfirm gcc 134 | sudo pacman -S --noconfirm python 135 | sudo pacman -S --noconfirm python-pip 136 | sudo pacman -S --noconfirm curl 137 | sudo pacman -S --noconfirm clang 138 | sudo pacman -S --noconfirm nodejs 139 | sudo pacman -S --noconfirm npm 140 | sudo pacman -S --noconfirm lua-language-server 141 | sudo pacman -S --noconfirm pyright 142 | sudo pacman -S --noconfirm python-pynvim 143 | sudo pacman -S --noconfirm python-openai 144 | sudo pacman -S --noconfirm python-tiktoken 145 | } 146 | 147 | install_apt() { 148 | export DEBIAN_FRONTEND=noninteractive 149 | sudo apt update 150 | pcall sudo apt-get install -y ripgrep 151 | pcall sudo apt-get install -y fzf 152 | sudo apt-get install -y cmake 153 | sudo apt-get install -y make 154 | sudo apt-get install -y git 155 | sudo apt-get install -y gcc 156 | sudo apt-get install -y python3 157 | sudo apt-get install -y python3-pip 158 | sudo apt-get install -y curl 159 | pcall sudo apt-get install -y clangd 160 | pcall sudo apt-get install -y clang-format 161 | pcall sudo apt-get install -y nodejs 162 | pcall sudo apt-get install -y npm 163 | install_pip 164 | install_npm 165 | } 166 | 167 | install_yum() { 168 | sudo yum-config-manager --add-repo=https://copr.fedorainfracloud.org/coprs/carlwgeorge/ripgrep/repo/epel-7/carlwgeorge-ripgrep-epel-7.repo 169 | pcall sudo yum install -y ripgrep 170 | pcall sudo yum install -y fzf 171 | sudo yum install -y cmake 172 | sudo yum install -y make 173 | sudo yum install -y git 174 | sudo yum install -y gcc 175 | sudo yum install -y python3 || sudo yum install -y python 176 | sudo yum install -y curl 177 | pcall sudo yum install -y clangd 178 | pcall sudo yum install -y clang-format 179 | pcall sudo yum install -y nodejs 180 | pcall sudo yum install -y npm 181 | install_pip 182 | install_npm 183 | } 184 | 185 | 186 | install_dnf() { 187 | pcall sudo dnf install -y ripgrep 188 | pcall sudo dnf install -y fzf 189 | sudo dnf install -y cmake 190 | sudo dnf install -y make 191 | sudo dnf install -y git 192 | sudo dnf install -y gcc 193 | sudo dnf install -y python3 || sudo dnf install -y python 194 | sudo dnf install -y curl 195 | pcall sudo dnf install -y clangd 196 | pcall sudo dnf install -y clang-tools-extra 197 | pcall sudo dnf install -y clang-format 198 | pcall sudo dnf install -y nodejs 199 | pcall sudo dnf install -y npm 200 | install_pip 201 | install_npm 202 | } 203 | 204 | install_zypper() { 205 | pcall sudo zypper in --no-confirm ripgrep || true 206 | pcall sudo zypper in --no-confirm fzf || true 207 | sudo zypper in --no-confirm cmake 208 | sudo zypper in --no-confirm make 209 | sudo zypper in --no-confirm git 210 | sudo zypper in --no-confirm gcc 211 | sudo zypper in --no-confirm python 212 | sudo zypper in --no-confirm curl 213 | pcall sudo zypper in --no-confirm clangd 214 | pcall sudo zypper in --no-confirm clang-format 215 | pcall sudo zypper in --no-confirm nodejs 216 | pcall sudo zypper in --no-confirm npm 217 | install_pip 218 | install_npm 219 | } 220 | 221 | install_brew() { 222 | pcall brew install ripgrep 223 | pcall brew install fzf 224 | brew install cmake 225 | brew install make 226 | brew install git 227 | brew install gcc 228 | brew install python 229 | brew install curl 230 | pcall brew install clangd 231 | pcall brew install clang-format 232 | pcall brew install node 233 | pcall brew install npm 234 | pcall brew install lua-language-server 235 | install_pip 236 | install_npm 237 | } 238 | 239 | do_install() { 240 | distro=`get_linux_distro` 241 | echo "-- Linux distro detected: $distro" 242 | 243 | if [ $distro = "Ubuntu" ]; then 244 | install_apt 245 | elif [ $distro = "Deepin" ]; then 246 | install_apt 247 | elif [ $distro = "Debian" ]; then 248 | install_apt 249 | elif [ $distro = "Kali" ]; then 250 | install_apt 251 | elif [ $distro = "Raspbian" ]; then 252 | install_apt 253 | elif [ $distro = "ArchLinux" ]; then 254 | install_pacman 255 | elif [ $distro = "ManjaroLinux" ]; then 256 | install_pacman 257 | elif [ $distro = "fedora" ]; then 258 | install_dnf 259 | elif [ $distro = "openSUSE" ]; then 260 | install_zypper 261 | elif [ $distro = "CentOS" ]; then 262 | install_yum 263 | elif [ $distro = "MacOS" ]; then 264 | install_brew 265 | else 266 | # TODO: add more Linux distros here.. 267 | echo "-- WARNING: Unsupported Linux distro: $distro" 268 | echo "-- The script will not install any dependent packages like clangd." 269 | echo "-- You will have to manually install clangd, if you plan to make a working C++ IDE." 270 | echo "-- If you know how to install them, feel free to contribute to this GitHub repository: github.com/archibate/vimrc" 271 | exit 1 272 | fi 273 | 274 | echo "-- System dependency installation complete!" 275 | } 276 | 277 | do_install 278 | 279 | -------------------------------------------------------------------------------- /scripts/install_nvim.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | echo "-- NeoVim 0.9.1 or above not found, installing latest for you." 5 | 6 | cd "$(dirname $0)/.." 7 | 8 | install_snap() { 9 | if ! which apt >/dev/null 2>&1; then 10 | export DEBIAN_FRONTEND=noninteractive 11 | sudo apt update -y || true 12 | sudo apt install -y snapd || true 13 | elif ! which zypper >/dev/null 2>&1; then 14 | sudo zypper in --no-confirm snapd || true 15 | elif ! which dnf >/dev/null 2>&1; then 16 | sudo dnf install -y epel-release || true 17 | sudo dnf upgrade || true 18 | sudo dnf install -y snapd || true 19 | elif ! which yum >/dev/null 2>&1; then 20 | sudo yum install -y epel-release || true 21 | sudo yum install -y snapd || true 22 | fi 23 | sudo systemctl enable --now snapd || true 24 | } 25 | 26 | fix_nvim_appimage() { 27 | sudo mv /usr/bin/nvim /usr/bin/.nvim.appimage.noextract 28 | echo 'x=$$; mkdir -p /tmp/_nvim_appimg_.$x && bash -c "cd /tmp/_nvim_appimg_.$x && /usr/bin/.nvim.appimage.noextract --appimage-extract > /dev/null 2>&1" && /tmp/_nvim_appimg_.$x/squashfs-root/AppRun "$@"; x=$?; rm -rf /tmp/_nvim_appimg_.$x exit $x' | sudo tee /usr/bin/nvim 29 | sudo chmod +x /usr/bin/nvim 30 | # echo exec \"\$@\" > /bin/sudo; chmod +x /bin/sudo 31 | } 32 | 33 | if [ "x$(uname -sm)" = "xLinux x86_64" ]; then 34 | if which snap >/dev/null 2>&1; then 35 | sudo snap remove nvim || true 36 | fi 37 | test -f ./nvim.appimage || curl -L https://github.com/neovim/neovim/releases/latest/download/nvim.appimage -o ~/.config/nvim/nvim.appimage 38 | sudo chmod +x ./nvim.appimage 39 | test -f /usr/bin/nvim && sudo mv /usr/bin/nvim /tmp/.nvim-executable-backup || true 40 | sudo cp ./nvim.appimage /usr/bin/nvim 41 | /usr/bin/nvim --version || fix_nvim_appimage 42 | elif [ "x$(uname -s)" = "xDarwin" ]; then 43 | echo "-- MacOS detected, try installing latest nvim from brew..." 44 | brew uninstall neovim 2> /dev/null || true 45 | brew install neovim 46 | else 47 | if which pacman >/dev/null 2>&1; then 48 | echo "-- Installing latest nvim with pacman..." 49 | pacman -S --noconfirm neovim 50 | else 51 | echo "-- Non x86_64 Linux detected, trying installing latest nvim from snap..." 52 | if ! which snap >/dev/null 2>&1; then 53 | echo "-- Snap not found, try installing for you..." 54 | install_snap 55 | fi 56 | sudo snap install nvim 57 | fi 58 | fi 59 | -------------------------------------------------------------------------------- /todo.txt: -------------------------------------------------------------------------------- 1 | { "lsp_signatur handler", { 2 | code = -32602, 3 | message = "trying to get preamble for non-added document", 4 | = { 5 | __tostring = 6 | } 7 | } } 8 | 9 | Error executing Lua callback: BufReadPost Autocommands for "*": Vim(append):Error executing lua callback: /home/bate/.config/nvim/lua/archvim/config/bufferline.lua:65: attempt to get length of a nil value 10 | stack traceback: 11 | /home/bate/.config/nvim/lua/archvim/config/bufferline.lua:65: in function 'close_empty_unnamed_buffers' 12 | /home/bate/.config/nvim/lua/archvim/config/bufferline.lua:78: in function 13 | [C]: in function 'setqflist' 14 | ...cker/start/cmake-tools.nvim/lua/cmake-tools/quickfix.lua:40: in function 'run' 15 | .../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:259: in function <.../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:237> 16 | stack traceback: 17 | [C]: in function 'setqflist' 18 | ...cker/start/cmake-tools.nvim/lua/cmake-tools/quickfix.lua:40: in function 'run' 19 | .../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:259: in function <.../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:237> 20 | 21 | 22 | Error executing Lua callback: BufReadPost Autocommands for "*": Vim(append):E813: Cannot close autocmd window 23 | stack traceback: 24 | [C]: in function 'setqflist' 25 | ...cker/start/cmake-tools.nvim/lua/cmake-tools/quickfix.lua:40: in function 'run' 26 | .../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:259: in function <.../packer/start/cmake-tools.nvim/lua/cmake-tools/utils.lua:237> 27 | --------------------------------------------------------------------------------