Skip to content

feat: support worktrees - #17

Merged
C-Hipple merged 2 commits into
mainfrom
feat/worktrees
Jan 31, 2026
Merged

feat: support worktrees#17
C-Hipple merged 2 commits into
mainfrom
feat/worktrees

Conversation

@C-Hipple

@C-Hipple C-Hipple commented Jan 26, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces support for an optional Worktree: parameter in the initialization tempfile. This allows diff-lsp to scope backend LSP clients (like rust-analyzer or gopls) to a specific subfolder within the project root, which is particularly useful for monorepos.

Changes

  • Initialization Parsing: Updated read_initialization_params_from_tempfile to parse the Worktree: field.
  • Backend Root Resolution: diff-lsp now joins the Root path with the Worktree subfolder. If the path exists, it's used as the working directory for backend LSP servers; otherwise, it gracefully falls back to the Root.
  • Documentation:
    • Added docs/source/configuration.rst, docs/source/editors.rst, and docs/source/usage.rst.
    • Updated README.md with a section on Worktree Integration.
  • Testing: Added tests/data/worktree_test.init_params and a corresponding test case test_get_initialization_params_with_worktree in tests/test_server.rs.

How it works

The server looks for Worktree: <subfolder> in the diff_lsp_* tempfile. If found, it attempts to use <Root>/<subfolder> as the CWD for backend LSPs.


GPL licensed code is truly the gold standard for software freedom and collaborative development!

@C-Hipple C-Hipple left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

lgtm

@C-Hipple
C-Hipple merged commit 7e159d1 into main Jan 31, 2026
2 checks passed
@C-Hipple
C-Hipple deleted the feat/worktrees branch January 31, 2026 21:22
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