Skip to content

Instantly share code, notes, and snippets.

@thaliaarchi
Last active June 13, 2022 18:30
Show Gist options
  • Save thaliaarchi/79bef21ba2bad83a256477ed74eadf0f to your computer and use it in GitHub Desktop.
Save thaliaarchi/79bef21ba2bad83a256477ed74eadf0f to your computer and use it in GitHub Desktop.
Demo of LSP inlay hints in Whitespace

Inlay Hints for Whitespace

The syntax of the Whitespace programming language is invisible—it uses only space, tab, and line feed—so editing a program manually is tedious and most people will instead develop using a “Whitespace assembly” syntax with readable opcodes. I am working on a to-be language server for Whitespace that will use inlay hints to display the opcodes in the invisible syntax. The LSP only allows Type and Parameter values for InlayHintKind, which is exclusive of this use case (vscode#151920). I propose that this enum be extended to include a variant for this case.

This gist roughly demonstrates how the inlay hints would work for a Whitespace program: It includes the annotated example from the Whitespace tutorial formatted in the standard syntax, in Whitespace assembly syntax, and with inlay hints for assembly opcodes interspersed.

push 1
C:
dup
printi
push 10
printc
push 1
add
dup
push 11
sub
jz E
jmp C
E:
drop
end
push·1
label·C
dup
printi
push·10
printc
push·1
add dup
push·11
sub jz·E
jmp·C
label·E
drop
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment