takac / vim-hardtime

Plugin to help you stop repeating the basic movement keys
MIT License
826 stars 30 forks source link

Conflict with mapped key #50

Open ghost opened 7 years ago

ghost commented 7 years ago

Adding "w" to the keys and trying to use vim-wordmotion results in: E109: ':' missing after '?'

The problem seems to be with the arguments, so: let mapping["rhs"] = substitute(mapping["rhs"], "'", "''", "g") But know I get E117: Unknown function.

This works for me, but I don't know if it is equivalent (there's a reason to execute rhs and not the key itself?):

fun! s:RetrieveMapping(key, mode)
    let mapping = maparg(a:key, a:mode, 0, 1)
    if empty(mapping) || mapping["expr"] == 0
        return "'" . a:key . "'"
    endif
    return mapping["expr"]
endf
ghost commented 7 years ago

The code above doesn't work (non-recursive). A map with rhs like this is a problem: :call <SID>hello('world').

'world' should be escaped. <SID> will receive hardtime script id, resulting in a unknow function.

Something like this will fix it:

let mapping["rhs"] = substitute(mapping["rhs"], "'", "''", "g")
let mapping["rhs"] = substitute(mapping["rhs"], "<SID>", "<SNR>" . mapping["sid"] . "_", "g")