diff --git a/README.md b/README.md index b07d91c..aee366b 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,7 @@ Set `"lexical"` to `g:fern#comparator` like ```vim let g:fern#comparator = "lexical" ``` + +## Options + +- `let g:fern#comparator#lexical#case_sensitive`: Whether the listing should be case-sensitive or not (default: `1`) diff --git a/autoload/fern/comparator/lexical.vim b/autoload/fern/comparator/lexical.vim index bd8de0a..f69f710 100644 --- a/autoload/fern/comparator/lexical.vim +++ b/autoload/fern/comparator/lexical.vim @@ -1,3 +1,7 @@ +if !exists("g:fern#comparator#lexical#case_sensitive") + let g:fern#comparator#lexical#case_sensitive = 1 +endif + function! fern#comparator#lexical#new() abort return { \ 'compare': funcref('s:compare'), @@ -10,10 +14,16 @@ function! s:compare(n1, n2) abort let l1 = len(k1) let l2 = len(k2) for index in range(0, min([l1, l2]) - 1) - if k1[index] ==# k2[index] + let c1 = k1[index] + let c2 = k2[index] + if !g:fern#comparator#lexical#case_sensitive + let c1 = tolower(c1) + let c2 = tolower(c2) + endif + if c1 ==# c2 continue endif - return k1[index] > k2[index] ? 1 : -1 + return c1 > c2 ? 1 : -1 endfor " Shorter first let r = s:comp(l1, l2) diff --git a/doc/fern-comparator-lexical.txt b/doc/fern-comparator-lexical.txt index ad09617..22b84d4 100644 --- a/doc/fern-comparator-lexical.txt +++ b/doc/fern-comparator-lexical.txt @@ -22,5 +22,19 @@ Set "lexical" to |g:fern#comparator| like: let g:fern#comparator = "lexical" < + +============================================================================= +OPTIONS *fern-comparator-lexical-options* + +------------------------------------------------------------------------------ +g:fern#comparator#lexical#case_sensitive *fern-comparator-lexical-options-case_sensitive* + +Set this to 0 to make sorting case-insensitive. +> + let g:fern#comparator#lexical#case_sensitive = 0 +< +Default: 1 (case-sensitive) + + ============================================================================= vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl