Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PromptL LSP

Editor support for PromptL - a templating language for LLM prompts.

Built with ❤️ by Latitude

Features

  • Syntax Highlighting - Full syntax support for PromptL files
  • Real-time Diagnostics - Catch errors as you type
  • Go to Definition - Navigate to referenced prompts with Cmd+Click
  • Hover Information - See details about referenced files
  • Reference Validation - Ensure all <prompt path="..."> references exist

Packages

Package Description
promptl-lsp Language Server Protocol implementation
promptl-vscode VS Code extension
promptl-vim Vim/Neovim plugin

VS Code

Installation

From Marketplace (recommended):

Install from the VS Code Marketplace or search for "PromptL" in VS Code extensions.

From .vsix file:

code --install-extension promptl-vscode-0.1.0.vsix

Configuration

Open VS Code settings and search for "promptl", or add to your settings.json:

{
    "promptl.diagnostics.enable": true,
    "promptl.diagnostics.validateReferences": true
}
Setting Default Description
promptl.diagnostics.enable true Enable real-time diagnostics
promptl.diagnostics.validateReferences true Validate <prompt path="..."> references

Testing During Development

  1. Open this repository in VS Code
  2. Press F5 (or Run > Start Debugging)
  3. A new VS Code window opens with the extension loaded
  4. Open any .promptl file from the examples/ folder

To package and install locally:

cd packages/vscode
pnpm build
pnpm package
code --install-extension promptl-vscode-0.1.0.vsix

What to Test

Feature How to Test
Syntax highlighting Open any .promptl file - tags, expressions, YAML should be colored
Diagnostics Add {{ if true }} without {{ endif }} - should show error
Go to Definition Cmd+Click on path="..." in <prompt path="./other.promptl">
Hover Hover over a prompt path to see file information

Vim / Neovim

Installation

Neovim (with lazy.nvim)

{
  'latitude-dev/promptl',
  config = function()
    require('promptl').setup()
  end,
}

Neovim (with packer.nvim)

use {
  'latitude-dev/promptl',
  config = function()
    require('promptl').setup()
  end,
}

vim-plug

Plug 'latitude-dev/promptl'

For Neovim, add to your init.lua:

require('promptl').setup()

Manual Installation

Copy the plugin files to your config directory:

# For Neovim
cp -r packages/vim/* ~/.config/nvim/

# For Vim
cp -r packages/vim/ftdetect ~/.vim/
cp -r packages/vim/ftplugin ~/.vim/
cp -r packages/vim/syntax ~/.vim/

LSP Server Setup

The LSP server provides diagnostics, go-to-definition, and hover. Install it globally:

npm install -g promptl-lsp

Or if developing locally, link it:

cd packages/lsp
pnpm build
npm link

Configuration

require('promptl').setup({
  -- Optional: custom path to LSP server
  cmd = { 'promptl-lsp', '--stdio' },

  -- Diagnostics settings
  diagnostics = {
    enable = true,
    validate_references = true,
  },
})

Testing During Development

  1. Build the LSP server:
pnpm build:lsp
  1. Add to your Neovim config (temporary for testing):
-- Add plugin to runtimepath
vim.opt.runtimepath:append('/path/to/promptl-vscode/packages/vim')

-- Setup with local LSP server
require('promptl').setup({
  cmd = { 'node', '/path/to/promptl-vscode/packages/lsp/out/server.js', '--stdio' },
})
  1. Open a .promptl file:
nvim examples/basic/simple.promptl

What to Test

Feature How to Test
Syntax highlighting Open any .promptl file - should see colors
Diagnostics :LspInfo should show promptl attached, errors appear inline
Go to Definition gd on a prompt path reference
Hover K on a prompt path to see file info

Vim (without LSP)

Vim users get syntax highlighting out of the box. For LSP support, use a plugin like:


Development

Prerequisites

  • Node.js >= 18
  • pnpm >= 9

Setup

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Watch for changes
pnpm watch

Building Individual Packages

# Build only the LSP server
pnpm build:lsp

# Build only the VS Code extension
pnpm build:vscode

# Package the VS Code extension
pnpm package:vscode

Project Structure

promptl-editors/
├── packages/
│   ├── lsp/              # Language Server Protocol server
│   │   ├── src/
│   │   │   ├── server.ts           # LSP entry point
│   │   │   ├── handlers/           # LSP capability handlers
│   │   │   │   ├── diagnostics.ts
│   │   │   │   ├── definition.ts
│   │   │   │   ├── hover.ts
│   │   │   │   └── documentLink.ts
│   │   │   └── utils/
│   │   │       └── references.ts
│   │   └── bin/
│   │       └── promptl-lsp         # CLI executable
│   │
│   ├── vscode/           # VS Code extension
│   │   ├── src/
│   │   │   └── extension.ts        # Extension entry (LSP client)
│   │   ├── syntaxes/               # TextMate grammar
│   │   └── icons/
│   │
│   └── vim/              # Vim/Neovim plugin
│       ├── ftdetect/               # File type detection
│       ├── ftplugin/               # File type settings
│       ├── syntax/                 # Vim syntax highlighting
│       └── lua/                    # Neovim LSP configuration
│
├── examples/             # Example PromptL files
├── package.json          # Workspace root
└── pnpm-workspace.yaml

Architecture

The core intelligence lives in the LSP server (promptl-lsp), which provides:

  • Diagnostics (using the promptl-ai parser)
  • Go to Definition
  • Hover information
  • Document links

Editor-specific packages are thin clients that connect to the LSP:

  • VS Code: Uses vscode-languageclient to start and communicate with the LSP
  • Neovim: Uses built-in LSP client (vim.lsp.start)
  • Vim: Requires an LSP plugin like vim-lsp or coc.nvim

This architecture means new features only need to be implemented once in the LSP server.


See Also

  • PromptL - The PromptL language itself
  • Latitude - Open source platform for scaling AI products (where PromptL originated)

License

MIT

About

Official PromptL extension for vscode

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages