Skip to content

Lua keymaps and keymaps without actions #620

@MaxIDgis

Description

@MaxIDgis

Nixpkgs channel: unstable
Home-manager version: master branch and home.stateVersion = "23.05";

Description

Since #605 I am unable to define keymaps with only a description and no action.
I used this to get nice prefixes in which-key. Instead it results in the following error:

Error detected while processing /home/maxh/.config/nvim/init.lua:                                                                    
E5113: Error while calling lua chunk: vim/keymap.lua:0: rhs: expected string|function, got nil                                       
stack traceback:                                                                                                                     
        [C]: in function 'error'                                                                                                     
        vim/shared.lua: in function 'validate'                                                                                       
        vim/keymap.lua: in function 'set'                                                                                            
        /home/maxh/.config/nvim/init.lua:248: in main chunk                                                                          
Press ENTER or type command to continue  

In addition, keymaps that use actions defined in lua give the following error:

Error detected while processing /home/maxh/.config/nvim/init.lua:                                                                    
E5113: Error while calling lua chunk: vim/keymap.lua:0: rhs: expected string|function, got boolean                                   
stack traceback:                                                                                                                     
        [C]: in function 'error'                                                                                                     
        vim/shared.lua: in function 'validate'                                                                                       
        vim/keymap.lua: in function 'set'                                                                                            
        /home/maxh/.config/nvim/init.lua:248: in main chunk                                                                          
Press ENTER or type command to continue                                                                         

Config

First keymap for the first error, second keymap for the second error:

programs.nixvim.enable = true;
programs.nixvim.plugins = {
   mini = {
      enable = true;
      modules = {
         bufremove = {};
      };
   }
};
programs.nixvim.keymaps = [
    { key = "<leader>f"; options.desc = "File"; }
    { key = "<leader>bk"; action = "MiniBufremove.delete(0)"; lua = true; options.desc = "Kill buffer"; }
];

For the second keymap the following does work:

programs.nixvim.keymaps = [
   { key = "<leader>bk"; action = "<CMD>lua MiniBufremove.delete(0)<CR>"; options.desc = "Kill buffer"; }
];

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions