Skip to content

Commit

Permalink
✨ improve pact binary discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
salamaashoush committed Jan 14, 2025
1 parent bc3a420 commit a752392
Show file tree
Hide file tree
Showing 11 changed files with 212 additions and 74 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
tags:
- "v*"

jobs:
homebrew:
name: Release Zed Extension
runs-on: ubuntu-latest
steps:
- uses: huacnlee/zed-extension-action@v1
with:
extension-name: pact
# extension-path: extensions/${{ extension-name }}
push-to: salamaashoush/extensions
env:
# the personal access token should have "repo" & "workflow" scopes
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}
2 changes: 1 addition & 1 deletion .pact-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.11
nightly
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "pact-lang-zed-extension"
version = "0.0.2"
version = "0.0.3"
edition = "2021"

[lib]
crate-type = ["cdylib"]

[dependencies]
zed_extension_api = { git = "https://github.com/zed-industries/zed" }
zed_extension_api = "0.2.0"
124 changes: 112 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,117 @@
# pact-zed
# Pact for Zed

Pact Programming Language extension for [Zed](https://github.com/zed-industries/zed)
A zed extension that brings full Pact language support to the [Zed](https://github.com/zed-industries/zed) editor.

## Features
## Features

- Syntax highlighting
- Outline view
- Code folding
- Tasks for running pact files/tests
- LSP support for autocompletion, diagnostics, hover docs, go to defintion and more
- 🎨 Syntax highlighting
- 📑 Smart outline view for quick navigation
- 📦 Code folding
- ⚡️ Built-in tasks for running Pact files and tests
- 🚀 Intelligent code assistance:
- Auto-completion
- Real-time error checking
- Hover documentation
- Go to definition
- And more!

## Test locally
## 🚀 Getting Started

- Clone this repo: `git clone https://github.com/kadena-community/pact-zed`
- Open Zed
- Go to `Settings` -> `Extensions` -> Click the `Install Dev Extension` and select the `pact-zed` folder
### Option 1: Using Pactup (Recommended)

Pactup is the easiest way to manage your Pact installation:

follow the instructions to install Pactup: https://github.com/kadena-community/pactup then run the following commands:

```bash
# Install the latest nightly build
pactup install nightly --force

# Set it as your active version
pactup use nightly
```

Quick one-liner (no installation required):

```bash
npx pactup install nightly --force && npx pactup which nightly
# /home/salama/.local/share/pactup/pact-versions/nightly
```

Copy the path to the pact installation and append `/bin/pact` then paste it in your Zed settings

```json
{
"lsp": {
"pact": {
"path": "/home/salama/.local/share/pactup/pact-versions/nightly/bin/pact",
"arguments": ["--lsp"]
}
}
}
```

### Option 2: Manual Configuration

You can specify a custom Pact binary in your Zed settings:

1. Open Zed Settings
2. Add the following configuration:

```json
{
"lsp": {
"pact": {
"path": "/path/to/your/pact",
"arguments": ["--lsp"]
}
}
}
```

## 🔍 How It Works

The extension will look for a Pact binary in this order:

1. System PATH
2. Custom path specified in Zed settings
3. Automatically downloaded nightly build (cached for future use)

> 💡 **Tip**: Using Pactup is recommended as it helps you manage and update your Pact installation easily.
## 🔄 Keeping Pact Updated

To update to the latest nightly build:

```bash
pactup install nightly --force
pactup use nightly
```

You can also specify a Pact version for your project by creating a `.pact-version` file in your project root:

```
nightly
```

## 🛠️ Development

Want to contribute? Here's how to set up the extension locally:

1. Clone the repository:

```bash
git clone https://github.com/kadena-community/pact-zed
```

2. Open Zed
3. Go to `Settings``Extensions`
4. Click `Install Dev Extension` and select the `pact-zed` folder

## 🤝 Contributing

Contributions are welcome! Feel free to:

- Open issues for bugs or feature requests
- Submit pull requests
- Share feedback
4 changes: 2 additions & 2 deletions extension.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
id = "pact"
name = "PactLang"
version = "0.0.2"
version = "0.0.3"
schema_version = 1
authors = ["Salama Ashoush <[email protected]>"]
description = "Pact Programming Language extension for Zed"
repository = "https://github.com/kadena-community/pact-zed"

[grammars.pact]
repository = "https://github.com/kadena-community/tree-sitter-pact"
commit = "991b8e45b5455b516da51baa44bfe0a50a8464bb"
commit = "6e94b4d1fc720ea7b53015aa14499618cd92e02a"

[language_servers.pact]
name = "Pact Language Server"
Expand Down
18 changes: 9 additions & 9 deletions languages/pact/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
)

(s_expression
head: (s_expression_head) @keyword.operator
(#any-of? @keyword.operator
head: (s_expression_head) @keyword.operator
(#any-of? @keyword.operator
"and" "and?" "not" "not?" "or" "or?" "xor"
)
)

(s_expression
head: (s_expression_head) @keyword.conditional
(#any-of? @keyword.operator
(#any-of? @keyword.operator
"if" "cond"
)
)
Expand Down Expand Up @@ -63,35 +63,35 @@
"step-with-rollback"
] @keyword.return

"defpact" @keyword.coroutine
"defpact" @keyword.coroutine

[
"defun"
"defcap"
"defproperty"
] @keyword.function
] @keyword.function

[
"let"
"let*"
"deftable"
] @keyword.storage

"namespace" @keyword.directive
"namespace" @keyword.directive

[
(model)
(managed)
(doc)
(event)
(meta)
] @attribute
] @attribute


(type_annotation ":" @punctuation.delimiter)
(pair ":" @punctuation.delimiter)
(list "," @punctuation.delimiter)
(reference "." @punctuation.delimiter)
(reference "." @punctuation.delimiter)

[
"("
Expand Down Expand Up @@ -121,7 +121,7 @@
(boolean) @boolean
(symbol) @string.special.symbol
(property_identifier) @property
(schema_property_identifier) @property
(schema_field_identifier) @property
(doc_string) @string.documentation
(module_identifier) @module
(module_governance) @function
Expand Down
2 changes: 1 addition & 1 deletion languages/pact/locals.scm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
;------------
(reference (atom) @local.reference)
(def_identifier) @local.definition.function
(schema_property_identifier) @local.definition
(schema_field_identifier) @local.definition
(module_identifier) @local.definition
(module_governance) @local.reference

Expand Down
2 changes: 1 addition & 1 deletion languages/pact/runnables.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
(#any-of? @name
"begin-tx" "expect" "expect-failure" "expect-that" "bench" "verify" "typecheck"
)
tail: (string) @run
tail: (string) @run @script
(#set! tag pact-repl)
) @pact-repl
2 changes: 1 addition & 1 deletion languages/pact/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"args": ["$ZED_FILE"]
},
{
"label": "pact -t $ZED_FILE",
"label": "$ZED_FILE",
"command": "pact",
"args": ["-t", "$ZED_FILE"],
"tags": ["pact-repl"]
Expand Down
Loading

0 comments on commit a752392

Please sign in to comment.