chore: add Neovim Lua plugin#290
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis pull request introduces a Neovim plugin for snakefmt integration with configuration management and executable path resolution, updates editor integration documentation to include Neovim-specific guidance, and modifies Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Neovim as Neovim Editor
participant Init as snakefmt.init
participant Config as snakefmt.config
participant Paths as snakefmt.paths
participant System as vim.system
User->>Neovim: Call setup(opts)
Neovim->>Init: M.setup(opts)
Init->>Config: config.setup(opts)
Config->>Config: Deep merge opts into defaults
Init->>Init: Clear & recreate augroup<br/>Register BufWritePre & commands
User->>Neovim: Trigger :Snakefmt or BufWritePre
Neovim->>Init: M.format()
Init->>Paths: paths.get_snakefmt_bin(config.options)
Paths->>Paths: Resolve bin: configured,<br/>$VIRTUAL_ENV, .venv,<br/>global, or uvx fallback
Paths-->>Init: Return bin command array or nil
Init->>System: vim.system(bin + args,<br/>stdin=buffer_content)
System-->>Init: On completion: stdout/stderr
Init->>Neovim: Replace buffer with formatted output<br/>or display error notification
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 39 minutes and 20 seconds.Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #290 +/- ##
=======================================
Coverage 96.52% 96.52%
=======================================
Files 12 12
Lines 1497 1497
Branches 309 309
=======================================
Hits 1445 1445
Misses 24 24
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/editor_integration.md`:
- Line 84: Update the docs to reflect the actual fallback command: change the
wording that currently says "Automatic fallback to `uvx snakefmt`" to describe
that the plugin runs `uv run --with snakefmt snakefmt` as implemented in
lua/snakefmt/paths.lua; ensure the text explicitly matches that command so
readers/debuggers see the real runtime behavior.
In `@lua/snakefmt/init.lua`:
- Around line 42-44: Before starting the async format capture the buffer id and
its change tick (use bufnr and nvim_buf_get_changedtick) and include that tick
with the request; in the async callback (where you currently check
nvim_buf_is_valid and call nvim_buf_set_lines) re-check that the buffer is still
valid and that nvim_buf_get_changedtick(bufnr) equals the original tick before
replacing lines (do not overwrite if ticks differ), i.e., add a pre-write guard
around the nvim_buf_set_lines call to prevent applying stale output to an edited
buffer.
- Around line 11-18: The autocmd using BufWritePre calls M.format()
asynchronously which allows the buffer to be written before formatting finishes;
modify M.format to accept a sync boolean (e.g., M.format(sync)) and implement a
synchronous path when sync==true that uses vim.system(...):wait() (or equivalent
blocking API) to run snakefmt and apply edits before the write completes, then
change the BufWritePre autocmd callback to call M.format(true) while keeping the
existing async behavior for manual :Snakefmt calls (M.format(false) or default).
In `@lua/snakefmt/paths.lua`:
- Around line 12-13: The resolver currently builds a Unix-only path (venv ..
"/bin/snakefmt") and checks it with vim.fn.executable, which misses Windows venv
layouts; update the lookup to try multiple candidate paths (e.g., venv ..
"/bin/snakefmt", venv .. "/Scripts/snakefmt.exe", and venv ..
"/Scripts/snakefmt") and use vim.fn.executable over each candidate until one is
executable, replacing the single `path` check; refer to the `venv` and `path`
variables and the `vim.fn.executable` checks in the resolver so both Unix and
Windows virtualenv layouts are supported.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6e82b4e6-9ff9-4dc9-81a5-f1cf05032ada
📒 Files selected for processing (5)
.gitignoredocs/editor_integration.mdlua/snakefmt/config.lualua/snakefmt/init.lualua/snakefmt/paths.lua
Summary
snakefmt.vim.systemfor async formatting.uvx).docs/editor_integration.md.Test Plan
auto_formatenabled..venvbinaries.uvxfallback works when binary is not in path.Summary by CodeRabbit
New Features
:Snakefmtand:SnakefmtInfocommandsuvtool when snakefmt isn't available locallyDocumentation