Skip to content

m-epasta/vslp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

VScript Language Server Protocol (LSP)

A high-performance Language Server Protocol implementation for the VScript programming language, built in Rust.

Features

  • πŸš€ Fast and Reliable: Built in Rust for maximum performance
  • 🎯 Go-to Definition: Navigate to symbol definitions across files
  • πŸ’‘ Intelligent Completion: Context-aware code completion
  • πŸ” Hover Information: Rich type and documentation information
  • 🚨 Real-time Diagnostics: Syntax and semantic error detection
  • 🎨 Semantic Highlighting: Advanced syntax highlighting
  • πŸ“ Workspace Management: Full project and module support
  • πŸ”„ Module Resolution: Smart import resolution with v.mod support

Installation

From Source

# Clone the repository
git clone https://github.com/vscript/vscript-lsp.git
cd vscript-lsp

# Build the LSP server
cargo build --release

# The binary will be available at target/release/vscript-lsp

Using Cargo

cargo install vscript-lsp

Usage

Command Line

Start the LSP server:

vscript-lsp

The server communicates via stdin/stdout using the Language Server Protocol.

Editor Integration

The LSP server is designed to work with any editor that supports LSP. See the Zed extension for a complete integration example.

Manual Configuration

For editors that support LSP, configure them to run vscript-lsp for .vs files.

Example configuration for various editors:

VS Code (settings.json):

{
  "vscript.lsp.serverPath": "vscript-lsp"
}

Vim/Neovim with coc.nvim:

{
  "languageserver": {
    "vscript": {
      "command": "vscript-lsp",
      "filetypes": ["vscript"]
    }
  }
}

Configuration

The LSP server supports configuration through workspace settings:

{
  "vscript": {
    "diagnostics": {
      "enable": true,
      "unusedVariables": "warning"
    },
    "completion": {
      "enable": true,
      "autoImport": true
    },
    "hover": {
      "enable": true,
      "showDocumentation": true
    }
  }
}

VScript Language Features

Supported Constructs

  • βœ… Functions and methods
  • βœ… Classes and inheritance
  • βœ… Variables and parameters
  • βœ… Control flow (if/else, loops)
  • βœ… Arrays and objects
  • βœ… String interpolation
  • βœ… Async/await
  • βœ… Decorators (@[decorator])
  • βœ… Imports and exports
  • βœ… Try/catch blocks

Module System

The LSP understands VScript's module system:

// Import core modules
import core:os as os
import core:json as json

// Import local files
import "./utils.vs" as utils

// Module resolution follows v.mod files

Built-in Functions

The LSP provides hover information and completion for built-in functions:

  • print(), println() - Output functions
  • len(), push(), pop() - Collection functions
  • to_string(), to_number() - Conversion functions
  • Array methods: map(), filter(), reduce(), forEach()
  • String methods: split(), replace(), trim()
  • And many more...

Architecture

The VScript LSP is structured as follows:

src/
β”œβ”€β”€ main.rs          # LSP server entry point
β”œβ”€β”€ analyzer.rs      # Semantic analysis engine
β”œβ”€β”€ completion.rs    # Code completion provider
β”œβ”€β”€ diagnostics.rs   # Error and warning detection
β”œβ”€β”€ goto_definition.rs # Go-to-definition implementation
β”œβ”€β”€ hover.rs         # Hover information provider
β”œβ”€β”€ lexer.rs         # VScript tokenizer
β”œβ”€β”€ parser.rs        # VScript parser and AST
└── workspace.rs     # Workspace and project management

Key Components

  • Lexer: Fast tokenization of VScript source code
  • Parser: Builds Abstract Syntax Trees (AST) from tokens
  • Analyzer: Performs semantic analysis and symbol resolution
  • Workspace Manager: Handles project files and v.mod resolution

Development

Building

cargo build

Testing

cargo test

Debug Logging

Enable debug logging:

RUST_LOG=debug vscript-lsp

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests for your changes
  5. Run tests (cargo test)
  6. Commit your changes (git commit -am 'Add amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

Protocol Support

This LSP server implements the following LSP features:

  • textDocument/completion - Code completion
  • textDocument/hover - Hover information
  • textDocument/definition - Go to definition
  • textDocument/references - Find references
  • textDocument/documentSymbol - Document outline
  • workspace/symbol - Workspace symbol search
  • textDocument/publishDiagnostics - Error reporting
  • textDocument/semanticTokens - Semantic highlighting

Performance

The VScript LSP is designed for performance:

  • Fast Parsing: Incremental parsing with error recovery
  • Efficient Memory Usage: Smart caching and cleanup
  • Concurrent Analysis: Multi-threaded semantic analysis
  • Lazy Loading: On-demand file processing

License

This project is licensed under the MIT License - see the LICENSE file for details.

Related Projects

Support

About

Official vscript LSP

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages