Skip to content

Commit 3861510

Browse files
mhuisiclaude
andauthored
feat: picker-based input method for abbreviations in non-editor contexts (#762)
This PR adds three new abbreviation-related commands that have the goal of making it easier to insert Unicode symbols into non-editor dialogs and to make abbreviations more discoverable: - 'Find Unicode Symbol...': Displays a picker dialog that allows searching for Unicode symbols either by abbreviation or by symbol. Selecting an entry then provides an option to either copy the symbol or to insert it into the currently active text editor. Displayed in the forall menu. - 'Copy Unicode Symbol...': Like 'Find Unicode Symbol', but selecting a symbol from the dialog immediately copies it instead of opening another dialog to choose whether the symbol should be inserted or copied. Bound to Ctrl+Alt+\ when no text editor is focused. - 'Insert Unicode Symbol...': Like 'Find Unicode Symbol', but selecting a symbol from the dialog immediately inserts it instead of opening another dialog to choose whether the symbol should be inserted or copied. Bound to Ctrl+Alt+\ when a text editor is focused. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d6087e8 commit 3861510

File tree

4 files changed

+394
-1
lines changed

4 files changed

+394
-1
lines changed

vscode-lean4/manual/manual.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,16 @@ The Unicode input mechanism has several configuration options:
246246
| :--: |
247247
| *Hover for Unicode symbol displaying all abbreviation identifiers* |
248248

249+
To use Unicode symbols outside of text editors - for example in the search bar, find widget or settings - a symbol picker is available. The ['Input: Find Unicode Symbol...'](command:lean4.input.findSymbol) command can be used from the [command menu](#command-menu) or the [command palette](#command-palette). After selecting a symbol, a second dialog allows choosing between copying the symbol to the clipboard and inserting it into the active text editor.
250+
251+
There are also two direct commands that skip the second dialog:
252+
- ['Input: Insert Unicode Symbol...'](command:lean4.input.insertSymbol) inserts the chosen symbol directly into the active text editor. It is bound to `Ctrl+Alt+\` (`Cmd+Alt+\`) when a text editor is focused.
253+
- ['Input: Copy Unicode Symbol...'](command:lean4.input.copySymbol) copies the chosen symbol directly to the clipboard. It is bound to `Ctrl+Alt+\` (`Cmd+Alt+\`) when no text editor is focused.
254+
255+
Both direct commands display a button on each item for the other action, so that e.g. a symbol can be copied to the clipboard while using the insert command without having to reopen the dialog.
256+
257+
The search field in the symbol picker supports the same abbreviation identifiers as the regular abbreviation mechanism: typing an abbreviation like `alpha` will find the symbol `α`. The leader character (`\`) can optionally be included. Searching is also possible in reverse by typing or pasting a Unicode symbol to find the abbreviation identifiers that produce it.
258+
249259
### InfoView
250260

251261
The InfoView is the main interactive component of Lean. It can be used to inspect proof goals, expected types and [diagnostics](#errors-warnings-and-information), as well as render arbitrary user interfaces called ['widgets'](#widgets) for Lean code.

vscode-lean4/package.json

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,24 @@
345345
"title": "Convert Current Abbreviation",
346346
"description": "Converts the current abbreviation (e.g. \\lam)."
347347
},
348+
{
349+
"command": "lean4.input.findSymbol",
350+
"category": "Lean 4: Input",
351+
"title": "Find Unicode Symbol…",
352+
"description": "Opens a dialog to search Unicode abbreviations and lets the user choose to copy or insert the chosen symbol."
353+
},
354+
{
355+
"command": "lean4.input.insertSymbol",
356+
"category": "Lean 4: Input",
357+
"title": "Insert Unicode Symbol…",
358+
"description": "Opens a dialog to search Unicode abbreviations and inserts the chosen symbol into the active editor."
359+
},
360+
{
361+
"command": "lean4.input.copySymbol",
362+
"category": "Lean 4: Input",
363+
"title": "Copy Unicode Symbol…",
364+
"description": "Opens a dialog to search Unicode abbreviations and copies the chosen symbol to the clipboard."
365+
},
348366
{
349367
"command": "lean4.displayGoal",
350368
"category": "Lean 4: InfoView",
@@ -854,6 +872,18 @@
854872
"mac": "tab",
855873
"when": "editorTextFocus && lean4.input.isActive"
856874
},
875+
{
876+
"command": "lean4.input.insertSymbol",
877+
"key": "ctrl+alt+\\",
878+
"mac": "cmd+alt+\\",
879+
"when": "editorTextFocus"
880+
},
881+
{
882+
"command": "lean4.input.copySymbol",
883+
"key": "ctrl+alt+\\",
884+
"mac": "cmd+alt+\\",
885+
"when": "!editorTextFocus"
886+
},
857887
{
858888
"command": "lean4.restartFile",
859889
"key": "ctrl+shift+x",
@@ -967,6 +997,16 @@
967997
"command": "lean4.input.convert",
968998
"when": "lean4.isLeanFeatureSetActive && lean4.input.isActive"
969999
},
1000+
{
1001+
"command": "lean4.input.findSymbol"
1002+
},
1003+
{
1004+
"command": "lean4.input.insertSymbol",
1005+
"when": "lean4.input.isTextEditorActive"
1006+
},
1007+
{
1008+
"command": "lean4.input.copySymbol"
1009+
},
9701010
{
9711011
"command": "lean4.displayGoal",
9721012
"when": "lean4.isLeanFeatureSetActive"
@@ -1270,10 +1310,15 @@
12701310
"group": "3_infoview@1"
12711311
},
12721312
{
1273-
"command": "lean4.loogle.search",
1313+
"command": "lean4.input.findSymbol",
12741314
"when": "config.lean4.alwaysShowTitleBarMenu || lean4.isLeanFeatureSetActive",
12751315
"group": "4_search@1"
12761316
},
1317+
{
1318+
"command": "lean4.loogle.search",
1319+
"when": "config.lean4.alwaysShowTitleBarMenu || lean4.isLeanFeatureSetActive",
1320+
"group": "4_search@2"
1321+
},
12771322
{
12781323
"command": "lean4.troubleshooting.showTroubleshootingGuide",
12791324
"when": "config.lean4.alwaysShowTitleBarMenu || lean4.isLeanFeatureSetActive",

vscode-lean4/src/abbreviation/AbbreviationFeature.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { AbbreviationProvider } from '@leanprover/unicode-input'
22
import { Disposable, OutputChannel, languages } from 'vscode'
33
import { AbbreviationHoverProvider } from './AbbreviationHoverProvider'
44
import { AbbreviationRewriterFeature } from './AbbreviationRewriterFeature'
5+
import { SymbolPickerFeature } from './SymbolPickerFeature'
56
import { VSCodeAbbreviationConfig } from './VSCodeAbbreviationConfig'
67

78
export class AbbreviationFeature {
@@ -19,6 +20,7 @@ export class AbbreviationFeature {
1920
new AbbreviationHoverProvider(config, this.abbreviations),
2021
),
2122
new AbbreviationRewriterFeature(config, this.abbreviations, outputChannel),
23+
new SymbolPickerFeature(config, this.abbreviations),
2224
)
2325
}
2426

0 commit comments

Comments
 (0)