Add vimtex_mappings_prefix to configure leader mappings prefix#2611
Closed
wintermute-cell wants to merge 2 commits intolervag:masterfrom
wintermute-cell:master
Closed
Add vimtex_mappings_prefix to configure leader mappings prefix#2611wintermute-cell wants to merge 2 commits intolervag:masterfrom wintermute-cell:master
wintermute-cell wants to merge 2 commits intolervag:masterfrom
wintermute-cell:master
Conversation
Owner
|
Yes, this does not seem totally inappropriate. However, I think this should be expanded. If we allow to customize the prefix, then we should include I think a cleaner way to do it would be something like this: function! s:init_default_mappings() abort " {{{1
if !g:vimtex_mappings_enabled | return | endif
call s:map_prefixed(0, 'n', 'i', '<plug>(vimtex-info)')
" ...
endfunction
" ...
function! s:map_prefixed(ftype, mode, lhs, rhs, ...) abort " {{{1
return call('s:map_prefixed', [
\ a:ftype,
\ a:mode,
\ g:vimtex_mappings_prefix . a:lhs,
\ a:rhs
\] + a:000)
endfunction
" }}}1 |
Owner
|
I believe it is safe to ignore the varargs stuff as well, which would simplify it to this: function! s:map_prefixed(ftype, mode, lhs, rhs) abort " {{{1
let l:lhs = g:vimtex_mappings_prefix . a:lhs
call s:map_prefixed(a:ftype, a:mode, l:lhs a:rhs)
endfunction |
…cumentation entry
Contributor
Author
|
Okay thanks for the feedback, that's a good idea; That even brings us back down below 80 characters for all lines! I'm assuming you didn't mean to do a recursive call in your Based on that assumption I implemented your suggestion and added a documentation entry. |
lervag
added a commit
that referenced
this pull request
Jan 2, 2023
Adds new option `g:vimtex_mappings_prefix`. refer: #2611 * commit 'HEAD@{1}': chore: minor adjustments use function to apply mapping prefix, including <localleader>, add documentation entry add vimtex_mappings_prefix to configure leader mappings prefix
Owner
|
Thanks! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Would it make sense to you to allow users to customize the prefix used for
<localleader>based mappings?My Use-Case:
Usually, all
<localleader>vimtex mappings reside under<localleader>l....I like how the existing vimtex mappings are chosen, but
<localleader>lis the prefix I have been using for language-server related mappings. To remedy this, I want to modify all existing vimtex keymaps to start with<localleader>vinstead. Remapping each function manually would not feel like a clean solution to this.Some Notes:
g:andl:correctly.l:prfxshorthand is just for readability, asg:vimtex_mappings_prefixwould lengthen the lines a lot...or the older.is the preferred way to concat strings for this project.