michaelrommel / nvim-silicon

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

Feature Request: Lua Function Keymap #16

Closed kevintraver closed 4 months ago

kevintraver commented 5 months ago

Feature Request: Ability to set keymap using a lua function.

Example:

keys = {
  {
    "<leader>ci",
    function()
      require("silicon").silicone()
    end,
    desc = "Create Silicone Code Image"
  },
},

Happy to help with a PR.

dan-myles commented 5 months ago

please! this would make it a lot easier to integrate with keybinds

michaelrommel commented 5 months ago

Yes, I am working on it. Need to find out, how to manage options and arguments in the best way...

michaelrommel commented 5 months ago

Hi,

there is a new branch called luashooter. Please check it out, I still need to test existing functionality,

I use which-key to manage all keymappings, this is the config I used it with:

    wk.register({
        ['s'] = { function() require("nvim-silicon").shoot() end, "Create code screenshot" },
    }, { prefix = "<leader>", mode = "v" })
    wk.register({
        ['s'] = { function() require("nvim-silicon").shoot() end, "Create code screenshot" },
    }, { prefix = "<leader>", mode = "n" })

Can you give it a whirl?

Michael.

michaelrommel commented 5 months ago

@avvo-na would you give the branch a try? Regarding your fun facts 😸:

i will ... probably want to try to write most i can in Rust, I think it is an interesting approach love motorcycles - love too, thinking of buying a BMW R18 enjoy ricing linux - hm, terminal, tmux and neovim are dope and I LOVE wezterm and VictorMono C++ should have a package manager - I honestly like 'mise' that allows me to manage language versions, I can deal with the package mangers of rust or node... JS on the backend was a mistake - not sure I agree with this: I like the uniform language approach. BUT: the thousands of package dependencies, the security issues, the constant updates are a nightmare. But I guess every higher level backend will eventually suffer from the same problem...

Sorry, but not sorry for misusing this issue :-) Greetings to Arizona from lovely Bavaria...

CU,

Michael.

dan-myles commented 5 months ago

hahah, thanks for the in-depth responses, ill go ahead and give this a try later today and report back

dan-myles commented 5 months ago

seems to be working great! going to keep using this branch for now :) ...

just as a heads up, not sure if it was intentional, you changed the name of the module from silicon to nvim-silicon and that gave me some errors at first

michaelrommel commented 5 months ago

Yeah, the name change was intentional, I thought when the git name was nvim-silicon, the name of the lua module should match... Glad that it works, then I am to commit to master in the next days...

Cheers,

Michael.

michaelrommel commented 5 months ago

Hm, I realize now your point. We have now roughly 600 installations and if I correct the initial naming mistake, it would be a breaking change for all of them. Need to figure out a way to make that transition smoother, probably with deprecation notices, but without being too pushy. I have to research that, how it is best done...

dan-myles commented 4 months ago

Hm, I realize now your point. We have now roughly 600 installations and if I correct the initial naming mistake, it would be a breaking change for all of them. Need to figure out a way to make that transition smoother, probably with deprecation notices, but without being too pushy. I have to research that, how it is best done...

Hi, just coming back to this! Is it possible to use that new lua function with WSL2 on windows to save to clipboard?

michaelrommel commented 4 months ago

I have created a prototype. The clipboard functionality is built into silicon and that does not work with WSL2. But I have created a script that can push a created image to the Windows clipboard. I am not figuring out, what the best way is to enable this in the config and only on WSL.

Stay tuned.

michaelrommel commented 4 months ago

Hey @avvo-na,

can you now please try the new branch wslclipimg. This contains all code necessary to push images from WSL2 to Windows clipboard and also shows a deprecation notice properly, when people still use the superseded require("silicon") statement.

I have not run all possible tests, but so far it looks good on my system.

Cheers,

Michael.

dan-myles commented 4 months ago

Sounds good, I will try it later when I have a chance! Thanks <3

michaelrommel commented 4 months ago

I have published the changes to main now. Please change your plugin manager to use main again, as I will delete the two feature branches shortly.

Thanks for your suggestions and testing!