-
Notifications
You must be signed in to change notification settings - Fork 328
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
Vimscript plugin not loading when key is activated #97
Comments
The keys should be You also use |
I tried using |
Looking at some of the recently closed issues, I tried the following: {
'zirrostig/vim-schlepp',
keys = {
{'<plug>SchleppUp', mode = "v"},
{'<s-down>', mode = "v"},
},
}, Pressing
|
Can you provide a minimal init.lua? And add in the keys that worked with packer. |
Here's a minimal config for local install_path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.fn.system({'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path})
vim.api.nvim_command('packadd packer.nvim')
end
local packer = require('packer')
local use = require('packer').use
local plugins = function()
-- Packer
use {'wbthomason/packer.nvim'}
-- Firenvim
use {
'zirrostig/vim-schlepp',
keys = {'<Plug>SchleppUp', '<Plug>SchleppDown'}
}
end
packer.startup(plugins)
local map = vim.keymap.set
map ("v", [[<s-up>]], [[<Plug>SchleppUp]], {noremap = false})
map ("v", [[<s-down>]], [[<Plug>SchleppDown]], {noremap = false}) Here's for local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup {
{
'zirrostig/vim-schlepp',
keys = {'<plug>SchleppUp', '<Plug>SchleppDown'},
},
}
local map = vim.keymap.set
map ("v", [[<s-up>]], [[<Plug>SchleppUp]], {noremap = false})
map ("v", [[<s-down>]], [[<Plug>SchleppDown]], {noremap = false}) |
I see this issue has been closed. I just updated to the latest version of lazy. The plugin is still not loading. |
Sorry, forgot to mention that you need to fix your mapping: {
"zirrostig/vim-schlepp",
keys = { { "<Plug>SchleppUp", mode = "v" }, { "<Plug>SchleppDown", mode = "v" } },
}, |
Thanks for the fix, but it still doesn't work. Holding shift and up (as defined by the keybinding) works once and then stops. Here's a video. 2022-12-22.18-50-40.mp4 |
Just pushed another fix. Can you verify? |
Issue fixed, thanks!!!! Sorry for taking too much of your time. |
This might also be related. I use the plugin called vim-sandwich and I have the keymapping below to replace a pair of parenthesis, brackets, etc. map ("n", [[gsr]], [[<plug>(operator-sandwich-replace)<plug>(textobj-sandwich-query-a)]], {noremap = false})
map ("n", [[gsrr]], [[<plug>(operator-sandwich-replace)<plug>(textobj-sandwich-auto-a)]], {noremap = false}) This is how I call the plugin. {
'machakann/vim-sandwich',
keys = {
{ "<plug>(operator-sandwich-replace)", mode = "n" },
},
config = function() require('main.plugin.sandwich') end
}, When I press I tried doing this, but it got an error when loading vim. {
'machakann/vim-sandwich',
keys = {
{ "<plug>(operator-sandwich-replace)<plug>(textobj-sandwich-query-a)", mode = "n" },
},
config = function() require('main.plugin.sandwich') end
}, |
Just checked that vimtex also doesn't seem to work. The plugin is supposed to load inside {
'lervag/vimtex',
ft = { 'tex' },
config = function() vim.cmd('source ' .. path .. 'vimtex.vim') end
}, Inside a |
Do not load filetype plugins (like vimtex) on Just set |
|
Sorry, that can't be -- this is a known and documented fact that loading VimTeX on a
Report it to the plugin author so they can fix it. |
As I am just a user, I assumed that packer was indeed not loading the plugin. Here's a video showing that. Is packer faking it (that the plugin is not loaded) ? packer_vimtex.mp4 |
I will check if this is lazy, but @clason is probably right. What lazy does when lazy-loading on a filetype:
But since there is a specific message in vimtext docs about lazy-loading, there's probably a very specific reason why this does not work there. The plugins I'm using |
Thanks for the update. Can you tell whether packer is actually loading the plugin even when it says "not loaded"? |
I can confirm that the original issue is back. Will look into it further tomorrow. @medwatt I can't tell you anthing about packer. no idea |
I confirm that |
It should obviously work when you remove that line since it is no longer lazy-loaded. |
are you able to operate on the |
About the original issue with the keys, I suspect this to be a Neovim issue, but might be a feature, I don't know vim.keymap.set("n", "<Plug>Foobar", error)
vim.keymap.set("n", "F", "<Plug>Foobar")
vim.keymap.del("n", "<Plug>Foobar")
vim.keymap.del("n", "<Plug>Foobar") The code above correctly gives an error on line 4 that the keymap does not exist. vim.keymap.set("n", "<Plug>Foobar", error)
vim.keymap.set("n", "<c-f>", "<Plug>Foobar")
vim.keymap.del("n", "<Plug>Foobar")
vim.keymap.del("n", "<Plug>Foobar") Same code, but now I use |
I've posted an issue at Neovim's repo neovim/neovim#21530 |
I was able to fix this, by making sure we only delete the lazy key mapping once |
I would like to understand what the "Plug" directive (in brackets) does. Can anyone point me where I can find the documentation for that? @gennaro-tedesco make sure ft is a table of strings which signify filetypes. Try that and lemme know if that doesn't work. |
As per the examples in the README, |
@GersiD |
@folke, while the issue is solved for the plugin I initially mentioned, there are still cases that use Here's a minimal config that you can use. Position the cursor inside a local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup {
{
'machakann/vim-sandwich',
keys = {
{ "<plug>(operator-sandwich-add)", mode = "n" },
{ "<plug>(operator-sandwich-delete)", mode = "n" },
{ "<plug>(operator-sandwich-replace)", mode = "n" },
},
},
}
vim.keymap.set ("n", [[gsrr]], [[<plug>(operator-sandwich-replace)<plug>(textobj-sandwich-auto-a)]], {noremap = false}) Here, the plugin doesn't even load. local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
require("lazy").setup {
{
'booperlv/nvim-gomove',
keys = {
{"<plug>GoNSMDown", mode = "v"},
{"<plug>GoNSMUp", mode = "v"}
}
},
}
vim.keymap.set ("v", [[<s-down>]], "<plug>GoVSMDown")
vim.keymap.set ("v", [[<s-up>]], "<plug>GoVSMUp") |
In your second example, the plugs are different |
In your first example, those are operator pending modes, so the mappings are incorrect? |
It's operator pending mode with |
@medwatt I think I was able to fix it. Hopefully for good now ;) |
Seems fixed. Thanks once more. |
I think I was able to fix the Vimtex lazy-loading on ft="tex". Would be great if you could confirm, since I don't use Vimtext myself. |
Seems fixed. Nice !! |
@folke, is it possible to load a module using a vim function? For example, I am using a plugin called floaterm that allows you to create custom floating terminals by calling a vim function (see here). For example: vim.fn['floaterm#new'](false, cmd, {null="null"}, floaterm_config) How do I load the plugin when |
That's not possible and I'm not planning on adding this functionality |
Haven't tested this, but something like the below in vim.fn["floaterm#new"] = function(...)
vim.fn["floaterm#new"] = nil
require("lazy").load({ plugins = { "vim-floaterm" } })
return vim.fn["floaterm#new"](...)
end |
Describe the bug
I am trying testing out this plugin. Everything seems to be going fine, except when lazy loading some vim plugins.
This is how things are setup in
packer
.Kepmapping defined in some other file:
I tried this with
lazy
, but it is not loaded when I press the trigger keys.Which version of Neovim are you using?
v0.8.1
The text was updated successfully, but these errors were encountered: