refactoring.nvim
3,662
Stars
108
Forks
26
Watchers
6
Open Issues
MIT
许可证
Lua
语言
2021-07-20
创建时间
2026-11-12
最近更新
项目能做什么
基于 Martin Fowler《重构》一书打造的 Neovim 重构插件。
来源:AI 基于仓库事实生成
· 内容以仓库实际 README 为准
使用说明 查看原始 README 原仓库文档
中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
<div align="center">
<h1>refactoring.nvim</h1>
<h5>The Refactoring library based off the Refactoring book by Martin Fowler</h5>
<h6>'If I use an environment that has good automated refactorings, I can trust those refactorings' - Martin Fowler</h6>
</div>
### Tree-sitter and LSP powered refactoring
- Provides refactoring and print-debugging operators (see `:h operator`) powered by LSP and tree-sitter.
- Supports dot-repeat and any textobject/motion.
- Allows fine-grained customization while providing reasonable defaults.
More details on [Features](#features)
---
## Demo
https://github.com/user-attachments/assets/70b15d18-197a-4135-abe0-1fb4a6c06319
## Features
- Inline variable:
- Inline the definition of the variable under cursor into **all** its references.
- Requires:
- LSP server with support for `textDocument/references` and `textDocument/definition`
- Tree-sitter parser and queries (`refactor_reference` and `refactor_variable`)
- Extract variable:
- Extract an expression, and **all** its usages in a buffer, into a variable.
- Requires:
- Tree-sitter parser and queries (`refactor_scope` and `refactor_output_statement`)
- Inline function:
- Inline the definition of the function under cursor into **all** its references (only supports functions with a single return statement).
- Requires:
- LSP server with support for `textDocument/references` and `textDocument/definition`
- Tree-sitter parser and queries (`refactor_function` and `refactor_function_call`)
- Extract function:
- Extract text into a function and replace it with a call to that function.
- Requires:
- Tree-sitter parser and queries (`refactor_reference`, `refactor_scope`, `refactor_output_function` and `refactor_input_function`)
- Print location:
- Inserts a debug print statement with the location under cursor (e.g. `some_function#if#for`).
- Requires:
- Tree-sitter parser and queries (`refactor_comment` and `refactor_output_statement`)
- Print variable:
- Inserts a debug print statement with **all** the variable and locations (e.g. `some_function#if#for`) in the selected range.
- Requires:
- Tree-sitter parser and queries (`refactor_comment`, `refactor_reference`, `refactor_output_statement` and `refactor_scope`)
- Print expression:
- Inserts a debug print statement with the selected expression and location (e.g. `some_function#if#for`).
- Requires:
- Tree-sitter parser and queries (`refactor_comment` and `refactor_output_statement`)
- Debug print cleanup:
- Cleanup the debug print statements in the selected range.
- Requires:
- Tree-sitter parser and queries (`refactor_comment`)
> [!NOTE]
> Tree-sitter queries for supported languages are bundled with `refactoring.nvim`
## Installation
`refactoring.nvim` requires Neovim `0.12.5`.
<details>
<summary>With <code>vim.pack</code></summary>
```lua
vim.pack.add {
-- `async.nvim` is only required for Neovim 0.12. If you are using Neovim 0.13, you do
阅读完整原文
项目深度分析 AI 生成
Neovim 企业级代码规范与重构定制套件 (SaaS/On-Premise 插件)
| 产品构想 | 基于 tree-sitter 和项目重构逻辑,为企业研发团队提供符合内部架构约束的专属重构动作与自动化规范检查套件。 |
| 核心功能 | 团队专属重构规则共享、跨文件架构分层提取规则、自动生成重构变更说明、内网私有规则仓库同步。 |
| 目标用户 | 采用 Neovim/终端环境的研发团队 Tech Lead、中大型开源或专有技术栈团队。 |
| 难度/周期 | 高 · 3-6 个月 · 成本:中等(主要是开发维护与语法解析器测试成本) |
| 收费模式 | 团队席位订阅制(SaaS)或企业级买断授权与支持。 |
| 竞争风险 | Neovim 纯商业插件市场极小,企业统一采购意愿通常倾向 JetBrains 或 VSCode。 |
| 依据 | AI推测 |
代码现代化与重构顾问/培训服务 (DevRel/咨询模式)
| 产品构想 | 借助项目在重构领域与社区的知名度,针对重度技术债企业提供基于 Martin Fowler 理论的代码重构实战培训与重构工程咨询。 |
| 核心功能 | 自动化重构工具链导入方案、遗留单体代码解耦实战工作坊、基于 AST/Tree-sitter 的自动化改造工具定制。 |
| 目标用户 | 面临遗留代码维护痛点的工程团队、技术总监、架构师。 |
| 难度/周期 | 中等 · 1-2 个月 · 成本:极低(主要是专家时间与交付物编写) |
| 收费模式 | 企业咨询费、定制培训课时费、技术改造项目制收费。 |
| 竞争风险 | 高度依赖个人品牌声誉,难以实现规模化被动收入,属于劳务密集型交付。 |
| 依据 | 已验证事实 |
跨编辑器通用重构 LSP/CLI 引擎 (商业 CLI/通用工具)
| 产品构想 | 将 Tree-sitter + 重构逻辑解耦成独立的 CLI 或通用 LSP 扩展服务,使其不仅服务于 Neovim,还能接入 VSCode、Helix 等现代编辑器。 |
| 核心功能 | 独立命令行批量代码重构提取、多编辑器无缝对接的 LSP 接口、支持自定义 Tree-sitter 模式匹配规则。 |
| 目标用户 | 追求轻量化无 IDE 依赖重构体验的现代开发者、CLI 脚本编写者。 |
| 难度/周期 | 高 · 4-6 个月 · 成本:中等(需要 Rust/Go 等语言重构核心逻辑以跨平台运行) |
| 收费模式 | 高级功能/闭源模块双重许可(Dual-licensing)、企业版批量处理工具授权。 |
| 竞争风险 | 成熟 IDE(如 IntelliJ/VSCode 官方语言插件)内置重构能力极强,外部独立引擎竞争壁垒低。 |
| 依据 | 尚需验证的假设 |
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心
竞品与相似项目 GitHub Search 真实检索
| 项目 | 中文简介 | Stars | 语言 |
|---|---|---|---|
| sidlatau/dart-lsp-refactorings.nvim | 中文介绍暂未生成 | 5 | Lua |
| Sauric/nvim-dotnet-refactoring | 中文介绍暂未生成 Nvim plugin for dotnet rider-like refactoring options |
2 | Lua |
| archinautio/refactoring-kotlin.nvim | 中文介绍暂未生成 | 1 | Lua |
| archinautio/refactoring-kotlin.nvim-tests | 中文介绍暂未生成 | 0 | Kotlin |
以上为通过 GitHub 官方 Search API 检索的相似项目,功能差异与优劣势需进一步人工确认,配置 AI 后可生成对比分析。
项目优势与风险
| 技术成熟度 | 创建于 2021-07-20,近 30 天仍在推送 |
| 社区活跃 | Star 3,662 / Fork 108 / Issue 6(数据支持,可自行核实) |
| 许可证 | MIT |
| 主要风险 | 上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价 |
安装与使用
此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。