From 72b797686619e06364fdf5c10027f372fd37db87 Mon Sep 17 00:00:00 2001 From: konapun Date: Thu, 22 Jul 2021 22:06:09 -0500 Subject: [PATCH 1/2] add search results provider --- lua/galaxyline/provider.lua | 2 ++ lua/galaxyline/provider_search.lua | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lua/galaxyline/provider_search.lua diff --git a/lua/galaxyline/provider.lua b/lua/galaxyline/provider.lua index f1f4297..0dd94df 100644 --- a/lua/galaxyline/provider.lua +++ b/lua/galaxyline/provider.lua @@ -5,6 +5,7 @@ async_load_providers = uv.new_async(vim.schedule_wrap(function () local vcs = require('galaxyline.provider_vcs') local fileinfo = require('galaxyline.provider_fileinfo') local buffer = require('galaxyline.provider_buffer') + local search = require('galaxyline.provider_search') local extension = require('galaxyline.provider_extensions') local whitespace =require('galaxyline.provider_whitespace') local lspclient = require('galaxyline.provider_lsp') @@ -27,6 +28,7 @@ async_load_providers = uv.new_async(vim.schedule_wrap(function () ScrollBar = extension.scrollbar_instance, VistaPlugin = extension.vista_nearest, WhiteSpace = whitespace.get_item, + SearchResults = search.get_search_results, GetLspClient = lspclient.get_lsp_client, } local diagnostic = require('galaxyline.provider_diagnostic') diff --git a/lua/galaxyline/provider_search.lua b/lua/galaxyline/provider_search.lua new file mode 100644 index 0000000..debef61 --- /dev/null +++ b/lua/galaxyline/provider_search.lua @@ -0,0 +1,14 @@ +local vim = vim +local M = {} + +function M.get_search_results() + local search_term = vim.fn.getreg('/') + local search_count = vim.fn.searchcount({recompute = 1, maxcount = -1}) + local active = vim.v.hlsearch == 1 and search_count.total > 0 + + if active then + return '/' .. search_term .. '[' .. search_count.current .. '/' .. search_count.total .. ']' + end +end + +return M From abd7881f5ae0d4c91b566a1b1f87f68eb3f73cf2 Mon Sep 17 00:00:00 2001 From: konapun Date: Thu, 22 Jul 2021 22:15:08 -0500 Subject: [PATCH 2/2] Update README --- README.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b372fd..af83247 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,7 @@ using multiple then you must provide an array table for `provider`. -- source provider function local diagnostic = require('galaxyline.provider_diagnostic') local vcs = require('galaxyline.provider_vcs') +local search = require('galaxyline.provider_search') local fileinfo = require('galaxyline.provider_fileinfo') local extension = require('galaxyline.provider_extensions') local colors = require('galaxyline.colors') @@ -90,7 +91,7 @@ local buffer = require('galaxyline.provider_buffer') local whitespace = require('galaxyline.provider_whitespace') local lspclient = require('galaxyline.provider_lsp') --- provider +-- provider BufferIcon = buffer.get_buffer_type_icon, BufferNumber = buffer.get_buffer_number, FileTypeName = buffer.get_buffer_filetype, @@ -99,6 +100,8 @@ GitBranch = vcs.get_git_branch, DiffAdd = vcs.diff_add, -- support vim-gitgutter vim-signify gitsigns DiffModified = vcs.diff_modified, -- support vim-gitgutter vim-signify gitsigns DiffRemove = vcs.diff_remove, -- support vim-gitgutter vim-signify gitsigns +-- Search Provider +SearchResults = search.get_search_results, -- File Provider LineColumn = fileinfo.line_column, FileFormat = fileinfo.get_file_format, @@ -133,7 +136,7 @@ local condition = require('galaxyline.condition') condition.buffer_not_empty -- if buffer not empty return true else false condition.hide_in_width -- if winwidth(0)/ 2 > 40 true else false -- find git root, you can use this to check if the project is a git workspace -condition.check_git_workspace() +condition.check_git_workspace() -- built-in theme local colors = require('galaxyline.theme').default