diff --git a/colors.go b/colors.go index 0efd156a..ddbb1f85 100644 --- a/colors.go +++ b/colors.go @@ -233,22 +233,6 @@ func (sm styleMap) get(f *file) tcell.Style { } } - if val, ok := sm[f.Name()]; ok { - return val - } - - if val, ok := sm[f.Name()]; ok { - return val - } - - if val, ok := sm[filepath.Base(f.Name())+".*"]; ok { - return val - } - - if val, ok := sm["*"+f.ext]; ok { - return val - } - var key string switch { @@ -278,13 +262,27 @@ func (sm styleMap) get(f *file) tcell.Style { key = "sg" case f.Mode()&0111 != 0: key = "ex" - default: - key = "fi" } if val, ok := sm[key]; ok { return val } + if val, ok := sm[f.Name()]; ok { + return val + } + + if val, ok := sm[filepath.Base(f.Name())+".*"]; ok { + return val + } + + if val, ok := sm["*"+f.ext]; ok { + return val + } + + if val, ok := sm["fi"]; ok { + return val + } + return tcell.StyleDefault } diff --git a/doc.go b/doc.go index b0cebe39..27ba3c18 100644 --- a/doc.go +++ b/doc.go @@ -1241,19 +1241,31 @@ The full order of matchings from most specific to least are as follows: 1. Full Path (e.g. '~/.config/lf/lfrc') 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Name (e.g. '.git') - 4. Base Name (e.g. 'README.*') - 5. Extension (e.g. '*.txt') - 6. File Type (e.g. 'ln') + 3. File Type (e.g. 'ln') (except 'fi') + 4. File Name (e.g. '.git') + 5. Base Name (e.g. 'README.*') + 6. Extension (e.g. '*.txt') + 7. Default (i.e. 'fi') For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used: 1. '/path/to/README.txt' - 2. 'README.txt/' (skipped since the file is not a directory) - 3. 'README.txt' - 4. 'README.*' - 5. '*.txt' - 6. 'fi' + 2. (skipped since the file is not a directory) + 3. (skipped since the file is of type 'fi') + 4. 'README.txt' + 5. 'README.*' + 6. '*.txt' + 7. 'fi' + +Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used: + + 1. '/path/to/example.d' + 2. 'example.d/' + 3. 'di' + 4. 'example.d' + 5. 'example.*' + 6. '*.d' + 7. 'fi' Note that glob-like patterns do not actually perform glob matching due to performance reasons. diff --git a/docstring.go b/docstring.go index 9b341a92..45cb01a6 100644 --- a/docstring.go +++ b/docstring.go @@ -1400,20 +1400,33 @@ follows: 1. Full Path (e.g. '~/.config/lf/lfrc') 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Name (e.g. '.git') - 4. Base Name (e.g. 'README.*') - 5. Extension (e.g. '*.txt') - 6. File Type (e.g. 'ln') + 3. File Type (e.g. 'ln') (except 'fi') + 4. File Name (e.g. '.git') + 5. Base Name (e.g. 'README.*') + 6. Extension (e.g. '*.txt') + 7. Default (i.e. 'fi') For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used: 1. '/path/to/README.txt' - 2. 'README.txt/' (skipped since the file is not a directory) - 3. 'README.txt' - 4. 'README.*' - 5. '*.txt' - 6. 'fi' + 2. (skipped since the file is not a directory) + 3. (skipped since the file is of type 'fi') + 4. 'README.txt' + 5. 'README.*' + 6. '*.txt' + 7. 'fi' + +Given a regular directory '/path/to/example.d', the following entries are +checked in the configuration and the first one to match is used: + + 1. '/path/to/example.d' + 2. 'example.d/' + 3. 'di' + 4. 'example.d' + 5. 'example.*' + 6. '*.d' + 7. 'fi' Note that glob-like patterns do not actually perform glob matching due to performance reasons. diff --git a/icons.go b/icons.go index 2cb2d61a..cf233e72 100644 --- a/icons.go +++ b/icons.go @@ -74,18 +74,6 @@ func (im iconMap) get(f *file) string { } } - if val, ok := im[f.Name()]; ok { - return val - } - - if val, ok := im[filepath.Base(f.Name())+".*"]; ok { - return val - } - - if val, ok := im["*"+f.ext]; ok { - return val - } - var key string switch { @@ -115,13 +103,27 @@ func (im iconMap) get(f *file) string { key = "sg" case f.Mode()&0111 != 0: key = "ex" - default: - key = "fi" } if val, ok := im[key]; ok { return val } + if val, ok := im[f.Name()]; ok { + return val + } + + if val, ok := im[filepath.Base(f.Name())+".*"]; ok { + return val + } + + if val, ok := im["*"+f.ext]; ok { + return val + } + + if val, ok := im["fi"]; ok { + return val + } + return " " } diff --git a/lf.1 b/lf.1 index 5f457a19..d3975afc 100644 --- a/lf.1 +++ b/lf.1 @@ -1341,21 +1341,35 @@ Note that, lf first tries matching file names and then falls back to file types. .EX 1. Full Path (e.g. '~/.config/lf/lfrc') 2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end) - 3. File Name (e.g. '.git') - 4. Base Name (e.g. 'README.*') - 5. Extension (e.g. '*.txt') - 6. File Type (e.g. 'ln') + 3. File Type (e.g. 'ln') (except 'fi') + 4. File Name (e.g. '.git') + 5. Base Name (e.g. 'README.*') + 6. Extension (e.g. '*.txt') + 7. Default (i.e. 'fi') .EE .PP For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used: .PP .EX 1. '/path/to/README.txt' - 2. 'README.txt/' (skipped since the file is not a directory) - 3. 'README.txt' - 4. 'README.*' - 5. '*.txt' - 6. 'fi' + 2. (skipped since the file is not a directory) + 3. (skipped since the file is of type 'fi') + 4. 'README.txt' + 5. 'README.*' + 6. '*.txt' + 7. 'fi' +.EE +.PP +Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used: +.PP +.EX + 1. '/path/to/example.d' + 2. 'example.d/' + 3. 'di' + 4. 'example.d' + 5. 'example.*' + 6. '*.d' + 7. 'fi' .EE .PP Note that glob-like patterns do not actually perform glob matching due to performance reasons.