@xano/xanoscript-language-server
v11.2.0
Published
Language Server Protocol implementation for XanoScript
Downloads
656
Readme
██╗ ██╗███████╗ ██╗ █████╗ ███╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██████╗ ███████╗
╚██╗██╔╝██╔════╝ ██║ ██╔══██╗████╗ ██║██╔════╝ ██║ ██║██╔══██╗██╔════╝ ██╔════╝
╚███╔╝ ███████╗ ██║ ███████║██╔██╗ ██║██║ ███╗██║ ██║███████║██║ ███╗█████╗
██╔██╗ ╚════██║ ██║ ██╔══██║██║╚██╗██║██║ ██║██║ ██║██╔══██║██║ ██║██╔══╝
██╔╝ ██╗███████║ ███████╗██║ ██║██║ ╚████║╚██████╔╝╚██████╔╝██║ ██║╚██████╔╝███████╗
╚═╝ ╚═╝╚══════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝XanoScript Language Server
A Language Server Protocol (LSP) implementation for XanoScript, built on Chevrotain.
Maintained by the Xano team.
Installation
npm install @xano/xanoscript-language-serverRequirements: Node.js 20+
Features
The language server provides full LSP support including:
- Code Completion - Context-aware suggestions triggered by
.,:,$, and| - Syntax Highlighting - Semantic token-based highlighting for XanoScript constructs
- Hover Information - Documentation and type information on hover
- Diagnostics - Real-time error detection and reporting
Supported Object Types
The parser supports the following XanoScript constructs:
| Type | Description |
|------|-------------|
| query | API endpoints with HTTP verbs, input validation, and responses |
| function | Reusable logic blocks with testing capabilities |
| task | Scheduled operations with cron-like triggers |
| api_group | Collections of related API endpoints |
| table | Database schema definitions with column types |
| table_trigger | Database table trigger definitions |
| workflow_test | Test definitions for workflows |
| addon | Add-on definitions |
| agent | AI agent definitions |
| agent_trigger | Agent trigger handlers |
| branch | Branch logic |
| mcp_server | MCP server definitions |
| mcp_server_trigger | MCP server trigger handlers |
| middleware | Middleware definitions |
| realtime_channel | Realtime channel definitions |
| realtime_trigger | Realtime trigger handlers |
| tool | Tool definitions |
| workspace | Workspace definitions |
| workspace_trigger | Workspace trigger handlers |
Built-in Function Domains
XanoScript includes functions organized by domain:
- ai - AI and machine learning operations
- api - External API calls and HTTP requests
- array - Array manipulation and iteration
- cloud - Cloud service integrations
- controls - Flow control (conditionals, loops, etc.)
- db - Database queries and operations
- debug - Debugging and logging utilities
- expect - Testing assertions
- math - Mathematical operations
- object - Object manipulation
- redis - Redis cache operations
- schema - Schema operations
- security - Authentication and security functions
- storage - File storage operations
- stream - Streaming data operations
- text - String manipulation
- util - General utilities
- var - Variable operations
- zip - Compression utilities
Project Structure
├── server.js # LSP server entry point
├── lexer/ # Lexical analysis
│ ├── lexer.js # Chevrotain lexer implementation
│ ├── tokens.js # Main token registry
│ └── [domain].js # Domain-specific tokens (api, db, cloud, etc.)
├── parser/ # Syntax parsing
│ ├── base_parser.js # Core XanoBaseParser
│ ├── [type]_parser.js # Object type parsers
│ ├── attributes/ # Field attributes (description, disabled, sensitive)
│ ├── clauses/ # Language blocks (stack, input, response, etc.)
│ ├── definitions/ # Type and column definitions
│ ├── functions/ # Built-in functions by domain
│ └── generic/ # Reusable parsing components
├── onCompletion/ # Code completion logic
├── onDidChangeContent/ # Diagnostics and error reporting
├── onHover/ # Hover documentation
└── onSemanticCheck/ # Semantic token highlightingDevelopment
# Install dependencies
npm install
# Run all tests (~1800 tests)
npm test
# Run specific test
npm test -- -g "test name"
# Lint code
npm run lint
# Fix lint issues
npm run lint:fix
# Generate TextMate language definition
npm run tmAdding New Features
New Object Type
- Create a new parser in
parser/(e.g.,my_object_parser.js) - Follow existing parser patterns (see
query_parser.js,function_parser.js) - Register it in
server.js
New Keyword/Function
We have a hierarchy for the different statements XanoScript uses:
- Parser - Top level (Query parser, Function parser, etc.)
- Clause - Main blocks in a given object type (stack, response, input, etc.)
- Functions - Statements like
debug.logordb.query - Attributes/Definitions - Components used to define functions
- Generic - Shared language toolset
To add a new function:
- Add token definition in appropriate
lexer/file - Create function implementation in
parser/functions/[domain]/ - Register in parent clause or parser
- Add comprehensive tests in corresponding
.spec.jsfile
Testing
The language server is heavily tested and should remain that way. Tests should be:
- Easy to copy, paste, and extend
- Straightforward and easy to read
- Avoid dynamic generation (no loops)
Test files use .spec.js naming convention and mirror the source structure.
CI/CD
On commit, pre-commit hooks run linting via Husky. The CI pipeline runs all tests and linting checks. Configuration is in .github/workflows/ci.yml.
License
MIT License - see LICENSE for details.
