several updates
This commit is contained in:
parent
dac9f903c9
commit
4bc4e5b8ad
11 changed files with 91 additions and 161 deletions
|
@ -5,30 +5,43 @@
|
|||
require('vis')
|
||||
require('plugins/complete-word')
|
||||
require('plugins/myfiletype')
|
||||
require('plugins/editorconfig/editorconfig')
|
||||
require('plugins/editorconfig')
|
||||
|
||||
vis.events.subscribe(vis.events.INIT, function()
|
||||
-- Your global configuration options
|
||||
vis:command('set escdelay 0')
|
||||
vis:command('set tabwidth 4')
|
||||
vis:command('set autoindent on')
|
||||
vis:command('set theme dark-16')
|
||||
vis:command('set theme base-16')
|
||||
end)
|
||||
|
||||
vis.events.subscribe(vis.events.WIN_OPEN, function(win)
|
||||
-- Your per window configuration options
|
||||
vis:command('set show-tabs on')
|
||||
vis:command('set tabwidth 4')
|
||||
vis:command('set showtabs on')
|
||||
vis:command('set number')
|
||||
end)
|
||||
|
||||
vis.events.subscribe(vis.events.FILE_SAVE_PRE, function(file, path)
|
||||
if file.size ~= 0 and file:content(file.size - 1, 1) ~= "\n" then
|
||||
file:insert(file.size, "\n")
|
||||
vis.events.subscribe(vis.events.WIN_HIGHLIGHT, function(win)
|
||||
if win.file.path and win.file.path:match('.*%.tsx') then
|
||||
win:set_syntax('javascript')
|
||||
end
|
||||
return true
|
||||
end)
|
||||
|
||||
vis:map(vis.modes.NORMAL, ";;", "<vis-window-next>")
|
||||
vis:map(vis.modes.NORMAL, '<C-o>', '<vis-window-next>')
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Activate open-file-on-enter mode in this window
|
||||
vis:map(vis.modes.NORMAL, ";e", function()
|
||||
vis.win:map(vis.modes.NORMAL, "<Enter>", function()
|
||||
local line = vis.win.file.lines[vis.win.selection.line]
|
||||
local filename = string.find(line, ':')
|
||||
local linenumber = string.find(line, ':', filename + 1)
|
||||
local column = string.find(line, ':', linenumber + 1)
|
||||
vis:command(string.format('open "%s"', string.sub(line, 0, filename - 1)))
|
||||
vis.win.selection:to(tonumber(string.sub(line, filename + 1, linenumber - 1)), tonumber(string.sub(line, linenumber + 1, column - 1)))
|
||||
end)
|
||||
end)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Escape removes counts
|
||||
|
@ -41,15 +54,6 @@ vis:map(vis.modes.NORMAL, "<Escape>", function()
|
|||
end
|
||||
end)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Fancy cd
|
||||
vis:command_register("rcd", function(argv, force, cur_win, selection, range)
|
||||
handle = io.popen('f=$(mktemp); st -e ranger --choosedir="$f" --show-only-dirs; cat "$f"')
|
||||
local output = handle:read()
|
||||
handle:close()
|
||||
vis:command('cd '..output)
|
||||
end)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Fuzzy search filenames to open files
|
||||
|
||||
|
@ -90,12 +94,13 @@ end, 'fuzzy line copy')
|
|||
-- Fuzzy search lines to open files
|
||||
|
||||
vis:command_register("rg", function(argv, force, cur_win, selection, range)
|
||||
local out = io.popen("sk --ansi -i -c 'rg --color=always --line-number "..'"{}"'.."'"):read()
|
||||
local out = io.popen("sk --ansi -i -c 'rg --color=always --line-number --column --colors column:fg:green "..'"{}"'.."'"):read()
|
||||
if out then
|
||||
local filename = string.find(out, ':')
|
||||
local linenumber = string.find(out, ':', filename + 1)
|
||||
local column = string.find(out, ':', linenumber + 1)
|
||||
vis:command(string.format(argv[1]..' "%s"', string.sub(out, 0, filename - 1)))
|
||||
vis.win.selection:to(tonumber(string.sub(out, filename + 1, linenumber - 1)), 0)
|
||||
vis.win.selection:to(tonumber(string.sub(out, filename + 1, linenumber - 1)), tonumber(string.sub(out, linenumber + 1, column - 1)))
|
||||
vis:feedkeys("<vis-redraw>")
|
||||
end
|
||||
end, 'fuzzy grep open')
|
||||
|
@ -198,3 +203,30 @@ vis:command_register("sts", function(argv, force, win, selection, range)
|
|||
end
|
||||
return true
|
||||
end, "Strip line trailing spaces")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Git
|
||||
|
||||
git_commands = {
|
||||
["add"] = function(argv, force, win, selection, range)
|
||||
local output = io.popen('git add ' .. vis.win.file.path):read()
|
||||
if (output) then
|
||||
vis:message(output)
|
||||
end
|
||||
end,
|
||||
["status"] = function(argv, force, win, selection, range)
|
||||
local output = io.popen('git status'):read()
|
||||
if (output) then
|
||||
vis:message(output)
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
vis:command_register("git", function(argv, force, win, selection, range)
|
||||
local command = git_commands[argv[1]]
|
||||
if (command) then
|
||||
command(argv, force, win, selection, range)
|
||||
else
|
||||
vis:message("Unknown git command")
|
||||
end
|
||||
end, "Git commands")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue