summaryrefslogtreecommitdiff
path: root/README.md
blob: 0da3da7f56434ddf113f0ae0481dd71ef0fb6131 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# clever-tee

clever-tee extends Nvim's `f`, `F`, `t`, and `T` character motions with shared repetition, multiline search, counts, multibyte text, dot-repeat, configurable matching, and visual feedback.

## Installation

Install the complete repository root so that `plugin/`, `lua/`, and `autoload/` are on `runtimepath`. Load it at startup because it replaces core motion keys.

Example for lazy.nvim:

```lua
{
  "<owner>/clever-tee",
  lazy = false,

  init = function()
    -- Set configuration here, before plugin activation.
    vim.g.clever_tee_smart_case = true
  end,

  config = function()
    local clever_tee = require("clever_tee")

    -- Optional explicit repeat mappings.
    vim.keymap.set(
      { "n", "x", "o" },
      ";",
      clever_tee.RepeatSameDirection,
      { silent = true }
    )
    vim.keymap.set(
      { "n", "x", "o" },
      ",",
      clever_tee.RepeatOppositeDirection,
      { silent = true }
    )
  end,
}
```

Replace `<owner>/clever-tee` with the published repository identifier. For a local installation, use the repository root as the plugin manager's `dir`.

`plugin/clever_tee.lua` activates the plugin automatically. A manual runtime loader can call:

```lua
require("clever_tee").activate()
```

## Default mappings

The plugin installs these silent, non-recursive mappings in Normal, Visual, and operator-pending modes:

- `f`: find forward
- `F`: find backward
- `t`: till forward
- `T`: till backward

Counts work, for example `2fa`.

All four keys share the active FIND or TILL sequence. With the default direction policy, lower-case keys repeat the stored direction and upper-case keys use the opposite direction.

The explicit repeat functions provide semicolon and comma behavior:

- `RepeatSameDirection`
- `RepeatOppositeDirection`

## Suppressing the default mappings

Set this global before activation:

```lua
vim.g.clever_tee_not_overwrites_standard_mappings = true
```

Its presence suppresses the default mappings. Values such as `false` and `0` also suppress them. Leave the global absent to install the defaults.

Custom mappings can call these functions from `require("clever_tee")`:

- `StartFindForward`
- `StartFindBackward`
- `StartTillForward`
- `StartTillBackward`
- `RepeatSameDirection`
- `RepeatOppositeDirection`
- `Reset`

## Configuration

All regular settings use the `vim.g.clever_tee_` prefix.

Search and matching:

- `search_current_line_only`: Boolean, default `false`. The default searches toward the buffer boundary.
- `ignore_case`: Boolean, default `false`.
- `smart_case`: Boolean, default `false`. Lower-case ASCII targets ignore case; upper-case targets preserve case.
- `use_migemo`: Boolean, default `false`. UTF-8, CP932, and EUC-JP dictionaries are bundled.
- `chars_match_any_signs`: String, default `""`. Each listed trigger matches the complete supported symbol class.

Sequence behavior:

- `fix_key_direction`: Boolean, default `false`. When true, lower-case primary keys always move forward and upper-case keys always move backward.
- `repeat_timeout_ms`: Nonnegative integer, default `0`. Zero keeps repetition active without expiration.
- `repeat_last_char_inputs`: List of strings, default `{ "\r" }`. Enter reuses the last acquired target.

Input feedback:

- `show_prompt`: Boolean, default `false`.
- `mark_cursor`: Boolean, default `true`.
- `mark_cursor_color`: Highlight-group name, default target `Cursor`.
- `hide_cursor_on_cmdline`: Boolean, default `true`.
- `mark_direct`: Boolean, default `false`.
- `mark_direct_color`: Highlight-group name, default target `CleverTeeDefaultLabel`.

Persistent feedback:

- `mark_char`: Boolean, default `true`.
- `mark_char_color`: Highlight-group name, default target `CleverTeeDefaultLabel`.
- `highlight_timeout_ms`: Nonnegative integer, default `0`. Zero keeps labels until a lifecycle event clears them.
- `clean_labels_eagerly`: Boolean, default `true`.

Example:

```lua
vim.g.clever_tee_search_current_line_only = true
vim.g.clever_tee_smart_case = true
vim.g.clever_tee_mark_direct = true
vim.g.clever_tee_repeat_timeout_ms = 1500
vim.g.clever_tee_highlight_timeout_ms = 500
vim.g.clever_tee_mark_char_color = "Search"
```

Set `clean_labels_eagerly` and the mapping-suppression sentinel before activation. Setting all options before activation gives predictable highlight initialization. Most search and motion settings are sampled again for each action.

The available highlight groups are:

- `CleverTeeDefaultLabel`
- `CleverTeeCursor`
- `CleverTeeChar`
- `CleverTeeDirect`

The plugin refreshes their links after `ColorScheme`.

## Requirements

- Nvim 1.12.5
- The complete plugin repository, including the bundled Migemo assets
- A startup package or plugin manager that adds the repository root to `runtimepath`