Skip to content
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(mini-pairs): add toggle function #1456

Merged
merged 1 commit into from
Sep 26, 2023
Merged

feat(mini-pairs): add toggle function #1456

merged 1 commit into from
Sep 26, 2023

Conversation

kevintraver
Copy link
Contributor

Add function and keymap to toggle mini pairs.

lua/lazyvim/util/init.lua Outdated Show resolved Hide resolved
lua/lazyvim/util/init.lua Outdated Show resolved Hide resolved
@dpetka2001
Copy link
Contributor

dpetka2001 commented Sep 21, 2023

@kevintraver

Couldn't we just do the following

return {
  {
    "echasnovski/mini.pairs",
    keys = {
      {
        "<leader>up",
        function()
          local Util = require("lazy.core.util")
          vim.g.minipairs_disable = not vim.g.minipairs_disable
          if not vim.g.minipairs_disable then
            Util.info("Enabled auto pairs", { title = "Option" })
          else
            Util.warn("Disabled auto pairs", { title = "Option" })
          end
        end,
        desc = "Toggle mini.pairs",
      },
    },
  },
}

Why introduce new code of other plugins in lazyvim.util? This way the change will be entirely dependent on the plugin itself.

@jyuan0
Copy link
Contributor

jyuan0 commented Sep 21, 2023

@kevintraver

Couldn't we just do the following

return {
  {
    "echasnovski/mini.pairs",
    keys = {
      {
        "<leader>up",
        function()
          local Util = require("lazy.core.util")
          vim.g.minipairs_disable = not vim.g.minipairs_disable
          if not vim.g.minipairs_disable then
            Util.info("Enabled auto pairs", { title = "Option" })
          else
            Util.warn("Disabled auto pairs", { title = "Option" })
          end
        end,
        desc = "Toggle mini.pairs",
      },
    },
  },
}

Why introduce new code of other plugins in lazyvim.util? This way the change will be entirely dependent on the plugin itself.

This is pretty much what I was thinking of too. The mapping and function can all be part of the plugin spec.

@kevintraver
Copy link
Contributor Author

Ok, I updated the keymap to be in the spec. I also switched the enabled/disabled logic and remove the not to make the logic more clear.

Copy link
Contributor

@jyuan0 jyuan0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Only other improvement I can think of is a more descriptive title than "Option", but it's minor.

Copy link
Contributor

@jyuan0 jyuan0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks fine. In case you're not aware, you'll have to wait until folke (the maintainer of LazyVim) returns from vacation for any additional feedback, and to get this merged.

@folke folke merged commit a7f971f into LazyVim:main Sep 26, 2023
@folke
Copy link
Collaborator

folke commented Sep 26, 2023

thansk!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants