rawnly / gist.nvim

Neovim plugin that allows you to create a Github Gist from the current file
MIT License
187 stars 5 forks source link

Global variables for configuring plugin didn't work #6

Closed lnc3l0t closed 1 year ago

lnc3l0t commented 1 year ago

This PR fixes an issue with pcall and nvim_get_var that caused the global variables for configuring the plugin to not work properly. The original code used a table with 2 strings in the pcall call, but nvim_get_var expected only a single string not a table (:h nvim_get_var).

If a table is passed as the second argument to pcall, its items are not treated as single argument to pass to multiple function calls. (though that would be cool)

pcall({f}, {arg1}, {...})                                       *luaref-pcall()*
        Calls function {f} with the given arguments in `protected mode`.

To fix this issue, I modified the code to read the 2 global variables (gist_is_private and gist_clipboard) in 2 separate calls to nvim_get_var.

I have tested this change on my local machine and verified that it works as expected.

rawnly commented 1 year ago

Thank you very much! Appreciated