dotfiles
bugabingas dorkfiles
owned by bugabinga
neovim: map.lua throws an error, when used wrongly
8abaee34f10b38cd182a56b956f2454f42ad5a04
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
neovim/lua/std/map.lua
Modified 1 1 local available_modes
= {
2 - normal_visual_select_operator_pending =
"",
2 + normal_visual_select_operator_pending =
'',
14 - visual_select =
"v",
14 + visual_select =
'v',
20 - operator_pending =
"o",
20 + operator_pending =
'o',
24 - insert_command_line =
"!",
24 + insert_command_line =
'!',
33 -local bind = function(self, map)
35 - map = { map,
"table" },
36 - [
"map.keys"] = { map.keys, {
"string",
"table" } },
37 - [
"map.command"] = { map.command, {
"function",
"string" } },
33 +local bind = function ( self, map )
35 + map = { map,
'table' },
36 + [
'map.keys'] = { map.keys, {
'string',
'table' } },
37 + [
'map.command'] = { map.command, {
'function',
'string' } },
40 40 local keys
= map.keys
41 41 local command
= map.command
43 43 map.options
= map.options
or {}
45 45 if map.category
and map.description
then 46 - map.description
= map.category
.. ": " .. map.description
46 + map.description
= map.category
.. ': ' .. map.description
49 - local options
= vim.tbl_extend(
"keep", map.options, {
49 + local options
= vim.tbl_extend(
'keep', map.options, {
51 51 desc = map.description,
52 52 buffer = map.buffer,
56 - if vim.tbl_isempty(self.modes)
then 56 + if vim.tbl_isempty( self.modes )
then 57 57 self.modes[
1]
= available_modes.normal_visual_select_operator_pending
62 - if type(keys)
== "table" then 63 - for _, key
in ipairs(keys)
do 64 - vim.keymap.set(self.modes, key, command, options)
62 + if type( keys )
== 'table' then 63 + for _, key
in ipairs( keys )
do 64 + vim.keymap.set( self.modes, key, command, options )
67 - vim.keymap.set(self.modes, keys, command, options)
67 + vim.keymap.set( self.modes, keys, command, options )
73 73 local delete_options
= options.buffer
and {
buffer = options.buffer }
or {}
74 - if type(keys)
== "table" then 75 - for _, key
in ipairs(keys)
do 76 - vim.keymap.del(self.modes, key, delete_options)
74 + if type( keys )
== 'table' then 75 + for _, key
in ipairs( keys )
do 76 + vim.keymap.del( self.modes, key, delete_options )
79 - vim.keymap.del(self.modes, keys, delete_options)
79 + vim.keymap.del( self.modes, keys, delete_options )
84 -local add_mode = function(self, key)
84 +local add_mode = function ( self, key )
85 85 local new_mode
= available_modes[key]
86 86 if new_mode
== nil then 87 - error(
"unknown keymap mode requested: " .. key)
87 + error(
'unknown keymap mode requested: ' .. key )
89 89 if not self.modes[new_mode]
then 90 - table.
insert(self.modes, new_mode)
90 + table.
insert( self.modes, new_mode )
96 -local map
= setmetatable({
96 +local map
= setmetatable(
101 + __index = add_mode,
102 + __newindex =
function (
... )
error(
'Assigments are not supported for std.map.\n' .. vim.inspect(
...),
2)
end,