Git Product home page Git Product logo

commander.nvim's People

Contributors

al-ce avatar cagdassalur avatar d12bb avatar danielo515 avatar feiyoug avatar frankfang avatar lawrence-laz avatar mattdibi avatar naranyala avatar nargonath avatar okuramasafumi avatar tobinstultiens avatar zane- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

commander.nvim's Issues

Requests: ascedent order and remove current CommanderItems

I have two requests for command.nvim:

  1. Allow the commands to be shown in ascendent order [a-z]. Currently, we can define the components that are sorted, but they appear only in decrescent order [z-a]
  2. A function that eliminates all the current CommanderItems. When I reload the lua script that configures commander.nvim, all the CommanderItems appear twice. In this case, if we could eliminate the current Items, that repetition would not occur.

I don't think this plugin is needed

we should write keymaps, or using : in vim, if taking a step back, we still have Telescope Commands to search commands, I don't think add another menu is meaningful.

[Bug] <cmd>Telescope commander<cr> does not trigger the original command, but instead triggers the most recent command.

neovim config:

{
    "FeiyouG/commander.nvim",
    commit = "9febde3150e29915b72c2ee8da500d396c8dba03",
    dependencies = {
      "nvim-telescope/telescope.nvim",
    },
    keys = {
      {
        "<leader>fm",
        "<cmd>Telescope commander<cr>",
        desc = "telescope commander",
        mode = "n",
      },
    },
    config = function()
      require("commander").setup({
        -- Specify what components are shown in the prompt;
        -- Order matters, and components may repeat
        components = {
          "DESC",
          "KEYS",
          "CMD",
          "CAT",
        },

        -- Specify by what components the commands is sorted
        -- Order does not matter
        sort_by = {
          "DESC",
          "KEYS",
          "CMD",
          "CAT",
        },

        -- Change the separator used to separate each component
        separator = " ",

        -- When set to true,
        -- The desc component will be populated with cmd if desc is empty or missing.
        auto_replace_desc_with_cmd = true,

        -- Default title of the prompt
        prompt_title = "Commander",
        -- enable integration
        integration = {
          telescope = {
            enable = true,
          },
          lazy = {
            enable = true,
            -- set_plugin_name_as_cat = true,
          },
        },
      })
    end,
  }

desc:

Telescope commander does not trigger the original command, but instead triggers the most recent command.
eg:
1 Telescope commander --> show telescope table --> choose command "Find Files"
2 Telescope commander --> Find Files

The bug originated from commit 2b048d5.

Error requiring plugin: module 'commander.nvim' not found

I got this error while using 0.2 with example config on README.md (the minimal one)

Error detected while processing /home/chau/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/chau/.config/nvim/lua/command_palette.lua:1: module 'commander.nvim' not found:
        no field package.preload['commander.nvim']
cache_loader: module commander.nvim not found
cache_loader_lib: module commander.nvim not found
        no file './commander/nvim.lua'
        no file '/usr/share/luajit-2.1/commander/nvim.lua'
        no file '/usr/local/share/lua/5.1/commander/nvim.lua'
        no file '/usr/local/share/lua/5.1/commander/nvim/init.lua'
        no file '/usr/share/lua/5.1/commander/nvim.lua'
        no file '/usr/share/lua/5.1/commander/nvim/init.lua'
        no file './commander/nvim.so'
        no file '/usr/local/lib/lua/5.1/commander/nvim.so'
        no file '/usr/lib/lua/5.1/commander/nvim.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './commander.so'
        no file '/usr/local/lib/lua/5.1/commander.so'
        no file '/usr/lib/lua/5.1/commander.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        /home/chau/.config/nvim/lua/command_palette.lua:1: in main chunk
        [C]: in function 'require'
        /home/chau/.config/nvim/init.lua:6: in main chunk

From the paths listed, I can see it looking for commander/nvim/init.lua, so I changed it to just require('commander') and it works.

Set keybinding for non-commands

Hi,

thank you for this great plugin.

What do you think about adding keybindings for non-commands (just key sequences).
For example i have this keybinding in my config:

utils.map('n', '<leader>a', '"ayiw')

