-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: option to disable #85
feat: option to disable #85
Conversation
Moves config from main file to a separate file.
An additional consideration might be to change the individual declarations of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an issue with the setup call, otherwise nice work
lua/various-textobjs/config.lua
Outdated
if M.config.useDefaultKeymaps then | ||
require("various-textobjs.default-keymaps").setup(M.config.disabledKeymaps) | ||
end | ||
return M.config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think this needs a return value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the implementation I went with, the setup()
function both modifies the module's config
attribute and also returns a copy of it. If I were to use the setup()
only to set the user config, assigning the config could be done with the config
attribute instead in the init.lua
call.
Would this be preferred?
|
||
---optional setup function | ||
---@param userConfig? config | ||
function M.setup(userConfig) | ||
config = vim.tbl_deep_extend("force", defaultConfig, userConfig or {}) | ||
local config = require("various-textobjs.config").setup(userConfig) | ||
|
||
if config.useDefaultKeymaps then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default keymaps are now created twice
I think there were 1-2 exceptions to this, iirc the url text object. |
Previously, it returned a copy of the module. This is likely a bad pattern so it has been replaced by just having the user call the config attribut instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
btw, the returning of the config is not really a bad pattern, the return value is just unnecessary because it works have been never used, that is all |
Refactors config into a new file and then adds the option of
notifyNotFound
(default oftrue
) to allow disabling the notification.init.lua
configuration →configuration.lua
notifyNotFound
to configuration (default:true
)Example:
Peek.2024-05-18.00-53.mp4
Checklist
README.md (the
.txt
file is auto-generated and does not need to be modified).