From d25ef8c287e04909d64e7de107031a73b7709ec3 Mon Sep 17 00:00:00 2001 From: Austin Ziegler Date: Tue, 10 Sep 2024 17:16:00 -0400 Subject: [PATCH] vim9script Port of vim-unimpaired - Expose most of the functions used for map building through autoload so that others can more easily add maps in the same manner without copying code. - Incorporate tpope/vim-unimpaired#230, tpope/vim-unimpaired#228 - Use instead of `:`, which required some rethinking because of the use of `=`. - Added additional maps from - phongnh/vim-toggler: conceallevel, showmatch, incsearch, expandtab, showcmd - riceissa/vim-more-toggling: syntax --- .github/FUNDING.yml | 5 +- README.markdown => README.md | 58 ++-- autoload/pairs.vim | 558 +++++++++++++++++++++++++++++++ doc/pairs.txt | 198 +++++++++++ doc/unimpaired.txt | 165 ---------- plugin/pairs.vim | 181 ++++++++++ plugin/unimpaired.vim | 623 ----------------------------------- 7 files changed, 971 insertions(+), 817 deletions(-) rename README.markdown => README.md (57%) create mode 100644 autoload/pairs.vim create mode 100644 doc/pairs.txt delete mode 100644 doc/unimpaired.txt create mode 100644 plugin/pairs.vim delete mode 100644 plugin/unimpaired.vim diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index e2a49d1..be9531e 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ -github: tpope -custom: ["https://www.paypal.me/vimpope"] +github: halostatue +buy_me_a_coffee: halostatue +ko_fi: halostatue diff --git a/README.markdown b/README.md similarity index 57% rename from README.markdown rename to README.md index e5ab747..6d7fbcb 100644 --- a/README.markdown +++ b/README.md @@ -1,31 +1,34 @@ +# vim-pairs + +This is a vim 9 fork of [tpope/vim-unimpaired][unimpaired]. + # unimpaired.vim -Much of unimpaired.vim was extracted from my vimrc when I noticed a -pattern: complementary pairs of mappings. They mostly fall into four -categories. +Much of unimpaired.vim was extracted from my vimrc when I noticed a pattern: +complementary pairs of mappings. They mostly fall into four categories. -There are mappings which are simply short normal mode aliases for -commonly used ex commands. `]q` is :cnext. `[q` is :cprevious. `]a` is -:next. `[b` is :bprevious. See the documentation for the full set of -20 mappings and mnemonics. All of them take a count. +There are mappings which are simply short normal mode aliases for commonly used +ex commands. `]q` is :cnext. `[q` is :cprevious. `]a` is :next. `[b` is +:bprevious. See the documentation for the full set of 20 mappings and mnemonics. +All of them take a count. -There are linewise mappings. `[` and `]` add newlines -before and after the cursor line. `[e` and `]e` exchange the current -line with the one above or below it. +There are linewise mappings. `[` and `]` add newlines before and +after the cursor line. `[e` and `]e` exchange the current line with the one +above or below it. There are mappings for toggling options. `[os`, `]os`, and `yos` perform -`:set spell`, `:set nospell`, and `:set invspell`, respectively. There's also -`l` (`list`), `n` (`number`), `w` (`wrap`), `x` (`cursorline cursorcolumn`), -and several others, plus mappings to help alleviate the `set paste` dance. -Consult the documentation. +`:set spell`, `:set nospell`, and `:set invspell`, respectively. There's also +`l` (`list`), `n` (`number`), `w` (`wrap`), `x` (`cursorline cursorcolumn`), and +several others, plus mappings to help alleviate the `set paste` dance. Consult +the documentation. -There are mappings for encoding and decoding. `[x` and `]x` encode and -decode XML (and HTML). `[u` and `]u` encode and decode URLs. `[y` and -`]y` do C String style escaping. +There are mappings for encoding and decoding. `[x` and `]x` encode and decode +XML (and HTML). `[u` and `]u` encode and decode URLs. `[y` and `]y` do C String +style escaping. And in the miscellaneous category, there's `[f` and `]f` to go to the -next/previous file in the directory, and `[n` and `]n` to jump between -SCM conflict markers. +next/previous file in the directory, and `[n` and `]n` to jump between SCM +conflict markers. The `.` command works with all operator mappings, and will work with the linewise mappings as well if you install @@ -43,7 +46,7 @@ support: ## FAQ -> My non-US keyboard makes it hard to type `[` and `]`. Can I configure +> My non-US keyboard makes it hard to type `[` and `]`. Can I configure > different prefix characters? The easiest solution is to map to `[` and `]` directly: @@ -55,7 +58,7 @@ The easiest solution is to map to `[` and `]` directly: xmap < [ xmap > ] -Note we're not using the `noremap` family because we *do* want to recursively +Note we're not using the `noremap` family because we _do_ want to recursively invoke unimpaired.vim's maps. ## Contributing @@ -67,12 +70,13 @@ See the contribution guidelines for Like unimpaired.vim? Follow the repository on [GitHub](https://github.com/tpope/vim-unimpaired) and vote for it on -[vim.org](http://www.vim.org/scripts/script.php?script_id=1590). And if -you're feeling especially charitable, follow [tpope](http://tpo.pe/) on -[Twitter](http://twitter.com/tpope) and -[GitHub](https://github.com/tpope). +[vim.org](http://www.vim.org/scripts/script.php?script_id=1590). And if you're +feeling especially charitable, follow [tpope](http://tpo.pe/) on +[Twitter](http://twitter.com/tpope) and [GitHub](https://github.com/tpope). ## License -Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. -See `:help license`. +Copyright (c) Tim Pope. Distributed under the same terms as Vim itself. See +`:help license`. + +[unimpaired]: https://github.com/tpope/vim-unimpaired diff --git a/autoload/pairs.vim b/autoload/pairs.vim new file mode 100644 index 0000000..fbdd0c1 --- /dev/null +++ b/autoload/pairs.vim @@ -0,0 +1,558 @@ +vim9script + +# autoload/pairs.vim: Functions used for defining pair definitions. Translated to +# vim9script from tpope/vim-unimpaired. + +# Returns the string to define a single mapping `lhs` in `mode` that will execute `rhs`. +# +# If `rhs` does not begin with ``, then `