How to setup tinymist LSP in neovim?

Hi, dunno if this is the right place to post, but I gotta start somewhere.

I’ve been setting up neovim for the first time, and I wanna use it with typst. LSP worked with Lua, but not with tinymist.

:checkhealth vim.lsp shows tinymist is an active client.
and
vim.lsp.buf.format() gives no errors.
(ive done formatterMode = “typstyle”)
but
theres no autocompletion, no hover, no commands, no nothing. i have no clue what im missing.

any help would be appreciated.

1 Like

Hi.

There is https://github.com/Myriad-Dreamin/tinymist#installation, which leads to Tinymist Neovim Support for Typst - Tinymist Docs. Did you read this?

You basically only need https://github.com/neovim/nvim-lspconfig (as with almost any LSP server), with https://github.com/mason-org/mason.nvim being a bonus, if you are not on NixOS.

1 Like

Yeah it didnt work out of the box with nvim-lspconfig.
That is, i followed what youtuberguy sylvanfranklin did and copied the lsp config directory from nvim-lspconfig (including tinymist.lua) into .config/nvim/
This worked for lua_ls.lua; that is, i have autocomplete and everything in my init.lua.

but in test.typ lsp is… actually, its not entirely dead! i looked at it this morning, my newbie brain didn’t think to check autocomplete with functions (i assumed it would be more ubiquitous). these work, so im guessing thats autocomplete done. which is great.

But! commands (like :ExportPng or :Tinymist anything) are still dead. Error message E492. I think im gonna rawdog it for the time being but i would ofc be thankful for any help in this direction.

well, that was kind of a status update i guess. but i also wanna mention:
I did read the links you provided (that is, ive already read them/it many times)! But if there is some wisdom there im not smart enough to find it. I feel like ive done the intended steps. As mentioned, :checkhealth vim.lsp returns an “active” tinymist. And ive also tried installing tinymist with mason. Commands still didn’t work then (though now i realize autocomplete was probs there).

“Solved!”

Thanks for your help, @Andrew.

The problem turned out to be my diagnostics skills. Commands are also present, i just have to preface them with lsp even though i thought i had removed that format in the .lua lsp config file. oh well. Back to doublechecking how to make the format better!

I will say, though, the lsp on the typst website is a lot better than my local one. but im assuming tinymist is working as intended now.

1 Like

Great that you got it working.

For my setup, I already had LSP setup with neovim, so to add tinymist the only action needed was to install it (mason) and it was picked up by the help of nvim-lspconfig. I think that’s the ideal setup story - the main difficulty is usually with the “setting up LSP at all” step in neovim.

I want to say that with tinymist you have inline docs for both standard library functions and package functions using hover (for example the K key or similar), and that functionality does not exist on the webapp. So you also have access to a better IDE integration in that sense.

1 Like

Does this mean that you didn’t use Neovim before? These commands were there for a long time now. :h lspconfig-commands

No, it’s…mostly worse. But autocompletion is in basic cases better, I think. I reported several times that the autocompletion sometimes sucks a lot. Like if I write #block(), it will show field items at the very bottom of the list, above different colors. But it’s not too bad when you know what to type.

correct!

I thought i had changed the command prefixes from “lsp” to null, but apparently that was not the case.

haha good to know it will get better when i get better. im obv also new to typst, so the autocomplete online has so far given me more actionable info. also it’s less skittish when i mistype.

thanks for the info. regarding package hover that’s great news. im also guessing ill be utilizing the hover often in the learning phase (and obv also beyond that ofc, but i reckon ill be learning from it like ive been learning from the typst.app autocomplete till now)

Well, since you are new to Neovim, it’s safe to say that your overall efficiency will grow with practice. And it’s cool that web app has Vim mode. There are a ton of plugins that can be useful, and you won’t be able to live without them: GitHub - rockerBOO/awesome-neovim: Collections of awesome neovim plugins.. As a result, GitHub - subnut/nvim-ghost.nvim: 👻 GhostText plugin for Neovim with zero dependencies Supports neovim running inside WSL too! Windows/Linux/macOS supported out-of-the-box! (Other OSes need python3.6+ installed) can help you compose long messages on the web. It’s like Vim mode in the web app, but you actually can use your Neovim with all your useful plugins.

I think the most noticeable improvement is the ability to format everything. In the web app you must write everything perfectly, otherwise you would have to format everything separately, which is not fun. And you won’t see trailing white spaces, etc.

Aside from hover docs, Tinymist can also help with showing the types that are allowed as an argument or a return type. This can help when you don’t know the API. Even for custom functions.

1 Like