Bug: Loading condition of "snacks-picker" provider seems to be broken #199

Open
opened 2025-08-10 04:37:38 -05:00 by ravsii · 3 comments
ravsii commented 2025-08-10 04:37:38 -05:00 (Migrated from github.com)

The code that loads snacks at the moment looks like this (assuming I found the correct place):

github.com/kawre/leetcode.nvim@422b6beb4a/lua/leetcode/picker/init.lua (L12-L19)

but that doesn't seem to work anymore:

  1. Snacks config doesn't have an enabled option
  2. Picker seems to be always active and available via Snacks.picker.pickerFunc(), like Snacks.picker.files()

So in order to make it work, I had to manually set a non-existent setting, so it looks like this:

return {
  {
    "kawre/leetcode.nvim",
    dependencies = {
      "folke/snacks.nvim",
      -- other deps
    },
    opts = function()
      ---@diagnostic disable-next-line: inject-field
      Snacks.config.picker.enabled = true

      --- @module 'leetcode'
      return {
        ---@type lc.picker
        picker = { provider = "snacks-picker" },
 
        -- other options
      }
    end,
  },
}

Without Snacks.config.picker.enabled = true it doesn't work, but :lua Snacks.picker.files()

Image

And if we check manually:

Image

And with the mention above fix it's working as expected:

Image
The code that loads snacks at the moment looks like this (assuming I found the correct place): https://github.com/kawre/leetcode.nvim/blob/422b6beb4a64eca0524fbff94edd9550c156afc5/lua/leetcode/picker/init.lua#L12-L19 but that doesn't seem to work anymore: 1. [Snacks config](https://github.com/folke/snacks.nvim/blob/main/docs/picker.md#%EF%B8%8F-config) doesn't have an `enabled` option 2. Picker seems to be always active and available via `Snacks.picker.pickerFunc()`, like `Snacks.picker.files()` So in order to make it work, I had to manually set a non-existent setting, so it looks like this: ```lua return { { "kawre/leetcode.nvim", dependencies = { "folke/snacks.nvim", -- other deps }, opts = function() ---@diagnostic disable-next-line: inject-field Snacks.config.picker.enabled = true --- @module 'leetcode' return { ---@type lc.picker picker = { provider = "snacks-picker" }, -- other options } end, }, } ``` Without `Snacks.config.picker.enabled = true` it doesn't work, but `:lua Snacks.picker.files()` <img width="1326" height="1042" alt="Image" src="https://github.com/user-attachments/assets/01573215-e62f-488d-8bba-312bbe56eead" /> And if we check manually: <img width="1326" height="1042" alt="Image" src="https://github.com/user-attachments/assets/483ec6da-5891-44db-8dd4-c5464ce17260" /> And with the mention above fix it's working as expected: <img width="1326" height="1042" alt="Image" src="https://github.com/user-attachments/assets/f5176665-f011-45b5-9eaf-033bf0ca32d2" />
kawre commented 2025-08-10 10:37:40 -05:00 (Migrated from github.com)

There is enabled option in snacks config -> https://github.com/folke/snacks.nvim?tab=readme-ov-file#-usage. Can you enable it and try again?

There is `enabled` option in snacks config -> https://github.com/folke/snacks.nvim?tab=readme-ov-file#-usage. Can you enable it and try again?
ravsii commented 2025-08-11 03:28:13 -05:00 (Migrated from github.com)

Hi. I checked the actual code just in case, and there's no enabled as well https://github.com/folke/snacks.nvim/blob/main/lua/snacks/picker/config/defaults.lua#L65

Sorry, my weekdays are usually a bit busy, I'll try to make a minimal reproducible example when I have time and come back with the results in a couple of days

Hi. I checked the actual code just in case, and there's no `enabled` as well https://github.com/folke/snacks.nvim/blob/main/lua/snacks/picker/config/defaults.lua#L65 Sorry, my weekdays are usually a bit busy, I'll try to make a minimal reproducible example when I have time and come back with the results in a couple of days
ravsii commented 2025-08-12 12:54:36 -05:00 (Migrated from github.com)

So, I checked using this setup, and it really does work. My original config used picker options, but I haven't set enabled = true, as there's no such option, according to the snacks types.

Pics & Code
require("lazy").setup({
  spec = {
    {
      "kawre/leetcode.nvim",
      dependencies = {
        { "folke/snacks.nvim", opts = { picker = { enabled = true } } },
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",
      },
      opts = { picker = { provider = "snacks-picker" } },
    },
  },
})
Image

Weirdly enough, Snacks.picker even works with picker.enabled = false, so it doesn't seem to really do anything (anymore?). Maybe the readme is just outdated.

Pics & Code

require("lazy").setup({
  spec = {
    {
      "kawre/leetcode.nvim",
      dependencies = {
        { "folke/snacks.nvim", opts = { picker = { enabled = false } } },
        "nvim-lua/plenary.nvim",
        "MunifTanjim/nui.nvim",
      },
      opts = { picker = { provider = "snacks-picker" } },
    },
  },
})
Image

The question is, should we rely on an option that's only mentioned once, or would it be better to rewrite the original function as pcall(Snacks.picker) or something similar?

So, I checked using this setup, and it really does work. My original config used picker options, but I haven't set `enabled = true`, as there's no such option, according to the snacks types. <details> <summary>Pics & Code</summary> ```lua require("lazy").setup({ spec = { { "kawre/leetcode.nvim", dependencies = { { "folke/snacks.nvim", opts = { picker = { enabled = true } } }, "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", }, opts = { picker = { provider = "snacks-picker" } }, }, }, }) ``` <img width="2416" height="1332" alt="Image" src="https://github.com/user-attachments/assets/f6da063a-7c3d-4717-bc24-c4a6ff61cc18" /> </details> Weirdly enough, `Snacks.picker` even works with `picker.enabled = false`, so it doesn't seem to really do anything (anymore?). Maybe the readme is just outdated. <details> <summary>Pics & Code</summary> ```lua require("lazy").setup({ spec = { { "kawre/leetcode.nvim", dependencies = { { "folke/snacks.nvim", opts = { picker = { enabled = false } } }, "nvim-lua/plenary.nvim", "MunifTanjim/nui.nvim", }, opts = { picker = { provider = "snacks-picker" } }, }, }, }) ``` <img width="2416" height="1332" alt="Image" src="https://github.com/user-attachments/assets/88fa5f45-afeb-4641-bb21-6c9b83f23da0" /> </details> --- The question is, should we rely on an option that's only mentioned once, or would it be better to rewrite the original function as `pcall(Snacks.picker)` or something similar?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
arduinohatesme/leetcode.nvim#199
No description provided.