Would be nice to also add this into the command center.

/edit: This would also enable multiple commands. For example

utils.map('n', '<F5>', ':CMake build<CR>:copen<CR>')

lazy.nvim support to register commands with their plugin spec definition

One benefit I've found with switching to lazy.nvim is that it encourages grouping your config, keybindings, etc together with the plugin. I would love to be able to register commands in the same place.

I've found a way to do this that works, but figured I'd suggest this in case there's a shareable way to do it:

	{
		"gfeiyou/command-center.nvim",
		lazy = true,
		config = function()
			local command_center = require("command_center")

			local plugins = require("lazy").plugins()

			for _, plugin in ipairs(plugins) do
				if plugin.command_center then
					-- only add for enabled plugins
					-- copied from require('lazy.core.plugin').Spec:fix_disabled
					local enabled = not (
							plugin.enabled == false or (type(plugin.enabled) == "function" and not plugin.enabled())
						)

					if enabled then
						command_center.add(plugin.command_center)
					end
				end
			end
	},

[FeatReq] Different cmd per mode - like keybindings

I am new to vim with lua so this may make no sense... Lets do simple example: saving buffer.
In normal mode it is: :w<CR>
In insert mode it is: <Esc>:w<CR>a
And I would for example map those both to <c-s>

Now (I think) there is no way of adding this to the command center.

There is an option to add different keybinding per mode you are in, so for example you can run a command just by s in normal but <c-s> in insert but in both cases the command is the same, there is no way of passing different command for each mode.

I think it would be great addition to be able to invoke different commands dependent the mode you are currently in. What do you think?

The workaround I am currently thinking is to write lua function that will decide inside which cmd to run and pass the function to the command center, but I think CC should natively support this ;)

Reload on config source

Hi! I noticed that when I source my init.vim after changing something in the config the changed command will get appended to the list instead of replaced.
So for example, I have these set up

command_center.add({
	{
		description = "Show changed files",
		cmd = "<CMD>Telescope changed_files<CR>",
	},
	{
		description = "Edit init.vim",
		cmd = "<CMD>:e $CONFIG/nvim/init.vim<CR>",
	},
	{
		description = "Source init.vim",
		cmd = "<CMD>:source $CONFIG/nvim/init.vim<CR>",
	},
	{
		description = "Delete all buffers",
		cmd = "<CMD>:%bd|e#<CR>",
	},
})

if I change something, for example

command_center.add({
	{
		description = "I CHANGED THIS COMMAND",
		cmd = "<CMD>Telescope changed_files<CR>",
	},
	{
		description = "Edit init.vim",
		cmd = "<CMD>:e $CONFIG/nvim/init.vim<CR>",
	},
	{
		description = "Source init.vim",
		cmd = "<CMD>:source $CONFIG/nvim/init.vim<CR>",
	},
	{
		description = "Delete all buffers",
		cmd = "<CMD>:%bd|e#<CR>",
	},
})

and then run :source %, this is what I get:
image

keymap modes missing

Mode | Norm | Ins | Cmd | Vis | Sel | Opr | Term | Lang |
Command |------|-----|-----|-----|-----|-----|------|------|
[nore]map | yes | - | - | yes | yes | yes | - | - |
n[nore]map | yes | - | - | - | - | - | - | - |
[nore]map! | - | yes | yes | - | - | - | - | - |
i[nore]map | - | yes | - | - | - | - | - | - |
c[nore]map | - | - | yes | - | - | - | - | - |
v[nore]map | - | - | - | yes | yes | - | - | - |
x[nore]map | - | - | - | yes | - | - | - | - |
s[nore]map | - | - | - | - | yes | - | - | - |
o[nore]map | - | - | - | - | - | yes | - | - |
t[nore]map | - | - | - | - | - | - | yes | - |
l[nore]map | - | yes | yes | - | - | - | - | yes |

https://neovim.io/doc/user/map.html#map-overview

Encountering errors when using minimal examples

Hello, first: thanks for great plugin.

I have experienced following error:

