-
-
Notifications
You must be signed in to change notification settings - Fork 15
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
set up keymaps when plugin is lazy loaded #73
Conversation
lua/jupynium/init.lua
Outdated
local filename = vim.fn.expand "%" | ||
local buf_id = vim.api.nvim_get_current_buf() | ||
for _, pattern in ipairs(options.opts.jupynium_file_pattern) do | ||
if utils.string_wildcard_match(filename, pattern) 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.
You can instead use list_wildcard_match
and then remove the for loop?
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.
Can you also add a comment that this part is needed when you add lazy loading like event = "BufWinEnter *.ju.*"
in lazy.nvim?
If you lazy load it this way, what happens to the vim commands? Does Also, will auto attach to server work? |
I think the commands are loaded alright, but the auto starting server needs update as well. We can address this in a separate PR. |
this is a broader but related issue: is this the best way to do buffer-local keybinds? because the current implementation, and in this PR, non-default/user-defined keymaps remain global, requiring the user to set up autocommands themselves would it not make more sense to expose an |
Thanks for the idea, @sho-87! I get your point, but for things as simple as keymapping, I prefer not to add too many configurations that will make it harder to understand the structure, maintain the plugin and deprecate things at some point. I added the default keybindings not because I think that'd fit for everyone, but more because it'd make it easier to get started with the plugin and understand how things work. I still think that the best way to use the plugin is to turn off the default keybindings and add them on your own. |
@sho-87 Also, the current autocmd solution is not the best solution because it will remap the keybindings every time you enter |
I think this merge broke custom keymaps on my end - can you check if this is also the case on yours? @kiyoon @matthewsia98 after connecting to a server, the default keymaps always show up even though my config has them turned off reverting to the previous commit (93e4690) makes things work as expected |
Interesting, maybe the setup gets automatically called with the default configuration due to I'll probably need to move this into |
Hmmmm interesting indeed. function M.setup(opts)
print("setup")
print(vim.inspect(opts))
end On opening a |
Does the fix work if you pull the recent version? |
No..setup still gets called twice, first with |
yeah latest version still shows default binds |
Weird, it only gets called once for me |
Okay, I see that it gets called twice if the plugin is lazy-loaded. So even the What do you think? |
Can we not just add a |
This plugin is only compatible with neovim anyway. This is just there to make it possible to use without calling the setup function. Other plugins have this too. I thought lazy.nvim should call configuration before loading this file. |
I'll just remove the keymapping part for now. If you're lazy loading, you'll need to deal with the consequences. So you can do the following as you said: return {
"kiyoon/jupynium.nvim",
build = "pip3 install --user .",
event = "BufWinEnter *.ju.py",
config = function()
local jupynium = require("jupynium")
jupynium.setup({})
jupynium.set_default_keymaps()
require("jupynium.textobjects").set_default_keymaps()
end
} |
I just made another fix. @sho-87 |
working now, thanks! |
Addresses #72
Alternatively, we can skip the checks on setup and just expose the
set_default_keymaps
functions and leave it to the user to call them if they are lazy loading the plugin. Something like