Skip to content

Create Sublime Text package for LUMOS #49

@rz1989s

Description

@rz1989s

Goal

Create a Sublime Text package for LUMOS with syntax highlighting and LSP integration.

Phase: 5.2 IDE Integration
Depends On: #45 (LSP implementation)


Problem

Sublime Text users have no LUMOS support:

  • ❌ No syntax highlighting
  • ❌ No auto-completion
  • ❌ No diagnostics
  • ❌ Files treated as plain text

Solution

Create Sublime Text package with:

  1. Syntax definition (syntax highlighting)
  2. LSP-lumos configuration (IDE features via LSP)

Implementation

Package Structure

LUMOS/
├── LUMOS.sublime-syntax     # Syntax highlighting
├── LUMOS.sublime-settings   # Settings
├── LSP-lumos.sublime-settings # LSP configuration
├── Comments.tmPreferences   # Comment shortcuts
├── Indentation.tmPreferences # Auto-indent rules
└── README.md

Syntax Definition

File: LUMOS.sublime-syntax

%YAML 1.2
---
name: LUMOS
file_extensions: [lumos]
scope: source.lumos

contexts:
  main:
    - include: comments
    - include: attributes
    - include: keywords
    - include: types
    - include: strings

  comments:
    - match: //
      scope: punctuation.definition.comment.lumos
      push:
        - meta_scope: comment.line.double-slash.lumos
        - match: $\n?
          pop: true
    
    - match: /\*
      scope: punctuation.definition.comment.begin.lumos
      push:
        - meta_scope: comment.block.lumos
        - match: \*/
          scope: punctuation.definition.comment.end.lumos
          pop: true

  attributes:
    - match: '#\['
      scope: punctuation.definition.attribute.begin.lumos
      push:
        - meta_scope: meta.attribute.lumos
        - match: '\]'
          scope: punctuation.definition.attribute.end.lumos
          pop: true
        - match: '\b(solana|account|version|deprecated)\b'
          scope: entity.name.attribute.lumos
        - match: '='
          scope: keyword.operator.assignment.lumos
        - include: strings

  keywords:
    - match: '\b(struct|enum|pub)\b'
      scope: keyword.declaration.lumos

  types:
    - match: '\b(u8|u16|u32|u64|u128|i8|i16|i32|i64|i128|bool|String)\b'
      scope: storage.type.primitive.lumos
    
    - match: '\b(PublicKey|Signature)\b'
      scope: storage.type.solana.lumos
    
    - match: '\b(Vec|Option)\b'
      scope: storage.type.generic.lumos
    
    - match: '\b([A-Z][a-zA-Z0-9_]*)\b'
      scope: entity.name.type.lumos

  strings:
    - match: '"'
      scope: punctuation.definition.string.begin.lumos
      push:
        - meta_scope: string.quoted.double.lumos
        - match: '"'
          scope: punctuation.definition.string.end.lumos
          pop: true
        - match: '\\.'
          scope: constant.character.escape.lumos

LSP Configuration

File: LSP-lumos.sublime-settings

{
  "clients": {
    "lumos": {
      "enabled": true,
      "command": ["lumos-lsp"],
      "selector": "source.lumos",
      "initializationOptions": {},
      "settings": {}
    }
  }
}

Package Settings

File: LUMOS.sublime-settings

{
  "extensions": ["lumos"],
  "tab_size": 2,
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true
}

Comment Preferences

File: Comments.tmPreferences

<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
  <key>name</key>
  <string>Comments</string>
  <key>scope</key>
  <string>source.lumos</string>
  <key>settings</key>
  <dict>
    <key>shellVariables</key>
    <array>
      <dict>
        <key>name</key>
        <string>TM_COMMENT_START</string>
        <key>value</key>
        <string>// </string>
      </dict>
      <dict>
        <key>name</key>
        <string>TM_COMMENT_START_2</string>
        <key>value</key>
        <string>/*</string>
      </dict>
      <dict>
        <key>name</key>
        <string>TM_COMMENT_END_2</string>
        <key>value</key>
        <string>*/</string>
      </dict>
    </array>
  </dict>
