mirror of
https://github.com/d0zingcat/dotfiles.git
synced 2026-05-13 15:09:34 +00:00
- 架构重构:新增 plugins/lang/ 子目录,按语言拆分配置 - 补全引擎:nvim-cmp → blink.cmp + LuaSnip - 文件浏览:新增 neo-tree(<Space>e) - 语言支持: - Go: ray-x/go.nvim + dap-go + neotest-go - Rust: rustaceanvim + crates.nvim - Python: venv-selector + dap-python + neotest-python - TypeScript: typescript-tools.nvim(替换 ts_ls) - LSP: lazydev + mason + mason-lspconfig + fidget + inc-rename - 格式化: conform.nvim(lsp_format fallback,保存时自动格式化) - Lint: nvim-lint(selene 替换 luacheck,Mason 可直接安装) - UI: snacks.nvim(dashboard+notifier+picker)+ noice + lualine + bufferline - 编辑增强: mini.ai + mini.surround + grug-far + flash + ufo + trouble v3 - 删除废弃文件: cmp/coding/null-ls/mason/lspconfig/go/python 等旧文件 - 修复: Neovim 0.12 treesitter query 校验报错(noice routes 过滤) - 新增: NVIM_GUIDE.md 快捷键使用手册 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
82 lines
2.5 KiB
Lua
82 lines
2.5 KiB
Lua
-- treesitter.lua - 语法高亮与代码结构
|
||
|
||
return {
|
||
{
|
||
"nvim-treesitter/nvim-treesitter",
|
||
build = ":TSUpdate",
|
||
event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" },
|
||
dependencies = {
|
||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||
},
|
||
opts = {
|
||
ensure_installed = {
|
||
-- "comment" 已在新版 nvim-treesitter 中弃用,避免 query 校验错误
|
||
"bash", "c", "cmake", "css", "diff", "dockerfile",
|
||
"git_config", "git_rebase", "gitcommit", "gitignore",
|
||
"go", "gomod", "gosum", "gowork",
|
||
"html", "javascript", "jsdoc", "json", "jsonc",
|
||
"lua", "luadoc", "luap", "make", "markdown", "markdown_inline",
|
||
"python", "regex", "rst", "rust", "sql", "toml",
|
||
"tsx", "typescript", "vim", "vimdoc", "xml", "yaml",
|
||
},
|
||
highlight = { enable = true },
|
||
indent = { enable = true },
|
||
incremental_selection = {
|
||
enable = true,
|
||
keymaps = {
|
||
init_selection = "<C-space>",
|
||
node_incremental = "<C-space>",
|
||
scope_incremental = false,
|
||
node_decremental = "<bs>",
|
||
},
|
||
},
|
||
textobjects = {
|
||
select = {
|
||
enable = true,
|
||
lookahead = true,
|
||
keymaps = {
|
||
["af"] = "@function.outer",
|
||
["if"] = "@function.inner",
|
||
["ac"] = "@class.outer",
|
||
["ic"] = "@class.inner",
|
||
["aa"] = "@parameter.outer",
|
||
["ia"] = "@parameter.inner",
|
||
["ab"] = "@block.outer",
|
||
["ib"] = "@block.inner",
|
||
},
|
||
},
|
||
move = {
|
||
enable = true,
|
||
set_jumps = true,
|
||
goto_next_start = {
|
||
["]f"] = "@function.outer",
|
||
["]c"] = "@class.outer",
|
||
},
|
||
goto_next_end = {
|
||
["]F"] = "@function.outer",
|
||
["]C"] = "@class.outer",
|
||
},
|
||
goto_previous_start = {
|
||
["[f"] = "@function.outer",
|
||
["[c"] = "@class.outer",
|
||
},
|
||
goto_previous_end = {
|
||
["[F"] = "@function.outer",
|
||
["[C"] = "@class.outer",
|
||
},
|
||
},
|
||
},
|
||
},
|
||
config = function(_, opts)
|
||
-- nvim-treesitter v1+ 重构后移除了 configs 子模块,需要兼容两种 API
|
||
local ok, configs = pcall(require, "nvim-treesitter.configs")
|
||
if ok then
|
||
configs.setup(opts)
|
||
else
|
||
-- 新版 API:直接调用顶层模块
|
||
require("nvim-treesitter").setup(opts)
|
||
end
|
||
end,
|
||
},
|
||
}
|