Skip to content

fix(nvim): work around R.nvim cwd change on rout parser build failure#69

Merged
michaelbarton merged 1 commit intomasterfrom
fix/rnvim-cwd-rout-parser
Feb 27, 2026
Merged

fix(nvim): work around R.nvim cwd change on rout parser build failure#69
michaelbarton merged 1 commit intomasterfrom
fix/rnvim-cwd-rout-parser

Conversation

@michaelbarton
Copy link
Owner

Problem

R.nvim's check_rout_parser() function changes directory into resources/tree-sitter-rout/ to build the rout tree-sitter parser. When the build fails, early return statements skip the chdir(cwdir) restore call, leaving nvim stuck in the plugin directory for the rest of the session -- breaking :pwd, file saves, and any workflow that depends on cwd.

The build fails because the tree-sitter-rout submodule gitlink is absent from older pinned commits of R.nvim, so grammar.js is never present.

Upstream bug: R-nvim/R.nvim#466 (fix branch exists, not yet merged to main as of 2026-02-27)

Changes

  • nvim/lua/plugins/language.lua: adds a lazy.nvim build function for R.nvim that clones tree-sitter-rout directly if grammar.js is missing, so the parser build succeeds and cwd is properly restored
  • ansible/tasks/neovim.yml: adds a provisioning task that does the same clone for fresh machine setup; idempotent via grammar.js existence check
  • Makefile: adds nvim-check target that boots nvim headlessly across R/py/lua/md filetypes, captures :messages, and fails on any startup errors or warnings; wired into all:

Both workarounds include TODO markers with the upstream issue URL to remove once R-nvim/R.nvim#466 is merged and R.nvim is updated past the fix commit.

Removal criteria

Once R-nvim/R.nvim#466 is merged to R.nvim main:

  1. Run :Lazy update R.nvim to advance past the fix commit
  2. Delete the build block in nvim/lua/plugins/language.lua and the Ansible task
  3. Run make nvim-check -- confirm PASS [R]: clean startup

Made with Cursor

R.nvim's check_rout_parser() changes directory into resources/tree-sitter-rout
to build the rout parser, but when the build fails the early return statements
skip the chdir(cwdir) restore call, leaving nvim stuck in the plugin directory.
The build fails because the tree-sitter-rout submodule gitlink is absent from
older pinned commits so grammar.js is never present.

Upstream bug: R-nvim/R.nvim#466

Changes:
- nvim/lua/plugins/language.lua: add lazy.nvim build function that clones
  tree-sitter-rout directly if grammar.js is missing, so the parser build
  succeeds and cwd is properly restored
- ansible/tasks/neovim.yml: add provisioning task that does the same clone
  for fresh machine setup, idempotent via grammar.js existence check
- Makefile: add nvim-check target that boots nvim headlessly across R/py/lua/md
  filetypes and fails on any startup errors or warnings; add to all: chain

Both workarounds include TODO markers referencing the upstream issue to remove
once R-nvim/R.nvim#466 is merged and R.nvim is updated past the fix commit.

Made-with: Cursor
@michaelbarton michaelbarton merged commit f69509b into master Feb 27, 2026
1 check passed
@michaelbarton michaelbarton deleted the fix/rnvim-cwd-rout-parser branch February 27, 2026 23:03
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