aboutsummaryrefslogtreecommitdiff
path: root/plugins/openselected.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-11-01 20:57:07 -0400
committerjgmdev <jgmdev@gmail.com>2022-11-01 20:57:07 -0400
commit49139e03398c9d0ecb347267a4882a4eb3f7ee23 (patch)
tree6ac890a209172a29e09ad47ccd0156e7f7114382 /plugins/openselected.lua
parent380f6ef5fe9f8af19cd1f6b4c043eede51cbfcae (diff)
parent0971a7a686a4e18ee31b576c460966a5ec20ff01 (diff)
downloadlite-xl-plugins-49139e03398c9d0ecb347267a4882a4eb3f7ee23.tar.gz
lite-xl-plugins-49139e03398c9d0ecb347267a4882a4eb3f7ee23.zip
Merge branch '2.1'
Diffstat (limited to 'plugins/openselected.lua')
-rw-r--r--plugins/openselected.lua36
1 files changed, 29 insertions, 7 deletions
diff --git a/plugins/openselected.lua b/plugins/openselected.lua
index af00194..6333da9 100644
--- a/plugins/openselected.lua
+++ b/plugins/openselected.lua
@@ -1,19 +1,35 @@
--- mod-version:2 -- lite-xl 2.0
+-- mod-version:3
local core = require "core"
local command = require "core.command"
local keymap = require "core.keymap"
+local common = require "core.common"
local config = require "core.config"
+local contextmenu = require "plugins.contextmenu"
-config.plugins.openselected = {}
+local platform_filelauncher
if PLATFORM == "Windows" then
- config.plugins.openselected.filemanager = "start"
+ platform_filelauncher = "start"
elseif PLATFORM == "Mac OS X" then
- config.plugins.openselected.filemanager = "open"
+ platform_filelauncher = "open"
else
- config.plugins.openselected.filemanager = "xdg-open"
+ platform_filelauncher = "xdg-open"
end
+config.plugins.openselected = common.merge({
+ filelauncher = platform_filelauncher,
+ -- The config specification used by the settings gui
+ config_spec = {
+ name = "Open Selected Text",
+ {
+ label = "File Launcher",
+ description = "Command used to open the selected path or link externally.",
+ path = "filelauncher",
+ type = "string",
+ default = platform_filelauncher
+ }
+ }
+}, config.plugins.openselected)
command.add("core.docview", {
["open-selected:open-selected"] = function()
@@ -35,10 +51,16 @@ command.add("core.docview", {
core.log("Opening %s...", text)
- system.exec(config.plugins.openselected.filemanager .. " " .. text)
+ system.exec(config.plugins.openselected.filelauncher .. " " .. text)
end,
})
-keymap.add { ["ctrl+shift+o"] = "open-selected:open-selected" }
+contextmenu:register("core.docview", {
+ contextmenu.DIVIDER,
+ { text = "Open Selection", command = "open-selected:open-selected" }
+})
+
+
+keymap.add { ["ctrl+alt+o"] = "open-selected:open-selected" }