aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriceyrazor <iceyrazor@mailfence.com>2026-05-02 02:19:56 -0500
committericeyrazor <iceyrazor@mailfence.com>2026-05-02 02:19:56 -0500
commit2a3fca8be0428611137f22b25e0fdb39d52fcd78 (patch)
treeec7e0af401db63f05b4f3987ac2a2dd58a8d21ae
-rw-r--r--LICENSE21
-rw-r--r--README.md53
-rw-r--r--file-history.lua68
-rw-r--r--init.lua11
-rw-r--r--previous-file.lua25
5 files changed, 178 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e4e5954
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2026 iceyrazor
+
+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..d89774b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,53 @@
+# Vis Chain
+
+This plugin consist of 2 modules. Either of which can be removed entirely by editing `init.lua` and the line and if you wish respective file.
+
+## previous file
+
+Pretty much just <C-^> from vim. Keeps track of the last file you opened and you can go back to it with <C-^> (ctrl + 6)
+
+## file history
+
+Pseudo harpoon and buffers. Keeps track of ever file opened and puts it in a table.
+
+You can list the files with `<Space>l`.
+
+You can go to the first 4 files with `<Space>1` - `<Space>4`.
+
+To edit this list do `<Space>E` then change how you wish.
+
+Then multi selection (NOT SELECT MULTIBLE LINES WITH ONE CURSOR) `<C-j/k>`.
+Then visual mode `v`.
+Then select the end of the line excluding the new line at the end `$h`.
+Then `<Space>E`.
+
+# example config
+
+``require('plugins/vis-chain')``
+
+## with keybinds
+
+```lua
+local chain = require('plugins/vis-chain')
+
+vis:unmap(vis.modes.NORMAL, "<C-^>")
+
+vis:unmap(vis.modes.NORMAL,"<C-e>")
+vis:unmap(vis.modes.NORMAL," E")
+vis:unmap(vis.modes.VISUAL," E")
+vis:unmap(vis.modes.NORMAL," 1")
+vis:unmap(vis.modes.NORMAL," 2")
+vis:unmap(vis.modes.NORMAL," 3")
+vis:unmap(vis.modes.NORMAL," 4")
+
+vis:map(vis.modes.NORMAL, "<C-^>", chain.last.open_last,"")
+
+vis:map(vis.modes.NORMAL,"<C-e>",chain.hist.select_files)
+vis:map(vis.modes.NORMAL," E",chain.hist.list_files)
+vis:map(vis.modes.VISUAL," E",chain.hist.set_files)
+vis:map(vis.modes.NORMAL," 1",function() chain.hist.open(1) end)
+vis:map(vis.modes.NORMAL," 2",function() chain.hist.open(2) end)
+vis:map(vis.modes.NORMAL," 3",function() chain.hist.open(3) end)
+vis:map(vis.modes.NORMAL," 4",function() chain.hist.open(4) end)
+```
+
diff --git a/file-history.lua b/file-history.lua
new file mode 100644
index 0000000..580b72a
--- /dev/null
+++ b/file-history.lua
@@ -0,0 +1,68 @@
+require("vis")
+
+local module = {}
+
+module.files = {}
+
+vis.events.subscribe(vis.events.FILE_OPEN, function(file)
+ if file.path then
+ for _,v in ipairs(module.files) do
+ if v == file.path then return end
+ end
+ if file.path == "" then return end
+ table.insert(module.files,file.path)
+ end
+end)
+
+
+function module.list_files()
+ local content=""
+ for i,str in pairs(module.files) do
+ content=content..str
+ if i ~= #module.files then content=content.."\n" end
+ end
+ vis:insert(content)
+end
+
+function module.set_files()
+ module.files = {}
+ for i,selection in ipairs(vis.win.selections) do
+ local content=vis.win.file:content(selection.range)
+ if content ~= "" or content ~= "\n" then
+ module.files[i]=content
+ end
+ end
+end
+
+function module.open(index)
+ if module.files[index] and module.files[index] ~= "" then
+ vis:command("open "..module.files[index])
+ vis:feedkeys("<C-w>k")
+ vis:command("wq!")
+ end
+end
+
+function module.select_files()
+ local items = ""
+ for i,str in pairs(module.files) do
+ items=items..str
+ if i ~= #module.files then items=items.."\n" end
+ end
+
+ local _,selection = vis:pipe("printf \""..items.."\" | vis-menu", false)
+ if selection then
+ vis:command("open "..selection)
+ vis:feedkeys("<C-w>k")
+ vis:command("wq!")
+ end
+end
+
+vis:map(vis.modes.NORMAL,"<C-e>",module.select_files)
+vis:map(vis.modes.NORMAL," E",module.list_files)
+vis:map(vis.modes.VISUAL," E",module.set_files)
+vis:map(vis.modes.NORMAL," 1",function() module.open(1) end)
+vis:map(vis.modes.NORMAL," 2",function() module.open(2) end)
+vis:map(vis.modes.NORMAL," 3",function() module.open(3) end)
+vis:map(vis.modes.NORMAL," 4",function() module.open(4) end)
+
+return module
diff --git a/init.lua b/init.lua
new file mode 100644
index 0000000..6d0283d
--- /dev/null
+++ b/init.lua
@@ -0,0 +1,11 @@
+local module = {}
+
+local source_str = debug.getinfo(1, 'S').source:sub(2)
+local source_path = source_str:match('(.*/)')
+
+-- comment out or remove any function you dont want. you can delete that file too.
+
+module.last = dofile(source_path..'previous-file.lua')
+module.hist = dofile(source_path..'file-history.lua')
+
+return module
diff --git a/previous-file.lua b/previous-file.lua
new file mode 100644
index 0000000..cd3482b
--- /dev/null
+++ b/previous-file.lua
@@ -0,0 +1,25 @@
+require('vis')
+
+local module = {}
+
+module.lastFile=""
+module.curFile=""
+
+vis.events.subscribe(vis.events.FILE_OPEN, function(file)
+ if file.path then
+ module.lastFile=module.curFile
+ module.curFile=file.path
+ end
+end)
+
+function module.open_last()
+ if module.lastFile ~= "" then
+ vis:command("open "..module.lastFile)
+ vis:feedkeys("<C-w>k")
+ vis:command("wq!")
+ end
+end
+
+vis:map(vis.modes.NORMAL, "<C-^>", module.open_last,"")
+
+return module