Skip to content

Oxc support - #46

Merged
nikero41 merged 22 commits into
mainfrom
oxc-support
Jun 29, 2026
Merged

Oxc support#46
nikero41 merged 22 commits into
mainfrom
oxc-support

Conversation

@nikero41

Copy link
Copy Markdown
Owner

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:

  • Added a new oxfmt.config.ts default configuration file and integrated it into the toolchain.
  • Refactored the Tools module to centralize and standardize how default config paths are determined for all supported tools, including new or improved support for prettier, stylelint, stylua, selene, oxfmt, sqlfluff, and yamllint. [1] [2] [3] [4]

Tool Selection and Caching:

  • Implemented Tools:get_js_tools to 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:

  • Updated plugin configuration (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]
  • Simplified and unified formatter and linter selection for JavaScript and related filetypes, now relying on the new get_js_tools logic and providing consistent toolchains for all relevant languages. [1] [2] [3]

@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c37fb43-2810-4fd6-afce-1b72c94f3ac1

📥 Commits

Reviewing files that changed from the base of the PR and between af595ce and 2fe6117.

📒 Files selected for processing (2)
  • lua/nikero/tools.lua
  • lua/plugins/language/tools.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • lua/plugins/language/tools.lua

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a new code formatting configuration with consistent style settings and improved import sorting.
    • Expanded formatter and linter selection so common web, markup, and config files use the most appropriate tools automatically.
  • Bug Fixes

    • Improved project-aware config detection, reducing cases where tools use the wrong settings.
    • Added safer fallback behavior when no project config is found, helping linting and formatting continue to work reliably.

Walkthrough

Adds a new oxfmt config file, extends lua/nikero/tools.lua with project-aware config path helpers and cached JS tool selection, and updates linting and formatting setup to use the new config-aware helpers.

Changes

Tool config infrastructure and plugin wiring

Layer / File(s) Summary
oxfmt config file
config_files/oxfmt.config.ts
New file exporting formatting rules, ignore patterns, import-sorting groups, and Tailwind CSS sorting settings.
Tools helpers and config paths
lua/nikero/tools.lua
Adds project path discovery helpers, updates Tools typing and cache initialization, and adds per-tool default config path entries for prettier, stylelint, stylua, selene, oxfmt, sqlfluff, and yamllint.
Config lookup and JS tool selection
lua/nikero/tools.lua
Refactors config-file lookup to use project-aware start and stop paths with fallback probing, then adds cached JS linter and formatter selection based on discovered project configs.
Lint and formatter wiring
lua/plugins/language/tools.lua
Adds shared default-config CLI argument handling, updates nvim-lint argument and filter setup, and rewires conform.nvim filetype mappings and formatter conditions around the new tool selection helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped through configs, brisk and neat,
oxfmt found a cozy seat.
Paths and tools now line up just so,
lint and format start to glow.
A tidy burrow, cached and bright,
keeps the rabbit’s edits snug at night.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title is relevant to the PR but too vague to convey the main change. Use a more specific title like 'Add oxfmt support and centralize tool config selection.'
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the refactor to config lookup, oxfmt support, and JS tool selection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch oxc-support

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 win

Do not discard the config found by vim.fs.find.

Line 166 runs the fallback only when config_path already exists, then overwrites the nearer match with a root-level probe or nil. 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 win

Keep the Tools annotations aligned with the actual API.

default_config_path is now a local helper, not a Tools method, and _js_tools_cache.linter stores "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

📥 Commits

Reviewing files that changed from the base of the PR and between 959133d and af595ce.

📒 Files selected for processing (3)
  • config_files/oxfmt.config.ts
  • lua/nikero/tools.lua
  • lua/plugins/language/tools.lua

Comment thread lua/nikero/tools.lua Outdated
Comment thread lua/nikero/tools.lua
Comment thread lua/plugins/language/tools.lua Outdated
Comment thread lua/plugins/language/tools.lua
@nikero41
nikero41 merged commit ce625dc into main Jun 29, 2026
3 checks passed
@nikero41
nikero41 deleted the oxc-support branch June 29, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant