Skip to content

Commit 690ad1b

Browse files
committed
Updated docs, cleanup
1 parent 855e4f1 commit 690ad1b

6 files changed

Lines changed: 409 additions & 181 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Download latest [release](https://github.com/Nimaoth/Nev/releases) or [build fro
5353
- [Getting started](docs/getting_started.md)
5454
- [Cheatsheet](docs/cheatsheet.md)
5555
- [Configuration](docs/configuration.md)
56+
- [Keybindings](docs/keybindings.md)
5657
- [Finders](docs/finders.md)
5758
- [Plugin API](https://nimaoth.github.io/AbsytreeDocs/scripting_nim/htmldocs/theindex.html).
5859
- [Virtual filesystem](docs/virtual_file_system.md)

config/keybindings.json

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -299,33 +299,33 @@
299299
},
300300

301301
"vim#text_object": {
302-
"<?-count>iw": ["vim-select-text-object", "vim-word-inner", false, true, "<#move.count>"],
303-
"<?-count>aw": ["vim-select-text-object", "vim-word-outer", false, true, "<#move.count>"],
304-
"<?-count>iW": ["vim-select-text-object", "vim-WORD-inner", false, true, "<#move.count>"],
305-
"<?-count>aW": ["vim-select-text-object", "vim-WORD-outer", false, true, "<#move.count>"],
306-
"<?-count>ip": ["vim-select-text-object", "vim-paragraph-inner", false, true, "<#move.count>"],
307-
"<?-count>ap": ["vim-select-text-object", "vim-paragraph-outer", false, true, "<#move.count>"],
308-
309-
"<?-count>i{": ["vim-select-surrounding", "vim-surround-{-inner", false, true, "<#move.count>"],
310-
"<?-count>a{": ["vim-select-surrounding", "vim-surround-{-outer", false, true, "<#move.count>"],
311-
"<?-count>i}": ["vim-select-surrounding", "vim-surround-{-inner", false, true, "<#move.count>"],
312-
"<?-count>a}": ["vim-select-surrounding", "vim-surround-{-outer", false, true, "<#move.count>"],
313-
"<?-count>i(": ["vim-select-surrounding", "vim-surround-(-inner", false, true, "<#move.count>"],
314-
"<?-count>a(": ["vim-select-surrounding", "vim-surround-(-outer", false, true, "<#move.count>"],
315-
"<?-count>i)": ["vim-select-surrounding", "vim-surround-(-inner", false, true, "<#move.count>"],
316-
"<?-count>a)": ["vim-select-surrounding", "vim-surround-(-outer", false, true, "<#move.count>"],
317-
"<?-count>i[": ["vim-select-surrounding", "vim-surround-[-inner", false, true, "<#move.count>"],
318-
"<?-count>a[": ["vim-select-surrounding", "vim-surround-[-outer", false, true, "<#move.count>"],
319-
"<?-count>i]": ["vim-select-surrounding", "vim-surround-[-inner", false, true, "<#move.count>"],
320-
"<?-count>a]": ["vim-select-surrounding", "vim-surround-[-outer", false, true, "<#move.count>"],
321-
"<?-count>i\\<": ["vim-select-surrounding", "vim-surround-angle-inner", false, true, "<#move.count>"],
322-
"<?-count>a\\<": ["vim-select-surrounding", "vim-surround-angle-outer", false, true, "<#move.count>"],
323-
"<?-count>i\\>": ["vim-select-surrounding", "vim-surround-angle-inner", false, true, "<#move.count>"],
324-
"<?-count>a\\>": ["vim-select-surrounding", "vim-surround-angle-outer", false, true, "<#move.count>"],
325-
"<?-count>i\"": ["vim-select-surrounding", "vim-surround-\"-inner", false, true, "<#move.count>"],
326-
"<?-count>a\"": ["vim-select-surrounding", "vim-surround-\"-outer", false, true, "<#move.count>"],
327-
"<?-count>i'": ["vim-select-surrounding", "vim-surround-'-inner", false, true, "<#move.count>"],
328-
"<?-count>a'": ["vim-select-surrounding", "vim-surround-'-outer", false, true, "<#move.count>"],
302+
"<?-count>iw": ["vim-select-text-object", "vim-word-inner", false, true, "<#text_object.count>"],
303+
"<?-count>aw": ["vim-select-text-object", "vim-word-outer", false, true, "<#text_object.count>"],
304+
"<?-count>iW": ["vim-select-text-object", "vim-WORD-inner", false, true, "<#text_object.count>"],
305+
"<?-count>aW": ["vim-select-text-object", "vim-WORD-outer", false, true, "<#text_object.count>"],
306+
"<?-count>ip": ["vim-select-text-object", "vim-paragraph-inner", false, true, "<#text_object.count>"],
307+
"<?-count>ap": ["vim-select-text-object", "vim-paragraph-outer", false, true, "<#text_object.count>"],
308+
309+
"<?-count>i{": ["vim-select-surrounding", "vim-surround-{-inner", false, true, "<#text_object.count>"],
310+
"<?-count>a{": ["vim-select-surrounding", "vim-surround-{-outer", false, true, "<#text_object.count>"],
311+
"<?-count>i}": ["vim-select-surrounding", "vim-surround-{-inner", false, true, "<#text_object.count>"],
312+
"<?-count>a}": ["vim-select-surrounding", "vim-surround-{-outer", false, true, "<#text_object.count>"],
313+
"<?-count>i(": ["vim-select-surrounding", "vim-surround-(-inner", false, true, "<#text_object.count>"],
314+
"<?-count>a(": ["vim-select-surrounding", "vim-surround-(-outer", false, true, "<#text_object.count>"],
315+
"<?-count>i)": ["vim-select-surrounding", "vim-surround-(-inner", false, true, "<#text_object.count>"],
316+
"<?-count>a)": ["vim-select-surrounding", "vim-surround-(-outer", false, true, "<#text_object.count>"],
317+
"<?-count>i[": ["vim-select-surrounding", "vim-surround-[-inner", false, true, "<#text_object.count>"],
318+
"<?-count>a[": ["vim-select-surrounding", "vim-surround-[-outer", false, true, "<#text_object.count>"],
319+
"<?-count>i]": ["vim-select-surrounding", "vim-surround-[-inner", false, true, "<#text_object.count>"],
320+
"<?-count>a]": ["vim-select-surrounding", "vim-surround-[-outer", false, true, "<#text_object.count>"],
321+
"<?-count>i\\<": ["vim-select-surrounding", "vim-surround-angle-inner", false, true, "<#text_object.count>"],
322+
"<?-count>a\\<": ["vim-select-surrounding", "vim-surround-angle-outer", false, true, "<#text_object.count>"],
323+
"<?-count>i\\>": ["vim-select-surrounding", "vim-surround-angle-inner", false, true, "<#text_object.count>"],
324+
"<?-count>a\\>": ["vim-select-surrounding", "vim-surround-angle-outer", false, true, "<#text_object.count>"],
325+
"<?-count>i\"": ["vim-select-surrounding", "vim-surround-\"-inner", false, true, "<#text_object.count>"],
326+
"<?-count>a\"": ["vim-select-surrounding", "vim-surround-\"-outer", false, true, "<#text_object.count>"],
327+
"<?-count>i'": ["vim-select-surrounding", "vim-surround-'-inner", false, true, "<#text_object.count>"],
328+
"<?-count>a'": ["vim-select-surrounding", "vim-surround-'-outer", false, true, "<#text_object.count>"],
329329
},
330330

331331
"vim#move": {
@@ -658,7 +658,12 @@
658658
"<SPACE>": ["all", [".vim-paste", false, true, "vim-default-register"], [".set-mode", "vim.insert"]],
659659
},
660660

661-
661+
"vim.completion": {
662+
"<C-p>": ["select-prev-completion"],
663+
"<C-n>": ["select-next-completion"],
664+
"<C-y>": ["apply-selected-completion"],
665+
"<TAB>": ["apply-selected-completion"],
666+
},
662667

663668
// vscode
664669
"vscode.base": {

config/settings-vim.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// "selector.base-mode": "vim.selector",
1010
"text.modes": ["vim", "vim.normal"],
1111
"text.default-mode": "vim.normal",
12+
"text.completion-mode": "vim.completion",
1213

1314
"lang.command-line.text.modes": ["vim", "vim.insert"],
1415
"lang.command-line.text.default-mode": "vim.insert",

config/settings-vscode.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"editor.command-line-result-mode-low": "vscode.command-line-result-low",
77
"terminal.base-mode": "vscode.terminal",
88
"selector.base-mode": "vscode.selector",
9+
"text.modes": ["vscode"],
10+
"text.default-mode": "vscode",
11+
"text.completion-mode": "vscode.completion",
912

1013
"input": {
1114
"vscode.handle-inputs": true,
@@ -19,9 +22,6 @@
1922
"vscode.terminal.handle-keys": true,
2023
},
2124

22-
"text.completion-mode": "vscode.completion",
23-
"text.modes": ["vscode"],
24-
"text.default-mode": "vscode",
2525
"text.inclusive-selection": false,
2626

2727
"editor.text.cursor.movement.": "both",

docs/configuration.md

Lines changed: 0 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -235,156 +235,6 @@ setOption "editor.text.triple-click-command-args", %[%"vim-paragraph-inner", %tr
235235
# and "double-click-command"/"double-click-command-args"
236236
```
237237

238-
# Key bindings
239-
You can bind different key combinations to __commands__. Each function exposed by the editor (see `plugin_api.nim`) has a corresponding command,
240-
which has two names. If the function is called `myCommand`, then the command can be executed using either `myCommand` or `my-command`.
241-
242-
Key combinations are bound to a command and arguments for that command. The following binds the command `quit` to the key combination `CTRL-x + x`
243-
244-
```nim
245-
addCommand "editor", "<C-x>x", "quit"
246-
```
247-
248-
Key combinations can be as long as you want, and contain any combination of modifiers, as long as the OS supports that combination.
249-
Most keys can be specified using their ASCII value, i.e. to bind to e.g. the `k` key you would use `addCommand "editor", "k", "command-name"`.
250-
Special keys like the space bar are specified using < and >: `addCommand "editor", "<SPACE>", "command-name"`.
251-
The following special keys are defined:
252-
- ENTER
253-
- ESCAPE
254-
- BACKSPACE
255-
- SPACE
256-
- DELETE
257-
- TAB
258-
- LEFT
259-
- RIGHT
260-
- UP
261-
- DOWN
262-
- HOME
263-
- END
264-
- PAGE_UP
265-
- PAGE_DOWN
266-
- F1, ..., F12
267-
268-
To specify that a modifier should be held down together with another key you need to used `<XXX-YYY>`, where `XXX` is any combination of modifiers
269-
(`S` = shift, `C` = control, `A` = alt) and `YYY` is either a single ASCII character for the key, or one of the special keys (e.g. `ENTER`).
270-
271-
If you use an upper case ASCII character as key then this automatically means it uses shift, so `A` is equivalent to `<S-a>` and `<S-A>`
272-
273-
Some examples:
274-
275-
```nim
276-
addCommand "editor", "a", "command-name"
277-
addCommand "editor", "<C-a>", "command-name" # CTRL+a
278-
addCommand "editor", "<CS-a>", "command-name" # CTRL+SHIFT+a
279-
addCommand "editor", "<CS-SPACE>", "command-name" # CTRL+SHIFT+SPACE
280-
addCommand "editor", "SPACE<C-g>", "command-name" # SPACE, followed by CTRL+g
281-
```
282-
283-
Be careful not to do bind multiple keys where one is a prefix of another in the same mode:
284-
285-
```nim
286-
addCommand "editor", "a", "command-name"
287-
addCommand "editor", "aa", "command-name" # Will never be used, because pressing a once will immediately execute the first binding
288-
```
289-
290-
You can define multi key keybindings with keys which produce characters (like `w`) in modes that consume input (like insert mode) while still being able to insert the original key by waiting or pressing another key which is not in the bound sequence.
291-
- Example: when you bind `jj` in insert mode to exit to normal mode, three things can happen:
292-
- You press `j` once then after a configured delay the `j` will be inserted as text
293-
- You press `j` twice in a row, faster than the configured delay, then it will exit to normal mode
294-
- You press `j` once followed by another key (e.g `k`) faster than the configured delay. `j` will be inserted and
295-
the next key press will be handled as usual.
296-
297-
The delay is configured using `editor.insert-input-delay`.
298-
299-
## Repeat keys within longer keybindings
300-
301-
There is one special modifier `*` which means the following keys can be repeated without having to press the first keys again:
302-
303-
```nim
304-
# after pressing "<C-w>F", you can press "+" or "-" multiple times, and the input state machine resets to the <*-F> state instead of
305-
# to the beginning
306-
addCommand "editor", "<C-w><*-F>-", "change-font-size", -1
307-
addCommand "editor", "<C-w><*-F>+", "change-font-size", 1
308-
```
309-
310-
All keybindings in the same scope (e.g. `editor`) will be compiled into a state machine. When you press a key, the state machine will advance,
311-
and if it reaches and end state it will execute the command stored in the state (with the arguments also stored in the state).
312-
Each `addCommand` corresponds to one end state.
313-
314-
# Scopes/Context
315-
The first parameter to `addCommand` is a scope. Different scopes can have different keybindings, even conflicting ones.
316-
Depending on which scopes are active the corresponding commands will be executed.
317-
Which scopes are active depends on which editor view is selected, whether there is e.g. an auto completion window open.
318-
The scope stack looks like this
319-
At the bottom of the scope stack is always `editor`.
320-
- `editor`
321-
- `editor.<MODE>`, if the editor mode is not `""` and `editor.custom-mode-on-top` is false. `<MODE>` is the current editor mode.
322-
- One of the following:
323-
- `commandLine`, if the editor is in command line mode
324-
325-
- If there is a popup open, then the following scopes:
326-
- If the popup is a selector popup, then the following scopes:
327-
- Same as a text editor (i.e. `editor.text`, etc)
328-
- `popup.selector`, always
329-
330-
- If the selected view contains a text document, then the following scopes:
331-
- `editor.text`, always
332-
- `editor.text.<MODE>`, if the text editor mode is not `""`
333-
- `editor.text.completion`, if the text editor has a completion window open.
334-
335-
- If the selected view contains a model document, then the following scopes:
336-
- `editor.model`, always
337-
- `editor.model.<MODE>`, if the model editor mode is not `""`
338-
339-
- `editor.<MODE>`, if the editor mode is not `""` and `editor.custom-mode-on-top` is true. `<MODE>` is the current editor mode.
340-
341-
So if you for example have text editor selected and a completion window is open, and the text editor is in `insert` mode, the scope stack would look like this:
342-
343-
- `editor` (bottom, handled by Editor)
344-
- `editor.text` (handled by TextEditor)
345-
- `editor.text.insert` (handled by TextEditor)
346-
- `editor.text.completion` (top, handled by TextEditor)
347-
348-
If you have no completion window open and no mode selected then it would look like this:
349-
350-
- `editor` (bottom, handled by Editor)
351-
- `editor.text` (top, handled by TextEditor)
352-
353-
When a key is pressed, the editor will advance the state machine for every scope in the stack, from top to bottom (i.e. the `editor` scope will always be last).
354-
The first scope which reaches an end state will execute its' command, which will be handled by the owner of the scope. Then all state machines in the stack are reset.
355-
The owners of the scopes are the following:
356-
- `Editor`: `editor`, `commandLine`, `editor.<MODE>`
357-
- `TextEditor`: `editor.text`, `editor.text.<MODE>`, `editor.text.completion`
358-
- `ModelEditor`: `editor.model`, `editor.model.<MODE>`, `editor.model.completion`
359-
- `SelectorPopup`: `popup.selector`
360-
361-
# Summary
362-
To define keybindings specific for text documents (TextEditor), use:
363-
364-
```nim
365-
addCommand "editor.text", "a", "command-name"
366-
addTextCommand "", "a", "command-name" # Same as above
367-
368-
addCommand "editor.text.insert", "a", "command-name" # Insert mode
369-
addTextCommand "insert", "a", "command-name" # Same as above
370-
371-
addTextCommand "completion", "a", "command-name" # Only active while completion window is open
372-
373-
addTextCommandBlock "", "s": # First parameter is mode/"completion"
374-
## Creates an anonymous action which runs this block. `editor` (automatically defined) is the text editor handling this command
375-
editor.setMode("insert")
376-
editor.selections = editor.delete(editor.selections)
377-
378-
addTextCommand "", "a", proc(editor: TextDocumentEditor) =
379-
## Creates an anonymous action which runs this lambda. `editor` is the text editor handling this command.
380-
# ...
381-
382-
proc foo(editor: TextDocumentEditor) =
383-
# ...
384-
385-
addTextCommand "", "a", foo # Like above, but uses existing function
386-
```
387-
388238
# Scripting API Documentation
389239
The documentation for the scripting API is in scripting/htmldocs. You can see the current version [here](https://raw.githack.com/Nimaoth/AbsytreeDocs/main/scripting_nim/htmldocs/theindex.html) (using raw.githack.com) or [here](https://nimaoth.github.io/AbsytreeDocs/scripting_nim/htmldocs/theindex.html).
390240

0 commit comments

Comments
 (0)