camspiers / snap

A fast finder system for neovim.
The Unlicense
490 stars 17 forks source link

Crash from overwriting core string table #93

Open Leolainen opened 5 months ago

Leolainen commented 5 months ago

Hello! Thanks for an excellent plugin!

I've had problems with crashes when using absolute paths. Some debugging points to the string table being entirely overwritten in lua/snap/producer/ripgrep/general.lua. The string function imported from lua/snap/common/string.lua contains only a split function (and "aniseed/locals"). So string.format function ended up being nil, causing a crash.

Screenshot 2024-06-06 at 16 35 33

My problem is solved by changing a line in lua/snap/common/string.lua:

local _2amodule_name_2a = "snap.common.string"
local _2amodule_2a
do
    package.loaded[_2amodule_name_2a] = string <-- changed {} to string
    _2amodule_2a = package.loaded[_2amodule_name_2a]
end

This is my config that crashed:

snap.register.map({ "n" }, { "<Leader>sT" }, function()
                snap.run {
                    producer = snap.get 'producer.ripgrep.vimgrep'.args({
                        '--hidden',
                    }, vim.fn.systemlist('git rev-parse --show-toplevel')[1]),
                    select = snap.get 'select.vimgrep'.select,
                    multiselect = snap.get 'select.vimgrep'.multiselect,
                    views = { snap.get 'preview.vimgrep' },
                    steps = { {
                        consumer = snap.get 'consumer.fzf',
                        config = { prompt = "FZF>" }
                    } },
                }
            end)

This seem to have solved my issue, for now. But it's probably better if any contributors would look into it.

I'm not very experienced with Lua, and fennel even less so, nor have I found anyone else reporting the same issue so I can't tell if this is a real bug or just a "me" problem. For context: I'm on a mac with Neovim 0.10.0 and using LunarVim.