Add Neovim-related notes

This commit is contained in:
Gabriel Arazas 2022-04-03 17:00:15 +08:00
parent 1d7136bb4a
commit 951c9733f6
3 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,28 @@
:PROPERTIES:
:ID: 73bca39f-e492-47aa-92e7-629d3b8b92ad
:END:
#+title: Neovim folds
#+date: 2022-04-03 16:59:05 +08:00
#+date_modified: 2022-04-03 16:59:24 +08:00
#+language: en
- it is a built-in feature in Neovim;
enables you to quickly navigate a long document by hiding them and opening them when you want
- some keybindings for managing folds
| Keymap | Description |
|--------+----------------------------|
| ~zf~ | Create a fold. |
| ~zA~ | Toggle a fold recursively. |
| ~zM~ | Close all folds. |
| ~zR~ | Open all folds. |
| ~zj~ | Move one fold down. |
| ~zk~ | Move one fold up. |
- while in insert mode, there are no folds under your cursor so you can see what you type
- while manually managing folds can be tedious, Neovim does have a way to automatically manage folds for you;
this is dictated through the ~foldmethod~ variable;
for more information for the following methods, see ~fold-${VALUE}~ with the [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]]
- with ~manual~ value, no additional actions are done
- with ~marker~ value, a fold will be created ala-HTML markers
- with ~expr~ value, a fold will be managed through its fold level evaluated from ~foldexpr~ function;
certain tools like [[https://github.com/nvim-treesitter/nvim-treesitter][nvim-treesitter]] takes advantage of this to arrange the code through its blocks, scope, etc.

View File

@ -0,0 +1,15 @@
:PROPERTIES:
:ID: 0a0fe63e-dcf3-4928-9e82-5513784c1244
:END:
#+title: Neovim help system
#+date: 2022-04-01 16:20:55 +08:00
#+date_modified: 2022-04-03 16:59:48 +08:00
#+language: en
- the main command is ~:h~ which should open ~help.txt~ if given no arguments;
this should be enough if you want to explore much of Neovim itself as the document has
- if given an argument, Vim will open the section of the document with the closest match
- some points of interest
- you can view the complete listing of help tags with ~help-tags~
- there is also a index of tags from ~index.txt~

View File

@ -0,0 +1,30 @@
:PROPERTIES:
:ID: 5c4641ab-91d5-4cd6-bdec-4f899fdd9ea5
:END:
#+title: Neovim text objects
#+date: 2022-04-01 16:06:02 +08:00
#+date_modified: 2022-04-02 19:35:33 +08:00
#+language: en
(Neo)Vim has a bunch of text objects that are beyond simple boundaries other than a word (~aw~, ~aW~).
You can find more of them with ~text-objects~ section from [[id:0a0fe63e-dcf3-4928-9e82-5513784c1244][Neovim help system]].
| Text object | Description |
|-------------+---------------------------------|
| ~ap~ | A paragraph, equivalent to ~}~. |
| ~as~ | A sentence, equivalent to ~)~. |
| ~ab~ | A '( )' block. |
| ~aB~ | A '{ }' block. |
There is also a variation for selecting only the inner content of the previous text objects (e.g., ~ip~ for the inner paragraph, ~is~ for inner sentence) with the whitespace removed.
Note that selecting with text objects is different from selecting with [[roam:Neovim motions]] where it refers to the current position up to the end of the next selection.
Meanwhile, text objects selection will select to the referred object as a whole no matter where the cursor position.
For example, selecting with the paragraph (i.e., ~vap~) will select the whole paragraph where the cursor rests.
Aside from the built-in text objects, you can create your own.
Which also means others have created some custom text objects.
- [[https://github.com/nvim-treesitter/nvim-treesitter-textobjects][nvim-treesitter-textobjects]] add text objects support for selecting (and swapping, moving, and peeking) tree-sitter nodes.
(Assuming you have tree-sitter support enabled for Neovim.)