Skip to content

Commit 7ab95a5

Browse files
committed
Add LSP preflight, CLI override, and examples
1 parent 632167a commit 7ab95a5

File tree

15 files changed

+279
-5
lines changed

15 files changed

+279
-5
lines changed

FEATURES.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,10 @@ diffscope smart-review --old-file src/old.py --new-file src/new.py
9696
4. **Prioritized Workflow**: Issues ranked by severity and effort for efficient fixing
9797
5. **Professional Reporting**: Executive summaries suitable for team reviews
9898

99-
This enhanced system provides professional-grade code review capabilities while maintaining the simplicity and flexibility of the original diffscope architecture.
99+
This enhanced system provides professional-grade code review capabilities while maintaining the simplicity and flexibility of the original diffscope architecture.
100+
101+
## Symbol Indexing
102+
103+
- Regex and LSP-backed symbol indexing with auto-detection when `symbol_index_lsp_command` is omitted.
104+
- LSP preflight command: `diffscope lsp-check` validates binaries, language IDs, and unmapped extensions.
105+
- Ready-to-copy LSP configs in `examples/lsp/` and setup guide in `docs/lsp.md`.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ exclude_patterns:
223223
- "**/__pycache__/**"
224224
```
225225

226-
Set `symbol_index_provider: lsp` to use a language server; it falls back to regex indexing if the LSP binary is missing. Configure `symbol_index_lsp_languages` and `symbol_index_lsp_command` to match your server (for example, `typescript-language-server --stdio` with `ts`/`tsx` language IDs). If you omit `symbol_index_lsp_command`, diffscope will try to auto-detect a server based on installed binaries and the file types in your repo.
226+
Set `symbol_index_provider: lsp` to use a language server; it falls back to regex indexing if the LSP binary is missing. Configure `symbol_index_lsp_languages` and `symbol_index_lsp_command` to match your server (for example, `typescript-language-server --stdio` with `ts`/`tsx` language IDs). If you omit `symbol_index_lsp_command`, diffscope will try to auto-detect a server based on installed binaries and the file types in your repo. You can also force a server for a single run with `--lsp-command`.
227227

228228
### LSP Symbol Index Examples (All Common Languages)
229229

@@ -300,7 +300,13 @@ symbol_index_lsp_languages:
300300

301301
### LSP Setup Notes (Install + Command)
302302

303-
For detailed install commands, OS-specific package manager options, and troubleshooting, see `docs/lsp.md`.
303+
For detailed install commands, OS-specific package manager options, and troubleshooting, see `docs/lsp.md`. For ready-made configs per language, see `examples/lsp/`.
304+
305+
You can validate your setup with:
306+
307+
```
308+
diffscope lsp-check
309+
```
304310

305311
## Plugin Development
306312

@@ -627,6 +633,9 @@ diffscope pr [--number N] [--post-comments] [--summary]
627633
# Repository check (uncommitted changes at path)
628634
diffscope check [path]
629635

636+
# LSP preflight checks
637+
diffscope lsp-check [path]
638+
630639
# File comparison
631640
diffscope compare --old-file old.py --new-file new.py
632641

docs/lsp.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ If `symbol_index_provider: lsp` and `symbol_index_lsp_command` is not set, diffs
1010

1111
If it picks the wrong server, set `symbol_index_lsp_command` explicitly.
1212

13+
## CLI Overrides
14+
15+
- Force a command for this run: `diffscope --lsp-command "typescript-language-server --stdio" smart-review --diff diff.patch`
16+
- Preflight your setup: `diffscope lsp-check` (prints the detected command, whether it is available on PATH, and any unmapped extensions)
17+
- Ready-to-copy configs live in `examples/lsp/`.
18+
1319
## Package Manager Matrix (brew/apt/choco)
1420

1521
Use these when you prefer OS-level packages. If a cell says "manual", use the language-specific install section below.
@@ -72,3 +78,4 @@ bin/jdtls -configuration /path/to/config -data /path/to/workspace
7278
- LSP binary not found: check PATH or use an absolute path in `symbol_index_lsp_command`.
7379
- Server expects stdio: use the `--stdio` form when required (e.g., TypeScript, Solargraph).
7480
- JDT LS needs a unique `-data` directory per workspace; configure a stable path.
81+
- Use `diffscope lsp-check` to see unmapped extensions and missing binaries.

examples/lsp/cpp.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Diffscope LSP config for C/C++
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: clangd
5+
symbol_index_lsp_languages:
6+
c: c
7+
h: c
8+
cc: cpp
9+
cpp: cpp
10+
cxx: cpp
11+
hpp: cpp

examples/lsp/csharp.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Diffscope LSP config for C#
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: csharp-ls
5+
symbol_index_lsp_languages:
6+
cs: csharp

examples/lsp/go.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Diffscope LSP config for Go
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: gopls
5+
symbol_index_lsp_languages:
6+
go: go

examples/lsp/java.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Diffscope LSP config for Java
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: "jdtls -configuration /path/to/config -data /path/to/workspace"
5+
symbol_index_lsp_languages:
6+
java: java

examples/lsp/kotlin.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Diffscope LSP config for Kotlin
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: kotlin-lsp
5+
symbol_index_lsp_languages:
6+
kt: kotlin

examples/lsp/php.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Diffscope LSP config for PHP
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: "phpactor language-server"
5+
symbol_index_lsp_languages:
6+
php: php

examples/lsp/python.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Diffscope LSP config for Python
2+
symbol_index: true
3+
symbol_index_provider: lsp
4+
symbol_index_lsp_command: pylsp
5+
symbol_index_lsp_languages:
6+
py: python
7+
pyi: python

0 commit comments

Comments
 (0)