From 31e7796a46c35716a9a81bc1e05afe036a840c08 Mon Sep 17 00:00:00 2001 From: drmargarido Date: Mon, 19 Oct 2020 18:41:44 +0100 Subject: [PATCH 1/2] Added zeal_search plugin to search in zeal directly from lite. --- README.md | 1 + plugins/zeal_search.lua | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 plugins/zeal_search.lua diff --git a/README.md b/README.md index 502e1edf..4e5a666e 100644 --- a/README.md +++ b/README.md @@ -84,3 +84,4 @@ Plugin | Description [`togglesnakecamel`](plugins/togglesnakecamel.lua?raw=1) | Toggles symbols between `snake_case` and `camelCase` [`unboundedscroll`](plugins/unboundedscroll.lua?raw=1) | Allows scrolling outside the bounds of a document [`workspace`](plugins/workspace.lua?raw=1) | Retains project's layout and open documents between sessions +[`zeal_search`](plugins/zeal_search.lua?raw=1) | Offline documentation search in Zeal \ No newline at end of file diff --git a/plugins/zeal_search.lua b/plugins/zeal_search.lua new file mode 100644 index 00000000..5c001218 --- /dev/null +++ b/plugins/zeal_search.lua @@ -0,0 +1,11 @@ +local core = require "core" +local command = require "core.command" + +command.add("core.docview", { + ["zeal:search"] = function() + core.command_view:enter("Search", function(query) + system.exec("zeal " .. query) + end) + end, +}) + From 9fb15d8b18f8712fa773ea97cd3352e8b554800c Mon Sep 17 00:00:00 2001 From: drmargarido Date: Mon, 19 Oct 2020 21:44:59 +0100 Subject: [PATCH 2/2] Made current selected text appear in the search bar. --- plugins/zeal_search.lua | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/zeal_search.lua b/plugins/zeal_search.lua index 5c001218..6278903f 100644 --- a/plugins/zeal_search.lua +++ b/plugins/zeal_search.lua @@ -3,9 +3,17 @@ local command = require "core.command" command.add("core.docview", { ["zeal:search"] = function() + -- Make current selected text appear in the search bar + local dv = core.active_view + local sel = { dv.doc:get_selection() } + local text = dv.doc:get_text(table.unpack(sel)) + core.command_view:set_text(text, true) + + -- Ask for user input core.command_view:enter("Search", function(query) system.exec("zeal " .. query) end) end, + })