@@ -630,10 +630,29 @@ local FIELD_OVERRIDE_TYPECHECK = {
630
630
picker = { [" function" ] = true , string = true },
631
631
}
632
632
633
+ local ACCEPTED_STRINGS = {
634
+ sort = {
635
+ sorter = { " name" , " case_sensitive" , " modification_time" , " extension" , " suffix" , " filetype" },
636
+ },
637
+ view = {
638
+ side = { " left" , " right" },
639
+ signcolumn = { " yes" , " no" , " auto" },
640
+ },
641
+ renderer = {
642
+ highlight_opened_files = { " none" , " icon" , " name" , " all" },
643
+ highlight_modified = { " none" , " icon" , " name" , " all" },
644
+ icons = {
645
+ git_placement = { " before" , " after" , " signcolumn" },
646
+ diagnostics_placement = { " before" , " after" , " signcolumn" },
647
+ modified_placement = { " before" , " after" , " signcolumn" },
648
+ },
649
+ },
650
+ }
651
+
633
652
local function validate_options (conf )
634
653
local msg
635
654
636
- local function validate (user , def , prefix )
655
+ local function validate (user , def , strs , prefix )
637
656
-- only compare tables with contents that are not integer indexed
638
657
if type (user ) ~= " table" or type (def ) ~= " table" or not next (def ) or type (next (def )) == " number" then
639
658
return
@@ -650,6 +669,9 @@ local function validate_options(conf)
650
669
-- option is of the wrong type and is not a function
651
670
invalid =
652
671
string.format (" [NvimTree] invalid option: %s%s expected: %s actual: %s" , prefix , k , type (def [k ]), type (v ))
672
+ elseif type (v ) == " string" and strs [k ] and not vim .tbl_contains (strs [k ], v ) then
673
+ -- option has type `string` but value is not accepted
674
+ invalid = string.format (" [NvimTree] invalid value for field %s%s: '%s'" , prefix , k , v )
653
675
end
654
676
655
677
if invalid then
@@ -660,16 +682,16 @@ local function validate_options(conf)
660
682
end
661
683
user [k ] = nil
662
684
else
663
- validate (v , def [k ], prefix .. k .. " ." )
685
+ validate (v , def [k ], strs [ k ] or {}, prefix .. k .. " ." )
664
686
end
665
687
end
666
688
end
667
689
end
668
690
669
- validate (conf , DEFAULT_OPTS , " " )
691
+ validate (conf , DEFAULT_OPTS , ACCEPTED_STRINGS , " " )
670
692
671
693
if msg then
672
- vim .notify_once (msg .. " | see :help nvim-tree-setup for available configuration options\n " , vim .log .levels .WARN )
694
+ vim .notify_once (msg .. " | see :help nvim-tree-opts for available configuration options\n " , vim .log .levels .WARN )
673
695
end
674
696
end
675
697
0 commit comments