Oxc support - #46
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a new ChangesTool config infrastructure and plugin wiring
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
lua/nikero/tools.lua (1)
166-171: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winDo not discard the config found by
vim.fs.find.Line 166 runs the fallback only when
config_pathalready exists, then overwrites the nearer match with a root-level probe ornil. Nested package configs can be ignored, which makes default-config and JS-tool selection wrong.Proposed fix
- if config_path ~= nil then + if config_path == nil then + stop_path = vim.fs.normalize(stop_path) config_path = vim .iter(names) :map(function(name) return vim.fs.joinpath(stop_path, name) end) :find(function(path) return vim.uv.fs_stat(path) end) end🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/nikero/tools.lua` around lines 166 - 171, The fallback logic in the config resolution block is overwriting a config path that was already found, which can discard the nearer match from vim.fs.find. Update the config_path handling in lua/nikero/tools.lua so the fallback only runs when no config was found, and preserve the existing result instead of replacing it; use the surrounding config_path, vim.fs.find, and vim.uv.fs_stat flow to locate the fix.
🧹 Nitpick comments (1)
lua/nikero/tools.lua (1)
39-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winKeep the Tools annotations aligned with the actual API.
default_config_pathis now a local helper, not aToolsmethod, and_js_tools_cache.linterstores"eslint"while the annotation says"eslint_d".Proposed annotation cleanup
---@class Tools ---@field configs table<ToolConfigName, ToolConfig> ----@field default_config_path fun(self: Tools, filename: string): string ---@field package_json_has_key fun(self: Tools, key: string): boolean ---@field find_config_file fun(self: Tools, names: string[], opts?: { bufnr?: integer, stop?: string }): string|nil ---@field get_default_config fun(self: Tools, name: string): string|nil ---@field get_js_tools fun(self: Tools, buffer: integer): { linter: ("oxlint"|"eslint")[], formatter: ("oxfmt"|"prettier")[] } ----@field _js_tools_cache table<string, { linter: ("oxlint"|"eslint_d")[], formatter: ("oxfmt"|"prettier")[] }> +---@field _js_tools_cache table<string, { linter: ("oxlint"|"eslint")[], formatter: ("oxfmt"|"prettier")[] }>🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lua/nikero/tools.lua` around lines 39 - 46, Update the Tools annotations to match the real API: remove the default_config_path method entry from the Tools class because it is now only a local helper, and correct the _js_tools_cache / get_js_tools linter union so it reflects the actual cached/runtime value ("eslint" instead of "eslint_d"). Keep the symbols Tools, get_js_tools, and _js_tools_cache aligned with the implementation in tools.lua.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lua/nikero/tools.lua`:
- Around line 183-207: The JS tool selection in Tools:get_js_tools is cached too
broadly by project_dir, which can reuse oxlint/oxfmt and eslint/prettier choices
across different packages in the same repo. Update the cache key to include the
buffer-specific package or config scope used by find_config_file(), so each
package resolves its own tool set independently. Keep the existing tool
detection logic, but move the memoization in get_js_tools to a more specific key
than the git root.
- Around line 176-180: Make the default-config lookup buffer-aware so setup-time
resolution does not freeze a single config for all later buffers. Update
Tools:get_default_config to accept the current bufnr or opts and use that when
calling find_config_file, then thread that context from the tool setup path that
resolves yamllint. If that lookup cannot be made dynamic, defer assigning the
env/default config until lint time so project-local configs can still override
it per buffer.
In `@lua/plugins/language/tools.lua`:
- Line 129: Wire oxfmt into the Conform setup so Tools:get_js_tools() can
actually use it: update the formatter registration and the affected
formatters_by_ft entries in tools.lua so `oxfmt` is included where appropriate.
Make sure the Conform configuration references the existing `oxfmt` formatter
symbol and that `astro` (and any other matching JS/TS filetypes in this diff)
can resolve it, so `oxfmt.config.ts` is picked up for those buffers.
- Around line 3-9: The config check in default_config_args() is being evaluated
too early because sqlfluff and stylua call it while opts.formatters is
constructed, so the formatter choice gets frozen to startup context. Update the
formatter setup to use append_args instead of precomputed args, and change
default_config_args() to accept ctx.buf so tools:find_config_file() runs at
format time against the current buffer/cwd.
---
Outside diff comments:
In `@lua/nikero/tools.lua`:
- Around line 166-171: The fallback logic in the config resolution block is
overwriting a config path that was already found, which can discard the nearer
match from vim.fs.find. Update the config_path handling in lua/nikero/tools.lua
so the fallback only runs when no config was found, and preserve the existing
result instead of replacing it; use the surrounding config_path, vim.fs.find,
and vim.uv.fs_stat flow to locate the fix.
---
Nitpick comments:
In `@lua/nikero/tools.lua`:
- Around line 39-46: Update the Tools annotations to match the real API: remove
the default_config_path method entry from the Tools class because it is now only
a local helper, and correct the _js_tools_cache / get_js_tools linter union so
it reflects the actual cached/runtime value ("eslint" instead of "eslint_d").
Keep the symbols Tools, get_js_tools, and _js_tools_cache aligned with the
implementation in tools.lua.
🪄 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: 1c6d9055-1f5d-47f5-a553-d7152bffa7ef
📒 Files selected for processing (3)
config_files/oxfmt.config.tslua/nikero/tools.lualua/plugins/language/tools.lua
This pull request refactors and enhances the configuration management for code formatting and linting tools, improving the logic for selecting project-specific or default configs and simplifying how tools are configured across the codebase. It introduces a new default config for
oxfmt, centralizes config file lookup logic, and unifies how formatters and linters are selected and invoked, especially for JavaScript and related filetypes.Configuration Management Improvements:
oxfmt.config.tsdefault configuration file and integrated it into the toolchain.Toolsmodule to centralize and standardize how default config paths are determined for all supported tools, including new or improved support forprettier,stylelint,stylua,selene,oxfmt,sqlfluff, andyamllint. [1] [2] [3] [4]Tool Selection and Caching:
Tools:get_js_toolsto intelligently choose which JavaScript linters and formatters to use based on project configuration, with caching for efficiency. This ensures the correct tool is used depending on the presence of project configs.Plugin Integration and Simplification:
lua/plugins/language/tools.lua) to use the new centralized logic for passing default config arguments and environment variables, reducing duplication and improving maintainability. [1] [2]get_js_toolslogic and providing consistent toolchains for all relevant languages. [1] [2] [3]