</dict>
</plist>

Installation

Via Package Control

  1. Install LSP package first
  2. Cmd/Ctrl + Shift + P → "Package Control: Install Package"
  3. Search for "LUMOS"
  4. Install

Manual Installation

# Clone into Sublime Text packages directory
cd ~/Library/Application\ Support/Sublime\ Text/Packages  # macOS
cd ~/.config/sublime-text/Packages  # Linux
cd %APPDATA%\Sublime Text\Packages  # Windows

git clone https://github.com/getlumos/sublime-lumos LUMOS

LSP Server Setup

Install LUMOS LSP server:

cargo install lumos-lsp

Enable LSP in Sublime Text:

  1. Preferences → Package Settings → LSP → Settings
  2. Ensure lumos-lsp is in PATH

Features

Syntax Highlighting

  • Keywords: struct, enum, pub
  • Types: Primitives, Solana types, generics
  • Attributes: #[solana], #[account]
  • Comments: Line and block
  • Strings: With escape sequences

LSP Integration

  • Auto-completion (Ctrl+Space)
  • Diagnostics (inline errors)
  • Go to definition (F12)
  • Hover info (Ctrl+K, Ctrl+I)
  • Find references (Shift+F12)
  • Rename symbol (F2)

Editor Features

  • Auto-indent
  • Comment toggling (Cmd/Ctrl+/)
  • Bracket matching
  • Code folding

Testing

Manual Testing

  1. Open Sublime Text
  2. Create test.lumos
  3. Enter:
    #[solana]
    struct Player {
        wallet: PublicKey,
        level: u16,
    }
    
  4. Verify:
    • Syntax highlighting
    • Auto-completion works
    • Errors show inline
    • Cmd+/ comments/uncomments

Automated Testing

Use UnitTesting package:

File: tests/test_syntax.py

import sublime
from unittesting import DeferrableTestCase

class TestLumosSyntax(DeferrableTestCase):
    def test_file_extension(self):
        view = self.view
        view.assign_syntax('LUMOS.sublime-syntax')
        self.assertEqual(view.syntax().name, 'LUMOS')
    
    def test_keyword_highlighting(self):
        view = self.view
        view.run_command('insert', {'characters': 'struct Player {}'})
        # Verify 'struct' has keyword scope
        scope = view.scope_name(0)
        self.assertIn('keyword.declaration.lumos', scope)

Publishing

Submit to Package Control

  1. Fork packagecontrol.io
  2. Add repository to repository/l.json:
{
  "name": "LUMOS",
  "details": "https://github.com/getlumos/sublime-lumos",
  "releases": [
    {
      "sublime_text": ">=3211",
      "platforms": ["*"],
      "tags": true
    }
  ]
}
  1. Create PR

Success Criteria

  • Syntax highlighting works for all LUMOS syntax
  • LSP integration provides auto-completion
  • Diagnostics show errors inline
  • Comment toggling works (Cmd+/)
  • Auto-indent functional
  • Package installable via Package Control
  • Works on macOS, Linux, Windows
  • Tests passing
  • Documentation complete

Documentation

Create New Files

  • sublime-lumos/README.md - Package documentation
  • docs/editors/sublime.md - Sublime Text setup guide

Update Files

  • README.md - Add Sublime installation instructions
  • CHANGELOG.md - Document package release
  • ROADMAP.md - Mark Phase 5.2 item as complete ✅

Related


Priority: Low
Complexity: Low-Medium
Timeline: 3-4 days
Depends On: #45


📌 Remember: Update ROADMAP.md after completing this issue!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:ecosystemCross-repo initiatives and ecosystem-wide featuresarea:vscodeVSCode extension (syntax, commands, snippets)help wantedExtra attention is neededtype:featureNew feature or functionality

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions