Skip to content

feat: Add Aiken language server support for Cardano smart contracts #547

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

BurgessTheGamer
Copy link

Summary

Add Aiken language server support to enable intelligent code assistance for Cardano smart contract development.

Features Added

  • Auto-detection: Automatically detects .ak files and starts Aiken LSP
  • Auto-installation: Installs aikup and then aiken if not present via npm
  • Full LSP capabilities: Real-time diagnostics, code completion, hover information, and error checking
  • Documentation: Updated LSP configuration docs with Aiken examples

How it works

  1. When opencode encounters .ak files, it automatically starts the Aiken LSP server
  2. If aiken is not installed, it installs aikup (the Aiken version manager) via npm
  3. Then uses aikup to install the latest Aiken version
  4. Starts the language server with aiken lsp command
  5. Provides full LSP integration for better code assistance

Benefits for Cardano developers

  • Catch errors early before deployment (saves money on blockchain!)
  • Smart code completion for Aiken functions and types
  • Better development experience with instant feedback
  • Seamless integration - just open .ak files and it works

Test plan

  • Verify Aiken LSP starts automatically for .ak files
  • Test automatic installation of aikup and aiken
  • Confirm TypeScript compilation passes
  • Validate LSP integration follows existing patterns (TypeScript, Go, Ruby)

🤖 Generated with opencode

@thdxr
Copy link
Collaborator

thdxr commented Jun 30, 2025

you don't need npm! opencode itself has the functionality to run any npm package - check how we do the typescript server should work the same

@BurgessTheGamer BurgessTheGamer force-pushed the feat/aiken-lsp-support branch from c599bb9 to b4357b7 Compare June 30, 2025 21:44
@BurgessTheGamer
Copy link
Author

Thank you for the feedback @thdxr! You're absolutely right - I've updated the implementation to use OpenCode's built-in npm package execution functionality.

Changes Made:

The Aiken LSP now uses the same pattern as the TypeScript server:

export const Aiken: Info = {
  id: "aiken",
  extensions: [".ak"],
  async spawn() {
    // Simply use bun x to run aiken lsp, just like TypeScript
    const proc = spawn(
      BunProc.which(),
      ["x", "@aiken-lang/aiken", "lsp"],
      {
        env: {
          ...process.env,
          BUN_BE_BUN: "1",
        },
      },
    )
    return {
      process: proc,
    }
  },
}

This approach:

  • ✅ No global npm installations
  • ✅ Uses OpenCode's existing infrastructure
  • ✅ Matches the TypeScript server pattern exactly
  • ✅ Simpler and cleaner implementation

The PR has been updated with this improved implementation. Thanks for pointing me in the right direction!

@BurgessTheGamer BurgessTheGamer force-pushed the feat/aiken-lsp-support branch 2 times, most recently from 5217eb3 to 5c9576d Compare June 30, 2025 22:21
- Uses OpenCode's bun x pattern for package execution
- No global installations required
- Supports .ak files for Cardano smart contract development
- Follows same pattern as TypeScript and Pyright servers
@BurgessTheGamer BurgessTheGamer force-pushed the feat/aiken-lsp-support branch from 5c9576d to 0e4f886 Compare June 30, 2025 22:23
@thdxr thdxr self-assigned this Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants