nvarner / typst-lsp

[Deprecated] An early language server for Typst, plus a VS Code extension
MIT License
1.21k stars 78 forks source link

Can't disable `exportPdf` #265

Open Andrew15-5 opened 1 year ago

Andrew15-5 commented 1 year ago

Issue

It's cool, that typst-lsp now also supports new package system, this means I can use built-in typst watch again. But this doesn't help if I need to watch only for the "main" file and recompile if it or any of the included files are changed. So, I need to disable it. I think I was able to disable the option then, but I'm not sure. Now, I've tried on my host OS and even in docker container (attached it in zip file) with latest v0.9.4 and v0.6.2 (#178) — no use. I still think that maybe my config is wrong, but it's very hard to mess up 3 lines of config (mason, mason-lspconfig, lspconfig). So I also think that it's a bug.

What to do:

cd "$(mktemp -d)"
wget https://github.com/nvarner/typst-lsp/files/12430172/typst-lsp-neovim.zip
unzip typst-lsp-neovim.zip
cd typst-lsp-neovim/
just # cargo install just # sudo apt install -y cargo

# Inside container
init # After typst-lsp is installed, exit with `qZQ`
vi a.typ

# Inside Neovim add anything to the file & exit
ia<Esc>ZZ

# PDF file was created
ll a.pdf

typst-lsp-neovim.zip

Andrew15-5 commented 1 year ago

I've tried building release from master and then copying binary to ~/.local/share/nvim/mason/packages/typst-lsp/typst-lsp-x86_64-unknown-linux-gnu but it seems nothing have changed. I don't know if it's the correct way, since mason can only download binaries from release page, but the latest release was 6 days ago. Probably, bug didn't disappear.

nvarner commented 1 year ago

I haven't yet made a release with this fix, but I expect to soon. I'll reopen the issue for now.

Andrew15-5 commented 1 year ago

No, it still exports PDF. I've compiled typst-lsp from this commit: 46e1b0b8a667c3d4c29bdd6388df83e12e5c02dd. With:

cargo build --release --no-default-features

Change this part:

wget https://github.com/nvarner/typst-lsp/files/12430172/typst-lsp-neovim.zip
unzip typst-lsp-neovim.zip

to this:

wget https://github.com/nvarner/typst-lsp/files/12612843/typst-lsp-0.9.5-46e1b0b-neovim.zip
unzip typst-lsp-0.9.5-46e1b0b-neovim.zip
tar axf typst-lsp-0.9.5-46e1b0b-neovim.tar.zstd

typst-lsp-0.9.5-46e1b0b-neovim.zip

P.S. GitHub doesn't allow for files greater than 25 MiB, so I had to compress with zstd and then wrap it in zip, since only zip is supported. If it would have not fit, I would've gave a MEGA link.

KillTheMule commented 1 year ago

Can you post your config? disabling exportPdf works for me.

Andrew15-5 commented 1 year ago

Can you post your config? disabling exportPdf works for me.

Everything is in the archive. I'm really worried, that my config is bad, but I already triple checked it several times.

KillTheMule commented 1 year ago

Yeah looks fine. I also checked again that it works for me :) Maybe you're still not using the right binary, but I know nothing of mason...

Andrew15-5 commented 1 year ago

I also checked again that it works for me

Do you use VS Code? Did this issue exist for you in previous versions?

KillTheMule commented 1 year ago

Do you use VS Code? Did this issue exist for you in previous versions?

No I'm using neovim. Issue existed before #281 for me, too.

Andrew15-5 commented 1 year ago

I also compiled completely default binary and checked which version is used via :!typst-lsp -V<CR> in Neovim (of course, the binary with my custom version name).

KillTheMule commented 1 year ago

Might mason somehow call a different binary though? Maybe try without mason? Shouldn't be too hard to just start a new config for testing.

Andrew15-5 commented 1 year ago

No I'm using neovim. Issue existed before #281 for me, too.

Based on which commit have you compiled the binary?

I know nothing of mason...

I'm almost new to it, too. But I think mason is just a manager of many tools (LSP servers, formatter and other stuff), that can be used in Neovim. It makes it so that I can access typst-lsp from inside of Neovim, but outside the binary is not in the PATH.

KillTheMule commented 1 year ago

Current HEAD (46e1b0b8a667c3d4c29bdd6388df83e12e5c02dd). If you checked the version with typst-lsp -V you woulndn't see the commit, right? So I'm still wary of mason ;)

Andrew15-5 commented 1 year ago

Might mason somehow call a different binary though?

After latest version is installed (by mason):

image

After restarting the Neovim:

image

After running mv ~/.local/share/nvim/mason/packages/typst-lsp/typst-lsp-x86_64-unknown-linux-gnu{,.bak}:

image

