/agda-mode-vscode

agda-mode on VS Code

Primary LanguageReScriptMIT LicenseMIT

agda-mode on VS Code

Visual Studio Marketplace Tag Visual Studio Marketplace Downloads Visual Studio Marketplace Installs Visual Studio Marketplace Rating

Demo.mov

Installation

If you have Agda properly installed (to check this in your terminal, type agda and see if it's on your machine). Open an Agda file and you should be able to load it by typing C-c C-l.

It's okay if you don't have Agda installed, just proceed to the next section and check out our experimental language server for Agda.

Simply enable agdaMode.connection.agdaLanguageServer in the settings, and then hit restart C-x C-r.

The language server should be downloaded and installed within seconds.

截圖 2021-08-30 下午10 22 29

Prebuilt binaries for the language server are available on Windows, macOS, and Ubuntu.

Extension Activation

To activate the extension, open an Agda file, and trigger either of these 2 commands:

Command Keymap
load C-c C-l
activate unicode input method \

See the next section for the exhaustive list of other commands. You will get command ... not found if you try to trigger other commands without activating the extension first.

Commands

  • C-c stands for "press Ctrl and c at the same time"
  • When it comes to combos like C-c C-l, you can often slur them into "hold Ctrl while pressing c and then l"

Commands working with types (marked with the 🎚 emoji below) can have different levels of normalization. However, due to some technical limitations, we cannot prefix commands with C-u or C-u C-u like in Emacs. Instead, we replace the C-u C-c prefix with C-u and the C-u C-u C-c prefix with C-y.

Take infer type for example:

Level of normalization Keymap in VS Code Keymap in Emacs
"simplified" (default) C-c C-d C-c C-d
"instantiated" (without further normalisation) C-u C-d C-u C-c C-d
"normalized" (fully normalized) C-y C-d C-u C-u C-c C-d

Global commands

Command Keymap
load C-c C-l
compile C-x C-c
quit C-c C-q
quit and restart C-x C-r
toggle display of hidden arguments C-x C-h
toggle display of irrelevant arguments C-x C-i
show constraints C-c C-=
solve constraints 🎚 C-c C-s
show all goals C-c C-?
move to next goal (forward) C-c C-f
move to previous goal (backwards) C-c C-b
infer type 🎚 C-c C-d
module contents 🎚 C-c C-o
search definitions in scope 🎚 C-c C-z
compute normal form (default compute) C-c C-n
compute normal form (ignore abstract) C-u C-n
compute normal form (use show instance) C-y C-n
switch to a different Agda version C-x C-s
Unicode symbol input sequences lookup C-x C-=

Commands in context of a goal

Command Keymap
give (fill goal) C-c C-SPC
refine C-c C-r
elaborate and give 🎚 C-c C-m
auto C-c C-a
case split C-y C-c
compute helper function type and copy 🎚 C-y C-h
goal type 🎚 C-c C-t
context (environment) 🎚 C-c C-e
infer type 🎚 C-c C-d
goal type and context 🎚 C-c C-,
goal type, context and inferred term 🎚 C-c C-.
goal type, context and checked term 🎚 C-c C-;
module contents 🎚 C-c C-o
compute normal form (default compute) C-c C-n
compute normal form (ignore abstract) C-u C-n
compute normal form (use show instance) C-y C-n
why in scope C-c C-w

Commands yet to be implemented

Command Keymap
abort a command C-x C-a
remove goals and highlighting C-x C-d
comment/uncomment rest of buffer

Unicode Input

Pretty much the same like on Emacs. Press backslash "\" and you should see a keyboard popping up in the panel, with key suggestions and symbol candidates. Use arrow keys to explore and navigate between the candidates (if there's any).

Unicode input also works in the input prompt, though it's a bit less powerful.

If you are having trouble typing the backslash "\", you can change it by:

  1. Go to "Preferences: Open Keyboard Shortcurs" and configure the keybinding of "Agda: Activate input method" (agda-mode.input-symbol[Activate]).
  2. Go to "Settings > Agda Mode > Input Method: Activation Key" and replace it with the same keybinding as above.

Cancel agdaMode.inputMethod.enable in the settings to disable the input method.

Syntax Highlighting

Cancel agdaMode.highlighting.getHighlightWithThemeColors in the settings if you want to fallback to the old way of highlighting stuff with fixed colors.

Debug Buffer

Execute Agda: Open Debug Buffer in the Command Palette to open it. The number at the end of each message indicates its verbosity.

Troubleshooting

Agda files won't load, commands don't work

Please go to "Preferences: Open Keyboard Shortcurs" and see if any extension is fighting for the same key combo. You're probably a victim of the Vim extension.

"Give" command not working on macOS

Give (C-c C-SPC) would trigger "Spotlight" (C-SPC) on Mac. Please consider using Refine (C-c C-r) instead.

Contributing

See CONTRIBUTING.md