forked from nvimdev/galaxyline.nvim
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SearchResults provider, see glepnir#205
- Loading branch information
1 parent
8377f81
commit 2129bcf
Showing
3 changed files
with
33 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local search = {} | ||
|
||
function search.get_results() | ||
local search_term = vim.fn.getreg("/") | ||
local search_count = vim.fn.searchcount({ | ||
recompute = 1, | ||
maxcount = -1, | ||
}) | ||
|
||
local active_result = vim.v.hlsearch == 1 and search_count.total > 0 | ||
if active_result then | ||
return string.format("/%s [%d/%d]", search_term, search_count.current, search_count.total) | ||
end | ||
end | ||
|
||
return search |