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(keys): include custom keys in help menu #1105

Merged
merged 1 commit into from
Oct 12, 2023
Merged

Conversation

MariaSolOs
Copy link
Contributor

@MariaSolOs MariaSolOs commented Oct 12, 2023

Adds an optional description to custom keys. When present, the key is listed in the help menu.

This is how it looks:
image

if type(rhs) == "table" and rhs.desc then
self:append("- ", "LazySpecial", { indent = 2 })
self:append("Custom key ", "Title")
self:append(lhs, "LazyProp")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not surrounding the keys with angle brackets here because it looked kind of odd with mappings like <localleader>t, but I'm open to other ways to format these.

@folke folke merged commit 43c284a into folke:main Oct 12, 2023
3 checks passed
@folke
Copy link
Owner

folke commented Oct 12, 2023

Nice, thanks!!

As a thank you, here are my two custom Telescope keymaps, related to lazy I'm using all the time, that you may find useful as well :)

Especially the seconds one is really useful to quickly navigate to a spec somewhere in your config.

    keys = {
      {
        "<leader>fp",
        function()
          require("telescope.builtin").find_files({
            cwd = require("lazy.core.config").options.root,
          })
        end,
        desc = "Find Plugin File",
      },
      {
        "<leader>fl",
        function()
          local files = {} ---@type table<string, string>
          for _, plugin in pairs(require("lazy.core.config").plugins) do
            repeat
              if plugin._.module then
                local info = vim.loader.find(plugin._.module)[1]
                if info then
                  files[info.modpath] = info.modpath
                end
              end
              plugin = plugin._.super
            until not plugin
          end
          require("telescope.builtin").live_grep({
            default_text = "/",
            search_dirs = vim.tbl_values(files),
          })
        end,
        desc = "Find Lazy Plugin Spec",
      },
    },

@MariaSolOs MariaSolOs deleted the custom branch October 12, 2023 05:56
@MariaSolOs
Copy link
Contributor Author

@folke sweet, thanks for the lazy goodies :)

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

2 participants