diff options
author | rxi <rxi@users.noreply.github.com> | 2020-05-12 21:08:02 +0100 |
---|---|---|
committer | rxi <rxi@users.noreply.github.com> | 2020-05-12 21:08:02 +0100 |
commit | 38983228c83dcdf267a06be8b9174e233a082c76 (patch) | |
tree | 8bf1a7455c34c6fa1cb4e7a3b1a8043ae6274ad8 | |
parent | 21c2975b7e0ff3ba69dc0c550f034c1b3a9982f2 (diff) | |
download | lite-xl-plugins-38983228c83dcdf267a06be8b9174e233a082c76.tar.gz lite-xl-plugins-38983228c83dcdf267a06be8b9174e233a082c76.zip |
Added `openselected` and `openfilelocation`
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | plugins/openfilelocation.lua | 28 | ||||
-rw-r--r-- | plugins/openselected.lua | 26 |
3 files changed, 56 insertions, 1 deletions
@@ -37,6 +37,8 @@ Plugin | Description [`lineguide`](plugins/lineguide.lua?raw=1) | Displays a line-guide at the line limit offset *([screenshot](https://user-images.githubusercontent.com/3920290/81476159-2cf70000-9208-11ea-928b-9dae3884c477.png))* [`linter`](https://github.com/drmargarido/linters)* | Linters for multiple languages [`macmodkeys`](plugins/macmodkeys.lua?raw=1) | Remaps mac modkeys `command/option` to `ctrl/alt` +[`openfilelocation`](plugins/openfilelocation.lua?raw=1) | Opens the parent directory of the current file in the file manager +[`openselected`](plugins/openselected.lua?raw=1) | Opens the selected filename or url [`selectionhighlight`](plugins/selectionhighlight.lua?raw=1) | Highlights regions of code that match the current selection *([screenshot](https://user-images.githubusercontent.com/3920290/80710883-5f597c80-8ae7-11ea-97f0-76dfacc08439.png))* [`sort`](plugins/sort.lua?raw=1) | Sorts selected lines alphabetically [`spellcheck`](plugins/spellcheck.lua?raw=1) | Underlines misspelt words *([screenshot](https://user-images.githubusercontent.com/3920290/79923973-9caa7400-842e-11ea-85d4-7a196a91ca50.png))* @@ -46,4 +48,3 @@ 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 - diff --git a/plugins/openfilelocation.lua b/plugins/openfilelocation.lua new file mode 100644 index 0000000..e57b740 --- /dev/null +++ b/plugins/openfilelocation.lua @@ -0,0 +1,28 @@ +local core = require "core" +local command = require "core.command" +local config = require "core.config" + + +if PLATFORM == "Windows" then + config.filemanager = "explorer" +else + config.filemanager = "xdg-open" +end + + +command.add("core.docview", { + ["open-file-location:open-file-location"] = function() + local doc = core.active_view.doc + if not doc.filename then + core.error "Cannot open location of unsaved doc" + return + end + local folder_name = doc.filename:match("^(.-)[^/\\]*$") + core.log("Opening \"%s\"", folder_name) + if PLATFORM == "Windows" then + os.execute(string.format("start %s %s", config.filemanager, folder_name)) + else + os.execute(string.format("%s %q", config.filemanager, folder_name)) + end + end +}) diff --git a/plugins/openselected.lua b/plugins/openselected.lua new file mode 100644 index 0000000..5fadbec --- /dev/null +++ b/plugins/openselected.lua @@ -0,0 +1,26 @@ +local core = require "core" +local command = require "core.command" +local keymap = require "core.keymap" + + +command.add("core.docview", { + ["open-selected:open-selected"] = function() + local doc = core.active_view.doc + if not doc:has_selection() then + core.error("No text selected") + return + end + + local text = doc:get_text(doc:get_selection()) + core.log("Opening \"%s\"...", text) + + if PLATFORM == "Windows" then + os.execute(string.format("start explorer %s", text)) + else + os.execute(string.format("xdg-open %q &", text)) + end + end, +}) + + +keymap.add { ["ctrl+shift+o"] = "open-selected:open-selected" } |