summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-08-16 23:29:37 +0300
committerPaul Buetow <paul@buetow.org>2025-08-16 23:29:37 +0300
commit4974b40bd5126cb4215580c0d066057a973f50d1 (patch)
tree0c0febd66e4a59ae713d927474b46fdc4f0592b7 /README.md
parent765eda955eb811d08d867ff4d3914fc6d60c22dd (diff)
feat(lsp): code action to rewrite selection with instruction detection
- Adds textDocument/codeAction handler that rewrites the selected range.\n- Instruction preference: strict ;text; marker first, then //, #, -- line comments, then single-line block comments (/* */ and <!-- -->). Earliest in the selection wins.\n- Removes the matched instruction from the selection before sending to LLM.\n- README: document code action workflow and instruction formats.
Diffstat (limited to 'README.md')
-rw-r--r--README.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/README.md b/README.md
index 40102e4..6cd0827 100644
--- a/README.md
+++ b/README.md
@@ -92,3 +92,42 @@ Ensure `OPENAI_API_KEY` is set in your environment.
### Environment
- Only `OPENAI_API_KEY` is read from the environment when `provider` is `openai`.
+
+## Inline triggers
+
+Hexai supports inline trigger tags you can type in your code to request an
+action from the LLM and then clean up the tag automatically.
+
+- `;text;`: Do what is written in `text`, then remove just the `;text;` marker.
+ - Strict form: no space after the first `;` and no space before the last `;`.
+ - An optional single space immediately after the closing `;` is also removed.
+ - Multiple markers per line are supported.
+ - Example: `// TODO ;rename this function to add;` removes only the marker.
+
+- `;;text;`: Do what is written in `text`, then remove the entire line.
+ - Strict form: no space after `;;` and no space before the closing `;`.
+ - Any line containing such a marker is deleted after processing.
+ - Example:
+ ```
+ some() ;;extract helper; // this entire line is removed
+ ```
+
+- Spaced variants such as `; text ;` or `;; spaced ;` are ignored.
+
+## Code actions
+
+Hexai provides a code action for working with the current selection in Helix:
+
+- Rewrite selection: Select code and invoke code actions. Hexai looks for the
+ first instruction inside the selection and rewrites the selection accordingly.
+
+Instruction sources (first one found wins):
+- Strict marker: `;text;` (no space after first `;`, none before last `;`).
+- Line comments: `// text`, `# text`, `-- text`.
+- Single-line block comments: `/* text */`, `<!-- text -->`.
+
+Notes:
+- Only the earliest instruction in the selection is used; Hexai removes that
+ marker/comment from the selection before sending it to the LLM.
+- The action returns only the transformed code and replaces exactly the
+ selected range.