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

Cannot use mapping to lua functions #13

Open
nikonakoneko opened this issue May 6, 2022 · 0 comments
Open

Cannot use mapping to lua functions #13

nikonakoneko opened this issue May 6, 2022 · 0 comments

Comments

@nikonakoneko
Copy link

If I use vim.keymap.set and pass a lua function as rhs like this:

vim.keymap.set('n', '<Leader>cc', function()
    return vim.v.count == 0 and '<Plug>(comment_toggle_current_linewise)' or '<Plug>(comment_toggle_linewise_count)'
end, { expr = true })

I get the following error on opening leader guide:

Error detected while processing function leaderGuide#start_by_prefix[12]..<SNR>17_start_parser:
line   11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12:       continue
line 13:     endif
line 14:     let mapd.display = s:format_displaystring(mapd.rhs)
line   14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15:     let mapd.lhs = substitute(mapd.lhs, key, "", "")
line   15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16:     let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line   16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
E116: Invalid arguments for function substitute
line 17:     let mapd.lhs = substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
line   17:
E716: Key not present in Dictionary: "lhs, "<Tab>", "<C-I>", "g")"
E116: Invalid arguments for function substitute
line 18:     let mapd.rhs = substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
line   18:
E716: Key not present in Dictionary: "rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")"
E116: Invalid arguments for function substitute
line 19:     if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
line   19:
E716: Key not present in Dictionary: "lhs != '' && mapd.display !~# 'LeaderGuide.*'"
line 20:       if (visual && match(mapd.mode, "[vx ]") >= 0) || (!visual && match(mapd.mode, "[vx]") == -1)
line 22:         let mapd.lhs = s:string_to_keys(mapd.lhs)
line 23:         call s:add_map_to_dict(mapd, 0, a:dict)
line 24:       endif
line 25:     endif
line 26:   endfor
line 9:   for line in lines
line 10:     let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
line 11:     if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
line   11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12:       continue
line 13:     endif
line 14:     let mapd.display = s:format_displaystring(mapd.rhs)
line   14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15:     let mapd.lhs = substitute(mapd.lhs, key, "", "")
line   15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16:     let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line   16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
E116: Invalid arguments for function substitute
line 17:     let mapd.lhs = substitute(mapd.lhs, "<Tab>", "<C-I>", "g")
line   17:
E716: Key not present in Dictionary: "lhs, "<Tab>", "<C-I>", "g")"
E116: Invalid arguments for function substitute
line 18:     let mapd.rhs = substitute(mapd.rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")
line   18:
E716: Key not present in Dictionary: "rhs, "<SID>", "<SNR>".mapd['sid']."_", "g")"
E116: Invalid arguments for function substitute
line 19:     if mapd.lhs != '' && mapd.display !~# 'LeaderGuide.*'
line   19:
E716: Key not present in Dictionary: "lhs != '' && mapd.display !~# 'LeaderGuide.*'"
line 20:       if (visual && match(mapd.mode, "[vx ]") >= 0) || (!visual && match(mapd.mode, "[vx]") == -1)
line 22:         let mapd.lhs = s:string_to_keys(mapd.lhs)
line 23:         call s:add_map_to_dict(mapd, 0, a:dict)
line 24:       endif
line 25:     endif
line 26:   endfor
line 9:   for line in lines
line 10:     let mapd = maparg(split(line[3:])[0], line[0], 0, 1)
line   10:
E684: list index out of range: 0
E116: Invalid arguments for function maparg
line 11:     if mapd.lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'
line   11:
E716: Key not present in Dictionary: "lhs =~ '<Plug>.*' || mapd.lhs =~ '<SNR>.*'"
line 12:       continue
line 13:     endif
line 14:     let mapd.display = s:format_displaystring(mapd.rhs)
line   14:
E716: Key not present in Dictionary: "rhs)"
E116: Invalid arguments for function s:format_displaystring
line 15:     let mapd.lhs = substitute(mapd.lhs, key, "", "")
line   15:
E716: Key not present in Dictionary: "lhs, key, "", "")"
E116: Invalid arguments for function substitute
line 16:     let mapd.lhs = substitute(mapd.lhs, "<Space>", " ", "g")
line   16:
E716: Key not present in Dictionary: "lhs, "<Space>", " ", "g")"
function leaderGuide#start_by_prefix[12]..<SNR>17_start_parser aborted

continuing in function leaderGuide#start_by_prefix

function leaderGuide#start_by_prefix aborted
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

No branches or pull requests

1 participant