aboutsummaryrefslogtreecommitdiff
path: root/.config/vis
diff options
context:
space:
mode:
Diffstat (limited to '.config/vis')
-rw-r--r--.config/vis/plugins/complete-filename/init.lua68
m---------.config/vis/plugins/vis-autoclose0
m---------.config/vis/plugins/vis-colorizer0
m---------.config/vis/plugins/vis-lspc0
-rw-r--r--.config/vis/themes/caelus.lua39
-rw-r--r--.config/vis/visrc.lua25
6 files changed, 132 insertions, 0 deletions
diff --git a/.config/vis/plugins/complete-filename/init.lua b/.config/vis/plugins/complete-filename/init.lua
new file mode 100644
index 0000000..db0f2a7
--- /dev/null
+++ b/.config/vis/plugins/complete-filename/init.lua
@@ -0,0 +1,68 @@
+local complete_filename = function(expand)
+ local win = vis.win
+ local file = win.file
+ local pos = win.selection.pos
+ if not pos then return end
+
+ -- TODO do something clever here
+ local range = file:text_object_longword(pos > 0 and pos-1 or pos);
+ if not range then return end
+ if range.finish > pos then range.finish = pos end
+
+ local prefix = file:content(range)
+ if not prefix then return end
+
+ -- Strip leading delimiters for some programming languages
+ local _, j = prefix:find(".*[{[(<'\"]+")
+ if not expand and j then prefix = prefix:sub(j + 1) end
+
+ if prefix:match("^%s*$") then
+ prefix = ""
+ range.start = pos
+ range.finish = pos
+ end
+
+ -- Expand tilda for the home directory
+ _, j = prefix:find('^~')
+ if j ~= nil then
+ local home = assert(os.getenv("HOME"), "$HOME variable not set!")
+ prefix = home .. prefix:sub(j + 1)
+ end
+
+ local status, out, err
+ if prefix:sub(1, 1) == ":" then
+ status, out, err = vis:complete_command(prefix:sub(2))
+ if out then
+ out = out:gsub("\n$", ""):sub(#prefix) .. " "
+ end
+ pos = range.start + #prefix
+ expand = false
+ else
+ local cmdfmt = "vis-complete --file '%s'"
+ if expand then cmdfmt = "vis-open -- '%s'*" end
+ status, out, err = vis:pipe(cmdfmt:format(prefix:gsub("'", "'\\''")))
+ end
+ if status ~= 0 or not out then
+ if err then vis:info(err) end
+ return
+ end
+ out = out:gsub("\n$", "")
+
+ if expand then
+ file:delete(range)
+ pos = range.start
+ end
+
+ file:insert(pos, out)
+ win.selection.pos = pos + #out
+end
+
+-- complete file path at primary selection location using vis-complete(1)
+vis:map(vis.modes.INSERT, "<C-x><C-f>", function()
+ complete_filename(false);
+end, "Complete file name")
+
+-- complete file path at primary selection location using vis-open(1)
+vis:map(vis.modes.INSERT, "<C-x><C-o>", function()
+ complete_filename(true);
+end, "Complete file name (expands path) or command")
diff --git a/.config/vis/plugins/vis-autoclose b/.config/vis/plugins/vis-autoclose
new file mode 160000
+Subproject 9ab1d301a0e59c9366416f5c8030354b3de514f
diff --git a/.config/vis/plugins/vis-colorizer b/.config/vis/plugins/vis-colorizer
new file mode 160000
+Subproject 0d67d0f809d1779c5a01fc5a58c045608238ee9
diff --git a/.config/vis/plugins/vis-lspc b/.config/vis/plugins/vis-lspc
new file mode 160000
+Subproject 97d8bfa7adff156afe1dcf1e833c6dd864f6b5b
diff --git a/.config/vis/themes/caelus.lua b/.config/vis/themes/caelus.lua
new file mode 100644
index 0000000..4078b14
--- /dev/null
+++ b/.config/vis/themes/caelus.lua
@@ -0,0 +1,39 @@
+local lexers = vis.lexers
+
+local lightyellow = '#efbf71'
+local lightgray = '#9a9c8b'
+local darkgray = '#1e1f1e'
+
+lexers.STYLE_DEFAULT = 'back:black,fore:white'
+lexers.STYLE_NOTHING = 'back:black'
+lexers.STYLE_CLASS = 'fore:cyan,bold'
+lexers.STYLE_COMMENT = 'fore:white'
+lexers.STYLE_CONSTANT = 'fore:cyan'
+lexers.STYLE_DEFINITION = 'fore:white'
+lexers.STYLE_ERROR = 'fore:red'
+lexers.STYLE_FUNCTION = 'fore:'..lightyellow
+lexers.STYLE_KEYWORD = 'fore:red'
+lexers.STYLE_LABEL = 'fore:white'
+lexers.STYLE_NUMBER = 'fore:magenta'
+lexers.STYLE_OPERATOR = 'fore:white'
+lexers.STYLE_REGEX = 'fore:white'
+lexers.STYLE_STRING = 'fore:green'
+lexers.STYLE_PREPROCESSOR = 'fore:white'
+lexers.STYLE_TAG = 'fore:white'
+lexers.STYLE_TYPE = 'fore:cyan,bold'
+lexers.STYLE_VARIABLE = 'fore:white'
+lexers.STYLE_WHITESPACE = ''
+lexers.STYLE_EMBEDDED = 'fore:white'
+lexers.STYLE_IDENTIFIER = 'fore:blue'
+lexers.STYLE_LINENUMBER = 'fore:white'
+lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER
+lexers.STYLE_CURSOR = 'reverse'
+lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:cyan'
+lexers.STYLE_CURSOR_LINE = 'underlined'
+lexers.STYLE_COLOR_COLUMN = 'back:black'
+lexers.STYLE_SELECTION = 'fore:black,back:yellow'
+lexers.STYLE_STATUS = 'back:'..darkgray..'fore:'..lightgray
+lexers.STYLE_STATUS_FOCUSED = 'fore:'..darkgray..',back:'..lightgray..',bold'
+lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
+lexers.STYLE_INFO = 'fore:default,back:default,bold'
+lexers.STYLE_EOF = ''
diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua
new file mode 100644
index 0000000..948151f
--- /dev/null
+++ b/.config/vis/visrc.lua
@@ -0,0 +1,25 @@
+-- load standard vis module, providing parts of the Lua API, sets _G.vis
+require('vis')
+
+-- global configuration options
+vis.events.subscribe(vis.events.INIT, function()
+ vis:command("set theme caelus")
+end)
+-- per-window configuration options
+vis.events.subscribe(vis.events.WIN_OPEN, function(win)
+ vis:command("set tabwidth 2")
+ vis:command("set numbers true")
+end)
+
+ -- plugins --
+
+-- colorizer
+local colorizer = require('plugins/vis-colorizer')
+colorizer.three = false
+colorizer.six = true
+-- complete-filename
+local completefilename = require('plugins/complete-filename')
+-- vis-lspc
+local lsp = require('plugins/vis-lspc')
+-- vis-autoclose
+local autoclose = require('plugins/vis-autoclose')