Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
575 stars 28 forks source link

Not managing to make work tinymist in Neovim #125

Closed pauladam94 closed 6 months ago

pauladam94 commented 6 months ago

Describe the bug I am using neovim and I can't get tinymist to work.

I am using a modify version of kickstart.nvim not a distro.

Just to be clear about what I have done :

When I call the command LspInfo on a .typ file I get this :

 Language client log: /Users/pauladam/.local/state/nvim/lsp.log
 Detected filetype:   typst

 0 client(s) attached to this buffer: 

 Configured servers list: ocamllsp, rust_analyzer, clangd, lua_ls

Package/Software version:

tinymist extension version: v0.11.0. Get it by tinymist --version in terminal.

tinymist 
Build Timestamp:     2024-03-29T09:32:33.418921000Z
Build Git Describe:  858c100
Commit SHA:          858c10014672b62e93b38c5d85666da0decf273f
Commit Date:         None
Commit Branch:       None
Cargo Target Triple: aarch64-apple-darwin
Typst Version:       0.11.0

Neovim version

NVIM v0.10.0-dev-2528+g04232a19c-Homebrew
Build type: Release
LuaJIT 2.1.1710088188
Myriad-Dreamin commented 6 months ago

How do you configure typst-lsp? If you'd made typst-lsp work, then you can configure binary path to typst-lsp to tinymist. That's what I believe a dirty but quick way to make tinymist work on your neovim.

I'm not familiar with kickstart.nivm, but tinymist.lua was made for unmodified LazyVim. There should be something missing in comparison kickstart.nivm with unmodified LazyVim.

pauladam94 commented 6 months ago

Yes indeed I am not using LazyVim, so I was not using 'tinymist.lua' wright.

I installed typst_lsp with Mason. I didn't even put it in my config (I used the Mason Window).

Now I have tried many things but LspInfo just never catch tinymist as an lsp.

I have changed as advice the cmd of typst_lsp to tinymist.

It works however I can't import a file that is not on the same of the current directory. I have the exact issue of the #117 issue.

How to change the root directory by using only the binary ? I know about the rootDirectory argument however it doesn't seem to work because I run tinymist through typst_lsp config.

Thank you very much again.

Myriad-Dreamin commented 6 months ago

Thank you for you feed back. I get more information so I can answer some questions for you. They are mostly caused by tinymist is new. I'm not using neovim in my daily life but I have some knowledge, so please correct me if I'm wrong.

  1. To let mason identify tinymist out of box, there is an opening issue, https://github.com/williamboman/mason-lspconfig.nvim/pull/384
    • Otherwise you should probably require it in your lua config by yourself.
  2. To configure root directory for tinymist, you should add some extra lspconfig settings. https://github.com/Myriad-Dreamin/tinymist/blob/631f6e288c6cb369ef73b453cb4ca71b650cb20a/editors/neovim/plugins/tinymist.lua#L23-L27

Both are solved by 'tinymist.lua'. You can

Tips: the description to rootPath is at https://github.com/Myriad-Dreamin/tinymist/blob/main/editors/neovim/Configuration.md#rootpath, you can configure it like what you've done in typst-lsp.

pauladam94 commented 6 months ago

Thank you very much. I will wait for the mason issue to be resolved. I have tried tinnymist.lua without success.

I must say that it is already possible to install tinymist through mason. However to work properly right out of the gate, it will be cool.

pauladam94 commented 6 months ago

So I have seen the merged of your pull request in Mason. However, I have to wait the next Mason update ?

I still have the same problem. Tinymist never register as a "configured Lsp" when I do :LspInfo. However, typst_lps does and work.

I have this in my config and is it called by mason-lspconfig :

tinymist = {
    single_file_support = true,
    root_dir = function()
        return vim.fn.getcwd()
    end,
    settings = {}
 }

It is indeed called because when I uninstall tinymist in Mason, at startup of neovim it is reinstalled by Mason.

Thank you again for your answers. If you have any idea I am welcome.

Initially I was interested in tinymist because I didn't manage to make work import of files from higher directory in typst_lsp. And I have not found a way to setup the typst_lsp in neovim. In contrary to tinymist that has some parameters to be configured (like rootPath).

pauladam94 commented 6 months ago

The way I have now made it worked in my config :

for mason-lspconfig I have that :

typst_lsp = {
    cmd = {
         '/Users/pauladam/.local/share/nvim/mason/bin/tinymist',
    }, 
    single_file_support = true,
    root_dir = function()
        return vim.fn.getcwd()
    end,
    settings = {}
},
tinymist = {
 }

So I have achieved to have :

However it do all of that through the typst-lsp config.

This is the output I get from LspInfo Now. The most diferrent thing from the beginning in the fact that the root directory changed.

 Language client log: /Users/pauladam/.local/state/nvim/lsp.log
 Detected filetype:   typst

 1 client(s) attached to this buffer: 

 Client: typst_lsp (id: 1, bufnr: [1])
    filetypes:       typst
    autostart:       true
    root directory:  /Users/pauladam/PaulJR
    cmd:             /Users/pauladam/.local/share/nvim/mason/bin/tinymist

 Configured servers list: clangd, rust_analyzer, typst_lsp, lua_ls, ocamllsp
Myriad-Dreamin commented 6 months ago

Glad to hear that you've achieved it. We will manage to improve experience to mason users to reduce difficulty to use tinymist. It is just not great that we made slow progress on that PRs.

So I have seen the merged of your pull request in Mason. However, I have to wait the next Mason update ?

It is not merged but closed tho, I may try it again.

Myriad-Dreamin commented 4 months ago

This is merged and published: https://github.com/williamboman/mason-lspconfig.nvim/pull/405