Error executing Lua callback: ...vim/plugged/commander.nvim/lua/commander/model/Layer.lua:211: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
        [C]: in function 'pairs'
        ...vim/plugged/commander.nvim/lua/commander/model/Layer.lua:211: in function 'validate_cache'
        ...vim/plugged/commander.nvim/lua/commander/model/Layer.lua:92: in function 'get_commands'
        ...d/commander.nvim/lua/telescope/_extensions/commander.lua:20: in function <...d/commander.nvim/lua/telescope/_extensions/commander.lua:18>
        ...re/nvim/plugged/telescope.nvim/lua/telescope/command.lua:199: in function 'run_command'
        ...re/nvim/plugged/telescope.nvim/lua/telescope/command.lua:259: in function 'load_command'
        ...l/share/nvim/plugged/telescope.nvim/plugin/telescope.lua:108: in function <...l/share/nvim/plugged/telescope.nvim/plugin/telescope.lua:107>

When my config for commander was like this:

local command_center = require("commander")
command_center.add({{
   desc = "get github url to current line",
   cmd = '<CMD>lua require"gitlinker".get_buf_range_url()<CR>',
}})

(I have used this plugin named as command_center and didn't update variable name)

In order to make it work I have had to add any setup() call, this suffices:

command_center.setup({})

It only breaks when opening the commander telescope window but does not break using keys associated with commands.

I am using these versions (latest at this moment)

silent! let g:plugs['telescope.nvim'].commit = '6213322ab56eb27356fdc09a5078e41e3ea7f3bc'
silent! let g:plugs['commander.nvim'].commit = 'cef3cf34dc478b2cc27e72fb592690cba718a091'

[Bug] Plugin broken after last update

The following error is generated at Neovim startup after updating the plugin:

packer.nvim: Error running config for command-center.nvim: ...er\start\command-center.nvim/lua/command_center/init.lua:37: attempt to index local 'opts' (a number value)

Packer Config:

{
  "gfeiyou/command-center.nvim",
    config = function()
      require("user.cc").config()
      end,
    requires = "nvim-telescope/telescope.nvim",
},

Error if nothing was selected

  1. Open Command Center
  2. Type some gibberish until the filtered list list empty
  3. Hit <ENTER>

Alternatively, open Command Center without and bindings added and hit <ENTER>.

E5108: Error executing lua ...mand_center/lua/telescope/_extensions/command_center.lua:151: attempt to index local 'selection' (a nil value)
stack traceback:
        ...mand_center/lua/telescope/_extensions/command_center.lua:151: in function 'run_replace_or_original'
        ...ite/pack/paqs/opt/telescope/lua/telescope/actions/mt.lua:65: in function 'key_func'
        .../site/pack/paqs/opt/telescope/lua/telescope/mappings.lua:242: in function 'execute_keymap'
        [string ":lua"]:1: in main chunk

Telescope + CC config:

telescope.setup {
  extensions = {
    command_center = {
      -- Change what to show on telescope prompt and in which order
      -- Currently support the following three components
      -- Components may repeat
      components = {
        command_center.component.DESCRIPTION,
        command_center.component.KEYBINDINGS,
        -- command_center.component.COMMAND,
      },
      -- Change the separator used to separate each component
      separator = " ",
      -- When set to false,
      -- The description compoenent will be empty if it is not specified
      auto_replace_desc_with_cmd = false,
    }
  }
}

-- Plug Command Center into Telescope
telescope.load_extension('command_center')

`vim.keymap.set`

This looks really nice, but I have a suggestion:

With the (almost there) release of nvim 0.7, :h vim.keymap.set() was introduced. Maybe this could take similar syntax, but with an additional description field? This would make it both easier for the user (they do not need to change much about their configs, if they were to start using this plugin), and for the developer (they can just forward everything to vim.keymap.set())

After update cannot set keybinding mode to terminal

Hi, my config is partially broken after update to 31468fd.

Message I'm getting:

Invalid declaration of keys:
mode: expected one of { "n", "i", "c", "x", "v" }, got t
{ "t", "<C-\\>", {
    noremap = true
} }

Part of config in question:

command_center.add({{
    desc = "Toggle terminal",
    cmd = "<CMD>ToggleTerm<CR>",
    keys = {{"n", "<C-\\>", noremap}, {"t", "<C-\\>", noremap}}
}})

I have already tried to add t to the list in following line, and it seams to solve te issue. Is there any reason why it should't be there?
https://github.com/FeiyouG/command_center.nvim/blob/81a2200d90bcb2477d2db7375fe7aa9b8a9007d5/lua/command_center/constants.lua#L33

Anyway thanks for the work on this plugin. Apart for occasional issues, I really do enjoy using it.

[question] how to use themes?

Hi there, thanks for this amazing plugin. I would like to understand how to use themes. The config in the readme states one can use the command_center theme or any telescope or custom theme, but I don't understand where themes in theme = themes..command_center comes from. I also tried using a Telescope default theme, but because I lazy-load telescope, it becomes an chicken-or-egg problem where telescope is not yet loaded before I can require("telescope.themes") (at least that's my understanding of the error I'm getting, I'm still relatively new to lua/telescope).

