dotfiles

Configuration for the software I use.
git clone https://git.sr.ht/~jbauer/dotfiles
Log | Files | Refs | README | LICENSE

commit d285153d533d7ce28e52ab1eee1df74256aa0ca0
parent 884032658d24896f779446c8dcc15fe76d616486
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Fri,  2 Dec 2022 20:26:09 -0500

Remove leap.nvim

Diffstat:
M.config/nvim/init.vim | 3---
D.config/nvim/pack/bundle/start/leap.nvim/LICENSE.md | 20--------------------
D.config/nvim/pack/bundle/start/leap.nvim/README.md | 745-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/doc/leap.txt | 496-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/highlight.fnl | 101-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/init.fnl | 17-----------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/jump.fnl | 86-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/main.fnl | 876-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/opts.fnl | 34----------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/search.fnl | 267-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/user.fnl | 48------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/util.fnl | 127-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/highlight.lua | 113-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/init.lua | 24------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/jump.lua | 88-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/main.lua | 1372-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/opts.lua | 15---------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/search.lua | 354-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/user.lua | 35-----------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/lua/leap/util.lua | 165-------------------------------------------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/make.py | 46----------------------------------------------
D.config/nvim/pack/bundle/start/leap.nvim/plugin/init.lua | 59-----------------------------------------------------------
22 files changed, 0 insertions(+), 5091 deletions(-)

diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim @@ -10,9 +10,6 @@ " Leader key let mapleader = "," -" Leap.nvim -lua require('leap').add_default_mappings() - " Syntax Highlighting and Colours syntax on colorscheme monochrome-light diff --git a/.config/nvim/pack/bundle/start/leap.nvim/LICENSE.md b/.config/nvim/pack/bundle/start/leap.nvim/LICENSE.md @@ -1,20 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2022 György Andorka - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/.config/nvim/pack/bundle/start/leap.nvim/README.md b/.config/nvim/pack/bundle/start/leap.nvim/README.md @@ -1,745 +0,0 @@ -<img align="left" width="150" height="85" src="../media/kangaroo.png?raw=true"> - -# leap.nvim - -Leap is a general-purpose motion plugin for [Neovim](https://neovim.io/), with -the ultimate goal of establishing a new standard interface for moving around in -the visible area in Vim-like modal editors. - -![showcase](../media/showcase.gif?raw=true) - -### How to use it (TL;DR) - -Leap allows you to jump to any positions in the visible editor area by entering -a 2-character search pattern, and then potentially a "label" character to pick -your target from multiple matches, similar to -[Sneak](https://github.com/justinmk/vim-sneak). The novel idea in Leap is its -"clairvoyant" ability: you get a **live preview** of the target labels - by -mapping possible futures, Leap can show you which key(s) you will need to press -_before_ you actually need to do that. - -- Initiate the search in the forward (`s`) or backward (`S`) direction, or in - the other windows (`gs`). -- Start typing a 2-character pattern (`{c1}{c2}`). -- After typing the first character, you see "labels" appearing next to some of - the `{c1}{?}` pairs. You cannot _use_ the labels yet. -- Enter `{c2}`. If the pair was not labeled, then voilà, you're already there. - No need to be bothered by remaining labels, just continue editing. -- Else: select a label. In case of multiple groups, first switch to the desired - one, using `<space>` (step back with `<tab>`, if needed). - -### Why is this method cool? - -It is **ridiculously fast**: not counting the trigger key, leaping to literally -anywhere on the screen rarely takes more than 3 keystrokes in total, that can be -typed in one go. Often 2 is enough. - -At the same time, it **reduces mental effort to almost zero**: - -- You _don't have to weigh alternatives_: a single universal motion type can be - used in all non-trivial situations. - -- You _don't have to compose in your head_: one command achieves one logical - movement. - -- You _don't have to be aware of the context_: the eyes can keep focusing on the - target the whole time. - -- You _don't have to make decisions on the fly_: the sequence you should enter - is determined from the very beginning. - -- You _don't have to pause in the middle_: if typing at a moderate speed, at - each step you already know what the immediate next keypress should be, and - your mind can process the rest in the background. - -### Down the kangaroo hole - -This was just a teaser - mind that Leap is extremely flexible, and offers much -more beyond the defaults: you can configure it to resemble other similar -plugins, extend it with custom targeting methods, and even do arbitrary actions -with the selected target(s) - read on to dig deeper. - -- [Design considerations in detail](#design-considerations-in-detail) -- [Background](#background) -- [Status](#status) -- [FAQ](#faq) -- [Getting started](#getting-started) -- [Usage](#usage) -- [Configuration](#configuration) -- [Extending Leap](#extending-leap) -- [Plugins using Leap](#plugins-using-leap) - -## Design considerations in detail - -### The ideal - -Premise: jumping from point A to B on the screen should not be some [exciting -puzzle](https://www.vimgolf.com/), for which you should train yourself; it -should be a _non-issue_. An ideal keyboard-driven interface would impose almost -**no more cognitive burden than using a mouse**, without the constant -context-switching required by the latter. - -That is, **you do not want to think about** - -- **the context**: it should be enough to look at the target, and nothing else - (↔ vanilla Vim motion combinations using relative line numbers and/or repeats) -- **the command**: we need one fundamental targeting method that can bring you - anywhere: a "jetpack" instead of a "railway network" (↔ EasyMotion and its - derivatives) -- **the steps**: the motion should be atomic (↔ Vim motion combos), and you - should be able to type the sequence in one go, without having to make - semi-conscious decisions on the fly ("Shall I start a `<C-g>` streak, or try - one more input character?"), or instantly react to events (labels appearing). - -All the while using **as few keystrokes as possible**, and getting distracted by -**as little incidental visual noise as possible**. - -### How do we measure up? - -It is obviously impossible to achieve all of the above at the same time, without -some trade-offs at least; but Leap comes pretty close, occupying a sweet spot in -the design space. - -The one-step shift between perception and action cuts the Gordian knot: on the -one hand, the input sequence can be extended dynamically, to scale to any number -of targets, by adding new groups you can switch to; however, thanks to -ahead-of-time labeling, it still behaves as if it would be an already known -pattern, that you just have to type out. Leaping is like incremental search on -some kind of autopilot, where you know it in advance when to finish. - -Fortunately, a 2-character search pattern - the shortest one with which we can -play this trick - is also long enough to sufficiently narrow down the matches in -the vast majority of cases. It is very rare that you should type more than 3 -characters altogether to reach a given target. - -### Auxiliary principles - -- Optimize for the common case (not the pathological): a good example of this is - the Sneak-like "one-character labels and multiple groups"-approach (instead of - multi-character labels and no groups, EasyMotion-style), which can become - awkward for, say, 200 targets, but usually more comfortable, eliminates all - kinds of edge cases and implementation problems, and allows for features like - [multiselect](#extending-leap). - -- [Sharpen the saw](http://vimcasts.org/blog/2012/08/on-sharpening-the-saw/): - build on Vim's native interface, and aim for synergy as much as possible. The - plugin supports macros, operators, dot-repeat (`.`), inclusive/exclusive - toggle (`v`), multibyte text and - [keymaps](http://vimdoc.sourceforge.net/htmldoc/mbyte.html#mbyte-keymap) - (language mappings), autocommands via `User` events, among others, and intends - to continuously improve in this respect. - -- [Mechanisms instead of - policies](https://cacm.acm.org/magazines/2018/11/232214-a-look-at-the-design-of-lua/fulltext) - (or "be opinionated, but not stubborn"): aim for a small, maintainable core, - with reasonable defaults; at the same time, keep the plugin flexible and - future-proof via [extension points](#extending-leap). - -## Background - -Leap is a reboot of [Lightspeed](https://github.com/ggandor/lightspeed.nvim); a -streamlined but in many respects enhanced version of its ancestor. Compared to -Lightspeed, Leap: - -- gets rid of some gimmicks with a low benefit/cost ratio (like Lightspeed's - "shortcut" labels), but works the same way in the common case; all the really - important features are there -- has a smaller and simpler visual footprint; it feels like using Sneak -- is more flexible and extensible; it can be used as an engine for selecting - arbitrary targets, and performing arbitrary actions on them - -## Status - -The plugin is not fully stable yet, but don't let that stop you - the usage -basics are extremely unlikely to change. To follow breaking changes, subscribe -to the corresponding [issue](https://github.com/ggandor/leap.nvim/issues/18). - -## FAQ - -<details> -<summary>Bidirectional search</summary> - -```lua --- Beware that the trade-off in this mode is that you always have to --- select a label, as there is no automatic jump to the first target (it --- would be very confusing if the cursor would suddenly jump in the --- opposite direction than your goal). Former vim-sneak users will know --- how awesome a feature that is. I really suggest trying out the plugin --- with the defaults for a while first. --- An additional disadvantage is that operations cannot be dot-repeated --- if the search is non-directional. - --- Now that you have carefully considered my wise advice above, I'll --- tell you the simple trick: just initiate multi-window mode with the --- current window as the only target. -require('leap').leap { target_windows = { vim.fn.win_getid() } } -``` - -</details> - - -<details> -<summary>Search in all windows</summary> - -```lua --- The same caveats as above about bidirectional search apply here. - -require('leap').leap { target_windows = vim.tbl_filter( - function (win) return vim.api.nvim_win_get_config(win).focusable end, - vim.api.nvim_tabpage_list_wins(0) -)} -``` -</details> - - -<details> -<summary>Enhanced f/t motions</summary> - -Check flit.nvim, an extension plugin for Leap. - -</details> - - -<details> -<summary>Linewise motions</summary> - -See the "Extending Leap" section below for an example snippet. - -</details> - - -<details> -<summary>Other supernatural powers besides clairvoyance?</summary> - -You might be interested in leap-spooky.nvim. - -</details> - - -<details> -<summary>Disable auto-jumping to the first match</summary> - -```lua -require('leap').opts.safe_labels = {} -``` - -</details> - - -<details> -<summary>Greying out the search area</summary> - -```lua -vim.api.nvim_set_hl(0, 'LeapBackdrop', { link = 'Comment' }) -``` - -</details> - - -<details> -<summary>Lightspeed-style highlighting</summary> - -```lua --- The below settings make Leap's highlighting a bit closer to what you've been --- used to in Lightspeed. - -vim.api.nvim_set_hl(0, 'LeapBackdrop', { link = 'Comment' }) -vim.api.nvim_set_hl(0, 'LeapMatch', { - fg = 'white', -- for light themes, set to 'black' or similar - bold = true, - nocombine = true, -}) -require('leap').opts.highlight_unlabeled_phase_one_targets = true -``` - -</details> - - -<details> -<summary>How to live without `s`/`S`/`x`/`X`?</summary> - -All of them have aliases or obvious equivalents: - -- `s` = `cl` -- `S` = `cc` -- `v_s` = `v_c` -- `v_S` = `Vc`, unless already in linewise mode (then = `v_c`) -- `v_x` = `v_d` -- `v_X` -> `vnoremap D X`, and use `$D` for vanilla `v_b_D` behaviour - -</details> - - -<details> -<summary>I am too used to using `x` instead of `d` in Visual mode</summary> - -```lua --- Getting used to `d` shouldn't take long - after all, it is more comfortable --- than `x`, and even has a better mnemonic. --- If you still desperately want your old `x` back, then just delete these --- mappings set by Leap: -vim.keymap.del({'x', 'o'}, 'x') -vim.keymap.del({'x', 'o'}, 'X') --- To set alternative keys for "exclusive" selection: -vim.keymap.set({'x', 'o'}, <some-other-key>, '<Plug>(leap-forward-till)') -vim.keymap.set({'x', 'o'}, <some-other-key>, '<Plug>(leap-backward-till)') -``` - -</details> - - -<details> -<summary>Was the name inspired by Jef Raskin's Leap?</summary> - -To paraphrase Steve Jobs, I wish it were, but it is a coincidence. "Leap" is -just another synonym for "jump", that happens to rhyme with Sneak. That said, in -some respects you can indeed think of leap.nvim as a spiritual successor to -Raskin's work, and thus the name as a little tribute to the great pioneer of -interface design, even though embracing the modal paradigm is a fundamental -difference in our approach. - -</details> - -## Getting started - -### Requirements - -* Neovim >= 0.7.0 - -### Dependencies - -* For the moment, [repeat.vim](https://github.com/tpope/vim-repeat) is required - for dot-repeats (`.`) to work as intended. - -### Installation - -Use your preferred plugin manager. No extra steps needed besides defining -keybindings - to use the default ones, put the following into your config: - -`require('leap').add_default_mappings()` (init.lua) - -`lua require('leap').add_default_mappings()` (init.vim) - -## Usage - -Without further ado, let's cut to the chase, and learn by doing. -([Permalink](https://github.com/neovim/neovim/blob/8215c05945054755b2c3cadae198894372dbfe0f/src/nvim/window.c#L1078) -to the file, if you want to follow along.) - -The search is invoked with `s` in the forward direction, and `S` in the backward -direction. Let's target some word containing `ol`. After entering the letter -`o`, the plugin processes all character pairs starting with it, and from here -on, you have all the visual information you need to reach your specific target. - -![quick example 1](../media/quick_example_1.png?raw=true) - -To reach an unlabeled match, just finish the pattern, i.e., type the second -character. For the rest, you also need to type the label character that is -displayed right next to the match. (Note: the highlighting of unlabeled matches -\- green underlined on the screenshots - is opt-in, turned on for clarity here.) - -To continue with the example, type `l`. - -If you aimed for the first match (in `oldwin->w_frame`), you are good to go, -just continue your work! The labels for the subsequent matches of `ol` remain -visible until the next keypress, but they are carefully chosen "safe" letters, -guaranteed to not interfere with your following editing command. - -![quick example 2](../media/quick_example_2.png?raw=true) - -If you aimed for some other match, then type the label, for example `u`, and -move on to that. - -To show the last important feature, let's go back to the start position, and -target the struct member on the line `available = oldwin->w_frame->fr_height;` -near the bottom, using the pattern `fr`, by first pressing `s`, and then `f`: - -![quick example 3](../media/quick_example_3.png?raw=true) - -The blue labels indicate the "secondary" group of matches, where we start to -reuse the available labels for a given pair (`s`, `f`, `n`... again). You can -reach those by prefixing the label with `<space>`, that switches to the -subsequent match group. For example, to jump to the "blue" `j` target, you -should now press `r<space>j`. - -In very rare cases, if the large number of matches cannot be covered even by two -label groups, you might need to press `<space>` multiple times, until you see -the target labeled, first with blue, and then, after one more `<space>`, green. -(Substitute "green" and "blue" with the actual colors in the current theme.) - -### Cross-window motions - -`gs` searches in all the other windows on the tab page. In this case, the -matches are sorted by their screen distance from the cursor, advancing in -concentric circles. - -### Visual and Operator-pending mode - -In these modes, there are two different pairs of directional motions available, -providing the necessary additional comfort and precision. - -`s`/`S` are like their Normal-mode counterparts, except that `s` includes _the -whole match_ in the selection/operation (which might be considered the more -intuitive behaviour for these modes). - -On the other hand, `x`/`X` are like `t`/`T` for `f`/`F` - they exclude the -matched pair: - -``` -abcd| |bcde -████e ← Sab sde → █████ -ab██e ← Xab xde → ███de -``` - -Note that each of the forward motions are inclusive (`:h inclusive`), and the -`v` modifier (`:h o_v`) works as expected on them. - -### Jumping to the end of the line and to empty lines - -A character at the end of a line can be targeted by pressing `<space>` after it. -There is no special mechanism behind this: you can set aliases for the newline -character simply by defining a set in `opts.equivalence_classes` that contains -it. Empty lines can also be targeted, by pressing the newline alias twice -(`<space><space>` by default). This latter is a slightly more magical feature, -but fulfills the principle that any visible position you can move to with the -cursor should be reachable by Leap too. - -### Repeat and traversal - -Pressing `<enter>` after invoking any of Leap's motions sets the search pattern -to the previous one (`special_keys.repeat_search`). - -After entering at least one input character, `<enter>` initiates "traversal" -mode, moving on to the next match on each keypress -(`special_keys.next_phase_one_target` or `special_keys.next_target`). - -`<tab>` can revert the previous jump(s) in case you accidentally overshoot your -target (`special_keys.prev_target`). - -#### Tips - -- When repeating the previous search, you can immediately move on: - `s<enter><enter>...` - -- Accepting the first match after one input character is a useful shortcut in - operator-pending mode (e.g. `ds{char}<enter>`). - -- Traversal mode can be used as a substitute for normal-mode `f`/`t` motions. - `s{char}<enter><enter>` is the same as `f{char};`, but works over multiple - lines. - -#### Notes - -- If the safe label set is in use, the labels will remain available during the - whole time. - -- For cross-window search, traversal mode is not supported (since there's no - direction to follow), but you can still accept the first (presumably only) - match with `<enter>`, even after one input. - -### Resolving highlighting conflicts in phase one - -If a directly reachable match covers a label, the match will get highlighted -(telling the user, "Label underneath!"), and the label will only be displayed -after the second input, that resolves the ambiguity. If a label gets positioned -over another label (this might occur before EOL or the window edge, when the -labels need to be shifted left), an "empty" label will be displayed until -entering the second input. - -### Smart autojump - -Leap automatically jumps to the first match if the remaining matches can be -covered by a limited set of "safe" target labels (keys you would not use right -after a jump), but stays in place, and switches to an extended, more comfortable -label set otherwise. For fine-tuning, see `:h leap-config`. - -The rationale behind this is that the probability of the user aiming for the -very first target lessens with the number of targets; at the same time, the -probability of being able to reach the first target by other means (`www`, `f`, -etc.) increases. That is, staying in place in exchange for more comfortable -labels becomes a more and more acceptable trade-off. - -Smart autojump gives the best of both worlds between Sneak (jumps -unconditionally, can only use a seriously limited label set) and Hop (labels -everything, always requires that one extra keystroke). - -## Configuration - -Below is a list of all configurable values in the `opts` table, with their -defaults. Set them like: `require('leap').opts.<key> = <value>`. For details on -the particular fields, see `:h leap-config`. - -```Lua -max_phase_one_targets = nil -highlight_unlabeled_phase_one_targets = false -max_highlighted_traversal_targets = 10 -case_sensitive = false -equivalence_classes = { ' \t\r\n', } -substitute_chars = {} -safe_labels = { 's', 'f', 'n', 'u', 't', . . . } -labels = { 's', 'f', 'n', 'j', 'k', . . . } -special_keys = { - repeat_search = '<enter>', - next_phase_one_target = '<enter>', - next_target = {'<enter>', ';'}, - prev_target = {'<tab>', ','}, - next_group = '<space>', - prev_group = '<tab>', - multi_accept = '<enter>', - multi_revert = '<backspace>', -} -``` - -### Mappings - -You can add the default mappings (listed in `:h leap-default-mappings`) by -calling `require('leap').add_default_mappings()`. Note that the function will -check for conflicts with any custom mappings created by you or other plugins, -and will not overwrite them, unless explicitly told so (called with a `true` -argument). - -To define alternative mappings, you can use the `<Plug>` keys listed in `:h -leap-custom-mappings`. - -Note: To create custom motions, see [Extending Leap](#extending-leap) below. - -### Highlight groups - -For customizing the highlight colors, see `:h leap-highlight`. - -In case you - as a user - are not happy with a certain colorscheme's -integration, you could force reloading the default settings by calling -`leap.init_highlight(true)`. The call can even be wrapped in an -autocommand to automatically re-init on every colorscheme change: - -```Vim -autocmd ColorScheme * lua require('leap').init_highlight(true) -``` - -This can be tweaked further, you could e.g. check the actual colorscheme, and -only execute for certain ones, etc. - -## Extending Leap - -There is more to Leap than meets the eye. On a general level, you should think -of it as less of a motion plugin and more of an engine for selecting visible -targets on the screen (acquired by arbitrary means), and doing arbitrary things -with them. - -There are lots of ways you can extend the plugin and bend it to your will, and -the combinations of them give you almost infinite possibilities. - -### Calling `leap` with custom arguments - -Instead of using the provided `<Plug>` keys, you can also call the `leap` -function directly. The following arguments are available: - -`opts`: A table just like `leap.opts`, to override any default setting for the -specific call. E.g.: - -```lua -require('leap').leap { opts = { labels = {} } } -``` - -`offset`: Where to land with the cursor compared to the target position (-1, 0, -1, 2). - -`inclusive_op`: A flag indicating whether an operation should behave as -inclusive (`:h inclusive`). - -`backward`: Search backward instead of forward in the current window. - -`target_windows`: A list of windows (as `winid`s) to be searched. - -<details> -<summary>Example: bidirectional and all-windows search</summary> - -```lua --- Bidirectional search in the current window is just a specific case of the --- multi-window mode. -require('leap').leap { target_windows = { vim.fn.win_getid() } } - --- Searching in all windows (including the current one) on the tab page. -require('leap').leap { target_windows = vim.tbl_filter( - function (win) return vim.api.nvim_win_get_config(win).focusable end, - vim.api.nvim_tabpage_list_wins(0) -)} -``` -</details> - -This is where things start to become really interesting: - -`targets`: Either a list of targets, or a function returning such a list. The -elements of the list are tables of arbitrary structure, with the only mandatory -field being `pos` - a (1,1)-indexed tuple; this is the position of the label, -and also the jump target, if there is no custom `action` provided. If you have -targets in multiple windows, you also need to provide a `wininfo` field for each -(`:h getwininfo()`). Targets can represent anything with a position, like -Tree-sitter nodes, etc. - -<details> -<summary>Example: linewise motions</summary> - -```lua -local function get_line_starts(winid) - local wininfo = vim.fn.getwininfo(winid)[1] - local cur_line = vim.fn.line('.') - - -- Get targets. - local targets = {} - local lnum = wininfo.topline - while lnum <= wininfo.botline do - local fold_end = vim.fn.foldclosedend(lnum) - -- Skip folded ranges. - if fold_end ~= -1 then - lnum = fold_end + 1 - else - if lnum ~= cur_line then table.insert(targets, { pos = { lnum, 1 } }) end - lnum = lnum + 1 - end - end - -- Sort them by vertical screen distance from cursor. - local cur_screen_row = vim.fn.screenpos(winid, cur_line, 1)['row'] - local function screen_rows_from_cur(t) - local t_screen_row = vim.fn.screenpos(winid, t.pos[1], t.pos[2])['row'] - return math.abs(cur_screen_row - t_screen_row) - end - table.sort(targets, function (t1, t2) - return screen_rows_from_cur(t1) < screen_rows_from_cur(t2) - end) - - if #targets >= 1 then - return targets - end -end - --- Usage: -local function leap_to_line() - winid = vim.api.nvim_get_current_win() - require('leap').leap { - target_windows = { winid }, - targets = get_line_starts(winid), - } -end -``` -</details> - -`action`: A Lua function that will be executed by Leap in place of the jump. (You -could obviously implement some custom jump logic here too.) Its only argument is -either a target, or a list of targets (in multiselect mode). - -<details> -<summary>Example: pick a window</summary> - -```lua -function leap_to_window() - target_windows = require('leap.util').get_enterable_windows() - local targets = {} - for _, win in ipairs(target_windows) do - local wininfo = vim.fn.getwininfo(win)[1] - local pos = { wininfo.topline, 1 } -- top/left corner - table.insert(targets, { pos = pos, wininfo = wininfo }) - end - - require('leap').leap { - target_windows = target_windows, - targets = targets, - action = function (target) - vim.api.nvim_set_current_win(target.wininfo.winid) - end - } -end -``` -</details> - -`multiselect`: A flag allowing for selecting multiple targets for `action`. In -this mode, you can just start picking labels one after the other. You can revert -the most recent pick with `<backspace>`, and accept the selection with -`<enter>`. - -<details> -<summary>Example: multi-cursor `:normal`</summary> - -```lua --- The following example showcases a custom action, using `multiselect`. We're --- executing a `normal!` command at each selected position (this could be even --- more useful if we'd pass in custom targets too). - -function paranormal(targets) - -- Get the :normal sequence to be executed. - local input = vim.fn.input("normal! ") - if #input < 1 then return end - - local ns = vim.api.nvim_create_namespace("") - - -- Set an extmark as an anchor for each target, so that we can also execute - -- commands that modify the positions of other targets (insert/change/delete). - for _, target in ipairs(targets) do - local line, col = unpack(target.pos) - id = vim.api.nvim_buf_set_extmark(0, ns, line - 1, col - 1, {}) - target.extmark_id = id - end - - -- Jump to each extmark (anchored to the "moving" targets), and execute the - -- command sequence. - for _, target in ipairs(targets) do - local id = target.extmark_id - local pos = vim.api.nvim_buf_get_extmark_by_id(0, ns, id, {}) - vim.fn.cursor(pos[1] + 1, pos[2] + 1) - vim.cmd("normal! " .. input) - end - - -- Clean up the extmarks. - vim.api.nvim_buf_clear_namespace(0, ns, 0, -1) -end - --- Usage: -require('leap').leap { - target_windows = { vim.fn.win_getid() }, - action = paranormal, - multiselect = true, -} -``` -</details> - -### Accessing the arguments passed to `leap` - -The arguments of the current call are always available at runtime, in the -`state.args` table. - -### Setting up autocommands - -Leap triggers `User` events on entering/exiting (with patterns `LeapEnter` and -`LeapLeave`), so that you can set up autocommands, e.g. to change the values of -some editor options while the plugin is active (`:h leap-events`). - -### Customizing specific invocations - -Using autocommands together with the `args` table, you can customize practically -anything on a per-call basis - keep in mind that nothing prevents you from -passing arbitrary flags when calling `leap`: - -```Lua -function my_custom_leap_func() - require('leap').leap { my_custom_flag = true, ... } -end - -vim.api.nvim_create_autocmd('User', { - pattern = 'LeapEnter', - callback = function () - if require('leap').state.args.my_custom_flag then - -- Implement some special logic here, that will only apply to - -- my_custom_leap_func() (e.g., change the style of the labels), - -- and clean up with an analogous `LeapLeave` autocommand. - end - end -}) -``` - -## Plugins using Leap - -- [leap-spooky.nvim](https://github.com/ggandor/leap-spooky.nvim) (remote - operations on text objects) -- [flit.nvim](https://github.com/ggandor/flit.nvim) (enhanced f/t motions) -- [leap-ast.nvim](https://github.com/ggandor/leap-ast.nvim) (Tree-sitter nodes) - diff --git a/.config/nvim/pack/bundle/start/leap.nvim/doc/leap.txt b/.config/nvim/pack/bundle/start/leap.nvim/doc/leap.txt @@ -1,496 +0,0 @@ -*leap.txt* -For Neovim version 0.7.0 -Last change: 2022 November 18 - -============================================================================== -CONTENTS *leap.nvim* *leap-contents* - - Introduction ············································· |leap-introduction| - Usage ··························································· |leap-usage| - Configuration ·················································· |leap-config| - Default mappings ······································|leap-default-mappings| - Custom mappings ······································· |leap-custom-mappings| - Highlighting ················································ |leap-highlight| - Events ························································· |leap-events| - Extending Leap ············································· |leap-extensions| - -============================================================================== -INTRODUCTION *leap-introduction* - -Leap is a motion plugin that allows you to jump to any positions in the -visible editor area by entering a 2-character search pattern, and then -potentially a "label" character to pick your target from multiple matches, -similar to Justin M. Keyes' Sneak plugin. The novel idea in Leap is its -"clairvoyant" ability: you get a live preview of the target labels - by -mapping possible futures, Leap can show you which key(s) you will need to -press before you actually need to do that, resulting in a much more -frictionless experience. - -============================================================================== -USAGE *leap-usage* - -- Initiate the search in the forward (`s`) or backward (`S`) direction, or in - the other windows (`gs`). -- Start typing a 2-character pattern (`{c1}{c2}`). -- After typing the first character, you see "labels" appearing next to some of - the `{c1}{?}` pairs. You cannot _use_ the labels yet. -- Enter `{c2}`. If the pair was not labeled, then voilà, you're already there. - No need to be bothered by remaining labels, just continue editing. -- Else: select a label. In case of multiple groups, first switch to the desired - one, using `<space>` (step back with `<tab>`, if needed). - - *leap-cross-window* -`gs` searches in all the other windows on the tab page. In this case, the -matches are sorted by their screen distance from the cursor, advancing in -concentric circles. - - *leap-visual-mode* *leap-operator-pending-mode* -In Visual and Operator-pending mode, there are two different pairs of -directional motions available, providing the necessary additional comfort and -precision. - -`s`/`S` are like their Normal-mode counterparts, except that `s` includes the -whole match in the selection/operation (which might be considered the more -intuitive behaviour for these modes). - -On the other hand, `x`/`X` are like `t`/`T` for `f`/`F` - they exclude the -matched pair: - -``` -abcd| |bcde -████e ← Sab sde → █████ -ab██e ← Xab xde → ███de -``` - -Note that each of the forward motions are |inclusive|, and |o_v| works as -expected on them. - - *leap-match-newline* -A character at the end of a line can be targeted by pressing `<space>` after it. -There is no special mechanism behind this: you can set aliases for the -newline character simply by defining a set in |leap.opts.equivalence_classes| -that contains it. Empty lines can also be targeted, by pressing the newline -alias twice (`<space><space>` by default). This latter is a slightly more -magical feature, but fulfills the principle that any visible position you can -move to with the cursor should be reachable by Leap too. - - *leap-repeat* -Pressing `<enter>` after invoking any of Leap's motions sets the search -pattern to the previous one (`special_keys.repeat_search`). - - *leap-traversal* -After entering at least one input character, `<enter>` initiates "traversal" -mode, moving on to the next match on each keypress -(`special_keys.next_phase_one_target` or `special_keys.next_target`). - -`<tab>` can revert the previous jump(s) in case you accidentally overshoot -your target (`special_keys.prev_target`). - -Tips: - -- When repeating the previous search, you can immediately move on: - `s|S <enter> <enter> ...` - -- Accepting the first match after one input character is a useful shortcut in - operator-pending mode (e.g. `ds{char}<enter>`). - -- Traversal mode can be used as a substitute for normal-mode `f`/`t` motions. - `s{char}<enter><enter>` is the same as `f{char};`, but works over multiple - lines. - -Note: If |leap.opts.safe_labels| is in use, the labels will remain available -during the whole time. - -Note: For cross-window search, traversal mode is not supported (since there's -no direction to follow), but you can still accept the first (presumably only) -match with `<enter>`, even after one input. - - *leap-dot-repeat* -You can repeat change and delete operations with the `.` character, if -repeat.vim (https://github.com/tpope/vim-repeat) is installed. - -============================================================================== -CONFIGURATION *leap-config* *leap.opts* - -Below is the description of all configurable values in the `opts` table, with -their defaults. - -Example configuration: > - local leap = require('leap') - leap.opts.case_sensitive = true - leap.opts.substitute_chars = { ['\r'] = '¬' } - leap.opts.special_keys.prev_target = { '<s-enter>', ',' } -< -Available options~ - - *leap.opts.max_phase_one_targets* -`max_phase_one_targets = nil` - - By default, the plugin shows labels and/or highlights matches right after - the first input character. This option disables ahead-of-time displaying - of target beacons beyond a certain number of phase one targets (to - mitigate visual noise in extreme cases). Setting it to 0 disables - two-phase processing altogether. - - *leap.opts.highlight_unlabeled_phase_one_targets* -`highlight_unlabeled_phase_one_targets = false` - - Whether to highlight all unlabeled matches in phase one. (Matches covering - labels will get highlighted anyway.) - - *leap.opts.max_highlighted_traversal_targets* -`max_highlighted_traversal_targets = 10` - - Number of targets to be highlighted after the cursor in |leap-traversal| - mode (when there are no labels at all). - - *leap.opts.case_sensitive* -`case_sensitive = false` - - Whether to consider case in search patterns. - - *leap.opts.equivalence_classes* -`equivalence_classes = { ' \t\r\n' }` - - A character will match any other in its equivalence class. The sets can - either be defined as strings or tables. - - Example: > - { - '\r\n', - ')]}>', - '([{<', - { '"', "'", '`' }, - } -< - Note: Make sure to have a set containing `\n` if you want to be able to - target characters at the end of the line. - - Note: Non-mutual aliases are not possible in Leap, for the same reason - that supporting |smartcase| is not possible: we would need to show two - different labels, corresponding to two different futures, at the same - time. - - *leap.opts.substitute_chars* -`substitute_chars = {}` - - The keys in this table will be substituted in labels and highlighted - matches by the given characters. This way special (e.g. whitespace) - characters can be made visible in matches, or even be used as labels. - - Example: `{ ['\r'] = '¬' }` - - *leap.opts.safe_labels* -`safe_labels` > - { "s", "f", "n", "u", "t", "/", - "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z" } -< - When the number of matches does not exceed the number of these "safe" - labels plus one, the plugin jumps to the first match automatically after - entering the pattern. Obviously, for this purpose you should choose keys - that are unlikely to be used right after a jump! - - Setting the list to `{}` effectively disables the autojump feature. - - Note: Operator-pending mode ignores this, since we need to be able to - select the actual target before executing the operation. - - *leap.opts.labels* -`labels` > - { "s", "f", "n", - "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", - "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", - "S", "F", "N", - "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", - "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z" } -< - Target labels to be used when there are more matches than the number of - safe labels plus one. - - Setting the list to `{}` forces autojump to always be on (except for - Operator-pending mode, where it makes no sense). In this case, do not - forget to set `special_keys.next_group` to something "safe" too. - - Heuristics behind the defaults: - - At least the first few labels should be the same on the two lists, since - those become muscle memory, and might be used automatically, a bit like - [count] values. - - Since the commands invoking the motions are mapped to left-hand keys by - default, we tend to prioritize right-hand keys to get a better balance - for the whole sequence on average. - - *leap.opts.special_keys* -`special_keys` > - { - repeat_search = '<enter>', - next_phase_one_target = '<enter>', - next_target = {'<enter>', ';'}, - prev_target = {'<tab>', ','}, - next_group = '<space>', - prev_group = '<tab>', - multi_accept = '<enter>', - multi_revert = '<backspace>', - } -< - Keys captured by the plugin at runtime, to: - - repeat with the previous input after invocation - - jump to the next/previous match in traversal mode (|leap-traversal|) - - switch to the next/previous group of matches, when there are more - matches than available labels - - accept the selection, and deselect the last selected target in - |leap-multiselect| mode - -============================================================================== -DEFAULT MAPPINGS *leap-default-mappings* - -The defaults can be set by calling `require('leap').add_default_mappings()`. - -Note that the function will check for conflicts with any custom mappings -created by you or other plugins, and will not overwite them, unless explicitly -told so (called with a `true` argument). - -Trigger keys~ - -Normal mode - - *leap_s* -s{char1}{char2} Jump forward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor is placed on - {char1}. - - *leap_S* -S{char1}{char2} Jump backward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor is placed on - {char1}. - -Visual and Operator-pending mode - *leap_v_s* *leap_o_s* -s{char1}{char2} Jump forward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor is - placed on {char2} |inclusive|. - - *leap_v_S* *leap_o_S* -S{char1}{char2} Jump backward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor - is placed on {char1}. - - *leap_v_x* *leap_o_x* -x{char1}{char2} Jump forward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor is - placed on the character preceding {char1} - |inclusive|. - Mnemonic: "exclusive (s)". - - *leap_v_X* *leap_o_X* -X{char1}{char2} Jump backward to a labeled or [count]'th visible - occurrence of {char1}{char2}. The cursor - is placed on the character following {char2}. - Mnemonic: "eXclusive (S)". - -All modes - *leap_gs* -gs{char1}{char2} Jump to a labeled occurrence of {char1}{char2} in one - of the other windows on the tab page. The cursor is - placed on {char1} |exclusive|. - Mnemonic: "global s". - -Special keys~ - -<enter> Repeat search with the previous input (after - invocation); jump to the next match in - |leap-traversal| mode; accept the selection in - |leap-multiselect| mode. -<space> Substitute for an EOL character (after the first - input); shift to the next group of labeled matches - (after the second input). -<tab> Revert the previous jump (|leap-traversal| mode) or - the previous group shift. -<backspace> Deselect the last selected target in - |leap-multiselect| mode. -<esc> Exit Leap at any stage cleanly. - -============================================================================== -CUSTOM MAPPINGS *leap-custom-mappings* - -<Plug> keys are aliases for right hand sides of mappings - in our case, calls -to |leap.leap()|. If you are not familiar with the concept, see |<Plug>| and -|using-<Plug>|. - -Available <Plug> keys (with their corresponding argument tables): - -*<Plug>(leap-forward-to)* -arguments: `{}` in Normal mode, otherwise `{ offset = +1, inclusive_op = true }` -default mapping: `s` - -*<Plug>(leap-forward-till)* -arguments: `{ offset = -1, inclusive_op = true }` -default mapping: `x` (Visual and Operator-pending mode only) - -*<Plug>(leap-backward-to)* -arguments: `{ backward = true }` -default mapping: `S` - -*<Plug>(leap-backward-till)* -arguments: `{ backward = true, offset = 2 }` -default mapping: `X` (Visual and Operator-pending mode only) - -*<Plug>(leap-cross-window)* -arguments: `{ target_windows = require('leap.util').get_enterable_windows() }` -default mapping: `gs` - -Example: `vim.keymap.set({'n', 'x', 'o'}, 'f', '<Plug>(leap-forward-to)')` - -For creating custom motions with behaviours different from the above, see -|leap.leap()|. - -The keys for repeating the search, and for switching between groups of matches -can be set via |leap.opts.special_keys|. - -============================================================================== -HIGHLIGHTING *leap-highlight* - -Leap uses the following highlight groups that you can configure to your own -liking (using |nvim_set_hl()|): - - *LeapMatch* - Matches that can be reached directly, without having to use a label. - (By default, this is only used for traversal mode, or when a match - covers a label, indicating the conflict.) - - *LeapLabelPrimary* - The character needed to be pressed to jump to the match position, - after the whole search pattern has been given. It appears once the - first input has been entered, right next to the pair. - - *LeapLabelSecondary* - If the number of matches exceeds the available target labels, the next - group of labeled targets are shown with a different color. Those can - be reached by pressing `<space>` (`special_keys.next_group`) - before the label character. - - *LeapLabelSelected* - Labels that are selected for the action in |leap-multiselect| mode. - - *LeapBackdrop* - In some cases it might be useful or even necessary to apply certain - settings on the rest of the area, like disabling all `gui` attributes, - or adding a uniform grey foreground color, to make Leap matches and - labels more distinguishable. This group is not set by default. - -Example: `vim.api.nvim_set_hl(0, 'LeapBackdrop', { fg = 'grey' })` - -In order to preserve your custom settings after changing the colorscheme, you -might want to wrap them in a function, and define an autocommand like below. -(Leap does the same, but with |:hi-default|, so it will not overwrite yours.) -> - vim.api.nvim_create_autocmd('ColorScheme', { - callback = function () - vim.api.nvim_set_hl(0, 'LeapMatch', { <def. map> }) - -- etc. - end - }) - -============================================================================== -EVENTS *leap-events* - -The |User| event is triggered with the following patterns on entering/exiting -Leap (not in traversal mode): - -*LeapEnter* -*LeapLeave* - -Example: > - vim.api.nvim_create_autocmd('User', { - pattern = 'LeapEnter', - command = 'nohlsearch', - }) - vim.api.nvim_create_autocmd('User', { - pattern = 'LeapLeave', - command = 'let &hlsearch=&hlsearch', - }) -< -============================================================================== -EXTENDING LEAP *leap-extensions* - -There is more to Leap than meets the eye. On a general level, you should think -of it as less of a motion plugin and more of an engine for selecting visible -targets on the screen (acquired by arbitrary means), and doing arbitrary things -with them. - -There are lots of ways you can extend the plugin and bend it to your will, and -the combinations of them give you almost infinite possibilities. - -Instead of using the provided `<Plug>` keys, you can also call the `leap()` -function directly: - -leap({opts}) *leap.leap()* - Entry point for all |leap.nvim| actions. - - Parameters ~ - {opts} Optional parameters. - • opts: A table just like |leap.opts|, to override any default - setting for the specific call. - E.g.: `require('leap').leap { opts = { labels = {} } }` - - • offset: Where to land with the cursor compared to the target - position (-1, 0, 1, 2). - • inclusive_op: A flag indicating whether an operation should - behave as |inclusive|. - • backward: Search backward instead of forward in the current - window. - • target_windows: A list of windows (as |winid|s) to be - searched. - *leap-custom-targets* - • targets: Either a list of targets, or a function returning - such a list. The advantage of the latter is that the function - will be evaluated after |LeapEnter| (that is, after setting - temporary editor options, etc.), so that you can even prompt - the user for input while already "in" Leap. - - The elements of the list are tables of arbitrary structure, - with the only mandatory field being `pos` - a (1,1)-indexed - tuple; this is the position of the label, and also the jump - target, if there is no custom `action` provided. If you have - targets in multiple windows, you also need to provide a - `wininfo` field for each (|getwininfo()|). Targets can - represent anything with a position, like Tree-sitter nodes, - etc. - *leap-custom-action* - • action: A Lua function that will be executed by Leap in place - of the jump. (You could obviously implement some custom jump - logic here too.) Its only argument is either a target, or a - list of targets (in multiselect mode). - *leap-multiselect* - • multiselect: A flag allowing for selecting multiple targets - for `action`. In this mode, you can just start picking labels - one after the other. You can revert the most recent pick with - `<backspace>` (`special_keys.multi_revert`), and accept the - selection with `<enter>` (`special_keys.multi_accept`). - - *leap.state* *leap-runtime-args* -Accessing the arguments passed to leap() ~ - -The arguments of the current call are always available at runtime, in the -`state.args` table. - -Using |leap-events| together with the `args` table, you can customize practically -anything on a per-call basis. Keep in mind that you can even pass arbitrary -flags when calling |leap()|: -> - function my_custom_leap_func() - require'leap'.leap { my_custom_flag = true, ... } - end - - vim.api.nvim_create_autocmd('User', { - pattern = 'LeapEnter', - callback = function () - if require'leap'.state.args.my_custom_flag then - -- Implement some special logic here, that will only apply to - -- my_custom_leap_func() (e.g., change the style of the labels), - -- and clean up with an analogous `LeapLeave` autocommand. - end - end - }) -< -============================================================================== -vim:tw=78:ts=8:ft=help:norl: diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/highlight.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/highlight.fnl @@ -1,101 +0,0 @@ -(local util (require "leap.util")) - -(local {: inc : dec} util) -(local api vim.api) -(local map vim.tbl_map) - - -(local M {:ns (api.nvim_create_namespace "") - :extmarks [] - :group {:label-primary "LeapLabelPrimary" - :label-secondary "LeapLabelSecondary" - :label-selected "LeapLabelSelected" - :match "LeapMatch" - :backdrop "LeapBackdrop"} - :priority {:label 65535 - :cursor 65534 - :backdrop 65533}}) - - -(fn M.cleanup [self affected-windows] - ; Clear beacons & cursor. - (each [_ [bufnr id] (ipairs self.extmarks)] - (api.nvim_buf_del_extmark bufnr self.ns id)) - (set self.extmarks []) - ; Clear backdrop. - (when (pcall api.nvim_get_hl_by_name self.group.backdrop false) ; group exists? - (each [_ wininfo (ipairs affected-windows)] - (api.nvim_buf_clear_namespace - wininfo.bufnr self.ns (dec wininfo.topline) wininfo.botline)) - ; Safety measure for scrolloff > 0: we always clean up the current view too. - (api.nvim_buf_clear_namespace 0 self.ns - (dec (vim.fn.line "w0")) - (vim.fn.line "w$")))) - - -(fn M.apply-backdrop [self backward? ?target-windows] - (when (pcall api.nvim_get_hl_by_name self.group.backdrop false) ; group exists? - (if ?target-windows - (each [_ win (ipairs ?target-windows)] - (vim.highlight.range win.bufnr self.ns self.group.backdrop - [(dec win.topline) 0] - [(dec win.botline) -1] - {:priority self.priority.backdrop})) - (let [[curline curcol] (map dec [(vim.fn.line ".") (vim.fn.col ".")]) - [win-top win-bot] [(dec (vim.fn.line "w0")) (dec (vim.fn.line "w$"))] - [start finish] (if backward? - [[win-top 0] [curline curcol]] - [[curline (inc curcol)] [win-bot -1]])] - ; Expects 0,0-indexed args; `finish` is exclusive. - (vim.highlight.range 0 self.ns self.group.backdrop start finish - {:priority self.priority.backdrop}))))) - - -(fn M.highlight-cursor [self ?pos] - "The cursor is down on the command line during `getchar`, -so we set a temporary highlight on it to see where we are." - (let [[line col &as pos] (or ?pos (util.get-cursor-pos)) - ; nil means the cursor is on an empty line. - ch-at-curpos (or (util.get-char-at pos {}) " ") ; get-char-at needs 1,1-idx - ; (Ab)using extmarks even here, to be able to highlight the cursor on empty lines too. - id (api.nvim_buf_set_extmark 0 self.ns (dec line) (dec col) - {:virt_text [[ch-at-curpos :Cursor]] - :virt_text_pos "overlay" - :hl_mode "combine" - :priority self.priority.cursor})] - (table.insert self.extmarks [(api.nvim_get_current_buf) id]))) - - -(fn M.init-highlight [self force?] - (let [bg vim.o.background - defaults {self.group.match {:fg (match bg - :light "#222222" - _ "#ccff88") - :ctermfg "red" - :underline true - :nocombine true} - self.group.label-primary {:fg "black" - :bg (match bg - :light "#ff8877" - _ "#ccff88") - :ctermfg "black" - :ctermbg "red" - :nocombine true} - self.group.label-secondary {:fg "black" - :bg (match bg - :light "#77aaff" - _ "#99ccff") - :ctermfg "black" - :ctermbg "blue" - :nocombine true} - self.group.label-selected {:fg "black" - :bg "magenta" - :ctermfg "black" - :ctermbg "magenta" - :nocombine true}}] - (each [group-name def-map (pairs defaults)] - (when (not force?) (tset def-map :default true)) - (api.nvim_set_hl 0 group-name def-map)))) - - -M diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/init.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/init.fnl @@ -1,17 +0,0 @@ -; We're exposing some fields from other modules here so that they can be -; accessed directly as `require('leap').foo`. Using a metatable is a convenient -; way to avoid requiring the modules ahead of time. - -(setmetatable {} - {:__index - (fn [_ k] - (match k - :opts (. (require "leap.opts") :default) - :leap (. (require "leap.main") :leap) - :state (. (require "leap.main") :state) - :setup (. (require "leap.user") :setup) - :add_default_mappings (. (require "leap.user") :add_default_mappings) - :init_highlight (fn [...] (: (require "leap.highlight") :init-highlight ...)) - ; deprecated - :set_default_keymaps (. (require "leap.user") :set_default_keymaps) - ))}) diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/jump.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/jump.fnl @@ -1,86 +0,0 @@ -(local {: dec : push-cursor!} (require "leap.util")) - -(local api vim.api) - - -(fn cursor-before-eol? [] - (not= (vim.fn.search "\\_." "Wn") (vim.fn.line "."))) - - -(fn cursor-before-eof? [] - (and (= (vim.fn.line ".") (vim.fn.line "$")) - (= (vim.fn.virtcol ".") (dec (vim.fn.virtcol "$"))))) - - -(fn add-offset! [offset] - (if (< offset 0) (push-cursor! :bwd) - ; Safe first forward push for pre-EOL matches. - (> offset 0) (do (when (not (cursor-before-eol?)) (push-cursor! :fwd)) - (when (> offset 1) (push-cursor! :fwd))))) - - -(fn push-beyond-eof! [] - (local saved vim.o.virtualedit) - (set vim.o.virtualedit :onemore) - ; Note: No need to undo this afterwards, the cursor will be - ; moved to the end of the operated area anyway. - (vim.cmd "norm! l") - (api.nvim_create_autocmd - [:CursorMoved :WinLeave :BufLeave :InsertEnter :CmdlineEnter :CmdwinEnter] - {:callback #(set vim.o.virtualedit saved) - :once true})) - - -(fn simulate-inclusive-op! [mode] - "When applied after an exclusive motion (like setting the cursor via -the API), make the motion appear to behave as an inclusive one." - (match (vim.fn.matchstr mode "^no\\zs.") ; get forcing modifier - ; In the normal case (no modifier), we should push the cursor - ; forward. (The EOF edge case requires some hackery though.) - "" (if (cursor-before-eof?) (push-beyond-eof!) (push-cursor! :fwd)) - ; We also want the `v` modifier to behave in the native way, that - ; is, to toggle between inclusive/exclusive if applied to a charwise - ; motion (:h o_v). As `v` will change our (technically) exclusive - ; motion to inclusive, we should push the cursor back to undo that. - :v (push-cursor! :bwd) - ; Blockwise (<c-v>) itself makes the motion inclusive, do nothing in - ; that case. - )) - - -(fn force-matchparen-refresh [] - ; HACK: :DoMatchParen turns matchparen on simply by triggering - ; CursorMoved events (see matchparen.vim). We can do the same, which - ; is cleaner for us than calling :DoMatchParen directly, since that - ; would wrap this in a `windo`, and might visit another buffer, - ; breaking our visual selection (and thus also dot-repeat, - ; apparently). (See :h visual-start, and lightspeed#38.) - ; Programming against the API would be more robust of course, but in - ; the unlikely case that the implementation details would change, this - ; still cannot do any damage on our side if called with pcall (the - ; feature just ceases to work then). - (pcall api.nvim_exec_autocmds "CursorMoved" {:group "matchparen"}) - ; If vim-matchup is installed, it can similarly be forced to refresh - ; by triggering a CursorMoved event. (The same caveats apply.) - (pcall api.nvim_exec_autocmds "CursorMoved" {:group "matchup_matchparen"})) - - -(fn jump-to! [pos {: winid : add-to-jumplist? : mode - : offset : backward? : inclusive-op?}] - (local op-mode? (mode:match :o)) - ; Note: <C-o> will ignore this if the line has not changed (neovim#9874). - (when add-to-jumplist? (vim.cmd "norm! m`")) - (when (not= winid (vim.fn.win_getid)) - (api.nvim_set_current_win winid)) - (vim.fn.cursor pos) - (when offset (add-offset! offset)) - ; Since Vim interprets our jump as an exclusive motion (:h exclusive), - ; we need custom tweaks to behave as an inclusive one. (This is only - ; relevant in the forward direction, as inclusiveness applies to the - ; end of the selection.) - (when (and op-mode? inclusive-op? (not backward?)) - (simulate-inclusive-op! mode)) - (when (not op-mode?) (force-matchparen-refresh))) - - -{: jump-to!} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/main.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/main.fnl @@ -1,876 +0,0 @@ -; Imports & aliases ///1 - -(local hl (require "leap.highlight")) -(local opts (require "leap.opts")) - -(local {: inc - : dec - : clamp - : echo - : replace-keycodes - : get-cursor-pos - : push-cursor! - : get-eq-class-of - : ->representative-char - : get-input - : get-input-by-keymap} - (require "leap.util")) - -(local api vim.api) -(local contains? vim.tbl_contains) -(local empty? vim.tbl_isempty) -(local map vim.tbl_map) -(local {: abs : ceil : max : min : pow} math) - - -; Fennel utils ///1 - -(macro when-not [cond ...] - `(when (not ,cond) ,...)) - - -; Utils ///1 - -(fn exec-user-autocmds [pattern] - (api.nvim_exec_autocmds "User" {: pattern :modeline false})) - - -(fn handle-interrupted-change-op! [] - "Return to Normal mode and restore the cursor position after an -interrupted change operation." - (let [seq (.. "<C-\\><C-G>" ; :h CTRL-\_CTRL-G - (if (> (vim.fn.col ".") 1) "<RIGHT>" ""))] - (api.nvim_feedkeys (replace-keycodes seq) :n true))) - - -; repeat.vim support -; (see the docs in the script: -; https://github.com/tpope/vim-repeat/blob/master/autoload/repeat.vim) -(fn set-dot-repeat* [] - ; Note: dot-repeatable (i.e. non-yank) operation is assumed, we're not - ; checking it here. - (let [op vim.v.operator - cmd (replace-keycodes - "<cmd>lua require'leap'.leap { dot_repeat = true }<cr>") - ; We cannot getreg('.') at this point, since the change has not - ; happened yet - therefore the below hack (thx Sneak). - change (when (= op :c) (replace-keycodes "<c-r>.<esc>")) - seq (.. op cmd (or change ""))] - ; Using pcall, since vim-repeat might not be installed. - ; Use the same register for the repeated operation. - (pcall vim.fn.repeat#setreg seq vim.v.register) - ; Note: we're feeding count inside the seq itself. - (pcall vim.fn.repeat#set seq -1))) - - -; Return a char->eq-class lookup table (the relevant one for us). -(fn eq-classes->membership-lookup [eqcls] - (let [res {}] - (each [_ eqcl (ipairs eqcls)] - (let [eqcl* (if (= (type eqcl) :string) - (vim.fn.split eqcl "\\zs") - eqcl)] - (each [_ ch (ipairs eqcl*)] - (tset res ch eqcl*)))) - res)) - - -; Processing targets ///1 - -(fn set-autojump [targets force-noautojump?] - "Set a flag indicating whether we should autojump to the first target, -without having to select a label. -Note that there is no one-to-one correspondence between this flag and -the `label-set` field set by `attach-label-set`. No-autojump might be -forced implicitly, regardless of using safe labels." - (tset targets :autojump? - (and (not (or force-noautojump? (empty? opts.safe_labels))) - (or (empty? opts.labels) - ; Smart mode. - (>= (length opts.safe_labels) - (dec (length targets))))))) ; skipping the first if autojumping - - -(fn attach-label-set [targets] - "Set a field referencing the label set to be used for `targets`. -NOTE: `set-autojump` should be called BEFORE this function." - ; (assert (not (and (empty? opts.labels) (empty? opts.safe_labels)))) - (tset targets :label-set - (if (empty? opts.labels) opts.safe_labels - (empty? opts.safe_labels) opts.labels - targets.autojump? opts.safe_labels - opts.labels))) - - -(fn set-labels [targets multi-select?] - "Assign label characters to each target, using the given label set -repeated indefinitely. -Note: `label` is a once and for all fixed attribute - whether and how it -should actually be displayed depends on the `label-state` flag." - (when (or (> (length targets) 1) multi-select?) ; else we jump unconditionally - (local {: autojump? : label-set} targets) - (each [i target (ipairs targets)] - ; Skip labeling the first target if autojump is set. - (local i* (if autojump? (dec i) i)) - (when (> i* 0) - (tset target :label - (match (% i* (length label-set)) - 0 (. label-set (length label-set)) - n (. label-set n))))))) - - -(fn set-label-states [targets {: group-offset}] - (let [|label-set| (length targets.label-set) - offset (* group-offset |label-set|) - primary-start (+ offset (if targets.autojump? 2 1)) - primary-end (+ primary-start (dec |label-set|)) - secondary-start (inc primary-end) - secondary-end (+ primary-end |label-set|)] - (each [i target (ipairs targets)] - (when (and target.label (not= target.label-state :selected)) - (tset target :label-state - (if (<= primary-start i primary-end) :active-primary - (<= secondary-start i secondary-end) :active-secondary - (> i secondary-end) :inactive)))))) - - -(fn inactivate-labels [targets] - (each [_ target (ipairs targets)] - (tset target :label-state :inactive))) - - -; Two-step processing - -(fn populate-sublists [targets] - "Populate a sub-table in `targets` containing lists that allow for -easy iteration through each subset of targets with a given successor -char separately. - - at ar at at ar ar an ar -{ t1, t2, t3, t4, t5, t6, t7, t8 } ---> -{ - t1, t2, t3, t4, t5, t6, t7, t8, - sublists = { - ['t'] = { t1, t3, t4 }, - ['r'] = { t2, t5, t6, t8 }, - ['n'] = { t7 } - }, -} -" - ; Setting a metatable to handle case insensitivity and equivalence - ; classes (in both cases: multiple keys -> one value). - ; If `ch` is not found, try to get a sublist belonging to some common - ; key: the equivalence class that `ch` belongs to (if there is one), - ; or, if case insensivity is set, the lowercased verison of `ch`. - ; (And in the above cases, `ch` will not be found, since we also - ; redirect to the common keys when inserting a new sublist.) - (tset targets :sublists - (setmetatable {} - {:__index (fn [self ch] (rawget self (->representative-char ch))) - :__newindex (fn [self ch sublist] - (rawset self (->representative-char ch) sublist))})) - ; Filling the sublists. - (each [_ {:chars [_ ch2] &as target} (ipairs targets)] - ; "\n"-s after empty lines don't have a `ch2`. Still, we put these - ; targets into the sublist for "\n", so that they can be targeted - ; with <key><key> (as if there would be another "\n" after them). - (local ch2 (or ch2 "\n")) - (when-not (. targets.sublists ch2) - (tset targets.sublists ch2 [])) - (table.insert (. targets.sublists ch2) target))) - - -(fn set-initial-label-states [targets] - (each [_ sublist (pairs targets.sublists)] - (set-label-states sublist {:group-offset 0}))) - - -; Display ///1 - -; "Beacon" is an umbrella term for any kind of visual overlay tied to -; targets - in practice, either a label character, or a highlighting of -; the match itself. Technically an [offset virtualtext] tuple, where -; `offset` is counted from the match position, and `virtualtext` is a -; list of [text hl-group] tuples (the kind that `nvim_buf_set_extmark` -; expects). - - -; Handling multibyte characters. -(fn get-label-offset [target] - (let [{:chars [ch1 ch2]} target] - (if target.empty-line? 0 - target.edge-pos? (ch1:len) - (+ (ch1:len) (ch2:len))))) - - -(fn set-beacon-for-labeled [target {: user-given-targets? : aot?}] - (let [offset (if aot? (get-label-offset target) 0) ; user-given-targets implies (not aot) - pad (if (or user-given-targets? aot?) "" " ") - label (or (. opts.substitute_chars target.label) target.label) - text (.. label pad) - virttext (match target.label-state - :selected [[text hl.group.label-selected]] - :active-primary [[text hl.group.label-primary]] - :active-secondary [[text hl.group.label-secondary]] - :inactive (if (and aot? (not opts.highlight_unlabeled_phase_one_targets)) - ; In this case, "no highlight" should - ; unambiguously signal "no further keystrokes - ; needed", so it is mandatory to show all labeled - ; positions in some way. - [[(.. " " pad) hl.group.label-secondary]] - :else nil))] - (tset target :beacon (when virttext [offset virttext])))) - - -(fn set-beacon-to-match-hl [target] - (local virttext (->> target.chars - (map #(or (. opts.substitute_chars $) $)) - table.concat)) - (tset target :beacon [0 [[virttext hl.group.match]]])) - - -(fn set-beacon-to-empty-label [target] - (tset target :beacon 2 1 1 " ")) - - -(fn resolve-conflicts [targets] - "After setting the beacons in a context-unaware manner, the following -conflicts can occur: - -(A) An unlabeled match covers a label. - Fix: Force highlighting of the unlabeled match, to make the user - aware ('Label underneath!'). - -(B) An unlabeled match (X) touches the label of another match (Y) - (possible at EOL or window edge, where labels need to be shifted - left). This is unacceptable - it looks like the label is for X: - y1 ylabel | - x1 x2 | - ----------------- - -3 -2 -1 edge-pos - - Fix: Force highlighting of the unlabeled match, to avoid confusion. - -(C) Two labels on top of each other. (Possible if one of the - labels is shifted, like above.) - Fix: Display an 'empty' label at the position. - -Note: The three cases are mutually exclusive. Case A implies the label -is not shifted (if there is a match after us, we cannot be at the edge). -And if we have a target with a shifted label, then the conflicting other -is either labeled (C) or not (B). -" - ; Tables to help us check potential conflicts (we'll be filling them - ; as we go). - ; { "<bufnr> <winid> <lnum> <col>" = <target> } - (let [pos-unlabeled-match {} - pos-labeled-match {} - pos-label {}] - ; Note: A1-A2, B1-B2, C1-C2 are all necessary, as we do only one - ; traversal run, and we don't assume anything about the direction - ; and the ordering; we always resolve the conflict at the second - ; target - at that point, the first one has already been registered - ; as a potential source of conflict. - (each [_ target (ipairs targets)] - (when-not target.empty-line? - (local {: bufnr : winid} target.wininfo) - (local [lnum col] target.pos) - (local col-ch2 (+ col (string.len (. target.chars 1)))) - (macro ->key [col*] - `(.. bufnr " " winid " " lnum " " ,col*)) - ; Beacon can be nil (if label-state is inactive). - (if (and target.label target.beacon) - (let [label-offset (. target.beacon 1) - col-label (+ col label-offset) - shifted-label? (= col-label col-ch2)] - ; ------------------------------ - ; (A1) - ; [a][b][L][-] --> nil | current - ; [-][-][a][c] --> match-hl | other - ; ^ | column to check - ; or - ; [a][a][L] --> nil - ; [-][a][b] --> match-hl - ; ^ - (match (. pos-unlabeled-match (->key col-label)) - other (do (set target.beacon nil) - (set-beacon-to-match-hl other))) - ; ------------------------------ - ; (B1) - ; [-][a][L]| - ; [a][a][-]| --> match-hl - ; ^ - (when shifted-label? - (match (. pos-unlabeled-match (->key col)) - other (set-beacon-to-match-hl other))) - ; ------------------------------ - ; (C) - ; [-][a][L]| --> nil - ; [a][a][L]| --> empty - ; ^ - ; or - ; [a][a][L]| --> nil - ; [-][a][L]| --> empty - ; ^ - (match (. pos-label (->key col-label)) - other (do (set target.beacon nil) - (set-beacon-to-empty-label other))) - ; ------------------------------ - ; NOTE: We should register the label position _after_ - ; checking case C, as we don't want to literally chase our - ; own tail, i.e., our own label. - (tset pos-label (->key col-label) target) - (tset pos-labeled-match (->key col) target) - (when-not shifted-label? - (tset pos-labeled-match (->key col-ch2) target))) - - (not target.label) - (do - (each [_ key (ipairs [(->key col) (->key col-ch2)])] - (tset pos-unlabeled-match key target) - ; ------------------------------ - ; (A2) - ; [-][-][a][b] --> match-hl - ; [a][c][L][-] --> nil - ; ^ - ; and - ; [-][a][b] --> match-hl - ; [a][a][L] --> nil - ; ^ - (match (. pos-label key) - other (do (set other.beacon nil) - (set-beacon-to-match-hl target)))) - ; ------------------------------ - ; (B2) - ; [a][a][-]| --> match-hl - ; [-][a][L]| - ; ^ - (local col-after (+ col-ch2 (string.len (. target :chars 2)))) - (match (. pos-label (->key col-after)) - other (set-beacon-to-match-hl target)))))))) - - -(fn set-beacons [targets {: no-labels? : user-given-targets? : aot?}] - (if (and no-labels? (. targets 1 :chars)) ; user-given targets might not have :chars - (each [_ target (ipairs targets)] - (set-beacon-to-match-hl target)) - (do (each [_ target (ipairs targets)] - (if target.label - (set-beacon-for-labeled target {: user-given-targets? : aot?}) - - (and aot? opts.highlight_unlabeled_phase_one_targets) - (set-beacon-to-match-hl target))) - (when aot? - (resolve-conflicts targets))))) - - -(fn light-up-beacons [targets ?start ?end] - (for [i (or ?start 1) (or ?end (length targets))] - (local target (. targets i)) - (match target.beacon - [offset virttext] - (let [bufnr target.wininfo.bufnr - [lnum col] (map dec target.pos) ; 1/1 -> 0/0 indexing - id (api.nvim_buf_set_extmark bufnr hl.ns lnum (+ col offset) - {:virt_text virttext - :virt_text_pos "overlay" - :hl_mode "combine" - :priority hl.priority.label})] - ; Register each newly set extmark in a table, so that we can - ; delete them one by one, without needing any further contextual - ; information. This is relevant if we process user-given targets - ; and have no knowledge about the boundaries of the search area. - (table.insert hl.extmarks [bufnr id]))))) - - -; Main ///1 - -; State that is persisted between invocations. -(local state {:args nil ; arguments passed to the current call - :source_window nil - :repeat {:in1 nil :in2 nil} - :dot_repeat {:in1 nil :in2 nil - :target_idx nil - :backward nil - :inclusive_op nil - :offset nil} - :saved_editor_opts {}}) - - -(fn leap [kwargs] - "Entry point for Leap motions." - (let [{:dot_repeat dot-repeat? - :target_windows target-windows - :opts user-given-opts - :targets user-given-targets - :action user-given-action - :multiselect multi-select?} - kwargs - {:backward backward? - :match_last_overlapping match-last-overlapping? - :inclusive_op inclusive-op? - : offset} - (if dot-repeat? state.dot_repeat kwargs) - _ (set state.args kwargs) - _ (set opts.current_call (or user-given-opts {})) - _ (tset opts.current_call :eq_class_of - (-?> opts.current_call.equivalence_classes - eq-classes->membership-lookup)) - ;;; - id->wininfo #(. (vim.fn.getwininfo $) 1) - curr-winid (vim.fn.win_getid) - _ (set state.source_window curr-winid) - curr-win (id->wininfo curr-winid) - ?target-windows (-?>> target-windows (map id->wininfo)) - hl-affected-windows (icollect [_ w (ipairs (or ?target-windows [])) - &into [curr-win]] ; cursor is always highlighted - w) - directional? (not target-windows) - ; We need to save the mode here, because the `:normal` command - ; in `jump.jump-to!` can change the state. See vim/vim#9332. - mode (. (api.nvim_get_mode) :mode) - op-mode? (mode:match :o) - change-op? (and op-mode? (= vim.v.operator :c)) - dot-repeatable-op? (and op-mode? directional? (not= vim.v.operator :y)) - no-labels? (and (empty? opts.labels) (empty? opts.safe_labels)) - count (if (not directional?) nil - (= vim.v.count 0) (if (and op-mode? no-labels?) 1 nil) - vim.v.count) - force-noautojump? (or op-mode? ; should be able to select a target - multi-select? ; likewise - (not directional?) ; potentially disorienting - user-given-action) ; no jump, doing sg else - max-phase-one-targets (or opts.max_phase_one_targets math.huge) - user-given-targets? user-given-targets - prompt {:str ">"} ; pass by reference hack (for input fns) - spec-keys (setmetatable {} - {:__index (fn [_ k] - (match (. opts.special_keys k) - v (if (or (= k :next_target) (= k :prev_target)) - ; Force those into a table. - (match (type v) - :table (icollect [_ str (ipairs v)] - (replace-keycodes str)) - :string [(replace-keycodes v)]) - (replace-keycodes v))))})] - - (when (and target-windows (empty? target-windows)) - (echo "no targetable windows") - (lua :return)) - (when (and (not directional?) no-labels?) - (echo "no labels to use") - (lua :return)) - - ; Show beacons (labels & match highlights) ahead of time, - ; right after the first input? - (var aot? (not (or (= max-phase-one-targets 0) - count - no-labels? - multi-select? - user-given-targets?))) - - (var current-idx 0) - - ; Helpers /// - - (fn echo-not-found [s] (echo (.. "not found: " s))) - - ; Note: One of the main purpose of these macros, besides wrapping - ; cleanup stuff, is to enforce and encapsulate the requirement that - ; tail-positioned "exit" forms in `match` blocks should always - ; return nil. (Interop with side-effecting VimL functions can be - ; dangerous, they might return 0 for example, like `feedkey`, and - ; with that they can screw up Fennel match forms in a breeze, - ; resulting in misterious bugs, so it's better to be paranoid.) - (macro exit [...] - `(do (do ,...) - (hl:cleanup hl-affected-windows) - (exec-user-autocmds :LeapLeave) - nil)) - - ; Be sure not to call the macro twice accidentally, - ; `handle-interrupted-change-op!` moves the cursor! - (macro exit-early [...] - `(do (when change-op? (handle-interrupted-change-op!)) - (exit ,...))) - - (macro with-highlight-chores [...] - `(do (hl:cleanup hl-affected-windows) - (when-not count - (hl:apply-backdrop backward? ?target-windows)) - (do ,...) - (hl:highlight-cursor) - (vim.cmd :redraw))) - - (fn fill-wininfo [targets] - (when-not (empty? targets) - (when-not (. targets 1 :wininfo) - (each [_ t (ipairs targets)] - (set t.wininfo curr-win))) - targets)) - - (fn get-user-given-targets [targets] - (-?> (match targets [&as tbl] tbl func (func)) - fill-wininfo)) - - (fn expand-to-equivalence-class [in] ; <-- "b" - (match (get-eq-class-of in) - chars ; --> {"a","b","c"} - ; `vim.fn.search` cannot interpret actual newline (LF) chars in - ; the regex pattern, we need to insert them as raw \ + n. - ; Backslash itself might appear in the class, needs to be escaped. - (let [chars* (map #(match $ "\n" "\\n" "\\" "\\\\" _ $) chars)] - (.. "\\(" (table.concat chars* "\\|") "\\)")))) ; --> "\(a\|b\|c\)" - - ; NOTE: If two-step processing is ebabled (AOT beacons), for any - ; kind of input mapping (case-insensitivity, character classes, - ; etc.) we need to tweak things in two different places: - ; 1. For the first input, we modify the search pattern itself - ; (here). - ; 2. For the second input, we need to play with the sublist keys - ; (see `populate-sublists`). - (fn prepare-pattern [in1 ?in2] - (.. "\\V" - (if opts.case_sensitive "\\C" "\\c") - (or (expand-to-equivalence-class in1) - (in1:gsub "\\" "\\\\")) ; sole backslash needs to be escaped even for \V - (or (-?> ?in2 expand-to-equivalence-class) - ?in2 - "\\_."))) ; match anything, including EOL - - (fn get-target-with-active-primary-label [sublist input] - (var res nil) - (each [idx {: label : label-state &as target} (ipairs sublist) - &until (or res (= label-state :inactive))] - (when (and (= label input) (= label-state :active-primary)) - (set res [idx target]))) - res) - - (fn update-repeat-state [state*] - (when-not user-given-targets? - (set state.repeat state*))) - - (fn set-dot-repeat [in1 in2 target_idx] - (when (and dot-repeatable-op? - (not (or dot-repeat? (= (type user-given-targets) :table)))) - (set state.dot_repeat - (vim.tbl_extend :error - {: target_idx - ; Mind the naming conventions. - :backward backward? :inclusive_op inclusive-op? : offset} - (if user-given-targets {:callback user-given-targets} - {: in1 : in2}))) - (set-dot-repeat*))) - - (local jump-to! - (do - (var first-jump? true) ; better be managed by the function itself - (fn [target] - (local jump (require "leap.jump")) - (jump.jump-to! target.pos - {:winid target.wininfo.winid - :add-to-jumplist? first-jump? - : mode : offset : backward? : inclusive-op?}) - (set first-jump? false)))) - - ; When traversing without labels, keep highlighting the same one group - ; of targets, and do not shift until reaching the end of the group - it - ; is less disorienting if the "snake" does not move continuously, on - ; every jump. - (fn get-number-of-highlighted-targets [] - (match opts.max_highlighted_traversal_targets - group-size - ; Assumption: being here means we are after an autojump, and - ; started highlighting from the 2nd target (no `count`). - ; Thus, we can use `current-idx` as the reference, instead of - ; some separate counter (but only because of the above). - (let [consumed (% (dec current-idx) group-size) - remaining (- group-size consumed)] - ; Switch just before the whole group gets eaten up. - (if (= remaining 1) (inc group-size) - (= remaining 0) group-size - remaining)))) - - (fn get-highlighted-idx-range [targets no-labels?] - (if (and no-labels? (= opts.max_highlighted_traversal_targets 0)) - (values 0 -1) ; empty range - (let [start (inc current-idx) - end (when no-labels? - (-?> (get-number-of-highlighted-targets) - (+ (dec start)) - (min (length targets))))] - (values start end)))) - - (fn get-first-pattern-input [] - (with-highlight-chores (echo "")) ; clean up the command line - (match (or (get-input-by-keymap prompt) (exit-early)) - ; Here we can handle any other modifier key as "zeroth" input, - ; if the need arises. - spec-keys.repeat_search - (if state.repeat.in1 - (do (set aot? false) - (values state.repeat.in1 state.repeat.in2)) - (exit-early (echo "no previous search"))) - - in1 in1)) - - (fn get-second-pattern-input [targets] - (when (<= (length targets) max-phase-one-targets) - (with-highlight-chores (light-up-beacons targets))) - (or (get-input-by-keymap prompt) (exit-early))) - - (fn get-full-pattern-input [] - (match (get-first-pattern-input) - (in1 in2) (values in1 in2) - (in1 nil) (match (get-input-by-keymap prompt) - in2 (values in1 in2) - _ (exit-early)))) - - (fn post-pattern-input-loop [targets ?group-offset first-invoc?] - (fn loop [group-offset first-invoc?] - ; Do _not_ skip this on initial invocation - we might have skipped - ; setting the initial label states if using `spec-keys.repeat_search`. - (when targets.label-set - (set-label-states targets {: group-offset})) - (set-beacons targets {: aot? : no-labels? : user-given-targets?}) - (with-highlight-chores - (let [(start end) (get-highlighted-idx-range targets no-labels?)] - (light-up-beacons targets start end))) - (match (or (get-input) (exit-early)) - input - (if (and (or (= input spec-keys.next_group) - (and (= input spec-keys.prev_group) (not first-invoc?))) - ; Autojump, if it is not forced (by empty `labels`), - ; implies that there are no subsequent groups. - (or (not targets.autojump?) (empty? opts.labels))) - (let [inc/dec (if (= input spec-keys.next_group) inc dec) - |groups| (ceil (/ (length targets) (length targets.label-set))) - max-offset (dec |groups|) - group-offset* (-> group-offset inc/dec (clamp 0 max-offset))] - (loop group-offset* false)) - (values input group-offset)))) - (loop (or ?group-offset 0) (or (= nil first-invoc?) first-invoc?))) - - (local multi-select-loop - (let [selection []] - (var group-offset 0) - (var first-invoc? true) - (fn loop [targets] - (match (post-pattern-input-loop targets group-offset first-invoc?) - spec-keys.multi_accept - (if (next selection) selection ; accept selection - (loop targets)) - - spec-keys.multi_revert - (do (-?> (table.remove selection) - (tset :label-state nil)) - (loop targets)) - - (in group-offset*) - (do (set group-offset group-offset*) - (set first-invoc? false) - (match (get-target-with-active-primary-label targets in) - [_ target] (when-not (contains? selection target) - (table.insert selection target) - (tset target :label-state :selected))) - (loop targets)))))) - - (fn traversal-loop [targets idx {: no-labels?}] - (set current-idx idx) - (when no-labels? (inactivate-labels targets)) - (set-beacons targets {: no-labels? : aot? : user-given-targets?}) - (with-highlight-chores - (let [(start end) (get-highlighted-idx-range targets no-labels?)] - (light-up-beacons targets start end))) - (match (or (get-input) (exit)) - input - (match (if (contains? spec-keys.next_target input) (min (inc idx) (length targets)) - (contains? spec-keys.prev_target input) (max (dec idx) 1)) - new-idx (do - ; We need to update the repeat state continuously, in case - ; we have entered traversal mode after the first input - ; (i.e., traversing all matches, not just a given sublist)! - (update-repeat-state {:in1 state.repeat.in1 - ; ?. -> user-given targets might not have :chars - :in2 (?. targets new-idx :chars 2)}) - (jump-to! (. targets new-idx)) - (traversal-loop targets new-idx {: no-labels?})) - ; We still want the labels (if there are) to function. - _ (match (get-target-with-active-primary-label targets input) - [_ target] (exit (jump-to! target)) - _ (exit (vim.fn.feedkeys input :i)))))) - - ; //> Helpers - - (local do-action (or user-given-action jump-to!)) - - ; After all the stage-setting, here comes the main action you've all been - ; waiting for: - - (exec-user-autocmds :LeapEnter) - - (match-try (if dot-repeat? (if state.dot_repeat.callback (values true true) - (values state.dot_repeat.in1 - state.dot_repeat.in2)) - user-given-targets? (values true true) - ; This might also return in2 too, if using the `repeat_search` key. - aot? (get-first-pattern-input) ; REDRAW - (get-full-pattern-input)) ; REDRAW - (in1 ?in2) (if (and dot-repeat? state.dot_repeat.callback) - (get-user-given-targets state.dot_repeat.callback) - user-given-targets? (or (get-user-given-targets - user-given-targets) - (exit-early (echo "no targets"))) - (or (let [search (require "leap.search") - pattern (prepare-pattern in1 ?in2) - kwargs {: backward? : match-last-overlapping? - :target-windows ?target-windows}] - (search.get-targets pattern kwargs)) - (exit-early (echo-not-found (.. in1 (or ?in2 "")))))) - targets (if dot-repeat? (match (. targets state.dot_repeat.target_idx) - target (exit (do-action target)) - _ (exit-early)) - (let [prepare-targets #(doto $ - (set-autojump force-noautojump?) - (attach-label-set) - (set-labels multi-select?))] - (if ?in2 - (if no-labels? (tset targets :autojump? true) - (prepare-targets targets)) - (do (populate-sublists targets) - (each [_ sublist (pairs targets.sublists)] - (prepare-targets sublist)))) - (when (> (length targets) max-phase-one-targets) - (set aot? false)) - (or ?in2 - (do (doto targets - (set-initial-label-states) - (set-beacons {: aot?})) - (get-second-pattern-input targets))))) ; REDRAW - in2 (if - ; Jump to the very first match? - (= in2 spec-keys.next_phase_one_target) - (let [in2 (. targets 1 :chars 2)] - (update-repeat-state {: in1 : in2}) - (do-action (. targets 1)) - (if (or (= (length targets) 1) - op-mode? (not directional?) user-given-action) - (exit (set-dot-repeat in1 in2 1)) - (traversal-loop targets 1 {:no-labels? true}))) ; REDRAW (LOOP) - (do - (update-repeat-state {: in1 : in2}) ; do this now - repeat can succeed - (match (or (if targets.sublists (. targets.sublists in2) targets) - (exit-early (echo-not-found (.. in1 in2)))) - targets* - (if multi-select? (match (multi-select-loop targets*) - targets** (exit (with-highlight-chores - (light-up-beacons targets**)) - (do-action targets**))) - (let [exit-with-action (fn [idx] - (exit (set-dot-repeat in1 in2 idx) - (do-action (. targets* idx)))) - |targets*| (length targets*)] - (if count (if (<= count |targets*|) (exit-with-action count) - (exit-early)) - (= |targets*| 1) (exit-with-action 1) - (do - (when targets*.autojump? - (set current-idx 1) - (do-action (. targets* 1))) - ; This sets label states (i.e., modifies targets*) in each cycle. - (match (post-pattern-input-loop targets*) ; REDRAW (LOOP) - in-final - (if - ; Jump to the first match on the [rest of the] target list? - (contains? spec-keys.next_target in-final) - (if (or op-mode? (not directional?) user-given-action) - (exit-with-action 1) ; (no autojump) - (let [new-idx (inc current-idx)] - (do-action (. targets* new-idx)) - (when (and (empty? opts.labels) (not (empty? opts.safe_labels))) - (for [i (+ (length opts.safe_labels) 2) |targets*|] - (tset targets* i :label nil) - (tset targets* i :beacon nil))) - (traversal-loop targets* new-idx ; REDRAW (LOOP) - {:no-labels? - (or no-labels? (not targets*.autojump?))}))) - (match (get-target-with-active-primary-label targets* in-final) - [idx _] (exit-with-action idx) - _ (if targets*.autojump? (exit (vim.fn.feedkeys in-final :i)) - (exit-early))))))))))))))) - - -; Init ///1 - -; The equivalence class table can be potentially huge - let's do this -; here, and not each time `leap` is called, at least for the defaults. -(tset opts.default :eq_class_of - (-?> opts.default.equivalence_classes - eq-classes->membership-lookup)) - - -(api.nvim_create_augroup "LeapDefault" {}) - - -; Highlight - -(hl:init-highlight) -; Colorscheme plugins might clear out our highlight definitions, without -; defining their own, so we re-init the highlight on every change. -(api.nvim_create_autocmd "ColorScheme" {:callback #(hl:init-highlight) - :group "LeapDefault"}) - - -; Editor options - -(fn set-editor-opts [t] - (set state.saved_editor_opts {}) - (local wins (or state.args.target_windows [state.source_window])) - (each [opt val (pairs t)] - (let [[scope name] (vim.split opt "." {:plain true})] - (match scope - :w (each [_ w (ipairs wins)] - (->> (api.nvim_win_get_option w name) - (tset state.saved_editor_opts [:w w name])) - (api.nvim_win_set_option w name val)) - :b (each [_ w (ipairs wins)] - (local b (api.nvim_win_get_buf w)) - (->> (api.nvim_buf_get_option b name) - (tset state.saved_editor_opts [:b b name])) - (api.nvim_buf_set_option b name val)) - _ (do (->> (api.nvim_get_option name) - (tset state.saved_editor_opts name)) - (api.nvim_set_option name val)))))) - - -(fn restore-editor-opts [] - (each [key val (pairs state.saved_editor_opts)] - (match key - [:w w name] (api.nvim_win_set_option w name val) - [:b b name] (api.nvim_buf_set_option b name val) - name (api.nvim_set_option name val)))) - - -(local temporary-editor-opts {:w.conceallevel 0 - :g.scrolloff 0 - :w.scrolloff 0 - :g.sidescrolloff 0 - :w.sidescrolloff 0 - :b.modeline false}) ; lightspeed#81 - -(api.nvim_create_autocmd "User" {:pattern "LeapEnter" - :callback #(set-editor-opts temporary-editor-opts) - :group "LeapDefault"}) - -(api.nvim_create_autocmd "User" {:pattern "LeapLeave" - :callback #(restore-editor-opts) - :group "LeapDefault"}) - - -; Module ///1 - -{: state : leap} - - -; vim: foldmethod=marker foldmarker=///,//> diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/opts.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/opts.fnl @@ -1,34 +0,0 @@ -(local current_call {}) ; will be updated by `leap` on invocation - -(local default - {:max_phase_one_targets nil - :highlight_unlabeled_phase_one_targets false - :max_highlighted_traversal_targets 10 - :case_sensitive false - :equivalence_classes [" \t\r\n"] - :substitute_chars {} - :safe_labels ["s" "f" "n" "u" "t" "/" - "S" "F" "N" "L" "H" "M" "U" "G" "T" "?" "Z"] - :labels ["s" "f" "n" - "j" "k" "l" "h" "o" "d" "w" "e" "m" "b" - "u" "y" "v" "r" "g" "t" "c" "x" "/" "z" - "S" "F" "N" - "J" "K" "L" "H" "O" "D" "W" "E" "M" "B" - "U" "Y" "V" "R" "G" "T" "C" "X" "?" "Z"] - :special_keys {:repeat_search "<enter>" - :next_phase_one_target "<enter>" - :next_target ["<enter>" ";"] - :prev_target ["<tab>" ","] - :next_group "<space>" - :prev_group "<tab>" - :multi_accept "<enter>" - :multi_revert "<backspace>"}}) - -; First try to look up everything in the `current_call` table, -; so that we can override settings on a per-call basis. -(-> {: current_call - : default} - (setmetatable {:__index (fn [self k] - (match (. self.current_call k) - v v ; `false` should be returned too - _ (. self.default k)))})) diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/search.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/search.fnl @@ -1,267 +0,0 @@ -(local {: inc - : dec - : replace-keycodes - : get-cursor-pos - : push-cursor! - : get-char-at - : ->representative-char} - (require "leap.util")) - -(local api vim.api) -(local empty? vim.tbl_isempty) -(local {: abs : pow} math) - - -(fn get-horizontal-bounds [] - " - [--------------------] window-width - (--------] offset-in-win - [--] textoff (e.g. foldcolumn) - (----] offset-in-editable-win -+----------------------+ -|XXXX | -|XXXX C | -|XXXX | -+----------------------+ -" - (let [textoff (. (vim.fn.getwininfo (vim.fn.win_getid)) 1 :textoff) - offset-in-win (dec (vim.fn.wincol)) - offset-in-editable-win (- offset-in-win textoff) - ; I.e., screen column of the first visible column in the editable area. - left-bound (- (vim.fn.virtcol ".") offset-in-editable-win) - window-width (api.nvim_win_get_width 0) - right-bound (+ left-bound (dec (- window-width textoff)))] - [left-bound right-bound])) ; screen columns - - -(fn skip-one! [backward?] - (local new-line (push-cursor! (if backward? :bwd :fwd))) - (when (= new-line 0) :dead-end)) - - -; Assumes being in a closed fold, no checks! -(fn to-closed-fold-edge! [backward?] - (local edge-line ((if backward? vim.fn.foldclosed vim.fn.foldclosedend) - (vim.fn.line "."))) - (vim.fn.cursor edge-line 0) - (local edge-col (if backward? 1 (vim.fn.col "$"))) - (vim.fn.cursor 0 edge-col)) - - -(fn to-next-in-window-pos! [backward? left-bound right-bound stopline] - ; virtcol = like `col`, starting from the beginning of the line in the - ; buffer, but every char counts as the #of screen columns it occupies - ; (or would occupy), instead of the #of bytes. - (let [forward? (not backward?) - [line virtcol] [(vim.fn.line ".") (vim.fn.virtcol ".")] - left-off? (< virtcol left-bound) - right-off? (> virtcol right-bound)] - (match (if (and left-off? backward?) [(dec line) right-bound] - (and left-off? forward?) [line left-bound] - (and right-off? backward?) [line right-bound] - (and right-off? forward?) [(inc line) left-bound]) - [line* virtcol*] - (if (or (and (= line line*) (= virtcol virtcol*)) - (and backward? (< line* stopline)) - (and forward? (> line* stopline))) - :dead-end - ; HACK: vim.fn.cursor expects bytecol, but we only have `right-bound` - ; as virtcol (at least until `virtcol2col()` is not ported); so simply - ; start crawling to the right, checking the virtcol... (When targeting - ; the left bound, we might undershoot too - the virtcol of a position - ; is always <= the bytecol of it -, but in that case it's no problem, - ; just some unnecessary work afterwards, as we're still outside the - ; on-screen area). - (do (vim.fn.cursor [line* virtcol*]) - (when backward? - (while (and (< (vim.fn.virtcol ".") right-bound) - (not (>= (vim.fn.col ".") (dec (vim.fn.col "$"))))) ; reached EOL - (vim.cmd "norm! l")))))))) - - -(fn get-match-positions [pattern [left-bound right-bound] - {: backward? : whole-window? : skip-curpos?}] - "Return an iterator streaming all visible positions of `pattern` in the -current window. -Caveat: side-effects take place here (cursor movement, &cpo), and the -clean-up happens only when the iterator is exhausted, so be careful with -early termination in loops." - (let [skip-orig-curpos? skip-curpos? - [orig-curline orig-curcol] (get-cursor-pos) - wintop (vim.fn.line "w0") - winbot (vim.fn.line "w$") - stopline (if backward? wintop winbot) - saved-view (vim.fn.winsaveview) - saved-cpo vim.o.cpo - cleanup #(do (vim.fn.winrestview saved-view) - (set vim.o.cpo saved-cpo) - nil)] - - (set vim.o.cpo (vim.o.cpo:gsub "c" "")) ; do not skip overlapping matches - (var match-count 0) - (var moved-to-topleft? (when whole-window? - (vim.fn.cursor [wintop left-bound]) - true)) - - (fn iter [match-at-curpos?] - (let [match-at-curpos? (or match-at-curpos? moved-to-topleft?) - flags (.. (if backward? "b" "") (if match-at-curpos? "c" ""))] - (set moved-to-topleft? false) - (match (vim.fn.searchpos pattern flags stopline) - [line col &as pos] - (if (= line 0) (cleanup) ; no match - - ; At the original cursor position (bidirectional search)? - (and (= line orig-curline) (= col orig-curcol) skip-orig-curpos?) - (match (skip-one!) - :dead-end (cleanup) ; = right before EOF - _ (iter true)) - - ; Horizontally offscreen? - (not (or vim.wo.wrap - (<= left-bound (vim.fn.virtcol ".") right-bound))) - (match (to-next-in-window-pos! - backward? left-bound right-bound stopline) - :dead-end (cleanup) ; = on the first/last line in the window - _ (iter true)) - - ; In a closed fold? - (not= (vim.fn.foldclosed line) -1) - (do (to-closed-fold-edge! backward?) - (match (skip-one! backward?) ; to actually get out of the fold - :dead-end (cleanup) ; = fold starts at the beginning of the buffer, - ; or reaches till the end - _ (iter true))) - - (do (set match-count (+ match-count 1)) - pos))))))) - - -(fn get-targets* [pattern ; assumed to match 2 logical/multibyte chars - {: backward? - : match-last-overlapping? - : wininfo - : targets - : source-winid}] - "Return a table that will store the positions and other metadata of -all in-window pairs that match `pattern`, in the order of discovery. A -target element in its final form has the following fields (the latter -ones might be set by subsequent functions): - -Static attributes (set once and for all) -pos : [lnum col] 1/1-indexed -chars : [char+] -edge-pos? : bool -?wininfo : `vim.fn.getwininfo` dict -?label : char - -Dynamic attributes -?label-state : 'active-primary' - | 'active-secondary' - | 'selected' - | 'inactive' -?beacon : [col-offset [[char hl-group]]] -" - (let [[left-bound right-bound*] (get-horizontal-bounds) - right-bound (dec right-bound*) ; the whole match should be visible - whole-window? wininfo - wininfo (or wininfo (. (vim.fn.getwininfo (vim.fn.win_getid)) 1)) - skip-curpos? (and whole-window? (= (vim.fn.win_getid) source-winid)) - match-positions (get-match-positions pattern - [left-bound right-bound] - {: backward? - : skip-curpos? - : whole-window?})] - (local targets (or targets [])) - (var prev-match {}) ; to find overlaps - (each [[line col &as pos] match-positions] - (match (get-char-at pos {}) - nil - ; `get-char-at` works on "inner" lines, it cannot get \n. - ; We provide it here for empty lines... - (when (= col 1) - (table.insert targets {: wininfo : pos - :chars ["\n"] - :empty-line? true})) - - ch1 - (let [ch2 (or (get-char-at pos {:char-offset +1}) - "\n") ; ...and for pre-\n chars - overlap? - (and (= line prev-match.line) - (if backward? - ; | |ch1 |ch2 - ; |ch1 |ch2 | - ; curr prev <--- - (= (- prev-match.col col) (ch1:len)) - ; |ch1 |ch2 | - ; | |ch1 |ch2 - ; prev curr ---> - (= (- col prev-match.col) (prev-match.ch1:len))) - (= (->representative-char ch2) - (->representative-char (or prev-match.ch2 ""))))] - (set prev-match {: line : col : ch1 : ch2}) - (when (and overlap? match-last-overlapping?) - (table.remove targets)) ; replace the previous - (when (or (not overlap?) match-last-overlapping?) - (table.insert targets {: wininfo : pos - :chars [ch1 ch2] - ; TODO: `right-bound` = virtcol, but `col` = byte col! - :edge-pos? (or (= ch2 "\n") - (= col right-bound))}))))) - (when (next targets) - targets))) - - -(fn distance [[l1 c1] [l2 c2]] - (let [editor-grid-aspect-ratio 0.3 ; arbitrary (make it configurable? get it programmatically?) - [dx dy] [(abs (- c1 c2)) (abs (- l1 l2))] - dx (* dx editor-grid-aspect-ratio)] - (pow (+ (pow dx 2) (pow dy 2)) 0.5))) - - -(fn get-targets [pattern kwargs] - (local {: backward? : match-last-overlapping? : target-windows} kwargs) - (if (not target-windows) (get-targets* pattern kwargs) - (let [targets [] - cursor-positions {} - source-winid (vim.fn.win_getid) - curr-win-only? (match target-windows - [{:winid source-winid} nil] true) - cross-win? (not curr-win-only?)] - (each [_ {: winid &as wininfo} (ipairs target-windows)] - (when cross-win? - (api.nvim_set_current_win winid)) - (tset cursor-positions winid (get-cursor-pos)) - ; Fill up the provided `targets`, instead of returning a new table. - (get-targets* pattern {: targets : wininfo : source-winid - : match-last-overlapping?})) - (when cross-win? - (api.nvim_set_current_win source-winid)) - (when (not (empty? targets)) - ; Sort targets by their distance from the cursor. - ; TODO: Check vim.wo.wrap for each window, and calculate accordingly. - ; TODO: (Performance) vim.fn.screenpos is very costly for a large - ; number of targets... - ; -> Only get them when at least one line is actually wrapped? - ; -> Some FFI magic? - (local by-screen-pos? (and vim.o.wrap (< (length targets) 200))) - (when by-screen-pos? - ; Update cursor positions to screen positions. - (each [winid [line col] (pairs cursor-positions)] - (match (vim.fn.screenpos winid line col) - {: row : col} (tset cursor-positions winid [row col])))) - (each [_ {:pos [line col] :wininfo {: winid} &as t} (ipairs targets)] - (when by-screen-pos? - ; Add a screen position field to each target. - (match (vim.fn.screenpos winid line col) ; PERF. BOTTLENECK - {: row : col} (tset t :screenpos [row col]))) - (tset t :rank (distance (or t.screenpos t.pos) - (. cursor-positions winid)))) - (table.sort targets #(< (. $1 :rank) (. $2 :rank))) - targets)))) - - -{: get-horizontal-bounds - : get-match-positions - : get-targets} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/user.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/user.fnl @@ -1,48 +0,0 @@ -; Convenience functions for users. - -(fn add-default-mappings [force?] - (each [_ [modes lhs rhs] - (ipairs - [[[:n :x :o] "s" "<Plug>(leap-forward-to)"] - [[:n :x :o] "S" "<Plug>(leap-backward-to)"] - [ [:x :o] "x" "<Plug>(leap-forward-till)"] - [ [:x :o] "X" "<Plug>(leap-backward-till)"] - [[:n :x :o] "gs" "<Plug>(leap-cross-window)"]])] - (each [_ mode (ipairs modes)] - (when (or force? - ; Otherwise only set the keymaps if: - ; 1. (A keyseq starting with) `lhs` is not already mapped - ; to something else. - ; 2. There is no existing mapping to the <Plug> key. - (and (= (vim.fn.mapcheck lhs mode) "") - (= (vim.fn.hasmapto rhs mode) 0))) - (vim.keymap.set mode lhs rhs {:silent true}))))) - -; Deprecated. -(fn set-default-keymaps [force?] - (each [_ [mode lhs rhs] - (ipairs - [[:n "s" "<Plug>(leap-forward)"] - [:n "S" "<Plug>(leap-backward)"] - [:x "s" "<Plug>(leap-forward)"] - [:x "S" "<Plug>(leap-backward)"] - [:o "z" "<Plug>(leap-forward)"] - [:o "Z" "<Plug>(leap-backward)"] - [:o "x" "<Plug>(leap-forward-x)"] - [:o "X" "<Plug>(leap-backward-x)"] - [:n "gs" "<Plug>(leap-cross-window)"] - [:x "gs" "<Plug>(leap-cross-window)"] - [:o "gs" "<Plug>(leap-cross-window)"]])] - (when (or force? - (and (= (vim.fn.mapcheck lhs mode) "") - (= (vim.fn.hasmapto rhs mode) 0))) - (vim.keymap.set mode lhs rhs {:silent true})))) - -; Deprecated. -(fn setup [user-opts] - (each [k v (pairs user-opts)] - (tset (require "leap.opts") :default k v))) - -{:add_default_mappings add-default-mappings - :set_default_keymaps set-default-keymaps - : setup} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/util.fnl b/.config/nvim/pack/bundle/start/leap.nvim/fnl/leap/util.fnl @@ -1,127 +0,0 @@ -(local opts (require "leap.opts")) - -(local api vim.api) -(local filter vim.tbl_filter) - - -(fn inc [x] (+ x 1)) - -(fn dec [x] (- x 1)) - -(fn clamp [x min max] - (if (< x min) min - (> x max) max - x)) - -(fn echo [msg] - (api.nvim_echo [[msg]] false [])) - -(fn replace-keycodes [s] - (api.nvim_replace_termcodes s true false true)) - -(fn get-cursor-pos [] - [(vim.fn.line ".") (vim.fn.col ".")]) - -(fn push-cursor! [direction] - "Push cursor 1 character to the left or right, possibly beyond EOL." - (vim.fn.search "\\_." (match direction :fwd "W" :bwd "bW"))) - - -(fn get-char-at [[line byte-col] {: char-offset}] ; expects (1,1)-indexed input - "Get character at the given position in a multibyte-aware manner. -An optional offset argument can be given to get the nth-next screen -character instead." - (let [line-str (vim.fn.getline line) - char-idx (vim.fn.charidx line-str (- byte-col 1)) ; expects 0-indexed col - char-nr (vim.fn.strgetchar line-str (+ char-idx (or char-offset 0)))] - (when (not= char-nr -1) - (vim.fn.nr2char char-nr)))) - - -(fn get-enterable-windows [] - (let [wins (api.nvim_tabpage_list_wins 0) - curr-win (api.nvim_get_current_win) - curr-buf (api.nvim_get_current_buf)] - (filter #(and (. (api.nvim_win_get_config $) :focusable) - (not= $ curr-win)) - wins))) - - -; NOTE: Lua's string.lower/upper are only for ASCII, -; use vim.fn.tolower/toupper everywhere. - -(fn get-eq-class-of [ch] - (if opts.case_sensitive - (. opts.eq_class_of ch) - (or (. opts.eq_class_of (vim.fn.tolower ch)) - (. opts.eq_class_of (vim.fn.toupper ch))))) - - -(fn ->representative-char [ch] - ; We choose the first one from an equiv-class (arbitrary). - (local ch* (or (?. (get-eq-class-of ch) 1) ch)) - (if opts.case_sensitive ch* (vim.fn.tolower ch*))) - - -; Input - -(local <bs> (replace-keycodes "<bs>")) -(local <cr> (replace-keycodes "<cr>")) -(local <esc> (replace-keycodes "<esc>")) - - -(fn get-input [] - (local (ok? ch) (pcall vim.fn.getcharstr)) ; pcall for <C-c> - ; <esc> should cleanly exit anytime. - (when (and ok? (not= ch <esc>)) ch)) - - -; :help mbyte-keymap -; prompt = {:str <val>} (pass by reference hack) -(fn get-input-by-keymap [prompt] - - (fn echo-prompt [seq] - (api.nvim_echo [[prompt.str] [(or seq "") :ErrorMsg]] false [])) - - (fn accept [ch] - (set prompt.str (.. prompt.str ch)) - (echo-prompt) - ch) - - (fn loop [seq] - (local |seq| (length (or seq ""))) - ; Arbitrary limit (`mapcheck` will continue to give back a candidate - ; if the start of `seq` matches, need to cut the gibberish somewhere). - (when (<= 1 |seq| 5) - (echo-prompt seq) - (let [rhs-candidate (vim.fn.mapcheck seq :l) - rhs (vim.fn.maparg seq :l)] - (if (= rhs-candidate "") (accept seq) ; implies |seq|=1 (no recursion here) - (= rhs rhs-candidate) (accept rhs) ; seq is the longest LHS match - (match (get-input) - <bs> (loop (if (>= |seq| 2) (seq:sub 1 (dec |seq|)) seq)) - <cr> (if (not= rhs "") (accept rhs) ; <enter> can accept a shorter one - (= |seq| 1) (accept seq) - (loop seq)) - ch (loop (.. seq ch))))))) - - (if (not= vim.bo.iminsert 1) (get-input) ; no keymap is active - (do (echo-prompt) - (match (loop (get-input)) - in in - _ (echo ""))))) - - -{: inc - : dec - : clamp - : echo - : replace-keycodes - : get-cursor-pos - : push-cursor! - : get-char-at - :get_enterable_windows get-enterable-windows - : get-eq-class-of - : ->representative-char - : get-input - : get-input-by-keymap} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/highlight.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/highlight.lua @@ -1,113 +0,0 @@ -local util = require("leap.util") -local _local_1_ = util -local inc = _local_1_["inc"] -local dec = _local_1_["dec"] -local api = vim.api -local map = vim.tbl_map -local M = {ns = api.nvim_create_namespace(""), extmarks = {}, group = {["label-primary"] = "LeapLabelPrimary", ["label-secondary"] = "LeapLabelSecondary", ["label-selected"] = "LeapLabelSelected", match = "LeapMatch", backdrop = "LeapBackdrop"}, priority = {label = 65535, cursor = 65534, backdrop = 65533}} -M.cleanup = function(self, affected_windows) - for _, _2_ in ipairs(self.extmarks) do - local _each_3_ = _2_ - local bufnr = _each_3_[1] - local id = _each_3_[2] - api.nvim_buf_del_extmark(bufnr, self.ns, id) - end - self.extmarks = {} - if pcall(api.nvim_get_hl_by_name, self.group.backdrop, false) then - for _, wininfo in ipairs(affected_windows) do - api.nvim_buf_clear_namespace(wininfo.bufnr, self.ns, dec(wininfo.topline), wininfo.botline) - end - return api.nvim_buf_clear_namespace(0, self.ns, dec(vim.fn.line("w0")), vim.fn.line("w$")) - else - return nil - end -end -M["apply-backdrop"] = function(self, backward_3f, _3ftarget_windows) - if pcall(api.nvim_get_hl_by_name, self.group.backdrop, false) then - if _3ftarget_windows then - for _, win in ipairs(_3ftarget_windows) do - vim.highlight.range(win.bufnr, self.ns, self.group.backdrop, {dec(win.topline), 0}, {dec(win.botline), -1}, {priority = self.priority.backdrop}) - end - return nil - else - local _let_5_ = map(dec, {vim.fn.line("."), vim.fn.col(".")}) - local curline = _let_5_[1] - local curcol = _let_5_[2] - local _let_6_ = {dec(vim.fn.line("w0")), dec(vim.fn.line("w$"))} - local win_top = _let_6_[1] - local win_bot = _let_6_[2] - local function _8_() - if backward_3f then - return {{win_top, 0}, {curline, curcol}} - else - return {{curline, inc(curcol)}, {win_bot, -1}} - end - end - local _let_7_ = _8_() - local start = _let_7_[1] - local finish = _let_7_[2] - return vim.highlight.range(0, self.ns, self.group.backdrop, start, finish, {priority = self.priority.backdrop}) - end - else - return nil - end -end -M["highlight-cursor"] = function(self, _3fpos) - local _let_11_ = (_3fpos or util["get-cursor-pos"]()) - local line = _let_11_[1] - local col = _let_11_[2] - local pos = _let_11_ - local ch_at_curpos = (util["get-char-at"](pos, {}) or " ") - local id = api.nvim_buf_set_extmark(0, self.ns, dec(line), dec(col), {virt_text = {{ch_at_curpos, "Cursor"}}, virt_text_pos = "overlay", hl_mode = "combine", priority = self.priority.cursor}) - return table.insert(self.extmarks, {api.nvim_get_current_buf(), id}) -end -M["init-highlight"] = function(self, force_3f) - local bg = vim.o.background - local defaults - local _13_ - do - local _12_ = bg - if (_12_ == "light") then - _13_ = "#222222" - elseif true then - local _ = _12_ - _13_ = "#ccff88" - else - _13_ = nil - end - end - local _18_ - do - local _17_ = bg - if (_17_ == "light") then - _18_ = "#ff8877" - elseif true then - local _ = _17_ - _18_ = "#ccff88" - else - _18_ = nil - end - end - local _23_ - do - local _22_ = bg - if (_22_ == "light") then - _23_ = "#77aaff" - elseif true then - local _ = _22_ - _23_ = "#99ccff" - else - _23_ = nil - end - end - defaults = {[self.group.match] = {fg = _13_, ctermfg = "red", underline = true, nocombine = true}, [self.group["label-primary"]] = {fg = "black", bg = _18_, ctermfg = "black", ctermbg = "red", nocombine = true}, [self.group["label-secondary"]] = {fg = "black", bg = _23_, ctermfg = "black", ctermbg = "blue", nocombine = true}, [self.group["label-selected"]] = {fg = "black", bg = "magenta", ctermfg = "black", ctermbg = "magenta", nocombine = true}} - for group_name, def_map in pairs(defaults) do - if not force_3f then - def_map["default"] = true - else - end - api.nvim_set_hl(0, group_name, def_map) - end - return nil -end -return M diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/init.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/init.lua @@ -1,24 +0,0 @@ -local function _1_(_, k) - local _2_ = k - if (_2_ == "opts") then - return (require("leap.opts")).default - elseif (_2_ == "leap") then - return (require("leap.main")).leap - elseif (_2_ == "state") then - return (require("leap.main")).state - elseif (_2_ == "setup") then - return (require("leap.user")).setup - elseif (_2_ == "add_default_mappings") then - return (require("leap.user")).add_default_mappings - elseif (_2_ == "init_highlight") then - local function _3_(...) - return (function(tgt, m, ...) return tgt[m](tgt, ...) end)(require("leap.highlight"), "init-highlight", ...) - end - return _3_ - elseif (_2_ == "set_default_keymaps") then - return (require("leap.user")).set_default_keymaps - else - return nil - end -end -return setmetatable({}, {__index = _1_}) diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/jump.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/jump.lua @@ -1,88 +0,0 @@ -local _local_1_ = require("leap.util") -local dec = _local_1_["dec"] -local push_cursor_21 = _local_1_["push-cursor!"] -local api = vim.api -local function cursor_before_eol_3f() - return (vim.fn.search("\\_.", "Wn") ~= vim.fn.line(".")) -end -local function cursor_before_eof_3f() - return ((vim.fn.line(".") == vim.fn.line("$")) and (vim.fn.virtcol(".") == dec(vim.fn.virtcol("$")))) -end -local function add_offset_21(offset) - if (offset < 0) then - return push_cursor_21("bwd") - elseif (offset > 0) then - if not cursor_before_eol_3f() then - push_cursor_21("fwd") - else - end - if (offset > 1) then - return push_cursor_21("fwd") - else - return nil - end - else - return nil - end -end -local function push_beyond_eof_21() - local saved = vim.o.virtualedit - vim.o.virtualedit = "onemore" - vim.cmd("norm! l") - local function _5_() - vim.o.virtualedit = saved - return nil - end - return api.nvim_create_autocmd({"CursorMoved", "WinLeave", "BufLeave", "InsertEnter", "CmdlineEnter", "CmdwinEnter"}, {callback = _5_, once = true}) -end -local function simulate_inclusive_op_21(mode) - local _6_ = vim.fn.matchstr(mode, "^no\\zs.") - if (_6_ == "") then - if cursor_before_eof_3f() then - return push_beyond_eof_21() - else - return push_cursor_21("fwd") - end - elseif (_6_ == "v") then - return push_cursor_21("bwd") - else - return nil - end -end -local function force_matchparen_refresh() - pcall(api.nvim_exec_autocmds, "CursorMoved", {group = "matchparen"}) - return pcall(api.nvim_exec_autocmds, "CursorMoved", {group = "matchup_matchparen"}) -end -local function jump_to_21(pos, _9_) - local _arg_10_ = _9_ - local winid = _arg_10_["winid"] - local add_to_jumplist_3f = _arg_10_["add-to-jumplist?"] - local mode = _arg_10_["mode"] - local offset = _arg_10_["offset"] - local backward_3f = _arg_10_["backward?"] - local inclusive_op_3f = _arg_10_["inclusive-op?"] - local op_mode_3f = mode:match("o") - if add_to_jumplist_3f then - vim.cmd("norm! m`") - else - end - if (winid ~= vim.fn.win_getid()) then - api.nvim_set_current_win(winid) - else - end - vim.fn.cursor(pos) - if offset then - add_offset_21(offset) - else - end - if (op_mode_3f and inclusive_op_3f and not backward_3f) then - simulate_inclusive_op_21(mode) - else - end - if not op_mode_3f then - return force_matchparen_refresh() - else - return nil - end -end -return {["jump-to!"] = jump_to_21} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/main.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/main.lua @@ -1,1372 +0,0 @@ -local hl = require("leap.highlight") -local opts = require("leap.opts") -local _local_1_ = require("leap.util") -local inc = _local_1_["inc"] -local dec = _local_1_["dec"] -local clamp = _local_1_["clamp"] -local echo = _local_1_["echo"] -local replace_keycodes = _local_1_["replace-keycodes"] -local get_cursor_pos = _local_1_["get-cursor-pos"] -local push_cursor_21 = _local_1_["push-cursor!"] -local get_eq_class_of = _local_1_["get-eq-class-of"] -local __3erepresentative_char = _local_1_["->representative-char"] -local get_input = _local_1_["get-input"] -local get_input_by_keymap = _local_1_["get-input-by-keymap"] -local api = vim.api -local contains_3f = vim.tbl_contains -local empty_3f = vim.tbl_isempty -local map = vim.tbl_map -local _local_2_ = math -local abs = _local_2_["abs"] -local ceil = _local_2_["ceil"] -local max = _local_2_["max"] -local min = _local_2_["min"] -local pow = _local_2_["pow"] -local function exec_user_autocmds(pattern) - return api.nvim_exec_autocmds("User", {pattern = pattern, modeline = false}) -end -local function handle_interrupted_change_op_21() - local seq - local function _3_() - if (vim.fn.col(".") > 1) then - return "<RIGHT>" - else - return "" - end - end - seq = ("<C-\\><C-G>" .. _3_()) - return api.nvim_feedkeys(replace_keycodes(seq), "n", true) -end -local function set_dot_repeat_2a() - local op = vim.v.operator - local cmd = replace_keycodes("<cmd>lua require'leap'.leap { dot_repeat = true }<cr>") - local change - if (op == "c") then - change = replace_keycodes("<c-r>.<esc>") - else - change = nil - end - local seq = (op .. cmd .. (change or "")) - pcall(vim.fn["repeat#setreg"], seq, vim.v.register) - return pcall(vim.fn["repeat#set"], seq, -1) -end -local function eq_classes__3emembership_lookup(eqcls) - local res = {} - for _, eqcl in ipairs(eqcls) do - local eqcl_2a - if (type(eqcl) == "string") then - eqcl_2a = vim.fn.split(eqcl, "\\zs") - else - eqcl_2a = eqcl - end - for _0, ch in ipairs(eqcl_2a) do - res[ch] = eqcl_2a - end - end - return res -end -local function set_autojump(targets, force_noautojump_3f) - targets["autojump?"] = (not (force_noautojump_3f or empty_3f(opts.safe_labels)) and (empty_3f(opts.labels) or (#opts.safe_labels >= dec(#targets)))) - return nil -end -local function attach_label_set(targets) - local _6_ - if empty_3f(opts.labels) then - _6_ = opts.safe_labels - elseif empty_3f(opts.safe_labels) then - _6_ = opts.labels - elseif targets["autojump?"] then - _6_ = opts.safe_labels - else - _6_ = opts.labels - end - targets["label-set"] = _6_ - return nil -end -local function set_labels(targets, multi_select_3f) - if ((#targets > 1) or multi_select_3f) then - local _local_8_ = targets - local autojump_3f = _local_8_["autojump?"] - local label_set = _local_8_["label-set"] - for i, target in ipairs(targets) do - local i_2a - if autojump_3f then - i_2a = dec(i) - else - i_2a = i - end - if (i_2a > 0) then - local _11_ - do - local _10_ = (i_2a % #label_set) - if (_10_ == 0) then - _11_ = label_set[#label_set] - elseif (nil ~= _10_) then - local n = _10_ - _11_ = label_set[n] - else - _11_ = nil - end - end - target["label"] = _11_ - else - end - end - return nil - else - return nil - end -end -local function set_label_states(targets, _17_) - local _arg_18_ = _17_ - local group_offset = _arg_18_["group-offset"] - local _7clabel_set_7c = #targets["label-set"] - local offset = (group_offset * _7clabel_set_7c) - local primary_start - local function _19_() - if targets["autojump?"] then - return 2 - else - return 1 - end - end - primary_start = (offset + _19_()) - local primary_end = (primary_start + dec(_7clabel_set_7c)) - local secondary_start = inc(primary_end) - local secondary_end = (primary_end + _7clabel_set_7c) - for i, target in ipairs(targets) do - if (target.label and (target["label-state"] ~= "selected")) then - local _20_ - if (function(_21_,_22_,_23_) return (_21_ <= _22_) and (_22_ <= _23_) end)(primary_start,i,primary_end) then - _20_ = "active-primary" - elseif (function(_24_,_25_,_26_) return (_24_ <= _25_) and (_25_ <= _26_) end)(secondary_start,i,secondary_end) then - _20_ = "active-secondary" - elseif (i > secondary_end) then - _20_ = "inactive" - else - _20_ = nil - end - target["label-state"] = _20_ - else - end - end - return nil -end -local function inactivate_labels(targets) - for _, target in ipairs(targets) do - target["label-state"] = "inactive" - end - return nil -end -local function populate_sublists(targets) - local function _29_(self, ch) - return rawget(self, __3erepresentative_char(ch)) - end - local function _30_(self, ch, sublist) - return rawset(self, __3erepresentative_char(ch), sublist) - end - targets["sublists"] = setmetatable({}, {__index = _29_, __newindex = _30_}) - for _, _31_ in ipairs(targets) do - local _each_32_ = _31_ - local _each_33_ = _each_32_["chars"] - local _0 = _each_33_[1] - local ch2 = _each_33_[2] - local target = _each_32_ - local ch20 = (ch2 or "\n") - if not targets.sublists[ch20] then - targets.sublists[ch20] = {} - else - end - table.insert(targets.sublists[ch20], target) - end - return nil -end -local function set_initial_label_states(targets) - for _, sublist in pairs(targets.sublists) do - set_label_states(sublist, {["group-offset"] = 0}) - end - return nil -end -local function get_label_offset(target) - local _let_35_ = target - local _let_36_ = _let_35_["chars"] - local ch1 = _let_36_[1] - local ch2 = _let_36_[2] - if target["empty-line?"] then - return 0 - elseif target["edge-pos?"] then - return ch1:len() - else - return (ch1:len() + ch2:len()) - end -end -local function set_beacon_for_labeled(target, _38_) - local _arg_39_ = _38_ - local user_given_targets_3f = _arg_39_["user-given-targets?"] - local aot_3f = _arg_39_["aot?"] - local offset - if aot_3f then - offset = get_label_offset(target) - else - offset = 0 - end - local pad - if (user_given_targets_3f or aot_3f) then - pad = "" - else - pad = " " - end - local label = (opts.substitute_chars[target.label] or target.label) - local text = (label .. pad) - local virttext - do - local _42_ = target["label-state"] - if (_42_ == "selected") then - virttext = {{text, hl.group["label-selected"]}} - elseif (_42_ == "active-primary") then - virttext = {{text, hl.group["label-primary"]}} - elseif (_42_ == "active-secondary") then - virttext = {{text, hl.group["label-secondary"]}} - elseif (_42_ == "inactive") then - if (aot_3f and not opts.highlight_unlabeled_phase_one_targets) then - virttext = {{(" " .. pad), hl.group["label-secondary"]}} - elseif "else" then - virttext = nil - else - virttext = nil - end - else - virttext = nil - end - end - local _45_ - if virttext then - _45_ = {offset, virttext} - else - _45_ = nil - end - target["beacon"] = _45_ - return nil -end -local function set_beacon_to_match_hl(target) - local virttext - local function _47_(_241) - return (opts.substitute_chars[_241] or _241) - end - virttext = table.concat(map(_47_, target.chars)) - do end (target)["beacon"] = {0, {{virttext, hl.group.match}}} - return nil -end -local function set_beacon_to_empty_label(target) - target["beacon"][2][1][1] = " " - return nil -end -local function resolve_conflicts(targets) - local pos_unlabeled_match = {} - local pos_labeled_match = {} - local pos_label = {} - for _, target in ipairs(targets) do - if not target["empty-line?"] then - local _local_48_ = target.wininfo - local bufnr = _local_48_["bufnr"] - local winid = _local_48_["winid"] - local _local_49_ = target.pos - local lnum = _local_49_[1] - local col = _local_49_[2] - local col_ch2 = (col + string.len(target.chars[1])) - if (target.label and target.beacon) then - local label_offset = target.beacon[1] - local col_label = (col + label_offset) - local shifted_label_3f = (col_label == col_ch2) - do - local _50_ = pos_unlabeled_match[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col_label)] - if (nil ~= _50_) then - local other = _50_ - target.beacon = nil - set_beacon_to_match_hl(other) - else - end - end - if shifted_label_3f then - local _52_ = pos_unlabeled_match[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col)] - if (nil ~= _52_) then - local other = _52_ - set_beacon_to_match_hl(other) - else - end - else - end - do - local _55_ = pos_label[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col_label)] - if (nil ~= _55_) then - local other = _55_ - target.beacon = nil - set_beacon_to_empty_label(other) - else - end - end - pos_label[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col_label)] = target - pos_labeled_match[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col)] = target - if not shifted_label_3f then - pos_labeled_match[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col_ch2)] = target - else - end - elseif not target.label then - for _0, key in ipairs({(bufnr .. " " .. winid .. " " .. lnum .. " " .. col), (bufnr .. " " .. winid .. " " .. lnum .. " " .. col_ch2)}) do - pos_unlabeled_match[key] = target - local _58_ = pos_label[key] - if (nil ~= _58_) then - local other = _58_ - other.beacon = nil - set_beacon_to_match_hl(target) - else - end - end - local col_after = (col_ch2 + string.len(target.chars[2])) - local _60_ = pos_label[(bufnr .. " " .. winid .. " " .. lnum .. " " .. col_after)] - if (nil ~= _60_) then - local other = _60_ - set_beacon_to_match_hl(target) - else - end - else - end - else - end - end - return nil -end -local function set_beacons(targets, _64_) - local _arg_65_ = _64_ - local no_labels_3f = _arg_65_["no-labels?"] - local user_given_targets_3f = _arg_65_["user-given-targets?"] - local aot_3f = _arg_65_["aot?"] - if (no_labels_3f and targets[1].chars) then - for _, target in ipairs(targets) do - set_beacon_to_match_hl(target) - end - return nil - else - for _, target in ipairs(targets) do - if target.label then - set_beacon_for_labeled(target, {["user-given-targets?"] = user_given_targets_3f, ["aot?"] = aot_3f}) - elseif (aot_3f and opts.highlight_unlabeled_phase_one_targets) then - set_beacon_to_match_hl(target) - else - end - end - if aot_3f then - return resolve_conflicts(targets) - else - return nil - end - end -end -local function light_up_beacons(targets, _3fstart, _3fend) - for i = (_3fstart or 1), (_3fend or #targets) do - local target = targets[i] - local _69_ = target.beacon - if ((_G.type(_69_) == "table") and (nil ~= (_69_)[1]) and (nil ~= (_69_)[2])) then - local offset = (_69_)[1] - local virttext = (_69_)[2] - local bufnr = target.wininfo.bufnr - local _let_70_ = map(dec, target.pos) - local lnum = _let_70_[1] - local col = _let_70_[2] - local id = api.nvim_buf_set_extmark(bufnr, hl.ns, lnum, (col + offset), {virt_text = virttext, virt_text_pos = "overlay", hl_mode = "combine", priority = hl.priority.label}) - table.insert(hl.extmarks, {bufnr, id}) - else - end - end - return nil -end -local state = {args = nil, source_window = nil, ["repeat"] = {in1 = nil, in2 = nil}, dot_repeat = {in1 = nil, in2 = nil, target_idx = nil, backward = nil, inclusive_op = nil, offset = nil}, saved_editor_opts = {}} -local function leap(kwargs) - local _let_72_ = kwargs - local dot_repeat_3f = _let_72_["dot_repeat"] - local target_windows = _let_72_["target_windows"] - local user_given_opts = _let_72_["opts"] - local user_given_targets = _let_72_["targets"] - local user_given_action = _let_72_["action"] - local multi_select_3f = _let_72_["multiselect"] - local function _74_() - if dot_repeat_3f then - return state.dot_repeat - else - return kwargs - end - end - local _let_73_ = _74_() - local backward_3f = _let_73_["backward"] - local match_last_overlapping_3f = _let_73_["match_last_overlapping"] - local inclusive_op_3f = _let_73_["inclusive_op"] - local offset = _let_73_["offset"] - local _ - state.args = kwargs - _ = nil - local _0 - opts.current_call = (user_given_opts or {}) - _0 = nil - local _1 - local _76_ - do - local _75_ = opts.current_call.equivalence_classes - if (nil ~= _75_) then - _76_ = eq_classes__3emembership_lookup(_75_) - else - _76_ = _75_ - end - end - opts.current_call["eq_class_of"] = _76_ - _1 = nil - local id__3ewininfo - local function _78_(_241) - return (vim.fn.getwininfo(_241))[1] - end - id__3ewininfo = _78_ - local curr_winid = vim.fn.win_getid() - local _2 - state.source_window = curr_winid - _2 = nil - local curr_win = id__3ewininfo(curr_winid) - local _3ftarget_windows - do - local _79_ = target_windows - if (_79_ ~= nil) then - _3ftarget_windows = map(id__3ewininfo, _79_) - else - _3ftarget_windows = _79_ - end - end - local hl_affected_windows - do - local tbl_17_auto = {curr_win} - local i_18_auto = #tbl_17_auto - for _3, w in ipairs((_3ftarget_windows or {})) do - local val_19_auto = w - if (nil ~= val_19_auto) then - i_18_auto = (i_18_auto + 1) - do end (tbl_17_auto)[i_18_auto] = val_19_auto - else - end - end - hl_affected_windows = tbl_17_auto - end - local directional_3f = not target_windows - local mode = api.nvim_get_mode().mode - local op_mode_3f = mode:match("o") - local change_op_3f = (op_mode_3f and (vim.v.operator == "c")) - local dot_repeatable_op_3f = (op_mode_3f and directional_3f and (vim.v.operator ~= "y")) - local no_labels_3f = (empty_3f(opts.labels) and empty_3f(opts.safe_labels)) - local count - if not directional_3f then - count = nil - elseif (vim.v.count == 0) then - if (op_mode_3f and no_labels_3f) then - count = 1 - else - count = nil - end - else - count = vim.v.count - end - local force_noautojump_3f = (op_mode_3f or multi_select_3f or not directional_3f or user_given_action) - local max_phase_one_targets = (opts.max_phase_one_targets or math.huge) - local user_given_targets_3f = user_given_targets - local prompt = {str = ">"} - local spec_keys - local function _84_(_3, k) - local _85_ = opts.special_keys[k] - if (nil ~= _85_) then - local v = _85_ - if ((k == "next_target") or (k == "prev_target")) then - local _86_ = type(v) - if (_86_ == "table") then - local tbl_17_auto = {} - local i_18_auto = #tbl_17_auto - for _4, str in ipairs(v) do - local val_19_auto = replace_keycodes(str) - if (nil ~= val_19_auto) then - i_18_auto = (i_18_auto + 1) - do end (tbl_17_auto)[i_18_auto] = val_19_auto - else - end - end - return tbl_17_auto - elseif (_86_ == "string") then - return {replace_keycodes(v)} - else - return nil - end - else - return replace_keycodes(v) - end - else - return nil - end - end - spec_keys = setmetatable({}, {__index = _84_}) - if (target_windows and empty_3f(target_windows)) then - echo("no targetable windows") - return - else - end - if (not directional_3f and no_labels_3f) then - echo("no labels to use") - return - else - end - local aot_3f = not ((max_phase_one_targets == 0) or count or no_labels_3f or multi_select_3f or user_given_targets_3f) - local current_idx = 0 - local function echo_not_found(s) - return echo(("not found: " .. s)) - end - local function fill_wininfo(targets) - if not empty_3f(targets) then - if not targets[1].wininfo then - for _3, t in ipairs(targets) do - t.wininfo = curr_win - end - else - end - return targets - else - return nil - end - end - local function get_user_given_targets(targets) - local _95_ - do - local _96_ = targets - if (_G.type(_96_) == "table") then - local tbl = _96_ - _95_ = tbl - elseif (nil ~= _96_) then - local func = _96_ - _95_ = func() - else - _95_ = nil - end - end - if (nil ~= _95_) then - return fill_wininfo(_95_) - else - return _95_ - end - end - local function expand_to_equivalence_class(_in) - local _99_ = get_eq_class_of(_in) - if (nil ~= _99_) then - local chars = _99_ - local chars_2a - local function _100_(_241) - local _101_ = _241 - if (_101_ == "\n") then - return "\\n" - elseif (_101_ == "\\") then - return "\\\\" - elseif true then - local _3 = _101_ - return _241 - else - return nil - end - end - chars_2a = map(_100_, chars) - return ("\\(" .. table.concat(chars_2a, "\\|") .. "\\)") - else - return nil - end - end - local function prepare_pattern(in1, _3fin2) - local function _104_() - if opts.case_sensitive then - return "\\C" - else - return "\\c" - end - end - local function _105_() - local _106_ = _3fin2 - if (nil ~= _106_) then - return expand_to_equivalence_class(_106_) - else - return _106_ - end - end - return ("\\V" .. _104_() .. (expand_to_equivalence_class(in1) or in1:gsub("\\", "\\\\")) .. (_105_() or _3fin2 or "\\_.")) - end - local function get_target_with_active_primary_label(sublist, input) - local res = nil - for idx, _108_ in ipairs(sublist) do - local _each_109_ = _108_ - local label = _each_109_["label"] - local label_state = _each_109_["label-state"] - local target = _each_109_ - if (res or (label_state == "inactive")) then break end - if ((label == input) and (label_state == "active-primary")) then - res = {idx, target} - else - end - end - return res - end - local function update_repeat_state(state_2a) - if not user_given_targets_3f then - state["repeat"] = state_2a - return nil - else - return nil - end - end - local function set_dot_repeat(in1, in2, target_idx) - if (dot_repeatable_op_3f and not (dot_repeat_3f or (type(user_given_targets) == "table"))) then - local function _112_() - if user_given_targets then - return {callback = user_given_targets} - else - return {in1 = in1, in2 = in2} - end - end - state.dot_repeat = vim.tbl_extend("error", {target_idx = target_idx, backward = backward_3f, inclusive_op = inclusive_op_3f, offset = offset}, _112_()) - return set_dot_repeat_2a() - else - return nil - end - end - local jump_to_21 - do - local first_jump_3f = true - local function _114_(target) - local jump = require("leap.jump") - jump["jump-to!"](target.pos, {winid = target.wininfo.winid, ["add-to-jumplist?"] = first_jump_3f, mode = mode, offset = offset, ["backward?"] = backward_3f, ["inclusive-op?"] = inclusive_op_3f}) - first_jump_3f = false - return nil - end - jump_to_21 = _114_ - end - local function get_number_of_highlighted_targets() - local _115_ = opts.max_highlighted_traversal_targets - if (nil ~= _115_) then - local group_size = _115_ - local consumed = (dec(current_idx) % group_size) - local remaining = (group_size - consumed) - if (remaining == 1) then - return inc(group_size) - elseif (remaining == 0) then - return group_size - else - return remaining - end - else - return nil - end - end - local function get_highlighted_idx_range(targets, no_labels_3f0) - if (no_labels_3f0 and (opts.max_highlighted_traversal_targets == 0)) then - return 0, -1 - else - local start = inc(current_idx) - local _end - if no_labels_3f0 then - local _118_ = get_number_of_highlighted_targets() - if (nil ~= _118_) then - local _119_ = (_118_ + dec(start)) - if (nil ~= _119_) then - _end = min(_119_, #targets) - else - _end = _119_ - end - else - _end = _118_ - end - else - _end = nil - end - return start, _end - end - end - local function get_first_pattern_input() - do - hl:cleanup(hl_affected_windows) - if not count then - hl["apply-backdrop"](hl, backward_3f, _3ftarget_windows) - else - end - do - echo("") - end - hl["highlight-cursor"](hl) - vim.cmd("redraw") - end - local _125_ - local function _126_() - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - _125_ = (get_input_by_keymap(prompt) or _126_()) - if (_125_ == spec_keys.repeat_search) then - if state["repeat"].in1 then - aot_3f = false - return state["repeat"].in1, state["repeat"].in2 - else - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - echo("no previous search") - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - elseif (nil ~= _125_) then - local in1 = _125_ - return in1 - else - return nil - end - end - local function get_second_pattern_input(targets) - if (#targets <= max_phase_one_targets) then - hl:cleanup(hl_affected_windows) - if not count then - hl["apply-backdrop"](hl, backward_3f, _3ftarget_windows) - else - end - do - light_up_beacons(targets) - end - hl["highlight-cursor"](hl) - vim.cmd("redraw") - else - end - local function _133_() - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - return (get_input_by_keymap(prompt) or _133_()) - end - local function get_full_pattern_input() - local _135_, _136_ = get_first_pattern_input() - if ((nil ~= _135_) and (nil ~= _136_)) then - local in1 = _135_ - local in2 = _136_ - return in1, in2 - elseif ((nil ~= _135_) and (_136_ == nil)) then - local in1 = _135_ - local _137_ = get_input_by_keymap(prompt) - if (nil ~= _137_) then - local in2 = _137_ - return in1, in2 - elseif true then - local _3 = _137_ - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - return nil - end - else - return nil - end - end - local function post_pattern_input_loop(targets, _3fgroup_offset, first_invoc_3f) - local function loop(group_offset, first_invoc_3f0) - if targets["label-set"] then - set_label_states(targets, {["group-offset"] = group_offset}) - else - end - set_beacons(targets, {["aot?"] = aot_3f, ["no-labels?"] = no_labels_3f, ["user-given-targets?"] = user_given_targets_3f}) - do - hl:cleanup(hl_affected_windows) - if not count then - hl["apply-backdrop"](hl, backward_3f, _3ftarget_windows) - else - end - do - local start, _end = get_highlighted_idx_range(targets, no_labels_3f) - light_up_beacons(targets, start, _end) - end - hl["highlight-cursor"](hl) - vim.cmd("redraw") - end - local _143_ - local function _144_() - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - _143_ = (get_input() or _144_()) - if (nil ~= _143_) then - local input = _143_ - if (((input == spec_keys.next_group) or ((input == spec_keys.prev_group) and not first_invoc_3f0)) and (not targets["autojump?"] or empty_3f(opts.labels))) then - local inc_2fdec - if (input == spec_keys.next_group) then - inc_2fdec = inc - else - inc_2fdec = dec - end - local _7cgroups_7c = ceil((#targets / #targets["label-set"])) - local max_offset = dec(_7cgroups_7c) - local group_offset_2a = clamp(inc_2fdec(group_offset), 0, max_offset) - return loop(group_offset_2a, false) - else - return input, group_offset - end - else - return nil - end - end - return loop((_3fgroup_offset or 0), ((nil == first_invoc_3f) or first_invoc_3f)) - end - local multi_select_loop - do - local selection = {} - local group_offset = 0 - local first_invoc_3f = true - local function loop(targets) - local _149_, _150_ = post_pattern_input_loop(targets, group_offset, first_invoc_3f) - if (_149_ == spec_keys.multi_accept) then - if next(selection) then - return selection - else - return loop(targets) - end - elseif (_149_ == spec_keys.multi_revert) then - do - local _152_ = table.remove(selection) - if (nil ~= _152_) then - _152_["label-state"] = nil - else - end - end - return loop(targets) - elseif ((nil ~= _149_) and (nil ~= _150_)) then - local _in = _149_ - local group_offset_2a = _150_ - group_offset = group_offset_2a - first_invoc_3f = false - do - local _154_ = get_target_with_active_primary_label(targets, _in) - if ((_G.type(_154_) == "table") and true and (nil ~= (_154_)[2])) then - local _3 = (_154_)[1] - local target = (_154_)[2] - if not contains_3f(selection, target) then - table.insert(selection, target) - do end (target)["label-state"] = "selected" - else - end - else - end - end - return loop(targets) - else - return nil - end - end - multi_select_loop = loop - end - local function traversal_loop(targets, idx, _158_) - local _arg_159_ = _158_ - local no_labels_3f0 = _arg_159_["no-labels?"] - current_idx = idx - if no_labels_3f0 then - inactivate_labels(targets) - else - end - set_beacons(targets, {["no-labels?"] = no_labels_3f0, ["aot?"] = aot_3f, ["user-given-targets?"] = user_given_targets_3f}) - do - hl:cleanup(hl_affected_windows) - if not count then - hl["apply-backdrop"](hl, backward_3f, _3ftarget_windows) - else - end - do - local start, _end = get_highlighted_idx_range(targets, no_labels_3f0) - light_up_beacons(targets, start, _end) - end - hl["highlight-cursor"](hl) - vim.cmd("redraw") - end - local _162_ - local function _163_() - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - _162_ = (get_input() or _163_()) - if (nil ~= _162_) then - local input = _162_ - local _164_ - if contains_3f(spec_keys.next_target, input) then - _164_ = min(inc(idx), #targets) - elseif contains_3f(spec_keys.prev_target, input) then - _164_ = max(dec(idx), 1) - else - _164_ = nil - end - if (nil ~= _164_) then - local new_idx = _164_ - local _167_ - do - local t_166_ = targets - if (nil ~= t_166_) then - t_166_ = (t_166_)[new_idx] - else - end - if (nil ~= t_166_) then - t_166_ = (t_166_).chars - else - end - if (nil ~= t_166_) then - t_166_ = (t_166_)[2] - else - end - _167_ = t_166_ - end - update_repeat_state({in1 = state["repeat"].in1, in2 = _167_}) - jump_to_21(targets[new_idx]) - return traversal_loop(targets, new_idx, {["no-labels?"] = no_labels_3f0}) - elseif true then - local _3 = _164_ - local _171_ = get_target_with_active_primary_label(targets, input) - if ((_G.type(_171_) == "table") and true and (nil ~= (_171_)[2])) then - local _4 = (_171_)[1] - local target = (_171_)[2] - do - jump_to_21(target) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - elseif true then - local _4 = _171_ - do - vim.fn.feedkeys(input, "i") - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - return nil - end - else - return nil - end - else - return nil - end - end - local do_action = (user_given_action or jump_to_21) - exec_user_autocmds("LeapEnter") - local function _175_(...) - local _176_, _177_ = ... - if ((nil ~= _176_) and true) then - local in1 = _176_ - local _3fin2 = _177_ - local function _178_(...) - local _179_ = ... - if (nil ~= _179_) then - local targets = _179_ - local function _180_(...) - local _181_ = ... - if (nil ~= _181_) then - local in2 = _181_ - if (in2 == spec_keys.next_phase_one_target) then - local in20 = targets[1].chars[2] - update_repeat_state({in1 = in1, in2 = in20}) - do_action(targets[1]) - if ((#targets == 1) or op_mode_3f or not directional_3f or user_given_action) then - do - set_dot_repeat(in1, in20, 1) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - return traversal_loop(targets, 1, {["no-labels?"] = true}) - end - else - update_repeat_state({in1 = in1, in2 = in2}) - local _183_ - local function _184_(...) - if targets.sublists then - return targets.sublists[in2] - else - return targets - end - end - local function _185_(...) - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - echo_not_found((in1 .. in2)) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - _183_ = (_184_(...) or _185_(...)) - if (nil ~= _183_) then - local targets_2a = _183_ - if multi_select_3f then - local _187_ = multi_select_loop(targets_2a) - if (nil ~= _187_) then - local targets_2a_2a = _187_ - do - do - hl:cleanup(hl_affected_windows) - if not count then - hl["apply-backdrop"](hl, backward_3f, _3ftarget_windows) - else - end - do - light_up_beacons(targets_2a_2a) - end - hl["highlight-cursor"](hl) - vim.cmd("redraw") - end - do_action(targets_2a_2a) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - return nil - end - else - local exit_with_action - local function _190_(idx) - do - set_dot_repeat(in1, in2, idx) - do_action((targets_2a)[idx]) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - exit_with_action = _190_ - local _7ctargets_2a_7c = #targets_2a - if count then - if (count <= _7ctargets_2a_7c) then - return exit_with_action(count) - else - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - elseif (_7ctargets_2a_7c == 1) then - return exit_with_action(1) - else - if targets_2a["autojump?"] then - current_idx = 1 - do_action((targets_2a)[1]) - else - end - local _194_ = post_pattern_input_loop(targets_2a) - if (nil ~= _194_) then - local in_final = _194_ - if contains_3f(spec_keys.next_target, in_final) then - if (op_mode_3f or not directional_3f or user_given_action) then - return exit_with_action(1) - else - local new_idx = inc(current_idx) - do_action((targets_2a)[new_idx]) - if (empty_3f(opts.labels) and not empty_3f(opts.safe_labels)) then - for i = (#opts.safe_labels + 2), _7ctargets_2a_7c do - targets_2a[i]["label"] = nil - targets_2a[i]["beacon"] = nil - end - else - end - return traversal_loop(targets_2a, new_idx, {["no-labels?"] = (no_labels_3f or not targets_2a["autojump?"])}) - end - else - local _197_ = get_target_with_active_primary_label(targets_2a, in_final) - if ((_G.type(_197_) == "table") and (nil ~= (_197_)[1]) and true) then - local idx = (_197_)[1] - local _3 = (_197_)[2] - return exit_with_action(idx) - elseif true then - local _3 = _197_ - if targets_2a["autojump?"] then - do - vim.fn.feedkeys(in_final, "i") - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - else - return nil - end - end - else - return nil - end - end - end - else - return nil - end - end - elseif true then - local __63_auto = _181_ - return ... - else - return nil - end - end - local function _216_(...) - if dot_repeat_3f then - local _208_ = targets[state.dot_repeat.target_idx] - if (nil ~= _208_) then - local target = _208_ - do - do_action(target) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - elseif true then - local _3 = _208_ - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - else - return nil - end - else - local prepare_targets - local function _211_(_241) - set_autojump(_241, force_noautojump_3f) - attach_label_set(_241) - set_labels(_241, multi_select_3f) - return _241 - end - prepare_targets = _211_ - if _3fin2 then - if no_labels_3f then - targets["autojump?"] = true - else - prepare_targets(targets) - end - else - populate_sublists(targets) - for _3, sublist in pairs(targets.sublists) do - prepare_targets(sublist) - end - end - if (#targets > max_phase_one_targets) then - aot_3f = false - else - end - local function _215_(...) - do - set_initial_label_states(targets) - set_beacons(targets, {["aot?"] = aot_3f}) - end - return get_second_pattern_input(targets) - end - return (_3fin2 or _215_(...)) - end - end - return _180_(_216_(...)) - elseif true then - local __63_auto = _179_ - return ... - else - return nil - end - end - local function _223_(...) - if (dot_repeat_3f and state.dot_repeat.callback) then - return get_user_given_targets(state.dot_repeat.callback) - elseif user_given_targets_3f then - local function _218_(...) - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - echo("no targets") - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - return (get_user_given_targets(user_given_targets) or _218_(...)) - else - local function _220_(...) - local search = require("leap.search") - local pattern = prepare_pattern(in1, _3fin2) - local kwargs0 = {["backward?"] = backward_3f, ["match-last-overlapping?"] = match_last_overlapping_3f, ["target-windows"] = _3ftarget_windows} - return search["get-targets"](pattern, kwargs0) - end - local function _221_(...) - if change_op_3f then - handle_interrupted_change_op_21() - else - end - do - echo_not_found((in1 .. (_3fin2 or ""))) - end - hl:cleanup(hl_affected_windows) - exec_user_autocmds("LeapLeave") - return nil - end - return (_220_(...) or _221_(...)) - end - end - return _178_(_223_(...)) - elseif true then - local __63_auto = _176_ - return ... - else - return nil - end - end - local function _226_() - if dot_repeat_3f then - if state.dot_repeat.callback then - return true, true - else - return state.dot_repeat.in1, state.dot_repeat.in2 - end - elseif user_given_targets_3f then - return true, true - elseif aot_3f then - return get_first_pattern_input() - else - return get_full_pattern_input() - end - end - return _175_(_226_()) -end -local _228_ -do - local _227_ = opts.default.equivalence_classes - if (nil ~= _227_) then - _228_ = eq_classes__3emembership_lookup(_227_) - else - _228_ = _227_ - end -end -opts.default["eq_class_of"] = _228_ -api.nvim_create_augroup("LeapDefault", {}) -hl["init-highlight"](hl) -local function _230_() - return hl["init-highlight"](hl) -end -api.nvim_create_autocmd("ColorScheme", {callback = _230_, group = "LeapDefault"}) -local function set_editor_opts(t) - state.saved_editor_opts = {} - local wins = (state.args.target_windows or {state.source_window}) - for opt, val in pairs(t) do - local _let_231_ = vim.split(opt, ".", {plain = true}) - local scope = _let_231_[1] - local name = _let_231_[2] - local _232_ = scope - if (_232_ == "w") then - for _, w in ipairs(wins) do - state.saved_editor_opts[{"w", w, name}] = api.nvim_win_get_option(w, name) - api.nvim_win_set_option(w, name, val) - end - elseif (_232_ == "b") then - for _, w in ipairs(wins) do - local b = api.nvim_win_get_buf(w) - do end (state.saved_editor_opts)[{"b", b, name}] = api.nvim_buf_get_option(b, name) - api.nvim_buf_set_option(b, name, val) - end - elseif true then - local _ = _232_ - state.saved_editor_opts[name] = api.nvim_get_option(name) - api.nvim_set_option(name, val) - else - end - end - return nil -end -local function restore_editor_opts() - for key, val in pairs(state.saved_editor_opts) do - local _234_ = key - if ((_G.type(_234_) == "table") and ((_234_)[1] == "w") and (nil ~= (_234_)[2]) and (nil ~= (_234_)[3])) then - local w = (_234_)[2] - local name = (_234_)[3] - api.nvim_win_set_option(w, name, val) - elseif ((_G.type(_234_) == "table") and ((_234_)[1] == "b") and (nil ~= (_234_)[2]) and (nil ~= (_234_)[3])) then - local b = (_234_)[2] - local name = (_234_)[3] - api.nvim_buf_set_option(b, name, val) - elseif (nil ~= _234_) then - local name = _234_ - api.nvim_set_option(name, val) - else - end - end - return nil -end -local temporary_editor_opts = {["w.conceallevel"] = 0, ["g.scrolloff"] = 0, ["w.scrolloff"] = 0, ["g.sidescrolloff"] = 0, ["w.sidescrolloff"] = 0, ["b.modeline"] = false} -local function _236_() - return set_editor_opts(temporary_editor_opts) -end -api.nvim_create_autocmd("User", {pattern = "LeapEnter", callback = _236_, group = "LeapDefault"}) -local function _237_() - return restore_editor_opts() -end -api.nvim_create_autocmd("User", {pattern = "LeapLeave", callback = _237_, group = "LeapDefault"}) -return {state = state, leap = leap} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/opts.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/opts.lua @@ -1,15 +0,0 @@ -local current_call = {} -local default = {max_phase_one_targets = nil, max_highlighted_traversal_targets = 10, equivalence_classes = {" \9\13\n"}, substitute_chars = {}, safe_labels = {"s", "f", "n", "u", "t", "/", "S", "F", "N", "L", "H", "M", "U", "G", "T", "?", "Z"}, labels = {"s", "f", "n", "j", "k", "l", "h", "o", "d", "w", "e", "m", "b", "u", "y", "v", "r", "g", "t", "c", "x", "/", "z", "S", "F", "N", "J", "K", "L", "H", "O", "D", "W", "E", "M", "B", "U", "Y", "V", "R", "G", "T", "C", "X", "?", "Z"}, special_keys = {repeat_search = "<enter>", next_phase_one_target = "<enter>", next_target = {"<enter>", ";"}, prev_target = {"<tab>", ","}, next_group = "<space>", prev_group = "<tab>", multi_accept = "<enter>", multi_revert = "<backspace>"}, highlight_unlabeled_phase_one_targets = false, case_sensitive = false} -local function _1_(self, k) - local _2_ = self.current_call[k] - if (nil ~= _2_) then - local v = _2_ - return v - elseif true then - local _ = _2_ - return self.default[k] - else - return nil - end -end -return setmetatable({current_call = current_call, default = default}, {__index = _1_}) diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/search.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/search.lua @@ -1,354 +0,0 @@ -local _local_1_ = require("leap.util") -local inc = _local_1_["inc"] -local dec = _local_1_["dec"] -local replace_keycodes = _local_1_["replace-keycodes"] -local get_cursor_pos = _local_1_["get-cursor-pos"] -local push_cursor_21 = _local_1_["push-cursor!"] -local get_char_at = _local_1_["get-char-at"] -local __3erepresentative_char = _local_1_["->representative-char"] -local api = vim.api -local empty_3f = vim.tbl_isempty -local _local_2_ = math -local abs = _local_2_["abs"] -local pow = _local_2_["pow"] -local function get_horizontal_bounds() - local textoff = vim.fn.getwininfo(vim.fn.win_getid())[1].textoff - local offset_in_win = dec(vim.fn.wincol()) - local offset_in_editable_win = (offset_in_win - textoff) - local left_bound = (vim.fn.virtcol(".") - offset_in_editable_win) - local window_width = api.nvim_win_get_width(0) - local right_bound = (left_bound + dec((window_width - textoff))) - return {left_bound, right_bound} -end -local function skip_one_21(backward_3f) - local new_line - local function _3_() - if backward_3f then - return "bwd" - else - return "fwd" - end - end - new_line = push_cursor_21(_3_()) - if (new_line == 0) then - return "dead-end" - else - return nil - end -end -local function to_closed_fold_edge_21(backward_3f) - local edge_line - local _5_ - if backward_3f then - _5_ = vim.fn.foldclosed - else - _5_ = vim.fn.foldclosedend - end - edge_line = _5_(vim.fn.line(".")) - vim.fn.cursor(edge_line, 0) - local edge_col - if backward_3f then - edge_col = 1 - else - edge_col = vim.fn.col("$") - end - return vim.fn.cursor(0, edge_col) -end -local function to_next_in_window_pos_21(backward_3f, left_bound, right_bound, stopline) - local forward_3f = not backward_3f - local _let_8_ = {vim.fn.line("."), vim.fn.virtcol(".")} - local line = _let_8_[1] - local virtcol = _let_8_[2] - local left_off_3f = (virtcol < left_bound) - local right_off_3f = (virtcol > right_bound) - local _9_ - if (left_off_3f and backward_3f) then - _9_ = {dec(line), right_bound} - elseif (left_off_3f and forward_3f) then - _9_ = {line, left_bound} - elseif (right_off_3f and backward_3f) then - _9_ = {line, right_bound} - elseif (right_off_3f and forward_3f) then - _9_ = {inc(line), left_bound} - else - _9_ = nil - end - if ((_G.type(_9_) == "table") and (nil ~= (_9_)[1]) and (nil ~= (_9_)[2])) then - local line_2a = (_9_)[1] - local virtcol_2a = (_9_)[2] - if (((line == line_2a) and (virtcol == virtcol_2a)) or (backward_3f and (line_2a < stopline)) or (forward_3f and (line_2a > stopline))) then - return "dead-end" - else - vim.fn.cursor({line_2a, virtcol_2a}) - if backward_3f then - while ((vim.fn.virtcol(".") < right_bound) and not (vim.fn.col(".") >= dec(vim.fn.col("$")))) do - vim.cmd("norm! l") - end - return nil - else - return nil - end - end - else - return nil - end -end -local function get_match_positions(pattern, _14_, _16_) - local _arg_15_ = _14_ - local left_bound = _arg_15_[1] - local right_bound = _arg_15_[2] - local _arg_17_ = _16_ - local backward_3f = _arg_17_["backward?"] - local whole_window_3f = _arg_17_["whole-window?"] - local skip_curpos_3f = _arg_17_["skip-curpos?"] - local skip_orig_curpos_3f = skip_curpos_3f - local _let_18_ = get_cursor_pos() - local orig_curline = _let_18_[1] - local orig_curcol = _let_18_[2] - local wintop = vim.fn.line("w0") - local winbot = vim.fn.line("w$") - local stopline - if backward_3f then - stopline = wintop - else - stopline = winbot - end - local saved_view = vim.fn.winsaveview() - local saved_cpo = vim.o.cpo - local cleanup - local function _20_() - vim.fn.winrestview(saved_view) - vim.o.cpo = saved_cpo - return nil - end - cleanup = _20_ - vim.o.cpo = (vim.o.cpo):gsub("c", "") - local match_count = 0 - local moved_to_topleft_3f - if whole_window_3f then - vim.fn.cursor({wintop, left_bound}) - moved_to_topleft_3f = true - else - moved_to_topleft_3f = nil - end - local function iter(match_at_curpos_3f) - local match_at_curpos_3f0 = (match_at_curpos_3f or moved_to_topleft_3f) - local flags - local function _22_() - if backward_3f then - return "b" - else - return "" - end - end - local function _23_() - if match_at_curpos_3f0 then - return "c" - else - return "" - end - end - flags = (_22_() .. _23_()) - moved_to_topleft_3f = false - local _24_ = vim.fn.searchpos(pattern, flags, stopline) - if ((_G.type(_24_) == "table") and (nil ~= (_24_)[1]) and (nil ~= (_24_)[2])) then - local line = (_24_)[1] - local col = (_24_)[2] - local pos = _24_ - if (line == 0) then - return cleanup() - elseif ((line == orig_curline) and (col == orig_curcol) and skip_orig_curpos_3f) then - local _25_ = skip_one_21() - if (_25_ == "dead-end") then - return cleanup() - elseif true then - local _ = _25_ - return iter(true) - else - return nil - end - elseif not (vim.wo.wrap or (function(_27_,_28_,_29_) return (_27_ <= _28_) and (_28_ <= _29_) end)(left_bound,vim.fn.virtcol("."),right_bound)) then - local _30_ = to_next_in_window_pos_21(backward_3f, left_bound, right_bound, stopline) - if (_30_ == "dead-end") then - return cleanup() - elseif true then - local _ = _30_ - return iter(true) - else - return nil - end - elseif (vim.fn.foldclosed(line) ~= -1) then - to_closed_fold_edge_21(backward_3f) - local _32_ = skip_one_21(backward_3f) - if (_32_ == "dead-end") then - return cleanup() - elseif true then - local _ = _32_ - return iter(true) - else - return nil - end - else - match_count = (match_count + 1) - return pos - end - else - return nil - end - end - return iter -end -local function get_targets_2a(pattern, _36_) - local _arg_37_ = _36_ - local backward_3f = _arg_37_["backward?"] - local match_last_overlapping_3f = _arg_37_["match-last-overlapping?"] - local wininfo = _arg_37_["wininfo"] - local targets = _arg_37_["targets"] - local source_winid = _arg_37_["source-winid"] - local _let_38_ = get_horizontal_bounds() - local left_bound = _let_38_[1] - local right_bound_2a = _let_38_[2] - local right_bound = dec(right_bound_2a) - local whole_window_3f = wininfo - local wininfo0 = (wininfo or vim.fn.getwininfo(vim.fn.win_getid())[1]) - local skip_curpos_3f = (whole_window_3f and (vim.fn.win_getid() == source_winid)) - local match_positions = get_match_positions(pattern, {left_bound, right_bound}, {["backward?"] = backward_3f, ["skip-curpos?"] = skip_curpos_3f, ["whole-window?"] = whole_window_3f}) - local targets0 = (targets or {}) - local prev_match = {} - for _39_ in match_positions do - local _each_40_ = _39_ - local line = _each_40_[1] - local col = _each_40_[2] - local pos = _each_40_ - local _41_ = get_char_at(pos, {}) - if (_41_ == nil) then - if (col == 1) then - table.insert(targets0, {wininfo = wininfo0, pos = pos, chars = {"\n"}, ["empty-line?"] = true}) - else - end - elseif (nil ~= _41_) then - local ch1 = _41_ - local ch2 = (get_char_at(pos, {["char-offset"] = 1}) or "\n") - local overlap_3f - local function _43_() - if backward_3f then - return ((prev_match.col - col) == ch1:len()) - else - return ((col - prev_match.col) == (prev_match.ch1):len()) - end - end - overlap_3f = ((line == prev_match.line) and _43_() and (__3erepresentative_char(ch2) == __3erepresentative_char((prev_match.ch2 or "")))) - prev_match = {line = line, col = col, ch1 = ch1, ch2 = ch2} - if (overlap_3f and match_last_overlapping_3f) then - table.remove(targets0) - else - end - if (not overlap_3f or match_last_overlapping_3f) then - table.insert(targets0, {wininfo = wininfo0, pos = pos, chars = {ch1, ch2}, ["edge-pos?"] = ((ch2 == "\n") or (col == right_bound))}) - else - end - else - end - end - if next(targets0) then - return targets0 - else - return nil - end -end -local function distance(_48_, _50_) - local _arg_49_ = _48_ - local l1 = _arg_49_[1] - local c1 = _arg_49_[2] - local _arg_51_ = _50_ - local l2 = _arg_51_[1] - local c2 = _arg_51_[2] - local editor_grid_aspect_ratio = 0.3 - local _let_52_ = {abs((c1 - c2)), abs((l1 - l2))} - local dx = _let_52_[1] - local dy = _let_52_[2] - local dx0 = (dx * editor_grid_aspect_ratio) - return pow((pow(dx0, 2) + pow(dy, 2)), 0.5) -end -local function get_targets(pattern, kwargs) - local _local_53_ = kwargs - local backward_3f = _local_53_["backward?"] - local match_last_overlapping_3f = _local_53_["match-last-overlapping?"] - local target_windows = _local_53_["target-windows"] - if not target_windows then - return get_targets_2a(pattern, kwargs) - else - local targets = {} - local cursor_positions = {} - local source_winid = vim.fn.win_getid() - local curr_win_only_3f - do - local _54_ = target_windows - if ((_G.type(_54_) == "table") and ((_G.type((_54_)[1]) == "table") and (((_54_)[1]).winid == source_winid)) and ((_54_)[2] == nil)) then - curr_win_only_3f = true - else - curr_win_only_3f = nil - end - end - local cross_win_3f = not curr_win_only_3f - for _, _56_ in ipairs(target_windows) do - local _each_57_ = _56_ - local winid = _each_57_["winid"] - local wininfo = _each_57_ - if cross_win_3f then - api.nvim_set_current_win(winid) - else - end - cursor_positions[winid] = get_cursor_pos() - get_targets_2a(pattern, {targets = targets, wininfo = wininfo, ["source-winid"] = source_winid, ["match-last-overlapping?"] = match_last_overlapping_3f}) - end - if cross_win_3f then - api.nvim_set_current_win(source_winid) - else - end - if not empty_3f(targets) then - local by_screen_pos_3f = (vim.o.wrap and (#targets < 200)) - if by_screen_pos_3f then - for winid, _60_ in pairs(cursor_positions) do - local _each_61_ = _60_ - local line = _each_61_[1] - local col = _each_61_[2] - local _62_ = vim.fn.screenpos(winid, line, col) - if ((_G.type(_62_) == "table") and (nil ~= (_62_).row) and ((_62_).col == col)) then - local row = (_62_).row - cursor_positions[winid] = {row, col} - else - end - end - else - end - for _, _65_ in ipairs(targets) do - local _each_66_ = _65_ - local _each_67_ = _each_66_["pos"] - local line = _each_67_[1] - local col = _each_67_[2] - local _each_68_ = _each_66_["wininfo"] - local winid = _each_68_["winid"] - local t = _each_66_ - if by_screen_pos_3f then - local _69_ = vim.fn.screenpos(winid, line, col) - if ((_G.type(_69_) == "table") and (nil ~= (_69_).row) and ((_69_).col == col)) then - local row = (_69_).row - t["screenpos"] = {row, col} - else - end - else - end - t["rank"] = distance((t.screenpos or t.pos), cursor_positions[winid]) - end - local function _72_(_241, _242) - return ((_241).rank < (_242).rank) - end - table.sort(targets, _72_) - return targets - else - return nil - end - end -end -return {["get-horizontal-bounds"] = get_horizontal_bounds, ["get-match-positions"] = get_match_positions, ["get-targets"] = get_targets} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/user.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/user.lua @@ -1,35 +0,0 @@ -local function add_default_mappings(force_3f) - for _, _1_ in ipairs({{{"n", "x", "o"}, "s", "<Plug>(leap-forward-to)"}, {{"n", "x", "o"}, "S", "<Plug>(leap-backward-to)"}, {{"x", "o"}, "x", "<Plug>(leap-forward-till)"}, {{"x", "o"}, "X", "<Plug>(leap-backward-till)"}, {{"n", "x", "o"}, "gs", "<Plug>(leap-cross-window)"}}) do - local _each_2_ = _1_ - local modes = _each_2_[1] - local lhs = _each_2_[2] - local rhs = _each_2_[3] - for _0, mode in ipairs(modes) do - if (force_3f or ((vim.fn.mapcheck(lhs, mode) == "") and (vim.fn.hasmapto(rhs, mode) == 0))) then - vim.keymap.set(mode, lhs, rhs, {silent = true}) - else - end - end - end - return nil -end -local function set_default_keymaps(force_3f) - for _, _4_ in ipairs({{"n", "s", "<Plug>(leap-forward)"}, {"n", "S", "<Plug>(leap-backward)"}, {"x", "s", "<Plug>(leap-forward)"}, {"x", "S", "<Plug>(leap-backward)"}, {"o", "z", "<Plug>(leap-forward)"}, {"o", "Z", "<Plug>(leap-backward)"}, {"o", "x", "<Plug>(leap-forward-x)"}, {"o", "X", "<Plug>(leap-backward-x)"}, {"n", "gs", "<Plug>(leap-cross-window)"}, {"x", "gs", "<Plug>(leap-cross-window)"}, {"o", "gs", "<Plug>(leap-cross-window)"}}) do - local _each_5_ = _4_ - local mode = _each_5_[1] - local lhs = _each_5_[2] - local rhs = _each_5_[3] - if (force_3f or ((vim.fn.mapcheck(lhs, mode) == "") and (vim.fn.hasmapto(rhs, mode) == 0))) then - vim.keymap.set(mode, lhs, rhs, {silent = true}) - else - end - end - return nil -end -local function setup(user_opts) - for k, v in pairs(user_opts) do - require("leap.opts")["default"][k] = v - end - return nil -end -return {add_default_mappings = add_default_mappings, set_default_keymaps = set_default_keymaps, setup = setup} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/util.lua b/.config/nvim/pack/bundle/start/leap.nvim/lua/leap/util.lua @@ -1,165 +0,0 @@ -local opts = require("leap.opts") -local api = vim.api -local filter = vim.tbl_filter -local function inc(x) - return (x + 1) -end -local function dec(x) - return (x - 1) -end -local function clamp(x, min, max) - if (x < min) then - return min - elseif (x > max) then - return max - else - return x - end -end -local function echo(msg) - return api.nvim_echo({{msg}}, false, {}) -end -local function replace_keycodes(s) - return api.nvim_replace_termcodes(s, true, false, true) -end -local function get_cursor_pos() - return {vim.fn.line("."), vim.fn.col(".")} -end -local function push_cursor_21(direction) - local function _3_() - local _2_ = direction - if (_2_ == "fwd") then - return "W" - elseif (_2_ == "bwd") then - return "bW" - else - return nil - end - end - return vim.fn.search("\\_.", _3_()) -end -local function get_char_at(_5_, _7_) - local _arg_6_ = _5_ - local line = _arg_6_[1] - local byte_col = _arg_6_[2] - local _arg_8_ = _7_ - local char_offset = _arg_8_["char-offset"] - local line_str = vim.fn.getline(line) - local char_idx = vim.fn.charidx(line_str, (byte_col - 1)) - local char_nr = vim.fn.strgetchar(line_str, (char_idx + (char_offset or 0))) - if (char_nr ~= -1) then - return vim.fn.nr2char(char_nr) - else - return nil - end -end -local function get_enterable_windows() - local wins = api.nvim_tabpage_list_wins(0) - local curr_win = api.nvim_get_current_win() - local curr_buf = api.nvim_get_current_buf() - local function _10_(_241) - return ((api.nvim_win_get_config(_241)).focusable and (_241 ~= curr_win)) - end - return filter(_10_, wins) -end -local function get_eq_class_of(ch) - if opts.case_sensitive then - return opts.eq_class_of[ch] - else - return (opts.eq_class_of[vim.fn.tolower(ch)] or opts.eq_class_of[vim.fn.toupper(ch)]) - end -end -local function __3erepresentative_char(ch) - local ch_2a - local function _12_() - local t_13_ = get_eq_class_of(ch) - if (nil ~= t_13_) then - t_13_ = (t_13_)[1] - else - end - return t_13_ - end - ch_2a = (_12_() or ch) - if opts.case_sensitive then - return ch_2a - else - return vim.fn.tolower(ch_2a) - end -end -local _3cbs_3e = replace_keycodes("<bs>") -local _3ccr_3e = replace_keycodes("<cr>") -local _3cesc_3e = replace_keycodes("<esc>") -local function get_input() - local ok_3f, ch = pcall(vim.fn.getcharstr) - if (ok_3f and (ch ~= _3cesc_3e)) then - return ch - else - return nil - end -end -local function get_input_by_keymap(prompt) - local function echo_prompt(seq) - return api.nvim_echo({{prompt.str}, {(seq or ""), "ErrorMsg"}}, false, {}) - end - local function accept(ch) - prompt.str = (prompt.str .. ch) - echo_prompt() - return ch - end - local function loop(seq) - local _7cseq_7c = #(seq or "") - if (function(_17_,_18_,_19_) return (_17_ <= _18_) and (_18_ <= _19_) end)(1,_7cseq_7c,5) then - echo_prompt(seq) - local rhs_candidate = vim.fn.mapcheck(seq, "l") - local rhs = vim.fn.maparg(seq, "l") - if (rhs_candidate == "") then - return accept(seq) - elseif (rhs == rhs_candidate) then - return accept(rhs) - else - local _20_ = get_input() - if (_20_ == _3cbs_3e) then - local function _21_() - if (_7cseq_7c >= 2) then - return seq:sub(1, dec(_7cseq_7c)) - else - return seq - end - end - return loop(_21_()) - elseif (_20_ == _3ccr_3e) then - if (rhs ~= "") then - return accept(rhs) - elseif (_7cseq_7c == 1) then - return accept(seq) - else - return loop(seq) - end - elseif (nil ~= _20_) then - local ch = _20_ - return loop((seq .. ch)) - else - return nil - end - end - else - return nil - end - end - if (vim.bo.iminsert ~= 1) then - return get_input() - else - echo_prompt() - local _26_ = loop(get_input()) - if (nil ~= _26_) then - local _in = _26_ - return _in - elseif true then - local _ = _26_ - return echo("") - else - return nil - end - end -end -return {inc = inc, dec = dec, clamp = clamp, echo = echo, ["replace-keycodes"] = replace_keycodes, ["get-cursor-pos"] = get_cursor_pos, ["push-cursor!"] = push_cursor_21, ["get-char-at"] = get_char_at, get_enterable_windows = get_enterable_windows, ["get-eq-class-of"] = get_eq_class_of, ["->representative-char"] = __3erepresentative_char, ["get-input"] = get_input, ["get-input-by-keymap"] = get_input_by_keymap} diff --git a/.config/nvim/pack/bundle/start/leap.nvim/make.py b/.config/nvim/pack/bundle/start/leap.nvim/make.py @@ -1,46 +0,0 @@ -#!/usr/bin/env python - -import glob -import os -from pathlib import Path - -FNL_ROOT = 'fnl' -LUA_ROOT = 'lua' - -def get_files(root): - return [f for f in glob.iglob(root + '/**', recursive=True) - if os.path.isfile(f)] - -fnlfiles = get_files(FNL_ROOT + "/") -luafiles = get_files(LUA_ROOT + "/") - -# Compile source files which have been created or modified since the -# last build. -changes = False -for src in fnlfiles: - out = src.replace(FNL_ROOT, LUA_ROOT, 1).replace('.fnl', '.lua') - if (not os.path.exists(out) - or os.path.getmtime(src) > os.path.getmtime(out)): - changes = True - # Create parent directories if they don't exist. - Path(os.path.dirname(out)).mkdir(parents=True, exist_ok=True) - cmd = "fennel --compile " + src + " > " + out - print(cmd) - os.system(cmd) -if not changes: - print("nothing to compile") - -# Remove leftover files whose sources have been deleted. -for out in luafiles: - if out not in map(lambda f: f - .replace(FNL_ROOT, LUA_ROOT, 1) - .replace('.fnl', '.lua'), - fnlfiles): - print("removing output file with missing source: " + out) - os.remove(out) - # Remove parent directories if they have become empty. - try: - os.removedirs(os.path.dirname(out)) - except OSError: - pass - diff --git a/.config/nvim/pack/bundle/start/leap.nvim/plugin/init.lua b/.config/nvim/pack/bundle/start/leap.nvim/plugin/init.lua @@ -1,59 +0,0 @@ -local plug_mappings = { - { - {'n'}, '<Plug>(leap-forward-to)', - function () - require('leap').leap {} - end - }, - { - {'x', 'o'}, '<Plug>(leap-forward-to)', - function () - require('leap').leap { - offset = 1, inclusive_op = true, match_last_overlapping = true - } - end - }, - { - {'n', 'x', 'o'}, '<Plug>(leap-forward-till)', - function () - require('leap').leap { offset = -1, inclusive_op = true } - end - }, - { - {'n'}, '<Plug>(leap-backward-to)', - function () - require('leap').leap { backward = true } - end - }, - { - {'x', 'o'}, '<Plug>(leap-backward-to)', - function () - require('leap').leap { backward = true, match_last_overlapping = true } - end - }, - { - {'n', 'x', 'o'}, '<Plug>(leap-backward-till)', - function () - require('leap').leap { backward = true, offset = 2 } - end - }, - { - {'n', 'x', 'o'}, '<Plug>(leap-cross-window)', - function () - require('leap').leap { - target_windows = require'leap.util'.get_enterable_windows() - } - end - }, - - -- Deprecated mappings. - {{'n', 'x', 'o'}, '<Plug>(leap-forward)', function () require('leap').leap {} end}, - {{'n', 'x', 'o'}, '<Plug>(leap-backward)', function () require('leap').leap { backward = true } end}, - {{'n', 'x', 'o'}, '<Plug>(leap-forward-x)', function () require('leap').leap { offset = 1, inclusive_op = true } end}, - {{'n', 'x', 'o'}, '<Plug>(leap-backward-x)', function () require('leap').leap { backward = true, offset = 2 } end}, -} - -for _, t in ipairs(plug_mappings) do - modes, lhs, rhs = unpack(t) - vim.keymap.set(modes, lhs, rhs, {silent = true}) -end