- Run all tests:
nvim --headless -c "luafile test.lua" - Run single test file:
nvim --headless -c "lua require('test_module').test_function()" - Integration test: Open test file and run
:Diffycommand manually
- Lua linting:
luacheck lua/ - Style checking:
stylua --check lua/ - Format code:
stylua lua/
- No build step required (pure Lua plugin)
- Reload plugin:
:lua package.loaded.diffy = nil; require('diffy')
- Functions:
snake_case(e.g.,get_diff_data()) - Variables:
snake_case(e.g.,diff_data) - Modules:
snake_case(e.g.,git.lua,ui.lua) - Constants:
UPPER_SNAKE_CASE
- Use
local M = {}for module exports - Require modules at top:
local git = require('diffy.git') - Avoid global variables except Neovim builtins (
vim.*)
- Check function return values before using
- Use
vim.notify()for user-facing errors - Return
nilfor failure cases, handle gracefully - Validate inputs before processing
- 2-space indentation
- Line length: 100 characters max
- Consistent spacing around operators
- Group related functions with blank lines
- Use descriptive variable names
- Add comments for complex logic
- Document public API functions
- Avoid Hungarian notation
- Use
vim.api.*for core operations - Handle window/buffer lifecycle properly
- Set appropriate buffer options (
buftype,bufhidden) - Clean up resources on plugin unload
- Cache expensive operations when possible
- Use async jobs for external commands
- Minimize API calls in loops
- Profile with
:lua vim.loop.hrtime()if needed