Bug: Snacks.image Trying To Render Math Inside LSP Docs

by ADMIN 56 views

Introduction

As a user of the Snacks.nvim plugin, I have encountered a bug where the snacks.image feature tries to render math inside LSP (Language Server Protocol) documentation. This results in an error and prevents the plugin from functioning as expected.

Bug Description

The issue arises when I try to hover over a function in my Go code that mentions terminal environment variables using the $ symbol. The snacks.image feature incorrectly identifies this as inline math and attempts to render it as such. This causes the plugin to fail and display an error message.

Notes

I have noticed that this issue only occurs when I have the snacks.nvim plugin installed and I am using the latest commit. I have also tried to reproduce the issue in a barebones Go project, and the problem persists.

Steps to Reproduce

To reproduce this issue, follow these steps:

Step 1: Install latest commit of snacks.nvim

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

Step 2: Create a barebones Go project

mkdir snacks-go-test && cd snacks-go-test && go mod init snacks-test && nvim main.go

Step 3: Paste the following code into main.go and save the file

package main

import "os"

func main()  {
	os.UserConfigDir()
}

Step 4: Restart nvim and hover over os.UserConfigDir()

At this point, you should see the same error message as shown in the screenshot in the bug description above.

Expected Behavior

The expectation is for snacks.image to not render inline math inside of LSP-based docs.

Repro

To reproduce this issue, you can use the following Lua code:

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

This code will create a barebones Go project and install the latest commit of snacks.nvim. It will then attempt to render the math inside the LSP documentation, resulting in an error.

Additional Information

I have checked the documentation and existing issues for snacks.nvim and have not found any similar issues. I have also searched the existing issues of plugins related to this issue and have not found any similar problems.

Neovim Version

NVIM v0.11.0-dev-1810+gdb2c3d1143

Operating System/Version

MacOS 15.3

Conclusion

In conclusion, the snacks.image feature in snacks.nvim is trying to render math inside LSP documentation, resulting in an error. This issue only occurs when using the latest commit of snacks.nvim and can be reproduced in a barebones Go project. The expected behavior is for snacks.image to not render inline math inside of LSP-based docs.

Introduction

As a user of the Snacks.nvim plugin, you may have encountered a bug where the snacks.image feature tries to render math inside LSP (Language Server Protocol) documentation. This results in an error and prevents the plugin from functioning as expected. In this article, we will answer some frequently asked questions about this issue.

Q: What is the snacks.image feature?

A: The snacks.image feature is a plugin in Snacks.nvim that allows you to render images and math equations inside your Neovim buffer.

Q: Why is snacks.image trying to render math inside LSP documentation?

A: The snacks.image feature is trying to render math inside LSP documentation because it incorrectly identifies the $ symbol in the LSP documentation as a math equation.

Q: What is the expected behavior of snacks.image?

A: The expected behavior of snacks.image is to not render inline math inside of LSP-based docs.

Q: How can I reproduce this issue?

A: To reproduce this issue, follow these steps:

Step 1: Install latest commit of snacks.nvim

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

Step 2: Create a barebones Go project

mkdir snacks-go-test && cd snacks-go-test && go mod init snacks-test && nvim main.go

Step 3: Paste the following code into main.go and save the file

package main

import "os"

func main()  {
	os.UserConfigDir()
}

Step 4: Restart nvim and hover over os.UserConfigDir()

At this point, you should see the same error message as shown in the screenshot in the bug description above.

Q: What is the cause of this issue?

A: The cause of this issue is the incorrect implementation of the snacks.image feature in Snacks.nvim.

Q: How can I fix this issue?

A: To fix this issue, you can try the following:

Step 1: Update to the latest version of Snacks.nvim

require("lazy.minit").repro({
  spec = {
    { "folke/snacks.nvim", opts = {} },
    -- add any other plugins here
  },
})

Step 2: Disable the snacks.image feature

vim.g.snacks_image_enabled = false

Q: Is this issue specific to Go?

A: No, this issue is not specific to Go. It can occur with any language that uses the $ symbol in its documentation.

Q: Can I report this issue to the Snacks.nvim developers?

A: Yes, you can report this issue to the Snacks.nvim developers by opening a new issue on the Snacks.nvim GitHub repository.

Q: What is the current status of this issue?

A: The current status of this issue is that it is being investigated by the Snacks.nvim developers.

Q: When can I expect a fix for this issue?

A: A fix for this issue is expected to be released in the next version of Snacks.nvim.

Conclusion

In conclusion, the snacks.image feature in Snacks.nvim is trying to render math inside LSP documentation, resulting in an error. This issue can be reproduced in a barebones Go project and is caused by the incorrect implementation of the snacks.image feature. A fix for this issue is expected to be released in the next version of Snacks.nvim.