# Unicode autocomplete howto

**URL:** <https://discourse.julialang.org/t/unicode-autocomplete-howto/96752>\
**Category:** VS Code\
**Tags:** repl\
**Created:** [March 29, 2023, 5:52am UTC](https://discourse.julialang.org/t/unicode-autocomplete-howto/96752 "2023-03-29T05:52:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![owiecc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/owiecc/32/8894_2.png) [@owiecc](https://discourse.julialang.org/u/owiecc)\
**Post date:** [March 29, 2023, 5:52am UTC](https://discourse.julialang.org/t/unicode-autocomplete-howto/96752/1 "2023-03-29T05:52:49Z")

</div>

We’d like to implement autocomplete, just like in Julia, of unicode characters in typst [VSCode extension](https://github.com/nvarner/typst-lsp/issues/49). Could you point me to how this implementation is done? Is it in [LanguageServer.jl](https://github.com/julia-vscode/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.

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [March 29, 2023, 10:00am UTC](https://discourse.julialang.org/t/unicode-autocomplete-howto/96752/2 "2023-03-29T10:00:28Z")

</div>

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`](https://github.com/JuliaLang/julia/blob/38d24e574caab20529a61a6f7444c9e473724ccc/stdlib/REPL/src/docview.jl#L631-L639) with an arbitrary cutoff for that.

---

<div class="post-metadata">

**Author:** ![owiecc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/owiecc/32/8894_2.png) [@owiecc](https://discourse.julialang.org/u/owiecc)\
**Post date:** [March 29, 2023, 10:58am UTC](https://discourse.julialang.org/t/unicode-autocomplete-howto/96752/3 "2023-03-29T10:58:05Z")

</div>

Thanks. I really do hope [typst-lsp](https://github.com/nvarner/typst-lsp) dev team can make this happen.

---

<div class="post-metadata">

**Author:** ![kapple](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kapple/32/218915_2.png) [@kapple](https://discourse.julialang.org/u/kapple)\
**Post date:** [September 15, 2024, 3:22am UTC](https://discourse.julialang.org/t/unicode-autocomplete-howto/96752/4 "2024-09-15T03:22:53Z")

</div>

@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](https://github.com/julia-vscode/LanguageServer.jl/blob/0da181a8e48da14c2ac46519311e01352c7c6fca/src/textdocument.jl#L17)

```julia
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](https://github.com/julia-vscode/LanguageServer.jl/blob/0da181a8e48da14c2ac46519311e01352c7c6fca/src/requests/init.jl#L212)

```julia
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.
