cshuaimin / ssr.nvim

Treesitter based structural search and replace plugin for Neovim.
MIT License
933 stars 13 forks source link

need a command for this plugin #20

Closed MrZLeo closed 1 year ago

MrZLeo commented 1 year ago

I think I need a command like Lazy or Mason for ssr.nvim in order to lazy load this plugin with lazy.nvim.

This is what I want to do:

    {
        "cshuaimin/ssr.nvim",
        config = function()
            require("ssr").setup {
                min_width = 50,
                min_height = 5,
                max_width = 120,
                max_height = 25,
                keymaps = {
                    close = "q",
                    next_match = "n",
                    prev_match = "N",
                    replace_confirm = "<cr>",
                    replace_all = "<leader><cr>",
                },
            }
        end,
        cmd = 'SsrOpen'
    },

cmd is the event that trigger loading of this plugin, so I can load it when I need it.

Please consider it as a feature. Thanks!

cshuaimin commented 1 year ago

Lazy.nvim can lazy load plugins with various methods, cmd is just one of it. You can set lazy = true to lazy load plugin by lua modules, which means it's only loaded with you call require.

Also note that if you don't want to change the default configs, you don't need to call setup at all.

{ "cshuaimin/ssr.nvim", lazy = true },
MrZLeo commented 1 year ago

Lazy.nvim can lazy load plugins with various methods, cmd is just one of it. You can set lazy = true to lazy load plugin by lua modules, which means it's only loaded with you call require.

Also note that if you don't want to change the default configs, you don't need to call setup at all.

{ "cshuaimin/ssr.nvim", lazy = true },

Yes, I choose lazy = true right now. But, as far as I am concerned, I need to :Lazy load ssr.nvim to activate the plugin. What I truly want is load this at some point that I really use ssr.nvim.

cshuaimin commented 1 year ago

You don’t need to call “:Lazy load”, the plugin will be loaded when you require it in keymap function.

vim.keymap.set({ "n", "x" }, "<leader>sr", function() require("ssr").open() end)
MrZLeo commented 1 year ago

You don’t need to call “:Lazy load”, the plugin will be loaded when you require it in keymap function.

vim.keymap.set({ "n", "x" }, "<leader>sr", function() require("ssr").open() end)

Understand! It's good to know: ) Thanks!