2017-10-04 15:11:16 +02:00
|
|
|
-- load standard vis module, providing parts of the Lua API
|
|
|
|
require('vis')
|
|
|
|
require('plugins/complete-word')
|
|
|
|
require('plugins/myfiletype')
|
2018-10-08 13:51:36 +02:00
|
|
|
require('plugins/editorconfig/editorconfig')
|
2017-10-04 15:11:16 +02:00
|
|
|
|
|
|
|
vis.events.subscribe(vis.events.INIT, function()
|
|
|
|
-- Your global configuration options
|
2018-02-26 11:56:19 +01:00
|
|
|
vis:command('set escdelay 0')
|
|
|
|
vis:command('set tabwidth 4')
|
|
|
|
vis:command('set autoindent on')
|
|
|
|
vis:command('set theme dark-16')
|
2017-10-04 15:11:16 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
|
2017-11-29 17:29:06 +01:00
|
|
|
-- Your per window configuration options
|
2017-10-04 15:11:16 +02:00
|
|
|
vis:command('set show-tabs on')
|
|
|
|
vis:command('set number')
|
|
|
|
end)
|
|
|
|
|
2017-11-17 17:37:24 +01:00
|
|
|
vis:command_register("fzf", function(argv, force, cur_win, selection, range)
|
2017-10-04 15:11:16 +02:00
|
|
|
local out = io.popen("fzf"):read()
|
2017-11-29 17:29:06 +01:00
|
|
|
--local out = io.popen("fzf " .. table.concat(argv, " ")):read()
|
2017-10-04 15:11:16 +02:00
|
|
|
if out then
|
2017-11-17 17:37:24 +01:00
|
|
|
if argv[1] then
|
2018-02-26 11:56:19 +01:00
|
|
|
vis:command(string.format('e "%s"', out))
|
2017-11-29 17:29:06 +01:00
|
|
|
-- or vis:command(string.format('open %s', out))
|
|
|
|
-- should e return false when failed
|
|
|
|
else
|
2018-02-26 11:56:19 +01:00
|
|
|
vis:command(string.format('open "%s"', out))
|
2017-11-17 17:37:24 +01:00
|
|
|
end
|
|
|
|
vis:feedkeys("<vis-redraw>")
|
2017-10-04 15:11:16 +02:00
|
|
|
end
|
2017-11-17 17:37:24 +01:00
|
|
|
end)
|
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";l", function()
|
|
|
|
vis:command('fzf')
|
|
|
|
end)
|
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";o", function()
|
|
|
|
vis:command('fzf true')
|
2017-10-04 15:11:16 +02:00
|
|
|
end)
|
2017-10-20 10:00:58 +02:00
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";;", "<vis-window-next>")
|
2018-02-26 11:56:19 +01:00
|
|
|
|
2018-10-08 13:39:26 +02:00
|
|
|
interactives = {
|
|
|
|
["python"] = "!python -i $vis_filename",
|
|
|
|
["haskell"] = "!stack ghci $vis_filepath",
|
|
|
|
["lithaskell"] = "!stack ghci $vis_filepath",
|
2019-03-11 10:42:41 +01:00
|
|
|
["latex"] = "!pdflatex $vis_filepath",
|
2018-10-08 13:39:26 +02:00
|
|
|
}
|
2018-02-26 11:56:19 +01:00
|
|
|
vis:map(vis.modes.NORMAL, ";i", function()
|
2018-10-08 13:39:26 +02:00
|
|
|
local command = interactives[vis.win.syntax]
|
|
|
|
if command then
|
|
|
|
vis:command(command)
|
2018-06-28 13:46:23 +02:00
|
|
|
end
|
|
|
|
end)
|
2018-10-08 13:39:26 +02:00
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";w", function()
|
|
|
|
vis:command('set theme light-16')
|
|
|
|
end)
|
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";b", function()
|
|
|
|
vis:command('set theme dark-16')
|
|
|
|
end)
|
2019-03-11 10:42:41 +01:00
|
|
|
|
|
|
|
vis:map(vis.modes.INSERT, '<Backspace>', function()
|
|
|
|
local found_tab = true
|
|
|
|
local tabwidth = 4
|
|
|
|
for selection in vis.win:selections_iterator() do
|
|
|
|
local pos = selection.pos
|
|
|
|
if not pos or pos < tabwidth or vis.win.file:content(pos - tabwidth, tabwidth) ~= string.rep(' ', tabwidth) then
|
|
|
|
found_tab = false
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
vis:feedkeys(string.rep('<vis-delete-char-prev>', found_tab and tabwidth or 1))
|
|
|
|
end)
|
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";s", function()
|
|
|
|
vis:command("!sent $vis_filepath")
|
|
|
|
end)
|
|
|
|
|
|
|
|
vis:map(vis.modes.NORMAL, ";p", function()
|
|
|
|
vis:command("<xclip -o")
|
|
|
|
end)
|