Sort options in alphabetical order (#2074)

* Sort options in alphabetical order

* Sort `eval.go` too
This commit is contained in:
Joe Lim authored and GitHub committed 2025-08-04 16:26:33 +10:00
1 parent 44483d7872
commit 47b3bc5617
5 files changed
+147 -147

No files matched your search

+83 -83
View File
@@ -47,6 +47,7 @@ var gOpts struct {
anchorfind bool
autoquit bool
borderfmt string
cleaner string
copyfmt string
cursoractivefmt string
cursorparentfmt string
@@ -59,77 +60,76 @@ var gOpts struct {
dirpreviews bool
drawbox bool
dupfilefmt string
searchmethod searchMethod
errorfmt string
filesep string
filtermethod searchMethod
findlen int
hidden bool
hiddenfiles []string
history bool
icons bool
ifs string
ignorecase bool
ignoredia bool
incfilter bool
incsearch bool
info []string
infotimefmtnew string
infotimefmtold string
locale string
mouse bool
number bool
numberfmt string
period int
preserve []string
preview bool
previewer string
promptfmt string
ratios []int
relativenumber bool
reverse bool
roundbox bool
rulerfmt string
scrolloff int
searchmethod searchMethod
selectfmt string
visualfmt string
selmode string
shell string
shellflag string
shellopts []string
showbinds bool
sixel bool
sortby sortMethod
smartcase bool
smartdia bool
sortby sortMethod
statfmt string
tabstop int
tagfmt string
tempmarks string
timefmt string
truncatechar string
truncatepct int
visualfmt string
waitmsg string
watch bool
wrapscan bool
wrapscroll bool
findlen int
period int
scrolloff int
tabstop int
errorfmt string
filesep string
ifs string
previewer string
cleaner string
promptfmt string
selmode string
shell string
shellflag string
statfmt string
timefmt string
infotimefmtnew string
infotimefmtold string
truncatechar string
truncatepct int
ratios []int
hiddenfiles []string
history bool
info []string
rulerfmt string
preserve []string
shellopts []string
nkeys map[string]expr
vkeys map[string]expr
cmdkeys map[string]expr
cmds map[string]expr
user map[string]string
tempmarks string
numberfmt string
tagfmt string
}
var gLocalOpts struct {
sortby map[string]sortMethod
dircounts map[string]bool
dirfirst map[string]bool
dironly map[string]bool
hidden map[string]bool
reverse map[string]bool
info map[string][]string
locale map[string]string
reverse map[string]bool
sortby map[string]sortMethod
}
func localOptPaths(path string) []string {
@@ -185,6 +185,15 @@ func getInfo(path string) []string {
return gOpts.info
}
func getLocale(path string) string {
for _, key := range localOptPaths(path) {
if val, ok := gLocalOpts.locale[key]; ok {
return val
}
}
return gOpts.locale
}
func getReverse(path string) bool {
for _, key := range localOptPaths(path) {
if val, ok := gLocalOpts.reverse[key]; ok {
@@ -203,18 +212,16 @@ func getSortBy(path string) sortMethod {
return gOpts.sortby
}
func getLocale(path string) string {
for _, key := range localOptPaths(path) {
if val, ok := gLocalOpts.locale[key]; ok {
return val
}
}
return gOpts.locale
}
func init() {
gOpts.anchorfind = true
gOpts.autoquit = true
gOpts.borderfmt = "\033[0m"
gOpts.cleaner = ""
gOpts.copyfmt = "\033[7;33m"
gOpts.cursoractivefmt = "\033[7m"
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.cutfmt = "\033[7;31m"
gOpts.dircache = true
gOpts.dircounts = false
gOpts.dirfirst = true
@@ -222,67 +229,60 @@ func init() {
gOpts.dirpreviews = false
gOpts.drawbox = false
gOpts.dupfilefmt = "%f.~%n~"
gOpts.borderfmt = "\033[0m"
gOpts.copyfmt = "\033[7;33m"
gOpts.cursoractivefmt = "\033[7m"
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.cutfmt = "\033[7;31m"
gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n"
gOpts.filtermethod = textSearch
gOpts.searchmethod = textSearch
gOpts.findlen = 1
gOpts.hidden = false
gOpts.hiddenfiles = gDefaultHiddenFiles
gOpts.history = true
gOpts.icons = false
gOpts.ifs = ""
gOpts.ignorecase = true
gOpts.ignoredia = true
gOpts.incfilter = false
gOpts.incsearch = false
gOpts.info = nil
gOpts.infotimefmtnew = "Jan _2 15:04"
gOpts.infotimefmtold = "Jan _2 2006"
gOpts.locale = localeStrDisable
gOpts.mouse = false
gOpts.number = false
gOpts.numberfmt = "\033[33m"
gOpts.period = 0
gOpts.preserve = []string{"mode"}
gOpts.preview = true
gOpts.previewer = ""
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
gOpts.ratios = []int{1, 2, 3}
gOpts.relativenumber = false
gOpts.reverse = false
gOpts.roundbox = false
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t"
gOpts.scrolloff = 0
gOpts.searchmethod = textSearch
gOpts.selectfmt = "\033[7;35m"
gOpts.visualfmt = "\033[7;36m"
gOpts.selmode = "all"
gOpts.shell = gDefaultShell
gOpts.shellflag = gDefaultShellFlag
gOpts.shellopts = nil
gOpts.showbinds = true
gOpts.sixel = false
gOpts.sortby = naturalSort
gOpts.smartcase = true
gOpts.smartdia = false
gOpts.sortby = naturalSort
gOpts.statfmt = "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l"
gOpts.tabstop = 8
gOpts.tagfmt = "\033[31m"
gOpts.tempmarks = "'"
gOpts.timefmt = time.ANSIC
gOpts.truncatechar = "~"
gOpts.truncatepct = 100
gOpts.visualfmt = "\033[7;36m"
gOpts.waitmsg = "Press any key to continue"
gOpts.watch = false
gOpts.wrapscan = true
gOpts.wrapscroll = false
gOpts.findlen = 1
gOpts.period = 0
gOpts.scrolloff = 0
gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n"
gOpts.ifs = ""
gOpts.previewer = ""
gOpts.cleaner = ""
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
gOpts.selmode = "all"
gOpts.shell = gDefaultShell
gOpts.shellflag = gDefaultShellFlag
gOpts.statfmt = "\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l"
gOpts.timefmt = time.ANSIC
gOpts.infotimefmtnew = "Jan _2 15:04"
gOpts.infotimefmtold = "Jan _2 2006"
gOpts.truncatechar = "~"
gOpts.truncatepct = 100
gOpts.ratios = []int{1, 2, 3}
gOpts.hiddenfiles = gDefaultHiddenFiles
gOpts.history = true
gOpts.info = nil
gOpts.rulerfmt = " %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t"
gOpts.preserve = []string{"mode"}
gOpts.shellopts = nil
gOpts.tempmarks = "'"
gOpts.numberfmt = "\033[33m"
gOpts.tagfmt = "\033[31m"
// Normal and Visual mode
keys := map[string]expr{
@@ -416,14 +416,14 @@ func init() {
gOpts.cmds = make(map[string]expr)
gOpts.user = make(map[string]string)
gLocalOpts.sortby = make(map[string]sortMethod)
gLocalOpts.dircounts = make(map[string]bool)
gLocalOpts.dirfirst = make(map[string]bool)
gLocalOpts.dironly = make(map[string]bool)
gLocalOpts.hidden = make(map[string]bool)
gLocalOpts.reverse = make(map[string]bool)
gLocalOpts.info = make(map[string][]string)
gLocalOpts.locale = make(map[string]string)
gLocalOpts.reverse = make(map[string]bool)
gLocalOpts.sortby = make(map[string]sortMethod)
setDefaults()
}