summaryrefslogtreecommitdiff
path: root/config/essentials
diff options
context:
space:
mode:
Diffstat (limited to 'config/essentials')
-rw-r--r--config/essentials/vis/Makefile15
-rw-r--r--config/essentials/vis/backup.lua47
-rw-r--r--config/essentials/vis/build.lua66
-rw-r--r--config/essentials/vis/cursors.lua123
-rw-r--r--config/essentials/vis/themes/nord.lua132
-rw-r--r--config/essentials/vis/title.lua22
-rw-r--r--config/essentials/vis/visrc.lua68
7 files changed, 278 insertions, 195 deletions
diff --git a/config/essentials/vis/Makefile b/config/essentials/vis/Makefile
index 5f41043..be230e3 100644
--- a/config/essentials/vis/Makefile
+++ b/config/essentials/vis/Makefile
@@ -1,16 +1,11 @@
-.PHONY: check format check-luacheck check-format
+.PHONY: check format all
-LUA_FILES := $(shell find -name "*.lua")
+LUA_FILES := $(shell find . -name "*.lua")
-check: check-luacheck
+all: check format
-all: check check-format
-
-check-luacheck:
- luacheck --globals=vis -- $(LUA_FILES)
-
-check-format:
- set -e; for lf in $(LUA_FILES); do tools/check-format "$${lf}"; done
+check:
+ luacheck --no-color --globals=vis -- $(LUA_FILES)
format:
lua-format -i $(LUA_FILES)
diff --git a/config/essentials/vis/backup.lua b/config/essentials/vis/backup.lua
new file mode 100644
index 0000000..f48895f
--- /dev/null
+++ b/config/essentials/vis/backup.lua
@@ -0,0 +1,47 @@
+local backup = {}
+
+-- Return the backup path concatenated with the filename, replace / with %
+backup.entire_path_with_double_percentage_signs =
+ function(backup_dir, path)
+ return backup_dir .. "/" .. string.gsub(path, "/", "%%")
+ end
+
+-- Return the backup path concatenated with the filename, replace / with %
+-- and append the current time using time_format
+backup.entire_path_with_double_percentage_signs_and_timestamp = function(
+ backup_dir, path)
+ return backup_dir .. "/" .. os.date(backup.time_format) ..
+ string.gsub(path, "/", "%%")
+end
+
+-- Before saving the file, copy the current contents of the file to a backup file
+vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
+ if file.size > backup.byte_limit then return end
+
+ -- E.g. when editing stdin as an interactive filter
+ -- `vis -`
+ if path == nil then return end
+
+ local backup_path = backup.get_fname(backup.directory, path)
+
+ local backup_file = io.open(backup_path, "w")
+ local current_file = io.open(path)
+ if backup_file == nil or current_file == nil then return end
+
+ for line in current_file:lines() do backup_file:write(line .. "\n") end
+
+ backup_file:close()
+end)
+
+-- Set defaults
+backup.directory = os.getenv("XDG_DATA_HOME") .. "/Trash/vis-backups"
+
+backup.get_fname = backup.entire_path_with_double_percentage_signs
+
+backup.time_format = "%H-%M-"
+
+-- Do not make backups if the file is greater than this
+-- 1MB by default
+backup.byte_limit = 1000000
+
+return backup
diff --git a/config/essentials/vis/build.lua b/config/essentials/vis/build.lua
new file mode 100644
index 0000000..8a062cd
--- /dev/null
+++ b/config/essentials/vis/build.lua
@@ -0,0 +1,66 @@
+-- Copyright (c) 2024 Florian Fischer. All rights reserved.
+--
+-- vis-build is free software: you can redistribute it and/or modify it under
+-- the terms of the GNU General Public License as published by the Free Software
+-- Foundation, either version 3 of the License, or (at your option) any later
+-- version.
+--
+-- vis-build is distributed in the hope that it will be useful, but WITHOUT
+-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+-- FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- vis-build found in the LICENSE file.
+-- If not, see <https://www.gnu.org/licenses/>.
+local M = {}
+M.get_default_build_cmd = function() return 'make' end
+
+local build_id = 0
+local builds = {}
+
+M.new_build = function(cmd)
+ build_id = build_id + 1
+ local build_name = 'build' .. build_id
+ local build_fd = vis:communicate(build_name, cmd)
+ local build = {fd = build_fd, out = '', err = '', cmd = cmd}
+ builds[build_name] = build
+end
+
+vis.events.subscribe(vis.events.PROCESS_RESPONSE,
+ function(name, event, code, msg)
+ local build = builds[name]
+ if not build then return end
+
+ if event == 'EXIT' or event == 'SIGNAL' then
+ if code ~= 0 then
+ vis:message('build: ' .. name .. ' cmd: ' .. build.cmd)
+ if event == 'EXIT' then
+ vis:message('failed with: ' .. code)
+ else
+ vis:message('got signal: ' .. code)
+ end
+ vis:message('stdout:\n' .. build.out)
+ vis:message('stderr:\n' .. build.err)
+ else
+ vis:message(name .. ':\n' .. build.out)
+ end
+ builds[name] = nil
+ end
+
+ if event == 'STDOUT' then
+ build.out = build.out .. msg
+ elseif event == 'STDERR' then
+ build.err = build.err .. msg
+ end
+end)
+
+vis:command_register('build', function(argv)
+ M.new_build(argv[1] or M.get_default_build_cmd())
+end, 'Asynchronously build the current file or project')
+
+vis:map(vis.modes.NORMAL, '<M-b>', function()
+ vis:command('build')
+ return 0
+end, 'Asynchronously build the current file or project')
+
+return M
diff --git a/config/essentials/vis/cursors.lua b/config/essentials/vis/cursors.lua
index a4e7fa3..37165b6 100644
--- a/config/essentials/vis/cursors.lua
+++ b/config/essentials/vis/cursors.lua
@@ -7,10 +7,10 @@ M.maxsize = 1000
-- get the default system cache directory
local get_default_cache_path = function()
- local HOME = os.getenv('HOME')
- local XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME')
- local BASE = XDG_CACHE_HOME or HOME
- return BASE .. '/.vis-cursors'
+ local HOME = os.getenv('HOME')
+ local XDG_CACHE_HOME = os.getenv('XDG_CACHE_HOME')
+ local BASE = XDG_CACHE_HOME or HOME
+ return BASE .. '/.vis-cursors'
end
-- default save path
@@ -18,100 +18,83 @@ M.path = get_default_cache_path()
local read_files = function()
- -- read file
- local file = io.open(M.path)
- if file == nil then
- return
- end
+ -- read file
+ local file = io.open(M.path)
+ if file == nil then return end
- files = {}
+ files = {}
- -- read positions per file path
- for line in file:lines() do
- for path, pos in string.gmatch(line, '(.+)[,%s](%d+)') do
- cursors[path] = pos
- table.insert(files, path)
- end
- end
+ -- read positions per file path
+ for line in file:lines() do
+ for path, pos in string.gmatch(line, '(.+)[,%s](%d+)') do
+ cursors[path] = pos
+ table.insert(files, path)
+ end
+ end
- file:close()
+ file:close()
end
-- read cursors from file on init
-local on_init = function()
- read_files()
-end
+local on_init = function() read_files() end
-- apply cursor pos on win open
local on_win_open = function(win)
- if win.file == nil or win.file.path == nil then
- return
- end
+ if win.file == nil or win.file.path == nil then return end
- -- init cursor path if nil
- local pos = cursors[win.file.path]
- if pos == nil then
- cursors[win.file.path] = win.selection.pos
- return
- end
+ -- init cursor path if nil
+ local pos = cursors[win.file.path]
+ if pos == nil then
+ cursors[win.file.path] = win.selection.pos
+ return
+ end
- -- set current cursor
- win.selection.pos = tonumber(pos)
+ -- set current cursor
+ win.selection.pos = tonumber(pos)
- -- center view around cursor
- vis:feedkeys("zz")
+ -- center view around cursor
+ vis:feedkeys("zz")
end
-- set cursor pos on close
local on_win_close = function(win)
- if win.file == nil or win.file.path == nil then
- return
- end
-
- -- re-read files in case they've changed
- read_files()
+ if win.file == nil or win.file.path == nil then return end
- -- remove old occurences of current path
- for i, path in ipairs(files) do
- if path == win.file.path then
- table.remove(files, i)
- end
- end
+ -- re-read files in case they've changed
+ read_files()
- -- ignore files with cursor at the beginning
- if win.selection.pos == 0 then
- return
- end
+ -- remove old occurences of current path
+ for i, path in ipairs(files) do
+ if path == win.file.path then table.remove(files, i) end
+ end
+ -- ignore files with cursor at the beginning
+ if win.selection.pos == 0 then return end
- -- insert current path to top of files
- table.insert(files, 1, win.file.path)
+ -- insert current path to top of files
+ table.insert(files, 1, win.file.path)
- -- set cursor pos for current file path
- cursors[win.file.path] = win.selection.pos
+ -- set cursor pos for current file path
+ cursors[win.file.path] = win.selection.pos
end
-- write cursors to file on quit
local on_quit = function()
- local file = io.open(M.path, 'w+')
- if file == nil then
- return
- end
-
- -- buffer cursors string
- local buffer = {}
- for _, path in ipairs(files) do
- table.insert(buffer, string.format('%s,%d', path, cursors[path]))
- if M.maxsize and #buffer >= M.maxsize then
- break
- end
- end
- local output = table.concat(buffer, '\n')
- file:write(output)
- file:close()
+ local file = io.open(M.path, 'w+')
+ if file == nil then return end
+
+ -- buffer cursors string
+ local buffer = {}
+ for _, path in ipairs(files) do
+ table.insert(buffer, string.format('%s,%d', path, cursors[path]))
+ if M.maxsize and #buffer >= M.maxsize then break end
+ end
+ local output = table.concat(buffer, '\n')
+ file:write(output)
+ file:close()
end
vis.events.subscribe(vis.events.INIT, on_init)
diff --git a/config/essentials/vis/themes/nord.lua b/config/essentials/vis/themes/nord.lua
index a21f0fa..71635cf 100644
--- a/config/essentials/vis/themes/nord.lua
+++ b/config/essentials/vis/themes/nord.lua
@@ -1,65 +1,64 @@
-- base16-vis (https://github.com/pshevtsov/base16-vis)
-- by Petr Shevtsov
-- Nord scheme by arcticicestudio
-
local lexers = vis.lexers
local colors = {
- ['bg'] = '#2E3440',
- ['black'] = '#3B4252',
- ['light_black'] = '#434C5E',
- ['dark_gray'] = '#4C566A',
- ['gray'] = '#D8DEE9',
- ['light_gray'] = '#616E88',
- ['fg'] = '#E5E9F0',
- ['white'] = '#ECEFF4',
- ['turquoise'] = '#8FBCBB',
- ['light_cyan'] = '#88C0D0',
- ['cyan'] = '#81A1C1',
- ['blue'] = '#5E81AC',
- ['red'] = '#BF616A',
- ['orange'] = '#D08770',
- ['yellow'] = '#EBCB8B',
- ['green'] = '#A3BE8C',
- ['magenta'] = '#B48EAD',
+ ['bg'] = '#2E3440',
+ ['black'] = '#3B4252',
+ ['light_black'] = '#434C5E',
+ ['dark_gray'] = '#4C566A',
+ ['gray'] = '#D8DEE9',
+ ['light_gray'] = '#616E88',
+ ['fg'] = '#E5E9F0',
+ ['white'] = '#ECEFF4',
+ ['turquoise'] = '#8FBCBB',
+ ['light_cyan'] = '#88C0D0',
+ ['cyan'] = '#81A1C1',
+ ['blue'] = '#5E81AC',
+ ['red'] = '#BF616A',
+ ['orange'] = '#D08770',
+ ['yellow'] = '#EBCB8B',
+ ['green'] = '#A3BE8C',
+ ['magenta'] = '#B48EAD'
}
lexers.colors = colors
-local fg = 'fore:'..colors.fg
-local bg = 'back:'..colors.bg
+local fg = 'fore:' .. colors.fg
+local bg = 'back:' .. colors.bg
-lexers.STYLE_DEFAULT = bg..','..fg
+lexers.STYLE_DEFAULT = bg .. ',' .. fg
lexers.STYLE_NOTHING = bg
-lexers.STYLE_CLASS = 'fore:'..colors.blue
-lexers.STYLE_COMMENT = 'fore:'..colors.light_gray..',italics'
-lexers.STYLE_CONSTANT = 'fore:'..colors.cyan
-lexers.STYLE_DEFINITION = 'fore:'..colors.green
-lexers.STYLE_ERROR = 'fore:'..colors.light_cyan..',italics'
-lexers.STYLE_FUNCTION = 'fore:'..colors.light_cyan..',bold'
-lexers.STYLE_HEADING = 'fore:'..colors.bg..',back:'..colors.yellow
-lexers.STYLE_KEYWORD = 'fore:'..colors.cyan..',bold'
-lexers.STYLE_LABEL = 'fore:'..colors.blue
-lexers.STYLE_NUMBER = 'fore:'..colors.magenta
-lexers.STYLE_OPERATOR = 'fore:'..colors.light_cyan
-lexers.STYLE_REGEX = 'fore:'..colors.orange
-lexers.STYLE_STRING = 'fore:'..colors.green
-lexers.STYLE_PREPROCESSOR = 'fore:'..colors.blue
-lexers.STYLE_TAG = 'fore:'..colors.blue
-lexers.STYLE_TYPE = 'fore:'..colors.cyan
-lexers.STYLE_VARIABLE = 'fore:'..colors.cyan..',bold'
-lexers.STYLE_WHITESPACE = 'fore:'..colors.light_black
-lexers.STYLE_EMBEDDED = 'fore:'..colors.magenta
-lexers.STYLE_IDENTIFIER = fg..',bold'
-
-lexers.STYLE_LINENUMBER = 'fore:'..colors.light_black..',back:'..colors.bg
-lexers.STYLE_CURSOR = 'fore:'..colors.bg..',back:'..colors.fg
-lexers.STYLE_CURSOR_PRIMARY = 'fore:'..colors.bg..',back:'..colors.fg
-lexers.STYLE_CURSOR_LINE = 'back:'..colors.black
-lexers.STYLE_COLOR_COLUMN = 'back:'..colors.black
-lexers.STYLE_SELECTION = 'back:'..colors.light_black
-lexers.STYLE_STATUS = 'fore:'..colors.gray..',back:'..colors.black
-lexers.STYLE_STATUS_FOCUSED = 'fore:'..colors.cyan..',back:'..colors.black
+lexers.STYLE_CLASS = 'fore:' .. colors.blue
+lexers.STYLE_COMMENT = 'fore:' .. colors.light_gray .. ',italics'
+lexers.STYLE_CONSTANT = 'fore:' .. colors.cyan
+lexers.STYLE_DEFINITION = 'fore:' .. colors.green
+lexers.STYLE_ERROR = 'fore:' .. colors.light_cyan .. ',italics'
+lexers.STYLE_FUNCTION = 'fore:' .. colors.light_cyan .. ',bold'
+lexers.STYLE_HEADING = 'fore:' .. colors.bg .. ',back:' .. colors.yellow
+lexers.STYLE_KEYWORD = 'fore:' .. colors.cyan .. ',bold'
+lexers.STYLE_LABEL = 'fore:' .. colors.blue
+lexers.STYLE_NUMBER = 'fore:' .. colors.magenta
+lexers.STYLE_OPERATOR = 'fore:' .. colors.light_cyan
+lexers.STYLE_REGEX = 'fore:' .. colors.orange
+lexers.STYLE_STRING = 'fore:' .. colors.green
+lexers.STYLE_PREPROCESSOR = 'fore:' .. colors.blue
+lexers.STYLE_TAG = 'fore:' .. colors.blue
+lexers.STYLE_TYPE = 'fore:' .. colors.cyan
+lexers.STYLE_VARIABLE = 'fore:' .. colors.cyan .. ',bold'
+lexers.STYLE_WHITESPACE = 'fore:' .. colors.light_black
+lexers.STYLE_EMBEDDED = 'fore:' .. colors.magenta
+lexers.STYLE_IDENTIFIER = fg .. ',bold'
+
+lexers.STYLE_LINENUMBER = 'fore:' .. colors.light_black .. ',back:' .. colors.bg
+lexers.STYLE_CURSOR = 'fore:' .. colors.bg .. ',back:' .. colors.fg
+lexers.STYLE_CURSOR_PRIMARY = 'fore:' .. colors.bg .. ',back:' .. colors.fg
+lexers.STYLE_CURSOR_LINE = 'back:' .. colors.black
+lexers.STYLE_COLOR_COLUMN = 'back:' .. colors.black
+lexers.STYLE_SELECTION = 'back:' .. colors.light_black
+lexers.STYLE_STATUS = 'fore:' .. colors.gray .. ',back:' .. colors.black
+lexers.STYLE_STATUS_FOCUSED = 'fore:' .. colors.cyan .. ',back:' .. colors.black
lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT
lexers.STYLE_INFO = 'fore:default,back:default,bold'
lexers.STYLE_EOF = ''
@@ -67,9 +66,9 @@ lexers.STYLE_EOF = ''
-- lexer specific styles
-- Diff
-lexers.STYLE_ADDITION = 'back:'..colors.green..',fore:'..colors.bg
-lexers.STYLE_DELETION = 'back:'..colors.red..',fore:'..colors.bg
-lexers.STYLE_CHANGE = 'back:'..colors.yellow..',fore:'..colors.bg
+lexers.STYLE_ADDITION = 'back:' .. colors.green .. ',fore:' .. colors.bg
+lexers.STYLE_DELETION = 'back:' .. colors.red .. ',fore:' .. colors.bg
+lexers.STYLE_CHANGE = 'back:' .. colors.yellow .. ',fore:' .. colors.bg
-- CSS
lexers.STYLE_PROPERTY = lexers.STYLE_ATTRIBUTE
@@ -91,19 +90,21 @@ lexers.STYLE_TARGET = ''
-- Markdown
lexers.STYLE_HR = ''
-lexers.STYLE_HEADING_H1 = 'fore:'..colors.orange..',bold'
-lexers.STYLE_HEADING_H2 = 'fore:'..colors.red..',bold'
-for i = 3,6 do lexers['STYLE_HEADING_H'..i] = 'fore:'..colors.magenta..',bold' end
+lexers.STYLE_HEADING_H1 = 'fore:' .. colors.orange .. ',bold'
+lexers.STYLE_HEADING_H2 = 'fore:' .. colors.red .. ',bold'
+for i = 3, 6 do
+ lexers['STYLE_HEADING_H' .. i] = 'fore:' .. colors.magenta .. ',bold'
+end
lexers.STYLE_BOLD = 'bold'
lexers.STYLE_ITALIC = 'italics'
lexers.STYLE_LIST = lexers.STYLE_KEYWORD
-lexers.STYLE_LINK = 'fore:'..colors.yellow..',italics'
-lexers.STYLE_REFERENCE = 'fore:'..colors.blue
-lexers.STYLE_CODE = 'back:'..colors.black..',fore:'..colors.turquoise
+lexers.STYLE_LINK = 'fore:' .. colors.yellow .. ',italics'
+lexers.STYLE_REFERENCE = 'fore:' .. colors.blue
+lexers.STYLE_CODE = 'back:' .. colors.black .. ',fore:' .. colors.turquoise
-- Output
lexers.STYE_FILENAME = 'bold'
-lexers.STYLE_LINE = 'fore:'..colors.green
+lexers.STYLE_LINE = 'fore:' .. colors.green
lexers.STYLE_COLUMN = 'underline'
lexers.STYLE_MESSAGE = ''
@@ -111,13 +112,12 @@ lexers.STYLE_MESSAGE = ''
lexers.STYLE_KEYWORD_SOFT = ''
-- YAML
-lexers.STYLE_ERROR_INDENT = 'back:'..colors.red
-
+lexers.STYLE_ERROR_INDENT = 'back:' .. colors.red
-- GO
-lexers.STYLE_CONSTANT_BUILTIN = 'fore:'..colors.yellow
-lexers.STYLE_FUNCTION_METHOD = 'fore:'..colors.light_cyan
-lexers.STYLE_FUNCTION_BUILTIN = 'fore:'..colors.light_cyan..',bold'
+lexers.STYLE_CONSTANT_BUILTIN = 'fore:' .. colors.yellow
+lexers.STYLE_FUNCTION_METHOD = 'fore:' .. colors.light_cyan
+lexers.STYLE_FUNCTION_BUILTIN = 'fore:' .. colors.light_cyan .. ',bold'
-- Lua
-lexers.STYLE_ATTRIBUTE = 'fore:'..colors.yellow..',bold'
+lexers.STYLE_ATTRIBUTE = 'fore:' .. colors.yellow .. ',bold'
diff --git a/config/essentials/vis/title.lua b/config/essentials/vis/title.lua
index c87088b..d743b63 100644
--- a/config/essentials/vis/title.lua
+++ b/config/essentials/vis/title.lua
@@ -1,22 +1,16 @@
require('vis')
local function set_title(title)
- -- print() cannot be used here as it will mess up vis
- vis:command(string.format(":!printf '\\033]2;vis %s\\007'", title))
+ -- print() cannot be used here as it will mess up vis
+ vis:command(string.format(":!printf '\\033]2;vis %s\\007'", title))
end
-vis.events.subscribe(vis.events.INIT, function()
- print('\27[22;2t')
-end)
+vis.events.subscribe(vis.events.INIT, function() print('\27[22;2t') end)
-vis.events.subscribe(vis.events.WIN_OPEN, function(win)
- set_title(win.file.name or '[No Name]')
-end)
+vis.events.subscribe(vis.events.WIN_OPEN,
+ function(win) set_title(win.file.name or '[No Name]') end)
-vis.events.subscribe(vis.events.FILE_SAVE_POST, function(file)
- set_title(file.name)
-end)
+vis.events.subscribe(vis.events.FILE_SAVE_POST,
+ function(file) set_title(file.name) end)
-vis.events.subscribe(vis.events.QUIT, function()
- print('\27[23;2t')
-end)
+vis.events.subscribe(vis.events.QUIT, function() print('\27[23;2t') end)
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index 05df7ee..3a9ff1d 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -1,41 +1,38 @@
------------------------------------
--- LIBRARIES
------------------------------------
-
require('vis')
-- plugins
+require("build")
require("backup")
require("cursors")
require("title")
+vis:command_register("make", function() vis:communicate() end, "make")
------------------------------------
--- FUNCTIONS
------------------------------------
local map_cmd = function(mode, map, command, help)
- vis:map(mode, map, function() vis:command(command) end, help)
+ vis:map(mode, map, function() vis:command(command) end, help)
end
local map_cmd_restore = function(mode, map, command, help)
- vis:map(mode, map, function()
- if (mode == vis.modes.INSERT) then
- vis:feedkeys("<Escape>")
- end
-
- vis:feedkeys("m")
- vis:command(command)
- vis:feedkeys("M")
-
- if (mode == vis.modes.INSERT) then
- vis:feedkeys("i")
- end
- end, help)
+ vis:map(mode, map, function()
+ if (mode == vis.modes.INSERT) then vis:feedkeys("<Escape>") end
+
+ vis:feedkeys("m")
+ vis:command(command)
+ vis:feedkeys("M")
+
+ if (mode == vis.modes.INSERT) then vis:feedkeys("i") end
+ end, help)
end
local map_keys = function(mode, map, keys, help)
- vis:map(mode, map, function() vis:feedkeys(keys) end, help)
+ vis:map(mode, map, function() vis:feedkeys(keys) end, help)
end
------------------------------------
@@ -49,6 +46,9 @@ local m = vis.modes
-----------------------------------
vis:command_register("Q", function() vis:command("qa!") end, "Quit all")
+vis:command_register("delws",
+ function() vis:command("x/[ \t]+$|^[ \t]+$/d") end,
+ "Remove trailing whitespace")
-------------------------------------
--- MAPPINGS
@@ -60,39 +60,37 @@ map_cmd(m.NORMAL, " c", "e ~/.config/vis/visrc.lua", "Edit config file")
map_cmd(m.NORMAL, " q", "q!", "Quit (force)")
map_cmd(m.NORMAL, " s", "!doas vis $vis_filepath", "Edit as superuser")
map_cmd(m.NORMAL, " w", "w", "Write")
-map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath", "Make active file executable")
+map_cmd(m.NORMAL, " x", "!chmod u+x $vis_filepath",
+ "Make active file executable")
vis:map(m.NORMAL, " eh", function()
- vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html")
- vis:info("exported.")
+ vis:command("!lowdown $vis_filepath > ${vis_filepath%.md}.html")
+ vis:info("exported.")
end, "Export markdown to html")
map_keys(m.NORMAL, " nl", ":<seq -f '%0.0f. ' 1 ", "Insert numbered list")
-map_keys(m.NORMAL, " ws", ":,x/[ \t]+$|^[ \t]+$/d<Enter>", "Remove trailing whitespace")
-- select markdown list element: ,x/^(\d+\.|[-*])\s+.+\n(^ .+\n)*/
-
-
------------------------------------
--- EVENTS
------------------------------------
vis.events.subscribe(vis.events.INIT, function()
- vis.options.ignorecase = true
- vis.options.autoindent = true
- vis.options.shell = "/bin/sh"
- local theme = "nord"
- vis:command("set theme " .. theme)
+ vis.options.ignorecase = true
+ vis.options.autoindent = true
+ vis.options.shell = "/bin/sh"
+ local theme = "nord"
+ vis:command("set theme " .. theme)
end)
-vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
- win.options.relativenumbers = true
-
- if win.syntax == "bash" then
- map_keys(m.NORMAL, " v",
- "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>", "Print variable")
- end
+vis.events.subscribe(vis.events.WIN_OPEN,
+ function(win) -- luacheck: no unused args
+ win.options.relativenumbers = true
+ if win.syntax == "bash" then
+ map_keys(m.NORMAL, " v",
+ "V:x/^(\\s*)(.+)$/ c/\\1>\\&2 printf '\\2: %s\\\\n' \"$\\2\"/<Enter><Escape>",
+ "Print variable")
+ end
end)
-