summaryrefslogtreecommitdiff
path: root/config/essentials
diff options
context:
space:
mode:
Diffstat (limited to 'config/essentials')
-rw-r--r--config/essentials/vis/build.lua78
-rw-r--r--config/essentials/vis/vis-go.lua18
-rw-r--r--config/essentials/vis/vis-lua.lua12
-rw-r--r--config/essentials/vis/visrc.lua25
4 files changed, 72 insertions, 61 deletions
diff --git a/config/essentials/vis/build.lua b/config/essentials/vis/build.lua
index 90dd905..bccf402 100644
--- a/config/essentials/vis/build.lua
+++ b/config/essentials/vis/build.lua
@@ -5,7 +5,6 @@ Changes made:
- print build messages on success
--]]
-
-- Copyright (c) 2024 Florian Fischer. All rights reserved.
--
-- vis-build is free software: you can redistribute it and/or modify it under
@@ -21,54 +20,57 @@ Changes made:
-- 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
+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
+ 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
+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 == "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
+ 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: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')
+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/vis-go.lua b/config/essentials/vis/vis-go.lua
index bb0c7ab..c4788cc 100644
--- a/config/essentials/vis/vis-go.lua
+++ b/config/essentials/vis/vis-go.lua
@@ -6,6 +6,8 @@ Changes made:
- no formatting because already handled by format.lua
- removed the goimports option
- set env variable for godef that fixes "no definition found"
+- removed syntax checks
+- gorename is a keybind
--]]
local function jump_to(path, line, col)
@@ -32,9 +34,6 @@ end
local function godef()
local win = vis.win
- if win.syntax ~= "go" then
- return 0
- end
local file = win.file
local pos = win.selection.pos
@@ -60,24 +59,13 @@ local function godef()
end
local function godef_back()
- if vis.win.syntax ~= "go" then
- return 0
- end
-
local pos = Gostack:pop()
if pos then
jump_to(pos.path, pos.line, pos.col)
end
end
-vis:map(vis.modes.NORMAL, "gd", godef, "Jump to Go symbol/definition")
-vis:map(vis.modes.NORMAL, "gD", godef_back, "Jump back to previous Go symbol/definition")
-
local function gorename(argv, force, win, selection)
- if win.syntax ~= "go" then
- return true
- end
-
local name = argv[1]
if not name then
vis:info("empty new name provided")
@@ -107,6 +95,8 @@ local function gorename(argv, force, win, selection)
return true
end
+vis:map(vis.modes.NORMAL, "gd", godef, "Jump to Go symbol/definition")
+vis:map(vis.modes.NORMAL, "gD", godef_back, "Jump back to previous Go symbol/definition")
vis:command_register(
"gorename",
gorename,
diff --git a/config/essentials/vis/vis-lua.lua b/config/essentials/vis/vis-lua.lua
new file mode 100644
index 0000000..83a831a
--- /dev/null
+++ b/config/essentials/vis/vis-lua.lua
@@ -0,0 +1,12 @@
+vis:command_register("check", function(_, _, win)
+ local fd = vis:communicate("check", "luacheck --no-color " .. win.file.path)
+ if not fd then
+ vis:info("error")
+ end
+ vis.events.subscribe(vis.events.PROCESS_RESPONSE, function(name, _, _, msg)
+ if name ~= "check" then
+ return
+ end
+ vis:message(msg)
+ end)
+end, "Check for errors in the file")
diff --git a/config/essentials/vis/visrc.lua b/config/essentials/vis/visrc.lua
index 8b83eb4..30e4946 100644
--- a/config/essentials/vis/visrc.lua
+++ b/config/essentials/vis/visrc.lua
@@ -12,8 +12,6 @@ require("ctags")
require("title")
require("commentary")
require("complete-line")
--- removed formatting because already fulfilled by format.lua
-require("vis-go")
-- set height to 40%
require("fzf-open")
require("vis-ultisnips")
@@ -78,6 +76,7 @@ end, "Quit all")
vis:command_register("delws", function()
vis:command(",x/[ \t]+$|^[ \t]+$/d")
end, "Remove trailing whitespace")
+vis:command_register("redraw", function() vis:redraw() end, "Redraw UI")
-------------------------------------
--- MAPPINGS
@@ -121,8 +120,8 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
-- automatically cd in parent dir of file
vis:command_register("cdp", function()
if win and win.file and win.file.path then
- -- local dir = win.file.path:match(".*/")
- -- vis:info("cd " .. tostring(dir))
+ local dir = win.file.path:match(".*/")
+ vis:info("cd " .. tostring(dir))
end
end, "Cd to parent dir of file")
@@ -133,6 +132,10 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
end
-- FILETYPE OPTIONS
+ if win.syntax == "ansi_c" then
+ map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table")
+ end
+
if win.syntax == "bash" then
vis:command_register("curl", function()
vis:command("x/ -H/ c/\\\n\t-H/")
@@ -157,9 +160,12 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
map_cmd(m.NORMAL, "\\si", "-/\\<if\\>/,/\\<fi\\>/", "Expand to if")
end
- if win.syntax == "yaml" then
- win.options.tabwidth = 2
- win.options.expandtab = true
+ if win.syntax == "go" then
+ require("vis-go")
+ end
+
+ if win.syntax == "lua" then
+ require("vis-lua")
end
if win.syntax == "markdown" then
@@ -175,7 +181,8 @@ vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused a
-- ,x/^# Planning\n([^#]|\n)+
end
- if win.syntax == "ansi_c" then
- map_keys(m.NORMAL, "\\a", "f,a <Escape>hdw<S-Tab>i<Tab><Escape>", "Align table")
+ if win.syntax == "yaml" then
+ win.options.tabwidth = 2
+ win.options.expandtab = true
end
end)