benlubas / molten-nvim

A neovim plugin for interactively running code with the jupyter kernel. Fork of magma-nvim with improvements in image rendering, performance, and more
GNU General Public License v3.0
608 stars 33 forks source link

[Help] Virtual Text offset apply only to output text? #178

Closed hahuang65 closed 7 months ago

hahuang65 commented 7 months ago
vim.g.molten_virt_lines_off_by_1 = true

makes it such taht the output is outside the code fence markers...

But I also use virtual text for my diagnostics. This makes all the LSP diagnostics appear 1 line lower than where they actually should be.

Is there any way to have the offset ONLY apply to the output text?

benlubas commented 7 months ago

Molten doesn't have anything to do with diagnostics, that option shouldn't (doesn't) affect diagnostics at all.

hahuang65 commented 7 months ago

That's what I thought should be the case, but it doesn't seem to be.

Screenshot 2024-04-03 at 18 38 18 Screenshot 2024-04-03 at 18 39 10

The only change is vim.g.molten_virt_lines_off_by_1 = true

benlubas commented 7 months ago

this could possibly be the weirdest bug I've ever encountered. Which plugin are you using for the pretty diagnostics? I can look into it.

assuming that it's lsp-lines

hahuang65 commented 7 months ago

assuming that it's lsp-lines

yup

benlubas commented 7 months ago

I'm not able to replicate this :/

benlubas commented 7 months ago

If you could provide a minimal configuration that can still replicate it that'd be great.

There's a minimal config in the docs folder, you can start with that, add otter and lsp lines, and the provide a simple example and what you do to get the bug to occur. If it still reproduces then I can debug. If it doesn't, then we know it's somewhere else in your config and we can look into that.

hahuang65 commented 7 months ago

@benlubas thanks for looking into it. I'll try to get a minimal reproducible config tomorrow and let you know :)

hahuang65 commented 7 months ago

Okay, very curious. I was trying to make a minimal reproduction config, but got stuck at getting Quarto to run. It just wouldn't run, neither would otter.

So I tried a wholesale copy of my existing config, and was going to remove config bit by bit until the issue resolved... which is when I noticed something.

If I open the file directly with nvim notebooks/notebook.ipynb, Quarto does NOT activate automatically. I have to run :QuartoActivate... at which point, the diagnostics are on the correct line.

However, if I open nvim . and use netrw to navigate to notebooks/notebook.ipynb, Quarto will automatically run... and the diagnostics will be off by 1.

hahuang65 commented 7 months ago

Right, so if I just remove

local ok, quarto = pcall(require, "quarto")
if ok then
  quarto.activate()
end

which is the contents of after/ftplugin/markdown.lua then I have to manually activate... which "fixes" the issue.

I've also tried moving it to ftplugin/markdown.lua instead, thinking it might be an order of operations issue, but that results in teh same off-by-1 behavior.

benlubas commented 7 months ago

Does it still happen without molten installed?

hahuang65 commented 7 months ago

Aha! Yes, it DOES still happen with molten removed from the equation. I'm guessing this is an otter issue then.