michaelrommel / nvim-silicon

neovim plugin to create code images using the external silicon tool.
MIT License
110 stars 8 forks source link

Command `Silicon` not found after loading `nvim-silicon` #12

Closed thiagodebastos closed 4 months ago

thiagodebastos commented 4 months ago

I get this error on MacOS on an M2.

I have tried installing silicon via homebrew and via cargo. I have also tried setting the command property to point to the homebrew and cargo binary directly, but this issue still persists.

For example, the following did not help:

command = "/opt/homebrew/bin/silicon",

In both cases, I tested in the terminal and silicon is in fact in my path.

michaelrommel commented 4 months ago

Hi,

this is very strange. I have tried this with several installations and had no problems. I have refactored the code a lot today and added a debug = true option that you could use to track down the error. Can you try that please:

-- create code images
local opts = {
    "michaelrommel/nvim-silicon",
    -- dir = '/Users/rommel/Software/michael/nvim-silicon',
    lazy = true,
    cmd = "Silicon",
    opts = {
        debug = true,
        disable_defaults = true,
        output = "code.png",
        language = "rust",
        -- command = "/opt/homebrew/bin/silicon",
        -- command = "/Users/rommel/.local/share/mise/installs/rust/latest/bin/silicon"
    }
}

and report back, what message you see? Or try again the command parameter, as commented out above...

Oh, and please share the complete package manager installation fragment, that you are using. It looks to me, as if there might be something wrong/missing there.

Thanks,

Michael.

michaelrommel commented 4 months ago

Hello,

have you had a chance to try this with debug = true? Would like to close that topic soon!

Thanks!

Michael.

thiagodebastos commented 4 months ago

Hi @michaelrommel ! Apologies for the delay, I have tried your settings and that fixed the issue. I apologise if I wasted your time, it seems I had configured it incorrectly:

return {
  "michaelrommel/nvim-silicon",
  lazy = true,
  cmd = "Silicon",
  command = "/opt/homebrew/bin/silicon",
  config = function()
    require("silicon").setup(debug_opts)
  end,
  },
}

Updating it fixed it:

return {
  "michaelrommel/nvim-silicon",
  lazy = true,
  cmd = "Silicon",
  opts = my_opts, -- this fixed it
  },
}

I was confused by the README that made me think I needed to add the opts in the config prop:

{
    "michaelrommel/nvim-silicon",
    lazy = true,
    cmd = "Silicon",
    config = function()
        require("silicon").setup({
            -- Configuration here, or leave empty to use defaults
            font = "VictorMono NF=34;Noto Emoji=34"
        })
    end
},
michaelrommel commented 4 months ago

No problem and don't worry! I just wanted to make sure everyone is happy...

The Lazy package manager has different ways of specifying the configuration. The simplest method is just to specify an opts table on the same level as the cmd specification. Lazy then automatically calls the config() function with this as argument:

Property Type Description
opts table or fun(LazyPlugin, opts:table) opts should be a table (will be merged with parent specs), return a table (replaces parent specs) or should change a table. The table will be passed to the Plugin.config() function. Setting this value will imply Plugin.config()

I used different variations in the README to show different variants. But maybe that was more confusing than helpful...

In the last example from your last comment the part:

{
  - - Configuration here, or leave empty to use defaults
  font = "VictorMono NF=34;Noto Emoji=34"
}

is actually the opts table...

Glad that it works for you now! Have a good day!

Michael.

thiagodebastos commented 4 months ago

@michaelrommel oh thank you so much for that! I apologise for the oversight! Today I learned something new :) Have a great day too!