Lazygit documentation typo: svim instead of vim
Did you check docs and existing issues?
- [x] I have read all the snacks.nvim docs
- [x] I have updated the plugin to the latest version before submitting this issue
- [x] I have searched the existing issues of snacks.nvim
- [x] I have searched the existing issues of plugins related to this issue
Neovim version (nvim -v)
not related
Operating system/version
not related
Describe the bug
https://github.com/folke/snacks.nvim/blob/main/docs/lazygit.md
You have svim instead of vim in config: theme_path = svim.fs.normalize(vim.fn.stdpath("cache") .. "/lazygit-theme.yml"),
Steps To Reproduce
Expected Behavior
Repro
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
},
})
As far as I know the docs are automatically generated from the code. And in the code svim is a valid wrapper for vim, the reason being that in Neovim versions <0.11 vim.fs.normalize did not work correctly for Windows paths.
Look through the code and git blame for more info. I'm sure there was an issue about it but can't remember off the top of my head.
@dpetka2001 hm..., but that's doesn't work in vim 0.11.5. If I change vim to svim, as it said in the docs, I will get an error:
Error detected while processing /home/me/.config/nvim/init.lua:
Failed to load plugins.snacks
/home/me/.config/nvim/lua/plugins/snacks.lua:76: attempt to index global 'svim' (a nil value)
Even if that is the correct code for nvim < 0.11, that seems not correct for nvim >= 0.11. Any way that should be either mentioned that in nvim > 0.11 it should be vim instead of svim or we have to change it to vim and mention somewhere that for nvim < 0.11 you have to use svim instead
That code is only meant to be used in the Snacks codebase. You should use vim.fs.normalize in your configuration. I just don't know if it's an easy fix for the docs, since that code already gets generated from the source files in Snacks and I believe even if you fix it with a PR it will probably will get auto-generated again next time the docs are built, but I might be wrong about it. Hopefully maintainer will have a better solution.
@dpetka2001 yeah, probably it will be overriten. I didn't pay attention that docs are autogenerated. But I don't get what you mean by "That code is only meant to be used in the Snacks codebase. You should use vim.fs.normalize in your configuration." Firstly, why it is only meant to be used in the snacks codebase if we provide the links to the documentation pages on the main page's readme? Also, the docs are provided with screenshots, take a look at the lazygit's docs for example. Is that also meant to be used for internal codebase only? "You should use vim.fs.normalize in your configuration." - probably people may not know that and that's normal for people to go to the documentation and see how to configure snacks, that is the main point of the documentation. But yeah, I should probably delete my PR
Yeah your PR probably won't fix that. But don't close this issue. Maintainer will definitely have a better idea on how to improve the docs.
I believe if you change your configuration into the following
{
"folke/snacks.nvim",
opts = function(_, opts)
opts.lazygit = opts.lazygit or {}
opts.lazygit.theme_path = svim.fs.normalize(vim.fn.stdpath("cache") .. "/lazygit-theme1.yml")
end,
},
then you won't get any error and you will see that a new file lazygit-theme1.yml created instead of the default one.
I believe this happens because svim is only available once Snacks will load. But the problem is that lazy.nvim parses the plugin spec and when opts is a table, it will directly parse it and you will get the error you said. If you make opts a function, then its evaluation will get deferred until the plugin actually loads and you won't get an error from svim.fs.normalize during the parsing phase, because by then svim will be available.
PS: Still the better solution is to fix the docs and for users to understand that they should use vim.fs.normalize in their configuration in my opinion.
@dpetka2001 I think you are right, that's a reason of the error.
Any way, that's seems not very convenient for me to configure snacks through opts as function and not as table
Of course, you are right. I did not insinuate otherwise. I was just playing around to see why it wasn't working and just thought I'd mention the reason here.
@dpetka2001 Of course, that was useful to know, thank you. I didn't mean to insinuate that you wrote that as an instruction for me on how I should configure snacks :) I'm just saying like "ahahah, if we really were to setup the plugin this way it would be a pain in the ass :D"