pat for Visual Studio Code
Language support for pat, a compiled language with
Python-like syntax and Rust-style ownership:
- Syntax highlighting for
.pat files, and for pat code blocks in
Markdown.
- Formatting with
patfmt: Format Document, and on every save by
default, with a ruler at column 100 (the width patfmt breaks lines at).
- The pat language server (
pat-lsp):
- diagnostics on every edit: type and borrow errors across the
program's modules, and the docstring lint;
- hover: a name's type, a function's signature and the summary of its
docstring;
- go to definition across files, the standard library included.
Requirements
The extension runs pat's own tools, patfmt and pat-lsp. Install pat
from a release:
tar xzf pat-<version>-<platform>.tar.gz
export PATH="$PWD/pat-<version>-<platform>/bin:$PATH"
Archives exist for macOS on Apple silicon and Linux x86-64; on other
platforms, build pat from source (cargo build --release in a clone of
https://github.com/pat-language/pat). The extension finds the tools on
the PATH, or in the directory set in the pat.toolPath setting (for
example the bin/ of an extracted release). When it cannot start them, it
offers a link to the releases.
Settings
| Setting |
Default |
Meaning |
pat.toolPath |
empty (the PATH) |
directory holding patfmt and pat-lsp |
To turn format-on-save off for pat files, in settings.json:
"[pat]": { "editor.formatOnSave": false }
Develop the extension
- Open
editors/vscode/ of the pat repository in VS Code.
- Run
npm install, then press F5 to launch an Extension Development
Host window.
- Open any
.pat file.
Package it with npx @vscode/vsce package, which writes
pat-language-<version>.vsix; install that with
code --install-extension pat-language-<version>.vsix.
License
Licensed under either of the Apache License, Version 2.0 or the MIT
license, at your option.