-
-
Notifications
You must be signed in to change notification settings - Fork 213
/
neo-tree.nix
1129 lines (975 loc) · 38.7 KB
/
neo-tree.nix
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
lib,
helpers,
config,
pkgs,
...
}:
with lib;
let
cfg = config.plugins.neo-tree;
basePluginPath = [
"plugins"
"neo-tree"
];
in
{
imports = [
(mkRemovedOptionModule (
basePluginPath
++ [
"sourceSelector"
"tabLabels"
]
) "Use `plugins.neo-tree.sourceSelector.sources` to achieve the same functionality.")
(mkRemovedOptionModule (
basePluginPath ++ [ "closeFloatsOnEscapeKey" ]
) "This option has been removed from upstream.")
];
options.plugins.neo-tree =
let
listOfRendererComponents = with types; listOf (either str attrs);
mkRendererComponentListOption = helpers.defaultNullOpts.mkNullable listOfRendererComponents;
mkMappingsOption =
defaults:
helpers.defaultNullOpts.mkNullable (
with types; attrsOf (either str attrs)
) defaults "Mapping options";
mkWindowMappingsOption = defaults: { mappings = mkMappingsOption defaults; };
mkFollowCurrentFileOption = default: {
enabled = helpers.defaultNullOpts.mkBool default ''
This will find and focus the file in the active buffer every time the current file is
changed while the tree is open.
'';
leaveDirsOpen = helpers.defaultNullOpts.mkBool false ''
`false` closes auto expanded dirs, such as with `:Neotree reveal`.
'';
};
in
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "neo-tree";
package = helpers.mkPluginPackageOption "neo-tree" pkgs.vimPlugins.neo-tree-nvim;
sources =
helpers.defaultNullOpts.mkListOf types.str
[
"filesystem"
"buffers"
"git_status"
]
''
If a user has a sources list it will replace this one.
Only sources listed here will be loaded.
You can also add an external source by adding it's name to this list.
The name used here must be the same name you would use in a require() call.
'';
extraSources = helpers.mkNullOrOption (types.listOf types.str) ''
Extra sources to be added to the sources. This is an internal nixvim option.
'';
addBlankLineAtTop = helpers.defaultNullOpts.mkBool false "Add a blank line at the top of the tree.";
autoCleanAfterSessionRestore = helpers.defaultNullOpts.mkBool false "Automatically clean up broken neo-tree buffers saved in sessions";
closeIfLastWindow = helpers.defaultNullOpts.mkBool false "Close Neo-tree if it is the last window left in the tab";
defaultSource = helpers.defaultNullOpts.mkStr "filesystem" "";
enableDiagnostics = helpers.defaultNullOpts.mkBool true "";
enableGitStatus = helpers.defaultNullOpts.mkBool true "";
enableModifiedMarkers = helpers.defaultNullOpts.mkBool true "Show markers for files with unsaved changes.";
enableRefreshOnWrite = helpers.defaultNullOpts.mkBool true "Refresh the tree when a file is written. Only used if `use_libuv_file_watcher` is false.";
gitStatusAsync = helpers.defaultNullOpts.mkBool true "";
gitStatusAsyncOptions = {
batchSize =
helpers.defaultNullOpts.mkInt 1000
"How many lines of git status results to process at a time";
batchDelay =
helpers.defaultNullOpts.mkInt 10
"delay in ms between batches. Spreads out the workload to let other processes run.";
maxLines = helpers.defaultNullOpts.mkInt 10000 ''
How many lines of git status results to process. Anything after this will be dropped.
Anything before this will be used.
The last items to be processed are the untracked files.
'';
};
hideRootNode = helpers.defaultNullOpts.mkBool false "Hide the root node.";
retainHiddenRootIndent = helpers.defaultNullOpts.mkBool false ''
If the root node is hidden, keep the indentation anyhow.
This is needed if you use expanders because they render in the indent.
'';
logLevel = helpers.defaultNullOpts.mkEnum [
"trace"
"debug"
"info"
"warn"
"error"
"fatal"
] "info" "";
logToFile =
helpers.defaultNullOpts.mkNullable (types.either types.bool types.str) false
"use :NeoTreeLogs to show the file";
openFilesInLastWindow = helpers.defaultNullOpts.mkBool true "If `false`, open files in top left window";
popupBorderStyle = helpers.defaultNullOpts.mkEnumFirstDefault [
"NC"
"double"
"none"
"rounded"
"shadow"
"single"
"solid"
] "";
resizeTimerInterval = helpers.defaultNullOpts.mkInt 500 ''
In ms, needed for containers to redraw right aligned and faded content.
Set to -1 to disable the resize timer entirely.
NOTE: this will speed up to 50 ms for 1 second following a resize
'';
sortCaseInsensitive = helpers.defaultNullOpts.mkBool false "Used when sorting files and directories in the tree";
sortFunction = helpers.defaultNullOpts.mkLuaFn "nil" "Uses a custom function for sorting files and directories in the tree";
usePopupsForInput = helpers.defaultNullOpts.mkBool true "If false, inputs will use vim.ui.input() instead of custom floats.";
useDefaultMappings = helpers.defaultNullOpts.mkBool true "";
# sourceSelector provides clickable tabs to switch between sources."
sourceSelector = {
winbar = helpers.defaultNullOpts.mkBool false "toggle to show selector on winbar";
statusline = helpers.defaultNullOpts.mkBool false "toggle to show selector on statusline";
showScrolledOffParentNode = helpers.defaultNullOpts.mkBool false ''
If `true`, tabs are replaced with the parent path of the top visible node when
scrolled down.
'';
sources = helpers.mkNullOrOption (
with types;
listOf (submodule {
options = {
source = mkOption {
type = str;
description = "Name of the source to add to the bar.";
};
displayName = helpers.mkNullOrOption str "How that source to appear in the bar.";
};
})
) "Configure the characters shown on each tab.";
contentLayout =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"start"
"end"
"focus"
]
''
Defines how the labels are placed inside a tab.
This only takes effect when the tab width is greater than the length of label i.e.
`tabsLayout = "equal", "focus"` or when `tabsMinWidth` is large enough.
Following options are available.
"start" : left aligned / 裡 bufname \/..
"end" : right aligned / 裡 bufname \/...
"center" : centered with equal padding / 裡 bufname \/...
'';
tabsLayout =
helpers.defaultNullOpts.mkEnum
[
"start"
"end"
"center"
"equal"
"focus"
]
"equal"
''
Defines how the tabs are aligned inside the window when there is more than enough
space.
The following options are available.
`active` will expand the focused tab as much as possible. Bars denote the edge of window.
"start" : left aligned ┃/ ~ \/ ~ \/ ~ \ ┃
"end" : right aligned ┃ / ~ \/ ~ \/ ~ \┃
"center" : centered with equal padding ┃ / ~ \/ ~ \/ ~ \ ┃
"equal" : expand all tabs equally to fit the window width ┃/ ~ \/ ~ \/ ~ \┃
"active" : expand the focused tab to fit the window width ┃/ focused tab \/ ~ \/ ~ \┃
'';
truncationCharacter = helpers.defaultNullOpts.mkStr "…" "Character to use when truncating the tab label";
tabsMinWidth =
helpers.defaultNullOpts.mkNullable types.int null
"If int padding is added based on `contentLayout`";
tabsMaxWidth =
helpers.defaultNullOpts.mkNullable types.int null
"This will truncate text even if `textTruncToFit = false`";
padding = helpers.defaultNullOpts.mkNullable (with types; either int (attrsOf int)) 0 ''
Defines the global padding of the source selector.
It can be an integer or an attrs with keys `left` and `right`.
Setting `padding = 2` is exactly the same as `{ left = 2; right = 2; }`.
Example: `{ left = 2; right = 0; }`
'';
separator =
helpers.defaultNullOpts.mkNullable
(
with types;
either str (submodule {
options = {
left = helpers.defaultNullOpts.mkStr "▏" "";
right = helpers.defaultNullOpts.mkStr "\\" "";
override = helpers.defaultNullOpts.mkStr null "";
};
})
)
{
left = "▏";
right = "▕";
}
"Can be a string or a table";
separatorActive =
helpers.defaultNullOpts.mkNullable
(
with types;
either str (submodule {
options = {
left = helpers.mkNullOrOption types.str "";
right = helpers.mkNullOrOption types.str "";
override = helpers.mkNullOrOption types.str "";
};
})
)
null
''
Set separators around the active tab.
null falls back to `sourceSelector.separator`.
'';
showSeparatorOnEdge = helpers.defaultNullOpts.mkBool false ''
Takes a boolean value where `false` (default) hides the separators on the far
left / right.
Especially useful when left and right separator are the same.
'true' : ┃/ ~ \/ ~ \/ ~ \┃
'false' : ┃ ~ \/ ~ \/ ~ ┃
'';
highlightTab = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" "";
highlightTabActive = helpers.defaultNullOpts.mkStr "NeoTreeTabActive" "";
highlightBackground = helpers.defaultNullOpts.mkStr "NeoTreeTabInactive" "";
highlightSeparator = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorInactive" "";
highlightSeparatorActive = helpers.defaultNullOpts.mkStr "NeoTreeTabSeparatorActive" "";
};
eventHandlers = helpers.mkNullOrOption (with types; attrsOf str) ''
Configuration of event handlers.
Attrs:
- keys are the events (e.g. `before_render`, `file_opened`)
- values are lua code defining the callback function.
Example:
```nix
{
before_render = \'\'
function (state)
-- add something to the state that can be used by custom components
end
\'\';
file_opened = \'\'
function(file_path)
--auto close
require("neo-tree").close_all()
end
\'\';
}
```
'';
defaultComponentConfigs = {
container = {
enableCharacterFade = helpers.defaultNullOpts.mkBool true "";
width = helpers.defaultNullOpts.mkStr "100%" "";
rightPadding = helpers.defaultNullOpts.mkInt 0 "";
};
diagnostics = {
symbols = {
hint = helpers.defaultNullOpts.mkStr "H" "";
info = helpers.defaultNullOpts.mkStr "I" "";
warn = helpers.defaultNullOpts.mkStr "!" "";
error = helpers.defaultNullOpts.mkStr "X" "";
};
highlights = {
hint = helpers.defaultNullOpts.mkStr "DiagnosticSignHint" "";
info = helpers.defaultNullOpts.mkStr "DiagnosticSignInfo" "";
warn = helpers.defaultNullOpts.mkStr "DiagnosticSignWarn" "";
error = helpers.defaultNullOpts.mkStr "DiagnosticSignError" "";
};
};
indent = {
indentSize = helpers.defaultNullOpts.mkInt 2 "";
padding = helpers.defaultNullOpts.mkInt 1 "";
withMarkers = helpers.defaultNullOpts.mkBool true "";
indentMarker = helpers.defaultNullOpts.mkStr "│" "";
lastIndentMarker = helpers.defaultNullOpts.mkStr "└" "";
highlight = helpers.defaultNullOpts.mkStr "NeoTreeIndentMarker" "";
withExpanders =
helpers.defaultNullOpts.mkNullable types.bool null
"If null and file nesting is enabled, will enable expanders.";
expanderCollapsed = helpers.defaultNullOpts.mkStr "" "";
expanderExpanded = helpers.defaultNullOpts.mkStr "" "";
expanderHighlight = helpers.defaultNullOpts.mkStr "NeoTreeExpander" "";
};
icon = {
folderClosed = helpers.defaultNullOpts.mkStr "" "";
folderOpen = helpers.defaultNullOpts.mkStr "" "";
folderEmpty = helpers.defaultNullOpts.mkStr "ﰊ" "";
folderEmptyOpen = helpers.defaultNullOpts.mkStr "ﰊ" "";
default = helpers.defaultNullOpts.mkStr "*" ''
Only a fallback, if you use nvim-web-devicons and configure default icons there
then this will never be used.
'';
highlight = helpers.defaultNullOpts.mkStr "NeoTreeFileIcon" ''
Only a fallback, if you use nvim-web-devicons and configure default icons there
then this will never be used.
'';
};
modified = {
symbol = helpers.defaultNullOpts.mkStr "[+] " "";
highlight = helpers.defaultNullOpts.mkStr "NeoTreeModified" "";
};
name = {
trailingSlash = helpers.defaultNullOpts.mkBool false "";
useGitStatusColors = helpers.defaultNullOpts.mkBool true "";
highlight = helpers.defaultNullOpts.mkStr "NeoTreeFileName" "";
};
gitStatus = {
symbols = mapAttrs (optionName: default: helpers.defaultNullOpts.mkStr default optionName) {
added = "✚";
deleted = "✖";
modified = "";
renamed = "";
untracked = "";
ignored = "";
unstaged = "";
staged = "";
conflict = "";
};
align = helpers.defaultNullOpts.mkStr "right" "icon alignment";
};
};
renderers = {
directory = mkRendererComponentListOption [
"indent"
"icon"
"current_filter"
{
name = "container";
content = [
{
name = "name";
zindex = 10;
}
{
name = "clipboard";
zindex = 10;
}
{
name = "diagnostics";
errors_only = true;
zindex = 20;
align = "right";
hide_when_expanded = true;
}
{
name = "git_status";
zindex = 20;
align = "right";
hide_when_expanded = true;
}
];
}
] "directory renderers";
file = mkRendererComponentListOption [
"indent"
"icon"
{
name = "container";
content = [
{
name = "name";
zindex = 10;
}
{
name = "clipboard";
zindex = 10;
}
{
name = "bufnr";
zindex = 10;
}
{
name = "modified";
zindex = 20;
align = "right";
}
{
name = "diagnostics";
zindex = 20;
align = "right";
}
{
name = "git_status";
zindex = 20;
align = "right";
}
];
}
] "file renderers";
message = mkRendererComponentListOption [
{
name = "indent";
with_markers = false;
}
{
name = "name";
highlight = "NeoTreeMessage";
}
] "message renderers";
terminal = mkRendererComponentListOption [
"indent"
"icon"
"name"
"bufnr"
] "message renderers";
};
nestingRules = helpers.defaultNullOpts.mkAttrsOf types.str { } "nesting rules";
window = {
position = helpers.defaultNullOpts.mkEnumFirstDefault [
"left"
"right"
"top"
"bottom"
"float"
"current"
] "position";
width = helpers.defaultNullOpts.mkInt 40 "Applies to left and right positions";
height = helpers.defaultNullOpts.mkInt 15 "Applies to top and bottom positions";
autoExpandWidth = helpers.defaultNullOpts.mkBool false ''
Expand the window when file exceeds the window width. does not work with
position = "float"
'';
popup = {
size = {
height = helpers.defaultNullOpts.mkStr "80%" "height";
width = helpers.defaultNullOpts.mkStr "50%" "height";
};
position = helpers.defaultNullOpts.mkStr "80%" ''
50% means center it.
You can also specify border here, if you want a different setting from the global
`popupBorderStyle`.
'';
};
sameLevel = helpers.defaultNullOpts.mkBool false ''
Create and paste/move files/directories on the same level as the directory under cursor
(as opposed to within the directory under cursor).
'';
insertAs =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"child"
"sibling"
]
''
Affects how nodes get inserted into the tree during creation/pasting/moving of files if
the node under the cursor is a directory:
- "child": Insert nodes as children of the directory under cursor.
- "sibling": Insert nodes as siblings of the directory under cursor.
'';
mappingOptions = {
noremap = helpers.defaultNullOpts.mkBool true "noremap";
nowait = helpers.defaultNullOpts.mkBool true "nowait";
};
mappings = mkMappingsOption (literalMD ''
```nix
{
"<space>" = {
command = "toggle_node";
# disable `nowait` if you have existing combos starting with this char that you want to use
nowait = false;
};
"<2-LeftMouse>" = "open";
"<cr>" = "open";
"<esc>" = "revert_preview";
P = {
command = "toggle_preview";
config = { use_float = true; };
};
l = "focus_preview";
S = "open_split";
# S = "split_with_window_picker";
s = "open_vsplit";
# s = "vsplit_with_window_picker";
t = "open_tabnew";
# "<cr>" = "open_drop";
# t = "open_tab_drop";
w = "open_with_window_picker";
C = "close_node";
z = "close_all_nodes";
# Z = "expand_all_nodes";
R = "refresh";
a = {
command = "add";
# some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none"; # "none", "relative", "absolute"
};
};
A = "add_directory"; # also accepts the config.show_path and config.insert_as options.
d = "delete";
r = "rename";
y = "copy_to_clipboard";
x = "cut_to_clipboard";
p = "paste_from_clipboard";
c = "copy"; # takes text input for destination, also accepts the config.show_path and config.insert_as options
m = "move"; # takes text input for destination, also accepts the config.show_path and config.insert_as options
e = "toggle_auto_expand_width";
q = "close_window";
"?" = "show_help";
"<" = "prev_source";
">" = "next_source";
}
```
'');
};
filesystem = {
window = mkWindowMappingsOption (literalMD ''
```nix
{
H = "toggle_hidden";
"/" = "fuzzy_finder";
D = "fuzzy_finder_directory";
# "/" = "filter_as_you_type"; # this was the default until v1.28
"#" = "fuzzy_sorter"; # fuzzy sorting using the fzy algorithm
# D = "fuzzy_sorter_directory";
f = "filter_on_submit";
"<C-x>" = "clear_filter";
"<bs>" = "navigate_up";
"." = "set_root";
"[g" = "prev_git_modified";
"]g" = "next_git_modified";
}
```
'');
asyncDirectoryScan =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"auto"
"always"
"never"
]
''
- "auto" means refreshes are async, but it's synchronous when called from the Neotree
commands.
- "always" means directory scans are always async.
- "never" means directory scans are never async.
'';
scanMode =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"shallow"
"deep"
]
''
- "shallow": Don't scan into directories to detect possible empty directory a priori.
- "deep": Scan into directories to detect empty or grouped empty directories a priori.
'';
bindToCwd = helpers.defaultNullOpts.mkBool true "true creates a 2-way binding between vim's cwd and neo-tree's root.";
cwdTarget = {
sidebar = helpers.defaultNullOpts.mkStr "tab" "sidebar is when position = left or right";
current = helpers.defaultNullOpts.mkStr "window" "current is when position = current";
};
filteredItems = {
visible = helpers.defaultNullOpts.mkBool false "when true, they will just be displayed differently than normal items";
forceVisibleInEmptyFolder = helpers.defaultNullOpts.mkBool false "when true, hidden files will be shown if the root folder is otherwise empty";
showHiddenCount = helpers.defaultNullOpts.mkBool true "when true, the number of hidden items in each folder will be shown as the last entry";
hideDotfiles = helpers.defaultNullOpts.mkBool true "hide dotfiles";
hideGitignored = helpers.defaultNullOpts.mkBool true "hide gitignored files";
hideHidden = helpers.defaultNullOpts.mkBool true "only works on Windows for hidden files/directories";
hideByName = helpers.defaultNullOpts.mkListOf types.str [
".DS_Store"
"thumbs.db"
] "hide by name";
hideByPattern = helpers.defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = [ ];
description = "Hide by pattern.";
example = [
"*.meta"
"*/src/*/tsconfig.json"
];
};
alwaysShow = helpers.defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = [ ];
description = "Files/folders to always show.";
example = [ ".gitignore" ];
};
neverShow = helpers.defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = [ ];
description = "Files/folders to never show.";
example = [
".DS_Store"
"thumbs.db"
];
};
neverShowByPattern = helpers.defaultNullOpts.mkListOf' {
type = types.str;
pluginDefault = [ ];
description = "Files/folders to never show (by pattern).";
example = [ ".null-ls_*" ];
};
};
findByFullPathWords = helpers.defaultNullOpts.mkBool false ''
`false` means it only searches the tail of a path.
`true` will change the filter into a full path
search with space as an implicit ".*", so `fi init` will match:
`./sources/filesystem/init.lua
'';
findCommand = helpers.defaultNullOpts.mkStr "fd" "This is determined automatically, you probably don't need to set it";
findArgs =
helpers.mkNullOrStrLuaFnOr
(types.submodule {
options = {
fd = helpers.defaultNullOpts.mkListOf types.str [
"--exclude"
".git"
"--exclude"
"node_modules"
] "You can specify extra args to pass to the find command.";
};
})
''
Find arguments
Either use a list of strings:
```nix
findArgs = {
fd = [
"--exclude"
".git"
"--exclude"
"node_modules"
];
};
```
Or use a function instead of list of strings
```
findArgs = \'\'
find_args = function(cmd, path, search_term, args)
if cmd ~= "fd" then
return args
end
--maybe you want to force the filter to always include hidden files:
table.insert(args, "--hidden")
-- but no one ever wants to see .git files
table.insert(args, "--exclude")
table.insert(args, ".git")
-- or node_modules
table.insert(args, "--exclude")
table.insert(args, "node_modules")
--here is where it pays to use the function, you can exclude more for
--short search terms, or vary based on the directory
if string.len(search_term) < 4 and path == "/home/cseickel" then
table.insert(args, "--exclude")
table.insert(args, "Library")
end
return args
end
\'\';
```
'';
groupEmptyDirs = helpers.defaultNullOpts.mkBool false "when true, empty folders will be grouped together";
searchLimit = helpers.defaultNullOpts.mkInt 50 "max number of search results when using filters";
followCurrentFile = mkFollowCurrentFileOption false;
hijackNetrwBehavior =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"open_default"
"open_current"
"disabled"
]
''
- "open_default": netrw disabled, opening a directory opens neo-tree in whatever
position is specified in window.position
- "open_current": netrw disabled, opening a directory opens within the window like netrw
would, regardless of window.position
- "disabled": netrw left alone, neo-tree does not handle opening dirs
'';
useLibuvFileWatcher = helpers.defaultNullOpts.mkBool false ''
This will use the OS level file watchers to detect changes instead of relying on nvim
autocmd events.
'';
};
buffers = {
bindToCwd = helpers.defaultNullOpts.mkBool true "Bind to current working directory.";
followCurrentFile = mkFollowCurrentFileOption true;
groupEmptyDirs = helpers.defaultNullOpts.mkBool true "When true, empty directories will be grouped together.";
window = mkWindowMappingsOption {
"<bs>" = "navigate_up";
"." = "set_root";
bd = "buffer_delete";
};
};
gitStatus = {
window = mkWindowMappingsOption {
A = "git_add_all";
gu = "git_unstage_file";
ga = "git_add_file";
gr = "git_revert_file";
gc = "git_commit";
gp = "git_push";
gg = "git_commit_and_push";
};
};
example = {
renderers = {
custom = mkRendererComponentListOption [
"indent"
{
name = "icon";
default = "C";
}
"custom"
"name"
] "custom renderers";
};
window = mkWindowMappingsOption {
"<cr>" = "toggle_node";
"<C-e>" = "example_command";
d = "show_debug_info";
};
};
documentSymbols = {
followCursor = helpers.defaultNullOpts.mkBool false "If set to `true`, will automatically focus on the symbol under the cursor.";
kinds =
helpers.mkNullOrOption
(
with types;
attrsOf (submodule {
options = {
icon = mkOption {
description = "Icon for this LSP kind.";
type = types.str;
example = "";
};
hl = mkOption {
description = "Highlight group for this LSP kind.";
type = types.str;
example = "Include";
};
};
})
)
''
An attrs specifying how LSP kinds should be rendered.
Each entry should map the LSP kind name to an icon and a highlight group, for example
`Class = { icon = ""; hl = "Include"; }`
'';
customKinds = mkOption {
type = with types; attrsOf str;
default = { };
example = {
"252" = "TypeAlias";
};
description = ''
A table mapping the LSP kind id (an integer) to the LSP kind name that is used for
`kinds`.
For the list of kinds (id and name), please refer to
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentSymbol
'';
};
window = mkWindowMappingsOption { };
};
};
config =
let
inherit (helpers) ifNonNull' mkRaw;
processRendererComponent =
component:
if isString component then
[ component ]
else
(mapAttrs' (name: value: {
name = if name == "name" then "__unkeyed" else name;
value = if isList value then processRendererComponentList value else value;
}) component);
processRendererComponentList =
componentList: ifNonNull' componentList (map processRendererComponent componentList);
processMapping =
key: action:
if isString action then
action
else
mapAttrs' (k: v: {
name = if k == "command" then "__unkeyed" else k;
value = v;
}) action;
processMappings = mappings: ifNonNull' mappings (mapAttrs processMapping mappings);
processWindowMappings = window: { mappings = processMappings window.mappings; };
setupOptions =
with cfg;
{
# Concatenate sources and extraSources, setting sources to it's default value if it is null
# and extraSources is not null
sources =
if (extraSources != null) then
if (sources == null) then
[
"filesystem"
"git_status"
"buffers"
]
++ extraSources
else
sources ++ extraSources
else
sources;
add_blank_line_at_top = addBlankLineAtTop;
auto_clean_after_session_restore = autoCleanAfterSessionRestore;
close_if_last_window = closeIfLastWindow;
default_source = defaultSource;
enable_diagnostics = enableDiagnostics;
enable_git_status = enableGitStatus;
enable_modified_markers = enableModifiedMarkers;
enable_refresh_on_write = enableRefreshOnWrite;
git_status_async = gitStatusAsync;
git_status_async_options = with gitStatusAsyncOptions; {
batch_size = batchSize;
batch_delay = batchDelay;
max_lines = maxLines;
};
hide_root_node = hideRootNode;
retain_hidden_root_indent = retainHiddenRootIndent;
log_level = logLevel;
log_to_file = logToFile;
open_files_in_last_window = openFilesInLastWindow;
popup_border_style = popupBorderStyle;
resize_timer_interval = resizeTimerInterval;
sort_case_insensitive = sortCaseInsensitive;
sort_function = sortFunction;
use_popups_for_input = usePopupsForInput;
use_default_mappings = useDefaultMappings;
source_selector = with sourceSelector; {
inherit winbar statusline;
show_scrolled_off_parent_node = showScrolledOffParentNode;
sources = ifNonNull' sources (
map (source: {
inherit (source) source;
display_name = source.displayName;
}) sources
);