diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2024-09-18 17:07:54 +0200 |
|---|---|---|
| committer | Matěj Cepl <mcepl@cepl.eu> | 2024-09-18 17:07:54 +0200 |
| commit | c349451d309c96c773c5fb3e04369aef940a8a96 (patch) | |
| tree | e124aee6ed73d1217445e1772814b9a87915af9b | |
| download | vis-open-extend-c349451d309c96c773c5fb3e04369aef940a8a96.tar.gz vis-open-extend-c349451d309c96c773c5fb3e04369aef940a8a96.zip | |
feat: initial commit
| -rw-r--r-- | LICENSE | 21 | ||||
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | init.lua | 11 |
3 files changed, 46 insertions, 0 deletions
@@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Matěj Cepl + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f3a1e7a --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +This is a [vis](https://github.com/martanne/vis/wiki/Plugins) plugin for +opening file according to Plan 9 style, so + +``` +$ vis filename.txt:9 +``` + +opens the file `filename.txt` on line 9. + +All issues, questions, complaints, or (even better!) patches +should be send via email to +[~mcepl/devel@lists.sr.ht](mailto:~mcepl/devel@lists.sr.ht) email +list (for patches use [git send-email](https://git-send-email.io/)). + diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..ccc84cf --- /dev/null +++ b/init.lua @@ -0,0 +1,11 @@ +vis.events.subscribe(vis.events.WIN_OPEN, function(win) + if win.file == nil or win.file.path == nil then return end + local ref = win.file.path + local _, _, path, line = string.find(ref, "^(.+):(%d+)$") + if path == nil or line == nil or line == 0 or not file_exists(path) then + return + end + win:close() + vis:command("e "..path) + vis:command("+"..line-1) +end) |
