Skip to content

Commit

Permalink
Merge pull request Shougo#799 from uplus/add_path_sorter
Browse files Browse the repository at this point in the history
Add sorter/path
  • Loading branch information
Shougo authored Sep 2, 2020
2 parents fa7d558 + 4ff9164 commit 5fbc044
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/denite.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
21 changes: 21 additions & 0 deletions rplugin/python3/denite/filter/sorter/path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ============================================================================
# FILE: sorter/path.py
# AUTHOR: uplus <uplus.e10 at gmail.com>
# 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'])

0 comments on commit 5fbc044

Please sign in to comment.