-
Notifications
You must be signed in to change notification settings - Fork 11
Improve API design #8
Comments
Thank you for opening the issue and your insights on improving the API design. I agree that the number of commands right now is not ideal. I quite like your 2nd option (two method option). It leads me to think that we can consider having arguments in our Vim commands. Something like: I didn't take the amount of commands into account when making the API. Changing the API now is not the difficult part, but how can we support users who're still using the old style commands. Not having command arguments was an oversight and a mistake. I suppose we could create a new branch that uses the new API for more "cleanliness", but is it necessary? Again, thank you so much for the PR and the issue. I'd love to hear your input on this. Cheers 👍 |
Hey @ziontee113, thanks for getting back to me so quickly!
Yeah definitely, so both options would support adding an
I like where your head is at! We definitely do not want to be breaking everyone's config overnight :) I think there are three options (please expand this list if you think of another option):
local function insert_user_choice_normal(choice)
vim.notify("WARNING: this command will be deprecated on YYYY-MM-DD with version 1.0.0. Please use new lua command `require('icon-picker').select`. See README for more information.")
if choice then
local split = vim.split(choice, " ")
vim.schedule(function()
vim.cmd("norm! a" .. split[1] .. "�")
end)
end
end You can add a specific date if you like and/or the version number when it will be deprecated (currently there are no versions, but you could consider add them). Here is a good resource on semantic versioning if you decide to version this project: https://semver.org/ I am looking forward to hearing from you! 😃 <- emoji yanked from |
Thank you for the suggestions. I think I've found the 4th solution, which is to give the user the choice to which type of commands (lua or vim cmd) to use. Since users will have to require("icon-picker").setup({
command_type = "arguments" | "legacy" -- legacy by default, for backwards compatibility
}) So we & the user can have the flexibility of choosing commands without breaking any existing users' config.
And the user will always have the option to use require('icon-picker').select({ mode = "paste", icons = {"emoji", "nerd"} }) |
Hi @logan-connolly , I've implemented the "arguments" method. With that approach I don't think users will need a Lua API for their mappings, since they can cherry pick the sources with arguments. 👍 |
I agree that having a I appreciate you taking the time to work through the comments though. I wish you the best in developing this plugin! and most importantly keep it fun :) |
Thank you for your feedback. I've added a fix so if users don't call the |
As mentioned in #7, I think there is an opportunity to improve the API of this package. Namely, shifting the focus around the actions as opposed to the symbols. From my point of view, this would have two main benefits:
n_actions * n_icon_sets
;Emoji + Nerd
.I think the easiest way to accomplish this is by making it into a lua package that exposes actions. Here is a very rough mock up of what the API could look like:
You may have noticed that I did not add insert mode as an option. The reason is that my hunch is that it is more of a matter of how you set the keybinding, as opposed to the actual function that is being used. Here is an example of how I imagine the key map could be set:
The text was updated successfully, but these errors were encountered: