Created
April 6, 2023 22:01
-
-
Save darksinge/b2eaca4bce35e4acb15ec62a8be6b7be to your computer and use it in GitHub Desktop.
Filetype detection: add "print statement" shortcuts to which-key (tailored for LunarVim)
This file contains 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
local wk_ok, wk = pcall(require, "which-key") | |
if not wk_ok then | |
return | |
end | |
local vopts = lvim.builtin.which_key.vopts | |
local opts = lvim.builtin.which_key.opts | |
local mappings = { | |
["z"] = { | |
name = " Print", | |
l = { '"ayiwoP(\'<C-R>a:\', <C-R>a);<Esc>', " Pretty Print" }, | |
} | |
} | |
local vmappings = { | |
['z'] = { | |
name = 'Print', | |
l = { 'yoP(\'<esc>pa\', <esc>pa)<Esc>', " Pretty Print" }, | |
}, | |
} | |
wk.register(mappings, opts) | |
wk.register(vmappings, vopts) |
This file contains 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
local wk_ok, wk = pcall(require, "which-key") | |
if not wk_ok then | |
return | |
end | |
local vopts = lvim.builtin.which_key.vopts | |
local opts = lvim.builtin.which_key.opts | |
local mappings = { | |
["z"] = { | |
name = " echo", | |
l = { '"ayiwoecho "<C-R>a: $<C-R>a"<Esc>', " echo" }, | |
} | |
} | |
local vmappings = { | |
["z"] = { | |
name = " echo", | |
l = { 'yoecho "<esc>pa: $<esc>p"' } | |
} | |
} | |
wk.register(mappings, opts) | |
wk.register(vmappings, vopts) |
This file contains 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
local wk_ok, wk = pcall(require, "which-key") | |
if not wk_ok then | |
return | |
end | |
local vopts = lvim.builtin.which_key.vopts | |
local opts = lvim.builtin.which_key.opts | |
local mappings = { | |
-- this uses 'z', but (obviously) you can choose your own prefix | |
["z"] = { | |
name = " console.log", | |
l = { '"ayiwoconsole.log(\'<C-R>a:\', <C-R>a);<Esc>', "console.log" }, | |
L = { '"ayiwoconsole.log(\'<C-R>a:\', JSON.stringify(<C-R>a, null, 3));<Esc>', "console.log + JSON.stringfy" }, | |
e = { '"ayiwoconsole.error(\'<C-R>a:\', <C-R>a);<Esc>', "console.error" }, | |
E = { '"ayiwoconsole.error(\'<C-R>a:\', JSON.stringify(<C-R>a, null, 3));<Esc>', | |
"console.error + JSON.stringfy" }, | |
d = { '"ayiwoconsole.debug(\'<C-R>a:\', <C-R>a);<Esc>', "console.debug" }, | |
D = { '"ayiwoconsole.debug(\'<C-R>a:\', JSON.stringify(<C-R>a, null, 3));<Esc>', | |
"console.debug + JSON.stringfy" }, | |
i = { '"ayiwoconsole.info(\'<C-R>a:\', <C-R>a);<Esc>', "console.info" }, | |
I = { '"ayiwoconsole.info(\'<C-R>a:\', JSON.stringify(<C-R>a, null, 3));<Esc>', "console.info + JSON.stringfy" }, | |
}, | |
} | |
local vmappings = { | |
["z"] = { | |
name = " console.log", | |
l = { 'yoconsole.log(\'<esc>pa:\', <esc>pa);<Esc>', "console.log" }, | |
L = { 'yoconsole.log(\'<esc>pa:\', JSON.stringify(<esc>pa, null, 3));<Esc>', "console.log + JSON.stringfy" }, | |
e = { 'yoconsole.error(\'<esc>pa:\', <esc>pa);<Esc>', "console.error" }, | |
E = { 'yoconsole.error(\'<esc>pa:\', JSON.stringify(<esc>pa, null, 3));<Esc>', | |
"console.error + JSON.stringfy" }, | |
d = { 'yoconsole.debug(\'<esc>pa:\', <esc>pa);<Esc>', "console.debug" }, | |
D = { 'yoconsole.debug(\'<esc>pa:\', JSON.stringify(<esc>pa, null, 3));<Esc>', | |
"console.debug + JSON.stringfy" }, | |
i = { 'yoconsole.info(\'<esc>pa:\', <esc>pa);<Esc>', "console.info" }, | |
I = { 'yoconsole.info(\'<esc>pa:\', JSON.stringify(<esc>pa, null, 3));<Esc>', "console.info + JSON.stringfy" }, | |
}, | |
} | |
wk.register(mappings, opts) | |
wk.register(vmappings, vopts) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment