telescope-frecency.nvim/plugin/frecency.vim
Senghan Bright e7c9dee1e7
feat: allow user to disable database validation safe_mode (#20)
* feat: allow user to disable database validation safe_mode

* fix safe_mode logic

* fix: fix user confirmation

* feat: allow disabling of auto-validation
2021-08-04 09:16:33 +02:00

34 lines
855 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
command FrecencyValidate lua require'telescope'.extensions.frecency.validate_db()