LSP Language Service
Get intelligent code hints and diagnostics with LSP
What is LSP?
LSP (Language Server Protocol) is a language service protocol developed by Microsoft that provides standardized communication between editors and language servers.
TalkCody integrates LSP support to provide you with professional IDE-level code intelligence features, including:
- Code Diagnostics: Real-time display of syntax errors and warnings
- Go to Definition: Quick navigation to symbol definition locations
- Find References: View all usage locations of a symbol in the code
- Hover Information: View type information and documentation
- Code Completion: Intelligent code auto-completion
Supported Languages
TalkCody supports LSP services for the following 7 programming languages:
| Language | Language Server | Supported File Extensions |
|---|---|---|
| TypeScript | typescript-language-server | .ts, .tsx, .mts, .cts |
| JavaScript | typescript-language-server | .js, .jsx, .mjs, .cjs |
| Rust | rust-analyzer | .rs |
| Python | Pyright | .py, .pyi |
| Go | gopls | .go |
| C | clangd | .c, .h |
| C++ | clangd | .cpp, .cc, .cxx, .c++, .hpp, .hh, .hxx, .h++ |
TSX and JSX files are correctly recognized as React components, ensuring the LSP server provides accurate type checking and code completion.
Features
Code Diagnostics
LSP analyzes your code in real-time and displays errors and warnings in the editor:
| Severity Level | Description | Display Color |
|---|---|---|
| Error | Syntax errors, type errors, etc. | Red |
| Warning | Potential issues, deprecation warnings, etc. | Yellow |
| Information | Informational hints | Blue |
| Hint | Code suggestions | Gray |
Diagnostic information is displayed as wavy underlines beneath the code, hover to view detailed descriptions.
Go to Definition
Click on a symbol or use keyboard shortcuts to quickly jump to the symbol's definition location. Supports:
- Variable and constant definitions
- Function and method definitions
- Class and interface definitions
- Type alias definitions
- Import module definitions
Find References
View all usage locations of a symbol throughout the project, including:
- Direct references
- Import statements
- Type annotations
- Declaration locations
Hover Information
Hover over a symbol to view:
- Type information
- Function signatures
- JSDoc/documentation comments
- Parameter descriptions
Code Completion
When typing code, LSP provides intelligent completion suggestions:
- Variable and function names
- Properties and methods
- Import suggestions
- Code snippets
Configuration Options
Enable/Disable LSP
LSP is enabled by default. To disable it, you can toggle it off in settings:
- Open Settings
- Find the LSP section
- Toggle off the Enable LSP switch
Diagnostic Display Settings
You can customize which severity levels of diagnostics to display:
| Setting | Default | Description |
|---|---|---|
| Show Diagnostics | On | Whether to show diagnostic information |
| Show Errors | On | Show error-level diagnostics |
| Show Warnings | On | Show warning-level diagnostics |
| Show Info | On | Show information-level diagnostics |
| Show Hints | Off | Show hint-level diagnostics |
If you find there are too many diagnostics, you can turn off Hints and Info levels, keeping only Errors and Warnings.
Automatic Installation
Language Server Auto-Download
When you first open a file of a certain language, TalkCody checks if the corresponding language server is installed:
- Already installed: Automatically starts the language server
- Not installed but downloadable: Shows download prompt, click to install automatically
- Requires manual installation: Shows installation instructions
A progress bar is displayed during download, and the language server starts automatically after completion.
Manual Installation Methods
If automatic download fails, you can manually install language servers:
TypeScript/JavaScript:
npm install -g typescript typescript-language-serverRust:
rustup component add rust-analyzerPython:
pip install pyright
# or use npm
npm install -g pyrightGo:
go install golang.org/x/tools/gopls@latestC/C++:
# macOS
brew install llvm
# Ubuntu/Debian
sudo apt install clangd
# Windows
# Download and install from https://releases.llvm.org/Workspace Detection
TalkCody intelligently detects the workspace root directory of your project so that the LSP server correctly understands the project structure.
Detection Rules
Different languages use different identifier files (in order of priority):
| Language | Root Directory Identifier Files |
|---|---|
| TypeScript | package-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, tsconfig.json, package.json |
| JavaScript | package-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, jsconfig.json, package.json |
| Rust | Cargo.toml, Cargo.lock |
| Python | pyproject.toml, setup.py, setup.cfg, requirements.txt, Pipfile, pyrightconfig.json |
| Go | go.work, go.mod, go.sum |
| C/C++ | compile_commands.json, compile_flags.txt, .clangd, CMakeLists.txt, Makefile |
Can new languages be added?
Currently supported languages are pre-configured. If you need support for other languages, you can submit a feature request on GitHub Issues.