telescope-frecency.nvim/plugin/frecency.vim
Senghan Bright 7afdd3c32c
Feature: filtered workspaces
* draft implementation of tags/filters

* .

* add filtering:

- extended substring sorter to have modes:
- when current string is prefixed by `:foo`, results are tag_names that
come from tags/workspaces table. (if `:foo ` token is incomplete it is
ignored)
- when a complete workspace tag is matched ':foobar:', results are
indexed_files filtered by if their parent_dir is a descendant of the
workspace_dir
- a recursive scan_dir() result is added to the  :foobar: filter
results; any non-indexed_files are given a score of zero, and are
alphabetically sorted below the indexed_results

- tab completion for tab_names in insert mode`:foo|` state: cycles
through available options

* add completion file

* use attach_mappings for <CR> map

* stop completion being enabled multiple times

* improve keys

* improve completion cancellation

* add dynamic `lsp` tag

* add dynamic `lsp` tag

* fix empty lsp workspaces

* remove hardcoded workspaces and allow config from ext_config

* add filter highlight and some fixes

* .

* add workspace filters to readme

* wip LSP workspace filter

* merge ignore_patterns fix

* change LSP_ROOT tagname to LSP

* fix setting default values

* .

* update readme with filter instructions

* remove debug message

* improve relative paths

* improve relative paths

* WIP dynamic column sizes

* WIP filter_column_width

* fix keymaps

* .

* feat: persistent filters

* refactor config creation

* fix: filter directory column autosize

* improve LSP workspace paths

* .

* remove workspace filter output

* cache persistent filter results

* fix cached results

* .

* remove results cache; sorting is the expensive part

* respect ignore patterns for non-indexed files.

* return table on on_input_filter_cb
2021-01-28 22:45:04 +01:00

37 lines
1004 B
VimL

function! frecency#FrecencyComplete(findstart, base)
if a:findstart
let line = getline('.')
" don't complete if there's already a completed `:tag:` in line
if count(line, ":") >= 2
return -3
endif
" locate the start of the tag
let start = col('.') - 1
while start > 0 && line[start -1] != ':'
let start -= 1
endwhile
return start
else
if pumvisible() && !empty(v:completed_item)
return ''
end
let l:workspace_tags = luaeval("require'telescope'.extensions.frecency.get_workspace_tags()")
let matches = []
for ws_tag in l:workspace_tags
if ":" .. ws_tag =~ '^:' .. a:base
call add(matches, ws_tag)
endif
endfor
return len(matches) != 0 ? matches : ''
end
endfunction
" lua require'telescope'.extensions.frecency.completefunc(action)
" lua require'telescope'.extensions.frecency.completefunc(res)
" require'telescope._extensions.frecency.db_client'.autocmd_handler(vim.fn.expand('<amatch>'))