refactor: code-golf pass + explanatory comments
Two logical changes that landed as one file rewrite: 1. Tighten the code. SLOC 168 -> 126 (-42), total lines 201 -> 146 pre-comments. Moves: inline single-statement if/while bodies (via stylua's `collapse_simple_statement = Always` and `column_width = 120`), collapse K-termcode table to one line, combine api/fn/M into one local declaration, drop verbose config comments, merge `two` / `ivs_by_line` / `li` into one local, inline CR-branch loop, drop the apply-indirection in setup(), and assorted smaller trims. 2. Re-add prose where the golf made intent non-obvious. Comments now explain: smartcase detection, the +start_line/-2 offset reconcile, the *global* avail disqualification, the cursor-proximity sort purpose, the slow/fast char encoding of pair labels (and why it keeps `prefixes` minimal), the overlap-skip interval math and the carryover-to-next-match behavior, why the augroup is recreated per setup call, and why table-form labels own a dedicated highlight group. No code change from the comment pass itself. Final sizes: 126 SLOC, 194 total lines including 55 comment lines and 13 blank lines. Still smaller than upstream (131 SLOC) and one to two orders of magnitude smaller than every other jump plugin.
This commit is contained in:
3 files changed
+107
-94
No files matched your search
@@ -12,17 +12,36 @@ This plugin is a fork of
|
||||
which is excellent and which I used happily for a long time. Big thanks
|
||||
to the original author for a clean, focused implementation.
|
||||
|
||||
I forked it because I wanted to pass label highlight attributes directly
|
||||
to `setup()` (instead of having to define a separate highlight group and
|
||||
re-apply it on every colorscheme change). I submitted that as a PR but
|
||||
it was declined, which is the maintainer's right — the upstream plugin
|
||||
is explicitly considered feature-complete. See the closed PR for
|
||||
context: <https://github.com/yorickpeterse/nvim-jump/pull/8>.
|
||||
I forked it because I wanted to pass label highlight attributes directly to
|
||||
`setup()` (instead of having to define a separate highlight group and re-apply
|
||||
it on every colorscheme change). I submitted that as a
|
||||
(PR)[https://github.com/yorickpeterse/nvim-jump/pull/8] but it was declined,
|
||||
which is the maintainer's right — the upstream plugin is explicitly considered
|
||||
feature-complete.
|
||||
|
||||
Since the upstream code is MPL-2.0, a fork is fair game. This plugin is
|
||||
a tiny extension of it — same core behavior, plus a slightly friendlier
|
||||
highlight API — maintained under the `tiny-*` family of my other
|
||||
Neovim plugins.
|
||||
Since the upstream code is MPL-2.0, a fork is fair game. This plugin is a tiny
|
||||
extension of it — same core behavior, plus a slightly friendlier highlight API —
|
||||
maintained under the `tiny-*` family of my other Neovim plugins.
|
||||
|
||||
## Size vs. the alternatives
|
||||
|
||||
`tokei lua/` (code lines only, ignoring comments and blank lines), run
|
||||
against a fresh `git clone --depth=1` of each project:
|
||||
|
||||
| Plugin | Files | SLOC |
|
||||
| -------------------------------------------------------------------------------- | ----: | ----: |
|
||||
| **swaits/tiny-jump.nvim** (this fork) | 1 | 126 |
|
||||
| [yorickpeterse/nvim-jump](https://github.com/yorickpeterse/nvim-jump) (upstream) | 1 | 131 |
|
||||
| [echasnovski/mini.jump2d](https://github.com/echasnovski/mini.nvim) | 1 | 553 |
|
||||
| [rlane/pounce.nvim](https://github.com/rlane/pounce.nvim) | 4 | 634 |
|
||||
| [smoka7/hop.nvim](https://github.com/smoka7/hop.nvim) | 18 | 1,489 |
|
||||
| [ggandor/leap.nvim](https://github.com/ggandor/leap.nvim) | 11 | 2,549 |
|
||||
| [folke/flash.nvim](https://github.com/folke/flash.nvim) | 22 | 2,695 |
|
||||
|
||||
Despite fixing a double-`setup()` bug, adding inline label-color configuration,
|
||||
cursor-proximity sorting, and two-char labels for overflow matches, this fork is
|
||||
slightly _smaller_ than upstream — and an order of magnitude smaller than every
|
||||
other alternative on this list.
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
Reference in new issue
Block a user