Created
August 12, 2012 10:13
-
-
Save stepnem/3331062 to your computer and use it in GitHub Desktop.
Jump to a command, mapping or option source definition from Pentadactyl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[.pentadactylrc:] | |
com! jumptodef,jd -literal=1 -nargs=1 -complete help | |
\ -js buffer.viewSource(plugins.misc.sourceLocation(args[0])) | |
[plugins/misc.js:] | |
function sourceLocation(str) { | |
if (isArray(str)) | |
str = str[0]; | |
function mapping(s) { | |
let [, mc, key] = /(?:(.)_)?(.*)/.exec(s); | |
return mappings.get(mc ? modes.modeChars[mc] : modes.NORMAL, key) || | |
dactyl.echoerr("Bad bad: " + s); | |
} | |
let frame = ((str[0] === ":") ? commands.get(str.substr(1)) : | |
/'.*?'/.test(str) ? options.get(str.slice(1,-1)) : | |
mapping(str)).definedAt; | |
return { url: util.fixURI(frame.filename), line: frame.lineNumber }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment