[DOCS] LSP not sending textDocument lifecycle events in `--print` mode (behavior undocumented)
Documentation Type
Missing documentation (feature not documented)
Documentation Location
Claude Code CLI documentation (LSP / --print mode)
Section/Topic
CLI modes / --print mode / LSP integration
Current Documentation
_No response_
What's Wrong or Missing?
When running Claude Code in --print mode, LSP servers (e.g. clangd) are initialized, but no textDocument/* lifecycle events are sent.
Specifically, in --print mode:
textDocument/didOpenis never senttextDocument/didChangeis never senttextDocument/didSaveis never sent
As a result, LSP-based features such as documentSymbol, diagnostics, or semantic analysis do not work.
This behavior differs from interactive Claude Code, where these events are sent as expected. The current documentation does not explain whether this limitation is expected by design or an undocumented constraint of --print mode.
Suggested Improvement
Please document the behavior of --print mode with respect to LSP.
For example, clarify whether:
--printmode is intended to be a headless / non-interactive mode- LSP document lifecycle events are intentionally disabled in this mode
- LSP-based features (diagnostics, documentSymbol, etc.) are unsupported in
--print
If this behavior is not intentional, guidance on how to enable LSP-based analysis in non-interactive usage would be very helpful.
Impact
High - Prevents users from using a feature
Additional Context
Use case
I want to use Claude Code in a non-interactive / CI-style workflow to perform LSP-based static analysis, for example:
claude --print --dangerously-skip-permissions \
"Use LSP documentSymbol to analyze all .h files under extensions/hata/ and output class and method structure"
Debug logs (in --print mode)
[DEBUG] [LSP SERVER plugin:clangd-lsp:clangd] Debian clangd version 14.0.6
[DEBUG] [LSP SERVER plugin:clangd-lsp:clangd] Starting LSP over stdin/stdout
[DEBUG] [LSP PROTOCOL plugin:clangd-lsp:clangd] Received response 'initialize'
[DEBUG] [LSP PROTOCOL plugin:clangd-lsp:clangd] Sending notification 'initialized'
[DEBUG] LSP server plugin:clangd-lsp:clangd initialized
[DEBUG] LSP server instance started: plugin:clangd-lsp:clangd
In interactive mode, I do see textDocument/didOpen, didChange, and didSave events, and LSP features work correctly.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