Unicode autocomplete howto

We’d like to implement autocomplete, just like in Julia, of unicode characters in typst VSCode extension. Could you point me to how this implementation is done? Is it in LanguageServer.jl or is it done in Julia itself?

PS. Do check out typst. It is a modern alternative to LaTeX. It is pretty nice.

1 Like

Yes, this is implemented as part of LanguageServer.jl. I won’t recommend looking at the implementation though, it’s not super easy to follow.

I’d recommend exporting the completion map in REPL.REPLCompletions.latex_symbols (and REPL.REPLCompletions.emoji_symbols if you’re interested in emojis) and injecting them into the typst-lsp completion response.
You’ll likely need to do some fuzzy filtering of the potential matches in the LS based on the word under the cursor; we’re just using REPL.fuzzyscore with an arbitrary cutoff for that.

Thanks. I really do hope typst-lsp dev team can make this happen.

2 Likes

@pfitzseb I realised that the unicode insertion works for more than just *.jl files.
I took a peak at the LanguageServer.jl source code and found this block

if endswith(uri.path, ".jmd")
    lid = "juliamarkdown"
elseif endswith(uri.path, ".md")
    lid = "markdown"
elseif endswith(uri.path, ".jl")
    lid = "julia"
else
    lid = ""
end

and this line

FileSystemWatcher("**/*.{jl,jmd,md}", missing)

Is it as simple as adding typ the list and an endswith(uri.path, ".typ") condition block to the control flow? I assume it’s not that simple, but I thought to ask just in case.