Skip to content

Commit 2a268f6

Browse files
committed
doc: help: syntax highlighting for lua and vimscript
1 parent f5f6789 commit 2a268f6

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

doc/nvim-tree-lua.txt

+38-36
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Disabling |netrw| is strongly advised, see |nvim-tree-netrw|
117117
==============================================================================
118118
2.1 QUICKSTART: SETUP *nvim-tree-quickstart-setup*
119119

120-
Setup the plugin in your `init.lua` >
120+
Setup the plugin in your `init.lua` e.g. >lua
121121

122122
-- disable netrw at the very start of your init.lua
123123
vim.g.loaded_netrw = 1
@@ -215,7 +215,7 @@ Show the mappings: `g?`
215215
2.3 QUICKSTART: CUSTOM MAPPINGS *nvim-tree-quickstart-custom-mappings*
216216

217217
|nvim-tree-mappings-default| are applied by default however you may customise
218-
via |nvim-tree.on_attach| e.g. >
218+
via |nvim-tree.on_attach| e.g. >lua
219219

220220
local function my_on_attach(bufnr)
221221
local api = require "nvim-tree.api"
@@ -245,7 +245,7 @@ via |nvim-tree.on_attach| e.g. >
245245
Run |:NvimTreeHiTest| to show all the highlights that nvim-tree uses.
246246

247247
They can be customised before or after setup is called and will be immediately
248-
applied at runtime. e.g. >
248+
applied at runtime. e.g. >lua
249249

250250
vim.cmd([[
251251
:hi NvimTreeExecFile guifg=#ffa0a0
@@ -366,15 +366,15 @@ again to apply a change in configuration without restarting nvim.
366366

367367
setup() function takes one optional argument: configuration table. If omitted
368368
nvim-tree will be initialised with default configuration.
369-
>
369+
370370
The first setup() call is cheap: it does nothing more than validate / apply
371371
the configuration. Nothing happens until the tree is first opened.
372372

373373
Subsequent setup() calls are expensive as they tear down the world before
374374
applying configuration.
375375

376-
Following is the default configuration. See |nvim-tree-opts| for details.
377-
>
376+
Following is the default configuration. See |nvim-tree-opts| for details. >lua
377+
378378
require("nvim-tree").setup { -- BEGIN_DEFAULT_OPTS
379379
on_attach = "default",
380380
hijack_cursor = false,
@@ -677,7 +677,7 @@ Completely disable netrw
677677

678678
It is strongly advised to eagerly disable netrw, due to race conditions at vim
679679
startup.
680-
Set the following at the very beginning of your `init.lua` / `init.vim`: >
680+
Set the following at the very beginning of your `init.lua` / `init.vim`: >lua
681681
vim.g.loaded_netrw = 1
682682
vim.g.loaded_netrwPlugin = 1
683683
<
@@ -739,7 +739,7 @@ Can be one of `"name"`, `"case_sensitive"`, `"modification_time"`, `"extension"`
739739
- `name`: `string`
740740
- `type`: `"directory"` | `"file"` | `"link"`
741741

742-
Example: sort by name length: >
742+
Example: sort by name length: >lua
743743
local sorter = function(nodes)
744744
table.sort(nodes, function(a, b)
745745
return #a.name < #b.name
@@ -871,7 +871,7 @@ Set to `false` to hide the root folder.
871871
Type: `string` or `boolean` or `function(root_cwd)`, Default: `":~:s?$?/..?"`
872872

873873
Function is passed the absolute path of the root folder and should
874-
return a string. e.g. >
874+
return a string. e.g. >lua
875875
my_root_folder_label = function(path)
876876
return ".../" .. vim.fn.fnamemodify(path, ":t")
877877
end
@@ -903,7 +903,7 @@ Show a summary of hidden files below the tree using `NvimTreeHiddenDisplay
903903
reasons and values are the count of hidden files for that reason.
904904

905905
The `hidden_stats` argument is structured as follows, where <num> is the
906-
number of hidden files related to the field: >
906+
number of hidden files related to the field: >lua
907907
hidden_stats = {
908908
bookmark = <num>,
909909
buf = <num>,
@@ -913,7 +913,7 @@ Show a summary of hidden files below the tree using `NvimTreeHiddenDisplay
913913
live_filter = <num>,
914914
}
915915
<
916-
Example of function that can be passed: >
916+
Example of function that can be passed: >lua
917917
function(hidden_stats)
918918
local total_count = 0
919919
for reason, count in pairs(hidden_stats) do
@@ -988,7 +988,7 @@ Configuration options for tree indent markers.
988988

989989
*nvim-tree.renderer.indent_markers.icons*
990990
Icons shown before the file/directory. Length 1.
991-
Type: `table`, Default: >
991+
Type: `table`, Default: >lua
992992
{
993993
corner = "└",
994994
edge = "│",
@@ -1300,7 +1300,7 @@ Severity for which the diagnostics will be displayed. See |diagnostic-severity|
13001300

13011301
*nvim-tree.diagnostics.icons*
13021302
Icons for diagnostic severity.
1303-
Type: `table`, Default: >
1303+
Type: `table`, Default: >lua
13041304
{
13051305
hint = "",
13061306
info = "",
@@ -1421,7 +1421,7 @@ function returning whether a path should be ignored.
14211421
Strings must be backslash escaped e.g. `"my-proj/\\.build$"`. See |string-match|.
14221422
Function is passed an absolute path.
14231423
Useful when path is not in `.gitignore` or git integration is disabled.
1424-
Type: `string[] | fun(path: string): boolean`, Default: >
1424+
Type: `string[] | fun(path: string): boolean`, Default: >lua
14251425
{
14261426
"/.ccls-cache",
14271427
"/build",
@@ -1513,7 +1513,7 @@ Configuration options for opening a file from nvim-tree.
15131513
or `nil` if an invalid window is picked or user cancelled the action.
15141514
The picker may create a new window.
15151515
Type: `string` | `function`, Default: `"default"`
1516-
e.g. s1n7ax/nvim-window-picker plugin: >
1516+
e.g. s1n7ax/nvim-window-picker plugin: >lua
15171517
window_picker = {
15181518
enable = true,
15191519
picker = require("window-picker").pick_window,
@@ -1526,7 +1526,7 @@ Configuration options for opening a file from nvim-tree.
15261526
Table of buffer option names mapped to a list of option values that
15271527
indicates to the picker that the buffer's window should not be
15281528
selectable.
1529-
Type: `table`, Default: >
1529+
Type: `table`, Default: >lua
15301530
{
15311531
filetype = {
15321532
"notify",
@@ -1685,9 +1685,7 @@ Specify which information to log.
16851685
==============================================================================
16861686
6. API *nvim-tree-api*
16871687

1688-
Nvim-tree's public API can be used to access features.
1689-
>
1690-
e.g. >
1688+
Nvim-tree's public API can be used to access features. e.g. >lua
16911689
local api = require("nvim-tree.api")
16921690
api.tree.toggle()
16931691
<
@@ -2286,7 +2284,7 @@ Active mappings may be viewed via HELP, default `g?`. The mapping's description
22862284
is used when displaying HELP.
22872285

22882286
The `on_attach` function is passed the `bufnr` of nvim-tree. Use
2289-
|vim.keymap.set()| or |nvim_set_keymap()| to define mappings as usual. e.g. >
2287+
|vim.keymap.set()| or |nvim_set_keymap()| to define mappings as usual. e.g. >lua
22902288

22912289
local function my_on_attach(bufnr)
22922290
local api = require("nvim-tree.api")
@@ -2326,7 +2324,7 @@ Single left mouse mappings can be achieved via `<LeftRelease>`.
23262324
Single right / middle mouse mappings will require changes to |mousemodel| or |mouse|.
23272325

23282326
|vim.keymap.set()| {rhs} is a `(function|string)` thus it may be necessary to
2329-
define your own function to map complex functionality e.g. >
2327+
define your own function to map complex functionality e.g. >lua
23302328

23312329
local function print_node_path()
23322330
local api = require("nvim-tree.api")
@@ -2343,8 +2341,8 @@ define your own function to map complex functionality e.g. >
23432341
In the absence of an |nvim-tree.on_attach| function, the following defaults
23442342
will be applied.
23452343

2346-
You are encouraged to copy these to your own |nvim-tree.on_attach| function.
2347-
>
2344+
You are encouraged to copy these to your own |nvim-tree.on_attach| function. >lua
2345+
23482346
local api = require("nvim-tree.api")
23492347

23502348
local function opts(desc)
@@ -2413,8 +2411,8 @@ You are encouraged to copy these to your own |nvim-tree.on_attach| function.
24132411
-- END_DEFAULT_ON_ATTACH
24142412
<
24152413
Alternatively, you may apply these default mappings from your |nvim-tree.on_attach| via
2416-
|nvim-tree-api.config.mappings.default_on_attach()| e.g.
2417-
>
2414+
|nvim-tree-api.config.mappings.default_on_attach()| e.g. >lua
2415+
24182416
local function my_on_attach(bufnr)
24192417
local api = require("nvim-tree.api")
24202418

@@ -2434,10 +2432,10 @@ All the following highlight groups can be configured by hand. Aside from
24342432
`NvimTreeWindowPicker`, it is not advised to colorize the background of these
24352433
groups.
24362434

2437-
Example |:highlight| >
2435+
Example |:highlight| >vim
24382436
:hi NvimTreeSymlink guifg=blue gui=bold,underline
24392437
<
2440-
It is recommended to enable 'termguicolors' for the more pleasant 24-bit
2438+
It is recommended to enable |termguicolors| for the more pleasant 24-bit
24412439
colours.
24422440

24432441
To view the nvim-tree highlight groups run |:NvimTreeHiTest|
@@ -2448,16 +2446,18 @@ as per |:highlight|
24482446
The `*HL` groups are additive as per |nvim-tree-opts-renderer| precedence.
24492447
Only present attributes will clobber each other.
24502448
In this example a modified, opened file will have magenta text, with cyan
2451-
undercurl: >
2449+
undercurl: >vim
24522450
:hi NvimTreeOpenedHL guifg=magenta guisp=red gui=underline
24532451
:hi NvimTreeModifiedFileHL guisp=cyan gui=undercurl
24542452
<
24552453
To prevent usage of a highlight:
2456-
- Before setup: link the group to `Normal` e.g.
2457-
`:hi NvimTreeExecFile Normal`
2458-
- After setup: link it to `NONE`, to override the default link e.g.
2459-
`:hi! link NvimTreeExecFile NONE`
24602454

2455+
- Before setup: link the group to `Normal` e.g. >vim
2456+
:hi NvimTreeExecFile Normal
2457+
<
2458+
- After setup: link it to `NONE`, to override the default link e.g. >lua
2459+
:hi! link NvimTreeExecFile NONE
2460+
<
24612461
==============================================================================
24622462
8.1 HIGHLIGHT: DEFAULT *nvim-tree-highlight-default*
24632463

@@ -2612,7 +2612,7 @@ See |nvim-tree-legacy-highlight| for old highlight group compatibility.
26122612
- NvimTreeSpecialFile PreProc -> SpellCap
26132613
- NvimTreeSymlink Statement -> SpellCap
26142614

2615-
Approximate pre-overhaul values for the `SpellCap` groups may be set via: >
2615+
Approximate pre-overhaul values for the `SpellCap` groups may be set via: >lua
26162616

26172617
vim.cmd([[
26182618
:hi NvimTreeExecFile gui=bold guifg=#ffa0a0
@@ -2639,7 +2639,8 @@ to |nvim_tree_registering_handlers| for more information.
26392639
Handlers are registered by calling |nvim-tree-api.events.subscribe()|
26402640
function with an |nvim-tree-api.events.Event|
26412641

2642-
e.g. handler for node renamed: >
2642+
e.g. handler for node renamed: >lua
2643+
26432644
local api = require("nvim-tree.api")
26442645
local Event = api.events.Event
26452646

@@ -2726,7 +2727,8 @@ There are two special startup events in the form of User autocommands:
27262727
Immediately before firing: a global variable of the same name will be set to a
27272728
value of 1.
27282729

2729-
Example subscription: >
2730+
Example subscription: >lua
2731+
27302732
vim.api.nvim_create_autocmd("User", {
27312733
pattern = "NvimTreeRequired",
27322734
callback = function(data)
@@ -2778,7 +2780,7 @@ It interferes with nvim-tree and the intended user experience is nvim-tree
27782780
replacing the |netrw| browser.
27792781

27802782
It is strongly recommended to disable |netrw|. As it is a bundled plugin it
2781-
must be disabled manually at the start of your `init.lua` as per |netrw-noload|: >
2783+
must be disabled manually at the start of your `init.lua` as per |netrw-noload|: >lua
27822784

27832785
vim.g.loaded_netrw = 1
27842786
vim.g.loaded_netrwPlugin = 1

0 commit comments

Comments
 (0)