How to add new autocompletions

I want to add autocompletions for unicode characters (like ‘->’ becoming ‘→’) so I can use it similar to a shortcut, but cannot find out how to implement this functionality as a JupyterLab extension. I have read the docs on the completer module, but it doesn’t seem to be able to do what I want. I have also tried googling for an answer and looking through Jupyter LSP github, but have been unsuccessful. Are there any examples, templates or explanations on how to add new autocompletions?

This depends on the language/kernel that you are using. For example, if you use IPython you could do something like this:

from IPython.core.latex_symbols import latex_symbols

# >l<eft a>r<row (okay, I could have chosen a better alias)
latex_symbols['\\lr'] = '→'

lr

See https://stackoverflow.com/a/50647764/6646912

I am making the extension in typescript and want to make it not specific to any language or notebook that is opened.

Also, as mentioned in my other question, the end goal is to add these types of auto completions to markdown cells and it doesn’t seem like IPython shortcuts can work in the markdown cells.

Oh, that’s a completely different situation. Sorry I did not realise you are writing an extension. It is not currently easy I am afraid. I will be working to make it possible (see Refactor completer to support external providers by krassowski · Pull Request #600 · krassowski/jupyterlab-lsp · GitHub and Completer public API refactor wishlist · Issue #9763 · jupyterlab/jupyterlab · GitHub) in July/August but this will only arrive for JupyterLab 4.0. If you absolutely have to have this functionality, then in the meantime you would likely need to follow the same path as jupyterlab-lsp.