From c349451d309c96c773c5fb3e04369aef940a8a96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Cepl?= Date: Wed, 18 Sep 2024 17:07:54 +0200 Subject: feat: initial commit --- LICENSE | 21 +++++++++++++++++++++ README.md | 14 ++++++++++++++ init.lua | 11 +++++++++++ 3 files changed, 46 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 init.lua diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fa6b85a --- /dev/null +++ b/LICENSE @@ -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) -- cgit v1.2.3