Skill站外收录 @skilllib/skill-2014279402421432321
skill-neovim-implementation
基于测试驱动开发规范实现 Neovim 的 Lua 插件与配置,通过编写单元测试先行、最小化编码、重构验证等流程确保代码质量,支持插件定义、模块化结构与错误安全处理,适用于高可靠性的编辑器功能扩展。
效率工具 AI 技能
Skills.MD
# Neovim Implementation Skill
Specialized implementation agent for Neovim configuration and Lua plugin development with test-driven development.
## Trigger Conditions
This skill activates when:
- Task language is "lua"
- Implementation involves Neovim plugins, configurations, or utilities
- /implement command is invoked for a Lua task
- Plan exists with phases ready for execution
## TDD Workflow
Follow strict test-driven development:
```
1. Load implementation plan
2. Identify target functionality
3. Write failing test first (busted/plenary)
4. Implement minimal code to pass
5. Run test to verify pass
6. Refactor while tests pass
7. Repeat for each feature
8. Verify with full test suite
```
### TDD Rules
1. **Write test first** - Never implement without a failing test
2. **Minimal implementation** - Only write code to make the test pass
3. **Refactor under green** - Only refactor when all tests pass
4. **One feature at a time** - Focus on single functionality per cycle
## Testing Commands
### Run All Tests
```bash
# Run all tests with plenary
nvim --headless -c "PlenaryBustedDirectory tests/"
# With minimal init (faster, isolated)
nvim --headless -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/minimal_init.lua'}"
```
### Run Specific Tests
```bash
# Run single test file
nvim --headless -c "PlenaryBustedFile tests/path/to/spec.lua"
# Run tests matching pattern
nvim --headless -c "PlenaryBustedDirectory tests/ {pattern = 'picker'}"
```
### Lint Lua Code
```bash
# Check for syntax errors
luacheck lua/ --codes
# Check specific file
luacheck lua/neotex/path/to/file.lua
```
## Test File Structure
Create test files following this pattern:
```lua
-- tests/module_name_spec.lua
describe("ModuleName", function()
local module
before_each(function()
-- Reset state before each test
package.loaded["neotex.module_name"] = nil
module = require("neotex.module_name")
end)
describe("function_name", function()
it("should do expected behavior", function()
local result = module.function_name(input)
assert.equals(expected, result)
end)
it("should handle edge case", function()
local result = module.function_name(edge_input)
assert.is_nil(result)
end)
end)
end)
```
### Assertion Patterns
```lua
-- Use is_nil/is_not_nil for pattern matching
assert.is_not_nil(str:match("pattern")) -- Match found
assert.is_nil(str:match("pattern")) -- Match not found
-- Equality
assert.equals(expected, actual)
assert.same(expected_table, actual_table)
-- Boolean
assert.is_true(condition)
assert.is_false(condition)
-- Errors
assert.has_error(function() error_func() end)
```
## Module Structure Patterns
### Lua Module Directory
```
nvim/
├── lua/neotex/
│ ├── core/ # Core utilities (loader, options, keymaps)
│ │ └── module.lua
│ ├── plugins/ # Plugin configurations
│ │ ├── ai/ # AI integrations
│ │ ├── editor/ # Editor enhancements
│ │ ├── lsp/ # Language server configs
│ │ ├── text/ # Format-specific (LaTeX, Markdown)
│ │ ├── tools/ # Development tools
│ │ └── ui/ # UI components
│ └── util/ # Utility functions
├── after/ftplugin/ # Filetype-specific settings
└── tests/ # Test suites
```
### Standard Module Template
```lua
-- lua/neotex/category/module-name.lua
local M = {}
--- Brief description of the module
--- @module neotex.category.module-name
--- Function description
--- @param input string Input parameter
--- @return string|nil result Result or nil on failure
function M.function_name(input)
if not input then
return nil
end
-- Implementation
return result
end
--- Setup function for configuration
--- @param opts table? Optional configuration
function M.setup(opts)
opts = opts or {}
-- Apply configuration
end
return M
```
### Plugin Definition Pattern
```lua
-- lua/neotex/plugins/category/plugin-name.lua
return {
"author/plugin-name",
event = "VeryLazy", -- or specific events: BufReadPre, InsertEnter
dependencies = {
"dep/plugin",
},
opts = {
-- Configuration options passed to setup()
option_key = "value",
},
config = function(_, opts)
require("plugin-name").setup(opts)
end,
}
```
### Complex Plugin with Keymaps
```lua
return {
"author/plugin-name",
event = "VeryLazy",
keys = {
{ "<leader>xx", "<cmd>PluginCommand<cr>", desc = "Plugin: Description" },
{ "<leader>xy", function() require("plugin").action() end, desc = "Plugin: Action" },
},
opts = {
-- Options
},
config = function(_, opts)
local plugin = require("plugin-name")
plugin.setup(opts)
-- Additional configuration after setup
end,
}
```
## Error Handling Patterns
### Using pcall for Safe Calls
```lua
local function safe_require(module_name)
local ok, module = pcall(require, module_name)
if not ok then
vim.notify(
"Failed to load " .. module_name .. ": " .. tostring(module),
vim.log.levels.WARN
)
return nil
end
return module
end
-- Usage
local telescope = safe_require("telescope")
if telescope then
telescope.setup({})
end
```
### Graceful Degradation
```lua
local function with_fallback(primary_fn, fallback_fn)
local ok, result = pcall(primary_fn)
if ok then
return result
end
return fallback_fn()
end
```
### User Notifications
```lua
-- Info level
vim.notify("Operation completed", vim.log.levels.INFO)
-- Warning level
vim.notify("Missing optional dependency", vim.log.levels.WARN)
-- Error level
vim.notify("Critical error: " .. err, vim.log.levels.ERROR)
```
## Implementation Flow
```
1. Receive task context with plan path
2. Load and parse implementation plan
3. Find resume point (first non-completed phase)
4. For each remaining phase:
a. Update phase status to [IN PROGRESS]
b. Write tests for phase features
c. Run tests (should fail)
d. Implement features
e. Run tests (should pass)
f. Verify with luacheck
g. Update phase status to [COMPLETED]
h. Git commit
5. Run full test suite
6. Create implementation summary
7. Return results
```
## Summary Format
Create summary at `.claude/specs/{N}_{SLUG}/summaries/implementation-summary-{DATE}.md`:
```markdown
# Implementation Summary: Task #{N}
**Completed**: {date}
**Duration**: {time}
## Changes Made
{Overview of implemented features}
## Files Created
- `lua/neotex/path/to/file.lua` - {description}
## Files Modified
- `lua/neotex/path/to/file.lua` - {change description}
## Tests Added
- `tests/path/to/spec.lua` - {test coverage}
## Test Results
```
N tests passed
0 tests failed
Coverage: X%
```
## Verification
- All tests pass
- luacheck reports no errors
- Plugin loads correctly
## Notes
{Any important notes or follow-ups}
```
## Return Format
```json
{
"status": "completed|partial",
"summary": "Implementation complete with TDD",
"artifacts": [
{
"path": ".claude/specs/{N}_{SLUG}/summaries/...",
"type": "summary",
"description": "Implementation summary"
}
],
"phases_completed": 3,
"phases_total": 3,
"files_created": [
"lua/neotex/path/to/file.lua"
],
"files_modified": [
"lua/neotex/existing/file.lua"
],
"tests_added": [
"tests/path/to/spec.lua"
],
"test_results": {
"passed": 10,
"failed": 0,
"total": 10
}
}
```
## Key Codebase Locations
- **Entry point**: `nvim/init.lua`
- **Core config**: `nvim/lua/neotex/config/`
- **Plugin configs**: `nvim/lua/neotex/plugins/`
- **Core utilities**: `nvim/lua/neotex/core/`
- **Utilities**: `nvim/lua/neotex/util/`
- **Tests**: `nvim/tests/`
- **Standards**: `nvim/CLAUDE.md`, `nvim/docs/CODE_STANDARDS.md`
- **Rules**: `.claude/rules/neovim-lua.md`
## Quality Standards
- **Indentation**: 2 spaces, expandtab
- **Line length**: ~100 characters
- **Naming**: lowercase_with_underscores
- **Comments**: LuaDoc style for public APIs
- **Error handling**: pcall for external dependencies
- **Testing**: All public APIs must have tests
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「skill-neovim-implementation」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次