Introduction

When writing math formulas in the DeepSeek Harness (DSH) web editor, manually entering LaTeX code is tedious and error-prone. The dsh-math-snippets plugin introduces a trigger-word mechanism that provides snippet expansion similar to LaTeX Suite, significantly improving formula input efficiency.

Plugin Overview

The plugin is maintained by the user huanglianqi and is an open-source tool under the MIT license. It maps common mathematical symbols to short trigger words. After the user enters a specific character combination, the plugin automatically replaces it with a complete LaTeX template and positions the cursor at the placeholder that needs to be filled in.

Core Features

1. Trigger Expansion

The plugin has a built-in trigger table containing 142 entries, of which 138 are automatically expanded by default, and 4 (such as \sum, \prod) require the Tab key. The trigger matching rules are consistent with Obsidian LaTeX Suite, making it easy for users familiar with that tool to migrate.

2. Tab Key Navigation

After a trigger expands, the cursor automatically moves to the first placeholder. Pressing Tab moves the cursor to subsequent placeholders (for example, $1, $2). This allows users to quickly build complex nested formula structures.

3. External Triggers

In addition to inside math mode, the plugin also supports inserting math blocks from plain text. This allows users to quickly insert math formulas into paragraphs or standalone display math blocks.

4. Editable Trigger Table

The plugin’s trigger table is written by the plugin to ~/.dsh/math-snippets.json on first launch. Trigger behavior can be customized by editing this file.

Installation and Activation

Use the official plugin installation command:

dsh plugin --profile <profile> add dsh-math-snippets

After installation, Harness must be restarted (because the configuration list is read at startup), and then the web editor page should be refreshed to apply the changes.

Usage Examples

The following are common triggers and their expansion results:

$//        → $\frac{}{}$
$sum       → $\sum_{i=1}^{n} $
$ff<Tab>   → $\frac{}{}$
mk         → $$
dm         → $$\n\n$$

Inside math mode, triggers usually expand automatically without pressing Tab:

$@a        → $\alpha$
$sr        → $^{2}$

Configuration and Customization

In the ~/.dsh/math-snippets.json file, you can add or override built-in triggers. This file is a JSON object, and each entry contains the following fields:

  • body: The LaTeX content after expansion. $0, $1, etc., indicate placeholders.
  • auto: Whether to expand automatically (defaults to true).
  • open: Whether triggering outside math mode is allowed.
  • word: Whether a non-word character after the trigger word is required (to prevent accidental triggering).
  • desc: A note or description.

Customization example:

{
  "snippets": {
    "capm": { "body": "$E[R_i]=R_f+\\beta_i(E[R_m]-R_f)$", "auto": true },
    "npv":  { "body": "\\mathrm{NPV}=\\sum_{t=0}^{n}\\frac{CF_t}{(1+r)^t}" },
    "par":  { "body": "\\frac{\\partial $0}{\\partial $1}", "auto": true }
  }
}

Limitations and Notes

  1. No Live Preview: The plugin does not hide or render formulas while typing, and it does not automatically adjust bracket size.
  2. Placeholder Text: The default text in placeholders such as ${1:\infty} is not automatically selected. This is a limitation of the Shell environment.
  3. Trigger Word Rules:
    * Pure alphabetic trigger words (such as ff) match complete words (for example, entering xff does not trigger ff).
    * Non-alphabetic trigger words (such as //, _) match exact characters.
    * LaTeX commands themselves (such as \sum) are never recognized as trigger words.
  4. Tab Behavior: Tab is consumed only when a valid trigger is matched; otherwise, Tab retains its default function.

Ecosystem Context

The core design philosophy of DeepSeek Harness is “everything is a plugin”. This plugin is maintained by the community. Its directory and GitHub repository addresses are as follows:

  • Directory: https://www.skillhub.cn/plugins/huanglianqi/dsh-math-snippets
  • Repository: https://github.com/huanglianqi/dsh-math-snippets