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

FEATURE: Set Keymap Description #1413

Open
1 task done
JustBarnt opened this issue Mar 23, 2024 · 0 comments · May be fixed by #1414
Open
1 task done

FEATURE: Set Keymap Description #1413

JustBarnt opened this issue Mar 23, 2024 · 0 comments · May be fixed by #1414
Labels
enhancement New feature or request

Comments

@JustBarnt
Copy link

JustBarnt commented Mar 23, 2024

Did you check the docs?

  • I have read all the docs.

Is your feature request related to a problem? Please describe.

I currently find it very inconvenient that a keymap can only be set by doing the following

  • Having to write the entire function in the value of the key.
  • Because if you try the following and replace the function call with a string related to a command the description in the help popup becomes just the name of the command. Ex: 'toggle_filesystem'
...
 ...
   mappings = {
     ["e"] = { function() ... end, desc = "Toggles Filesystem" } -- Help says "Toggles Filesystem
   }

Describe the solution you'd like.

I think it would make sense to be able to the same if you have a command written and you are calling that command you could still pass a table similar to what I have above

...
 ...
   mappings = {
     ["e"] = { 'toggle_filesystem' , desc = "Toggle Filesystem" } -- Popup should show 'Toggle Filesystem' instead of 'toggle_filesystem'
   }

Describe alternatives you've considered.

I've read the docs regarding mappings and commands. I have already tried setting a description like I did above in the proposed solution, but the only time my desc key took effect was when I write the function instead of calling a command.

Additional Context

Current opts set in my lazyvim

{
        open_files_do_not_replace_types = { "terminal", "trouble", "qf", "edgy" },
        default_component_configs = {
            file_size = { enabled = false },
            type = { enabled = false },
            last_modified = { enabled = false },
            created = { enabled = false },
        },
        window = {
            mappings = {
                ["e"] = {
                    function(_)
                        vim.api.nvim_exec2("Neotree focus filesystem left", { output = true })
                    end,
                    desc = "Toggle File Explorer", -- Sets help in popup to "Toggle File Explorer"
                },
                ["g"] = {
                    function(_)
                        vim.api.nvim_exec2("Neotree focus git_status left", { output = true })
                    end,
                    desc = "Toggle Git Status", -- Sets help in popup to "Toggle Git Status"
                },
                ["b"] = {
                    function(_)
                        vim.api.nvim_exec2("Neotree focus buffers left", { output = true })
                    end,
                    desc = "Toggle Open Buffers", -- Sets help in popup to "Toggle Open Buffers"
                },
                ["D"] = { 
                    "diff_files", 
                     config = { desc = "Diff Two Files" } -- Help still says "diff_files" instead of "Diff Two Files"
                },
                -- ["D"] = { 
                    -- "diff_files", 
                     -- desc = "Diff Two Files" 
                -- },
            },
        },
        commands = {
            diff_files = function(state)
                vim.print(vim.inspect(state.config))
                local node = state.tree:get_node()
                local log = require "neo-tree.log"
                state.clipboard = state.clipboard or {}
                if diff_Node and diff_Node ~= tostring(node.id) then
                    local current_Diff = node.id
                    require("neo-tree.utils").open_file(state, diff_Node, open)
                    vim.cmd("vert diffs " .. current_Diff)
                    log.info("Diffing " .. diff_Name .. " against " .. node.name)
                    diff_Node = nil
                    current_Diff = nil
                    state.clipboard = {}
                    require("neo-tree.ui.renderer").redraw(state)
                else
                    local existing = state.clipboard[node.id]
                    if existing and existing.action == "diff" then
                        state.clipboard[node.id] = nil
                        diff_Node = nil
                        require("neo-tree.ui.renderer").redraw(state)
                    else
                        state.clipboard[node.id] = { action = "diff", node = node }
                        diff_Name = state.clipboard[node.id].node.name
                        diff_Node = tostring(state.clipboard[node.id].node.id)
                        log.info("Diff source file " .. diff_Name)
                        require("neo-tree.ui.renderer").redraw(state)
                    end
                end
            end,
        },
    }
@JustBarnt JustBarnt added the enhancement New feature or request label Mar 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant