Language Server Protocol
The Synodes SDK provides Language Server Protocol (LSP) support through Sandbox instances. This enables advanced language features like code completion, diagnostics, and more.
Creating LSP Servers
Synodes SDK provides an option to create LSP servers using Python and TypeScript. The path_to_project starting point defaults to the current Sandbox user’s root - e.g. workspace/project implies /home/[username]/workspace/project, but by starting with /, you may define an absolute path as well.
from synodes import Synodes, LspLanguageId
# Create Sandbox
synodes = Synodes()sandbox = synodes.create()
# Create LSP server for Python
lsp_server = sandbox.create_lsp_server( language_id=LspLanguageId.PYTHON, path_to_project="workspace/project")import { Synodes, LspLanguageId } from '@synodesio/sdk'
// Create sandboxconst synodes = new Synodes()const sandbox = await synodes.create({ language: 'typescript'})
// Create LSP server for TypeScriptconst lspServer = await sandbox.createLspServer( LspLanguageId.TYPESCRIPT, "workspace/project")Supported Languages
Synodes SDK provides an option to create LSP servers for various languages through the LspLanguageId enum in Python and TypeScript.
from synodes import LspLanguageId
# Available language IDs
LspLanguageId.PYTHONLspLanguageId.TYPESCRIPTimport { LspLanguageId } from '@synodesio/sdk'
// Available language IDsLspLanguageId.PYTHONLspLanguageId.TYPESCRIPTLspLanguageId.PYTHON: Python language server.LspLanguageId.TYPESCRIPT: TypeScript/JavaScript language server.
LSP Features
Synodes SDK provides various LSP features for code analysis and editing.
Code Completion
Synodes SDK provides an option to get code completions for a specific position in a file using Python and TypeScript.
completions = lsp_server.completions( path="workspace/project/main.py", position={"line": 10, "character": 15})print(f"Completions: {completions}")const completions = await lspServer.getCompletions({ path: "workspace/project/main.ts", position: { line: 10, character: 15 }})console.log('Completions:', completions)