KillTheMule commented 1 year ago

After restarting the Neovim:

image

Wait a second, how did that happen? My compiled typst-lsp does not do that, it just shows Version: 0.9.5 (Typst version 0.7.0)

Andrew15-5 commented 1 year ago

Current HEAD (46e1b0b).

It's not the current HEAD for more than 2 hours, but I also compiled from this commit.

KillTheMule commented 1 year ago

Ah right, I missed that last commit ;) Still doesn't show a commit hash, though.

Andrew15-5 commented 1 year ago

Wait a second, how did that happen

I literally provided fully reproducible instructions in the https://github.com/nvarner/typst-lsp/issues/265#issue-1865282732 and an updated version in https://github.com/nvarner/typst-lsp/issues/265#issuecomment-1720062016 including the archive.

KillTheMule commented 1 year ago

Ah I missed that part. I just used the included binary, and also with that, there's no pdf produced, neither when typing nor when savin the typ file.

Andrew15-5 commented 1 year ago

I just used the included binary, and also with that, there's no pdf produced, neither when typing nor when savin the typ file.

But I can't use your machine for testing. The docker images shows that the bug is still present.

I have absolutely no idea how it doesn't work on my machine, it doesn't work in a container, but it works for you.

Since I know more about mason than I knew before, I really have to try using the server directly. This should give the ultimate answer.

KillTheMule commented 1 year ago

I have absolutely no idea how it doesn't work on my machine, it doesn't work in a container, but it works for you.

Yeah, a bit freakish :) The only thing I can see is the config, somehow, although the lsp-config setup seemed fine to me. I did load your config directly (had to mod in a root_directory function though), and even though there were a lot of unrelated errors, the lsp server was started and connected, but still did not make a pdf on save.

Andrew15-5 commented 1 year ago

What's in your config file?

Andrew15-5 commented 1 year ago

I'm not sure what it is, but I suspect, that the coc.nvim is the culprit. I think my init.vim is pretty old since Lua plugins are now everywhere and most of mine are probably still written in Vimscript. So I've tried using https://github.com/hrsh7th/nvim-cmp/, and it's default config... everything just works... I need to dig deeper.

I thought it was my nvim version, but it works great with the default Debian (pretty old now) version.

Andrew15-5 commented 1 year ago

I can confirm, that the current setup that works with latest commit's binary doesn't work with latest release's binary

Andrew15-5 commented 1 year ago

Here is the updated & simplified version:

cd "$(mktemp -d)"
wget https://github.com/nvarner/typst-lsp/files/12614551/typst-lsp-neovim-coc-cmp.tar.zstd.zip
unzip typst-lsp-neovim-coc-cmp.tar.zstd.zip
tar axf typst-lsp-neovim-coc-cmp.tar.zstd
cd typst-lsp-neovim/
just

# Inside container
vi cmp.typ

# Inside Neovim add anything to the file and exit.
ia<Esc>ZZ

# PDF file was not created.
ll cmp*

# Open init.vim
conf

# Uncomment coc.nvim, comment nvim-cmp, suspend
20G<c-/>jjvip<c-/><c-z>

# Test coc.nvim
vi coc.typ
ia<Esc>ZZ
ll coc*

# You can undo conf modifications and text nvim-cmp again
z
uu<c-z>

# You can redo conf modifications and text coc.nvim again
z
<c-r><c-r><c-z>

typst-lsp-neovim-coc-cmp.tar.zstd.zip

Andrew15-5 commented 1 year ago

I guess I'll wait for the fix to be in a new release, and then I can open an issue in coc.nvim. Clearly, coc.nvim doesn't work with nvim-lspconfig. I'm not sure why. I did the exact setup. Maybe there is something about this already fixed/opened.

nvarner commented 1 year ago

The new release, v0.10.0, is out now. @Andrew15-5 can you test again?

Andrew15-5 commented 1 year ago

Have you tested with coc.nvim yourself? There is no way it will work, because it doesn't check the lua config in the init.vim. Either you or nvim-lspconfig/coc.nvim should change something in order for it (coc.nvim) to read the config at all.

So I tried the initial test but updated to the newest version — of course it didn't work. But I'm sure nvim-cmp will work. I don't have time to test that.

cd "$(mktemp -d)"
wget https://github.com/nvarner/typst-lsp/files/12430172/typst-lsp-neovim.zip
unzip typst-lsp-neovim.zip
cd typst-lsp-neovim/
sed -i 's/0\.6\.2/0.10.0/' Dockerfile # Update init alias
just # cargo install just # sudo apt install -y cargo

# Inside container
init # After typst-lsp is installed, exit with `qZQ`
vi a.typ

# Inside Neovim add anything to the file & exit
ia<Esc>ZZ

# PDF file was created
ll a.pdf