TalkCodyTalkCody

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:

LanguageLanguage ServerSupported File Extensions
TypeScripttypescript-language-server.ts, .tsx, .mts, .cts
JavaScripttypescript-language-server.js, .jsx, .mjs, .cjs
Rustrust-analyzer.rs
PythonPyright.py, .pyi
Gogopls.go
Cclangd.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 LevelDescriptionDisplay Color
ErrorSyntax errors, type errors, etc.Red
WarningPotential issues, deprecation warnings, etc.Yellow
InformationInformational hintsBlue
HintCode suggestionsGray

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:

  1. Open Settings
  2. Find the LSP section
  3. Toggle off the Enable LSP switch

Diagnostic Display Settings

You can customize which severity levels of diagnostics to display:

SettingDefaultDescription
Show DiagnosticsOnWhether to show diagnostic information
Show ErrorsOnShow error-level diagnostics
Show WarningsOnShow warning-level diagnostics
Show InfoOnShow information-level diagnostics
Show HintsOffShow 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-server

Rust:

rustup component add rust-analyzer

Python:

pip install pyright
# or use npm
npm install -g pyright

Go:

go install golang.org/x/tools/gopls@latest

C/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):

LanguageRoot Directory Identifier Files
TypeScriptpackage-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, tsconfig.json, package.json
JavaScriptpackage-lock.json, bun.lockb, bun.lock, pnpm-lock.yaml, yarn.lock, jsconfig.json, package.json
RustCargo.toml, Cargo.lock
Pythonpyproject.toml, setup.py, setup.cfg, requirements.txt, Pipfile, pyrightconfig.json
Gogo.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.