Closed bloznelis closed 11 months ago
I'll take a closer look tomorrow but I suspect this is just because the option is being set too late. You need to set the option BEFORE Conjure loads anything and I have a feeling it's already too late there. I'm not sure but hopefully that breadcrumb leads you to the solution.
As soon as you require conjure.main it loads conjure.mapping and calls mapping.init which is what looks at that flag and decides to set up the filetype autocmds or not.
I updated the configuration to what I actually use, sorry. The change is at the config
function.
I have a feeling it's already too late there.
Hmm, that would be a bit weird then. Lazy's init
is supposed to run on startup, and for example other global variables set in the same init
stage (e.g., vim.g["conjure#mapping#eval_comment_root_form"] = "e;"
) are respected.
init functions are always executed during startup
Oh yeah! Interesting!
And I think there's you're problem, the enable_ft_mappings
flag is what decides to either call on-filetype
or skip it. The chain is as follows:
conjure.main/main
is invoked on startup / first load by your config or plugin/conjure.vim
conjure.mapping/init
is invoked with the result of conjure.config/filetypes
as it's first argument. mapping.init
should not be called with zero args as you have in your comment, it requires the filetype data as an argument. But since that's a comment that should be fine.enable_ft_mappings
is true then an autocmd on Filetype
for each of Conjure's currently configured filetypes is setup that calls conjure.mapping/on-filetype
.on-filetype
sets up all mappings for the buffer and hooks up the omnicompletion function for the buffer. Essentially rigging Conjure up into the buffer. If you skip this with the option mentioned you need to set up all of your own mappings and bind them all to your own functions.The conjure#mapping#...
configuration options are ONLY consumed inside the on-filetype
autocmd callback. I think what you might actually want for now is something like this:
vim.g["conjure#mapping#prefix"] = "<localleader>"
vim.g["conjure#mapping#log_split"] = "ls" -- example using the prefix, so <localleader>ls
vim.g["conjure#mapping#log_vsplit"] = ["Lv"] -- example not using the prefix, just press Lv
vim.g["conjure#mapping#log_tab"] = false
vim.g["conjure#mapping#log_buf"] = false
vim.g["conjure#mapping#log_toggle"] = false
vim.g["conjure#mapping#log_close_visible"] = false
vim.g["conjure#mapping#log_reset_soft"] = false
vim.g["conjure#mapping#log_reset_hard"] = false
vim.g["conjure#mapping#log_jump_to_latest"] = false
vim.g["conjure#mapping#eval_current_form"] = false
vim.g["conjure#mapping#eval_comment_current_form"] = false
vim.g["conjure#mapping#eval_root_form"] = false
vim.g["conjure#mapping#eval_comment_root_form"] = false
vim.g["conjure#mapping#eval_word"] = false
vim.g["conjure#mapping#eval_comment_word"] = false
vim.g["conjure#mapping#eval_replace_form"] = false
vim.g["conjure#mapping#eval_marked_form"] = false
vim.g["conjure#mapping#eval_file"] = false
vim.g["conjure#mapping#eval_buf"] = false
vim.g["conjure#mapping#eval_visual"] = false
vim.g["conjure#mapping#eval_motion"] = false
vim.g["conjure#mapping#eval_previous"] = false
vim.g["conjure#mapping#def_word"] = false
vim.g["conjure#mapping#doc_word"] = false
This doesn't account for some mappings that some clients will introduce though. Another thing you can do is set the prefix key to something obscure but possible to use in a pinch. Then replace each of the mappings you care about with a binding to ["<localleader>ee"]
or whatever. The table syntax is a kinda DSL that says "don't use the automatic prefixing on this mapping".
I think this route will be better because some of the mappings are quite hard to set up which is why Conjure does it for you, like mappings off the back of motions and wiring into vim-repeat. If you completely bypass Conjure's mapping system you'll have to do a lot more wiring yourself.
But I think the crux of this issue is the misconception that setting enable_ft_mappings = false
and then setting individual mapping config will work. That mapping config is only read when you have the filetype callback firing.
EDIT: Sorry, missed your previous comment, so this is purely based on the knowledge before it.
Ok, I think I kind of understand of what is going on.
If we have enable_ft_mappings
set to false, while the config loads it skips the mapping.on-filetype function. But this function is also responsible for mapping custom keybindings as well.
To have it work without manually disabling all the default bindings one-by-one, we would need a way to differentiate between default and custom mapping, it seems.
Maybe a flag that sets all of the mappings to false
somehow would be good, then the user just sets the config options they care about but knows they all default to off π€
I can't even remember why I added that enable_ft_mappings flag now, it doesn't seem very useful. Well. It's very useful at misleading people π¬
And glad you came to the same conclusions! I should've been slightly faster π
Maybe a flag that sets all of the mappings to false somehow would be good, then the user just sets the config options they care about but knows they all default to off π€
IMO this would be great.
Let me make another coffee and I'll get a first draft up on the develop branch.
On Fri, 20 Oct 2023, 12:15 Lukas Bloznelis, @.***> wrote:
Maybe a flag that sets all of the mappings to false somehow would be good, then the user just sets the config options they care about but knows they all default to off π€
IMO this would be great.
β Reply to this email directly, view it on GitHub https://github.com/Olical/conjure/issues/533#issuecomment-1772550694, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACM6XKNUMWU3BF27JSUU7TYAJMMTAVCNFSM6AAAAAA6HNGVA6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZSGU2TANRZGQ . You are receiving this because you commented.Message ID: @.***>
Okay, pushed! Set g:conjure#mapping#enable_defaults = v:false
/ vim.g["conjure#mapping#enable_defaults = false
before Conjure loads and all core mappings will be nil
, allowing you to set the ones you care about.
I have not spread this to the clients yet, so they will set their own mappings for some things, I will spread it to them after lunch / after we've verified this is the right solution for you and others.
Just tested it out and it works just perfectly! Thank you for being so swift to add this, it will improve my DX massively <3
Pushed integration for this flag for every client in Conjure, hope that works for you too!
Similar to https://github.com/Olical/conjure/issues/448
The ticket mentions that it default mappings can be disabled one-by-one, but is it possible to disable all default mappings? From the documentation it seems that
vim.g["conjure#mapping#enable_ft_mappings"] = false
should do the trick, but it does not.This is the config that I'm trying to use
I would like to have only a subset of commands mapped to my own keybindings. Thanks in advance!