diff --git a/doc/denite.txt b/doc/denite.txt index 03eac1a0f..461877ec9 100644 --- a/doc/denite.txt +++ b/doc/denite.txt @@ -1572,6 +1572,10 @@ sorter/oldfiles Note: The candidates must contain "action__path" key. Note: It should be used in neovim instead of Vim8. + *denite-filter-sorter/path* +sorter/path + Simple filter to sort candidates by ascii order of path + *denite-filter-sorter/rank* sorter/rank Uses the scoring algorithm from selecta: diff --git a/rplugin/python3/denite/filter/sorter/path.py b/rplugin/python3/denite/filter/sorter/path.py new file mode 100644 index 000000000..82237c063 --- /dev/null +++ b/rplugin/python3/denite/filter/sorter/path.py @@ -0,0 +1,21 @@ +# ============================================================================ +# FILE: sorter/path.py +# AUTHOR: uplus +# DESCRIPTION: Simple filter to sort candidates by ascii order of path +# License: MIT license +# ============================================================================ + +from denite.base.filter import Base +from denite.util import Nvim, UserContext, Candidates + + +class Filter(Base): + + def __init__(self, vim: Nvim) -> None: + super().__init__(vim) + + self.name = 'sorter/path' + self.description = 'sort candidates by ascii order of path' + + def filter(self, context: UserContext) -> Candidates: + return sorted(context['candidates'], key=lambda x: x['action__path'])