add 'setlocal' for directory specific options (#1381)

* add 'setlocal' for option 'sortby'

* save each local option separately

* add 'setlocal' for option 'reverse'

* add 'setlocal' for option 'dirfirst'

* add 'setlocal' for option 'hidden'

* add 'setlocal' for option 'dironly'

* add 'setlocal' for option 'info'

* add boolean toggling for 'setlocal' options

* check if the path is absolute for 'setlocal'

* add 'setlocal' options to completion

* add tests for 'setlocal'

* add 'setlocal' to the documentation

* use trailing '/' in 'setlocal' for subdir matching

* cleanup

* add 'setlocal' subdirs to the documentation
This commit is contained in:
Gökçehan Kara authored and GitHub committed 2023-09-02 22:22:56 +03:00
1 parent 990cea7e04
commit 8d013c9375
10 files changed
+486 -31

No files matched your search

+22 -1
View File
@@ -11,6 +11,7 @@ import (
var (
gCmdWords = []string{
"set",
"setlocal",
"map",
"maps",
"cmap",
@@ -224,6 +225,23 @@ var (
"truncatechar",
"truncatepct",
}
gLocalOptWords = []string{
"dirfirst",
"nodirfirst",
"dirfirst!",
"dironly",
"nodironly",
"dironly!",
"hidden",
"nohidden",
"hidden!",
"info",
"reverse",
"noreverse",
"reverse!",
"sortby",
}
)
func matchLongest(s1, s2 []rune) []rune {
@@ -410,6 +428,9 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) {
}
case 3:
switch f[0] {
case "setlocal":
matches, longest = matchWord(f[2], gLocalOptWords)
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
case "map", "cmap":
matches, longest = matchCmd(f[2])
longestAcc = append(acc[:len(acc)-len([]rune(f[len(f)-1]))], longest...)
@@ -419,7 +440,7 @@ func completeCmd(acc []rune) (matches []string, longestAcc []rune) {
}
default:
switch f[0] {
case "set", "map", "cmap", "cmd":
case "set", "setlocal", "map", "cmap", "cmd":
longestAcc = acc
default:
matches, longest = matchFile(f[len(f)-1])