nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.2k stars 78 forks source link

File extension (.typ) is not associated with the Typst language by default #38

Open BlueskyFR opened 1 year ago

BlueskyFR commented 1 year ago

The file association .typ with the Typst language should be done.

nvarner commented 1 year ago

It should be associated by default. What version of the extension are you using?

SpacewaIker commented 1 year ago

I seem to be having the same issue, with v0.3.2. However, I'm using the lsp on neovim, so I don't know if it is only for VS Code for now. I also tried set filetype=typst manually on a typ file, but the lsp still didn't seem to work. Maybe it's a config issue? I just installed it using Mason.

GaetanLepage commented 1 year ago

In neovim, when I open a .typ file, the automatically associated filetype is sql. Hence, the typst LS is not attached. Setting manually set filetype=typst does not work indeed. I was able to make the LSP work by adding vim.filetype.add({ extension = {typ = "typst"}}) to my neovim config.

Hence, the problem is indeed that this association is not made by default. I guess that it should be upstream directly to neovim but I am not 100% sure.

Pi77Bull commented 1 year ago

In neovim, when I open a .typ file, the automatically associated filetype is sql. Hence, the typst LS is not attached. Setting manually set filetype=typst does not work indeed. I was able to make the LSP work by adding vim.filetype.add({ extension = {typ = "typst"}}) to my neovim config.

Hence, the problem is indeed that this association is not made by default. I guess that it should be upstream directly to neovim but I am not 100% sure.

Hey, sorry to hijack this bug.

I'm using neovim and running into the same problem it seems. The language server is not being attached to the buffer no matter what I do.

I added the file extension .typ to my neovim setup, just like you did and the file is now being recognized as a typst file. This doesn't solve the problem though.

:LspInfo says the following:

Detected filetype:   typst

 0 client(s) attached to this buffer: 

 Other clients that match the filetype: typst

 Config: typst_lsp
    Refer to :h lspconfig-root-detection for help.
    filetypes:         typst
    root directory:    Not found.
    cmd:               typst-lsp
    cmd is executable: true
    autostart:         true
    custom handlers:   

 Configured servers list: typst_lsp

I think the problem is that it doesn't find the root directory, but it should attach to the file, shouldn't it?

GaetanLepage commented 1 year ago

I guess that it should be upstream directly to neovim but I am not 100% sure.

Done:

yeonsann commented 1 year ago

@Pi77Bull The typ file must be in some sort of git folder. I just do a quick git init.

GaetanLepage commented 1 year ago

@Pi77Bull The typ file must be in some sort of git folder. I just do a quick git init.

Why so ? I don't see why we need the document to be in a git repo...

yeonsann commented 1 year ago

Why so ? I don't see why we need the document to be in a git repo...

Because the default config uses this:

root_dir = function(fname)
      return util.find_git_ancestor(fname)
end,
GaetanLepage commented 1 year ago

Ok ! Thank you for the explanation

GaetanLepage commented 1 year ago

Done:

* vim: [vim/vim@4ce1bda](https://github.com/vim/vim/commit/4ce1bda869e4ec0152d7dcbe1e491ceac5341d5e)

* neovim:

I guess that we can close this issue. Users will have to either

GaetanLepage commented 1 year ago

I guess that we can close this issue.

@nvarner @BlueskyFR

BlueskyFR commented 1 year ago

I guess that we can close this issue.

@nvarner @BlueskyFR

Issue is still present on VsCode AFAIK, which was the original purpose of this issue. I'll check asap

nvarner commented 1 year ago

@BlueskyFR please update when you test in VS Code; it should work fine there with the latest version of the plugin.

I'm not familiar with Vim configuration, but it looks like that part of the issue has been resolved and wasn't strictly related to the language server. I'll have to look into Vim to see what's needed to improve support, though.