Can you please help shed some like on what I might possibly be doing wrong here? Thanks!

Minor documentation issue: missing `command_center` tag

Another minor thing: in the configuration section there's a missing command_center tag.

Right now we have:

local telescope = require("telescope")
local command_center = require("command_center")

telescope.setup {
  extensions = {
    -- Below are default settings that can be overriden ...

    -- Change what to show on telescope prompt and in which order
    -- Currently support the following three components
    -- Components may repeat
    components = {
      command_center.component.DESCRIPTION,
      command_center.component.KEYBINDINGS,
      command_center.component.COMMAND,
    },

    -- Change the seperator used to seperate each component
    seperator = " ",

    -- When set to false,
    -- The description compoenent will be empty if it is not specified
    auto_replace_desc_with_cmd = true,
  }
}

telescope.load_extension("command_center")

But it should be:

local telescope = require("telescope")
local command_center = require("command_center")

telescope.setup {
  extensions = {
    command_center = {
      -- Below are default settings that can be overriden ...
  
      -- Change what to show on telescope prompt and in which order
      -- Currently support the following three components
      -- Components may repeat
      components = {
        command_center.component.DESCRIPTION,
        command_center.component.KEYBINDINGS,
        command_center.component.COMMAND,
      },
  
      -- Change the seperator used to seperate each component
      seperator = " ",
  
      -- When set to false,
      -- The description compoenent will be empty if it is not specified
      auto_replace_desc_with_cmd = true,
    }
  }
}

telescope.load_extension("command_center")

after update command list order is not preserved

the order of command list display does not match insertion order

command_center.add({
  {
    description = 'history',
    cmd = '<cmd>FzfLua command_history<cr>',
  }, {
    description = 'tab new',
    cmd = '<cmd>tabnew<cr>',
  }, {
    description = 'tab close',
    cmd = '<cmd>tabclose<cr>',
  },
}, {
  mode = command_center.mode.ADD_ONLY,
  category = "command",
})

image

On each new nvim session the commands are shown in random order

Each new nvim session I get a new order of my commands in the command center for ex
open nvim, open command center (:Telescope command_center)
image
close nvim, open nvim again, open command center
image
The order of the commands should be fixed and prefereably to the order in which the command_center.add() functions are called

Set telescope width

Is there a way to set the telescope width when using commander? I have the following in my telescope setup() but it doesn't seem to be picked up by commander and instead it's set to minimum required

  defaults = {
    layout_config = {
      horizontal = { height = 0.65, width=0.9 }
    },
  }

Favour descriptions in the filtering

Hello!
It seems that telescope is giving more importance to the matches on the command definition than in the command description, which could lead to some confusing situations like in the screenshot below:
image

I usually put my attention to the descriptions, so you can imagine my surprise when my exact match appeared 6th in the list, and all the items above it were not even closer.
Is this already configurable? Can it be made default?
Regards

Filtering at time of calling

Hello,

I was wondering if it would be possible to call command_center with a filter set from the commands? Like Telescope command_center mode="normal" to only show keybindings from normal mode.

Sometimes I want to see my keybindings, but I am only interested in the ones in normal mode, or insert mode, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.