Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use <plug> mappings instead of global variables #186

Open
savq opened this issue Mar 4, 2021 · 7 comments
Open

Use <plug> mappings instead of global variables #186

savq opened this issue Mar 4, 2021 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@savq
Copy link

savq commented Mar 4, 2021

Conjure currently uses global variables for user-defined mappings, which is a bit unconventional. Vim already provides a mechanism for this. See :h <Plug> and :h 41.11 (/MAPPING).

Using <Plug> is more versatile because users can remap keys as they prefer, including remapping to other modes. It's also easy to check whether the mapping has already been defined.

I don't think this is that big of a change, so I'd be interested in contributing it myself. The global variables can stay for backwards compatibility of course.

@Olical
Copy link
Owner

Olical commented Mar 9, 2021

Hmm, possibly, yeah. I'm not completely opposed to this at all, but I'd consider it lower priority than the mountain of other things I want to get to 🤔 I hadn't thought of checking for existing definitions as a way to allow mapping with defaults before, makes sense.

I haven't really ever integrated plug mappings into my plugins, but I can see the appeal. I went with my own config system to keep things consistent within Conjure: All config for the entire plugin is done in the same way. I suppose this would simplify some things in a few ways.

Consider the idea in my head, I'll see what I make of it after some more development. I feel like it'll be a pretty delicate thing to integrate in a way I'm happy with + being backwards compatible for a time + warning. So maybe I'll at least write up the plan here some day, then if I get around to it or someone else does it'll fit into my idea of the architecture.

I need to make it fit well with the core mappings as well as every client, so there will be some edge cases to think through... I think. Maybe macros will help.

@savq
Copy link
Author

savq commented Mar 9, 2021

Yeah, This isn't really top priority. It's just to keep things tidy. A map can have the same implementation as a command, and it works with . too.

I also assumed it would be easier to change. I didn't know aniseed had it's own module system (?) and used nvim.lua. That tripped me up. Hopefully upgrading to nvim 0.5 in the future will simplify some stuff.

@ghost
Copy link

ghost commented Jul 12, 2023

It breaks my binds, literally even after all the configuration is done conjure swoops in and breaks it. How do I stop it from messing with the K key? This bind works except when conjure is enabled. Also how do I set mapping using lua? Using vimscript in the middle of lua configuration file is awkward.

@Olical
Copy link
Owner

Olical commented Jul 12, 2023

@Rawieo you can disable a mapping entirely by setting it to false.

conjure/doc/conjure.txt

Lines 229 to 231 in 2482871

You can disable a mapping entirely by setting it to `v:false` like so.
>
:let g:conjure#mapping#doc_word = v:false

You can configure that from Lua with:

vim.g.conjure#mapping#doc_word = false

An overhaul of the config system to use the "modern" Lua style of require("conjure").setup({...}) will happen some time soon when I retool the project to use nfnl instead of Aniseed internally. That'll replace the entire existing stack of config globals and may well end up introducing some breaking changes.

So that'll be on another branch some time soon.

@ghost
Copy link

ghost commented Jul 12, 2023

@Olical that's quite helpful, thank you very much!

@spellman
Copy link

I successfully used

vim.g["conjure#mapping#def_word"] = false

(Based on nanotee/nvim-lua-guide#66 (comment))

@ghost
Copy link

ghost commented Sep 22, 2023

That's even better! Thank you for your suggestion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants