Skip to content

Commit

Permalink
Walk docs in a hierarchical way
Browse files Browse the repository at this point in the history
With this heuristic we are most likely to get the correct docset as the
first docset, which is important if the query matches multiple docsets
at once, e.g. std::string matches both Rust and C++.

The only design problem with this is that it does not keep the order in
additional_docs(), since it gets lost in the lambda which only checks if
it matches. Instead the order is given by the way that we iterate over
s:docs. In the future it would be nice to instead keep the order from
additional_docs(), but for now this is fine.
  • Loading branch information
vimpostor committed Aug 28, 2024
1 parent 5c14f96 commit 79a6de6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion autoload/clue/dash.vim
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,26 @@ func clue#dash#query_external(s)
call system(printf("xdg-open 'dash-plugin:query=%s'", clue#util#uri_encode(a:s)))
endfunc

func clue#dash#additional_docs()
if &filetype == "cpp"
return ["C++", "Qt_6"]
endif
return []
endfunc

func clue#dash#priority_docs()
" most relevant docsets match in an earlier level, and move to the front
let levels = [{v -> v ==? &filetype}, {v -> index(clue#dash#additional_docs(), v) + 1}, {v -> 1}]
let r = []
for L in levels
call extend(r, filter(keys(s:docs), {_, v -> index(r, v) < 0 && L(v)}))
endfor
return r
endfunc

func clue#dash#open(query, mode)
let s:current_query = a:query
for doc in keys(s:docs)
for doc in clue#dash#priority_docs()
let res = clue#dash#query(doc, a:query)
if len(res)
break
Expand Down

0 comments on commit 79a6de6

Please sign in to comment.