Closed RomanoZumbe closed 1 year ago
you can do this with autocommands 😄 , qmk.setup()
can be called repeatedly with different configs (I'll add it to the README though, as it's not stated anywhere).
There's lots in :help autocmd
, and apologies if you already know, but here's a quick example of how it could look:
local group = vim.api.nvim_create_augroup('MyQMK', {})
vim.api.nvim_create_autocmd('BufEnter', { -- this gets called each time you enter a buffer
desc = 'Format simple keymap',
group = group,
pattern = '*simple.c', -- this is a pattern to match the filepath of whatever board you wish to target
callback = function()
require('qmk').setup({ -- this calls setup with whatever config you want
name = 'LAYOUT_preonic_grid',
auto_format_pattern = "simple.c",
layout = {
'_ x x x x x x _ x x x x x x',
},
})
end,
})
vim.api.nvim_create_autocmd('BufEnter', {
desc = 'Format overlap keymap',
group = group,
pattern = '*overlap.c',
callback = function()
require('qmk').setup({
name = 'LAYOUT_preonic_grid',
auto_format_pattern = "overlap.c",
layout = {
'x x x x x',
},
})
end,
})
going to close, but please reopen if this doesn't work as you'd expect 😇 thanks
The documented workaround works but I wonder if things could not be simpler. It would be great for qmk.nvim to use a default layout for different names, something like this.
require("qmk").setup({
{
name = "LAYOUT_split_3x5_3",
layout = {
"x x x x x _ _ _ x x x x x",
"x x x x x _ _ _ x x x x x",
"x x x x x _ _ _ x x x x x",
"_ _ _ x x x _ x x x _ _ _",
},
{
name = "LAYOUT_split_3x6_3",
layout = {
"x x x x x x _ _ _ x x x x x x",
"x x x x x x _ _ _ x x x x x x",
"x x x x x x _ _ _ x x x x x x",
"_ _ _ _ x x x _ x x x _ _ _ _",
},
},
},
})
Maybe this won't work all the time and this is not a good idea though 😅
thanks 🙂 I appreciate the suggestion but I'm afraid I won't be adding additional setup code that can be solved with existing functionality in neovim; it just helps keep the surface area down both in the code for me to think about and in the docs for folks reading how to set up the plugin 😇
Makes sense, thanks for answering.
I have a couple of boards I use and it would be nice if I could set up multiple named configurations that I can then give to the format command