dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit bef85e50299b15cc4300a0592c7d55925f669029
parent 05599fd6660edb02737a18e5849c85ca8d8c63fd
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 14 Nov 2019 11:48:13 +0100

Remove vis configuration

Diffstat:
D.config/vis/lexers/julia.lua | 50--------------------------------------------------
D.config/vis/plugins/ctags.lua | 271-------------------------------------------------------------------------------
D.config/vis/plugins/cursors.lua | 58----------------------------------------------------------
D.config/vis/plugins/fzf-mru.lua | 71-----------------------------------------------------------------------
D.config/vis/plugins/myfiletype.lua | 6------
D.config/vis/plugins/snippets.lua | 46----------------------------------------------
D.config/vis/plugins/vis-commentary.lua | 150-------------------------------------------------------------------------------
D.config/vis/themes/adbasic.lua | 38--------------------------------------
D.config/vis/visrc.lua | 188-------------------------------------------------------------------------------
9 files changed, 0 insertions(+), 878 deletions(-)

diff --git a/.config/vis/lexers/julia.lua b/.config/vis/lexers/julia.lua @@ -1,49 +0,0 @@ --- ? LPeg lexer. - -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S - -local M = {_NAME = 'julia'} - --- Whitespace. -local ws = token(l.WHITESPACE, l.space^1) - --- Comments. -local comment = token(l.COMMENT, '#' * l.nonnewline_esc^0) - --- Strings. -local dq_str = P('U')^-1 * l.delimited_range('"', true) -local triple_dq_str = '"""' * (l.any - '"""')^0 * P('"""')^-1 -local string = token(l.STRING, triple_dq_str + dq_str) - --- Keywords from `reserved-words` in Julia -local keyword = token(l.KEYWORD, word_match{ - 'begin', 'while', 'if', 'for', 'try', 'return', 'break', 'continue', - 'function', 'macro', 'quote', 'let', 'local' ', 'global', 'const', 'do', - 'struct', 'type', 'immutable', 'importall', 'module', 'baremodule', 'using', - 'import', 'export', 'end', 'else', 'catch', 'finally', 'true', 'false' -}) - --- Operators. -local operator = token(l.OPERATOR, S('!%^&*()[]{}-=+/|:;.,?<>~`')) - -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - -- {'function', func}, - -- {'constant', constant}, - -- {'self', self}, - -- {'identifier', identifier}, - {'comment', comment}, - -- {'string', string}, - -- {'number', number}, - -- {'decorator', decorator}, - {'operator', operator}, -} - -M._tokenstyles = { - -} - -return M- \ No newline at end of file diff --git a/.config/vis/plugins/ctags.lua b/.config/vis/plugins/ctags.lua @@ -1,271 +0,0 @@ -require('vis') - -local positions = {} - -local function get_path(prefix, path) - if string.find(path, '^./') ~= nil then - path = path:sub(3) - end - - return prefix .. path, path -end - -local function find_tags(path) - for i = #path, 1, -1 do - if path:sub(i, i) == '/' then - local prefix = path:sub(1, i) - local filename = prefix .. 'tags' - local file = io.open(filename, 'r') - - if file ~= nil then - return file, prefix - end - end - end -end - -local function bsearch(file, word) - local buffer_size = 8096 - local format = '\n(.-)\t(.-)\t(.-);\"\t' - - local from = 0 - local to = file:seek('end') - local startpos = nil - - while from <= to do - local mid = from + math.floor((to - from) / 2) - file:seek('set', mid) - - local content = file:read(buffer_size, '*line') - if content ~= nil then - local key, filename, excmd = string.match(content, format) - if key == nil then - break - end - - if key == word then - startpos = mid - end - - if key >= word then - to = mid - 1 - else - from = mid + 1 - end - else - to = mid - 1 - end - end - - if startpos ~= nil then - file:seek('set', startpos) - - local result = {} - while true do - local content = file:read(buffer_size, '*line') - if content == nil then - break - end - - for key, filename, excmd in string.gmatch(content, format) do - if key == word then - result[#result + 1] = {name = filename, excmd = excmd} - else - return result - end - end - end - - return result - end -end - -local function get_query() - local line = vis.win.selection.line - local pos = vis.win.selection.col - local str = vis.win.file.lines[line] - - local from, to = 0, 0 - while pos > to do - from, to = str:find('[%a_]+[%a%d_]*', to + 1) - if from == nil or from > pos then - return nil - end - end - - return string.sub(str, from, to) -end - -local function get_matches(word, path) - local file, prefix = find_tags(path) - - if file ~= nil then - local results = bsearch(file, word) - file:close() - - if results ~= nil then - local matches = {} - for i = 1, #results do - local result = results[i] - local path, name = get_path(prefix, result.name) - local desc = string.format('%s%s', name, tonumber(result.excmd) and ":"..result.excmd or "") - - matches[#matches + 1] = {desc = desc, path = path, excmd = result.excmd} - end - - return matches - end - end -end - -local function get_match(word, path) - local matches = get_matches(word, path) - if matches ~= nil then - for i = 1, #matches do - if matches[i].path == path then - return matches[i] - end - end - - return matches[1] - end -end - -local function escape(text) - return text:gsub("[][)(}{|+?*.]", "\\%0") - :gsub("%^", "\\^"):gsub("^/\\%^", "/^") - :gsub("%$", "\\$"):gsub("\\%$/$", "$/") - :gsub("\\\\%$%$/$", "\\$$") -end - ---[[ -- Can't test vis:command() as it will still return true if the edit command fails. -- Can't test File.modified as the edit command can succeed if the current file is - modified but open in another window and this behavior is useful. -- Instead just check the path again after trying the edit command. -]] -local function goto_pos(pos) - if pos.path ~= vis.win.file.path then - vis:command(string.format('e %s', pos.path)) - if pos.path ~= vis.win.file.path then - return false - end - end - if tonumber(pos.excmd) then - vis.win.selection:to(pos.excmd, pos.col) - else - vis.win.selection:to(1, 1) - vis:command(escape(pos.excmd)) - vis.win.selection.pos = vis.win.selection.range.start - vis.mode = vis.modes.NORMAL - end - return true -end - -local function goto_tag(path, excmd) - local old = { - path = vis.win.file.path, - excmd = vis.win.selection.line, - col = vis.win.selection.col, - } - - local last_search = vis.registers['/'] - if goto_pos({ path = path, excmd = excmd, col = 1 }) then - positions[#positions + 1] = old - vis.registers['/'] = last_search - end -end - -local function pop_pos() - if #positions < 1 then - return - end - if goto_pos(positions[#positions]) then - table.remove(positions, #positions) - end -end - -local function get_path() - if vis.win.file.path == nil then - return os.getenv('PWD') .. '/' - end - return vis.win.file.path -end - -local function tag_cmd(tag) - local match = get_match(tag, get_path()) - if match == nil then - vis:info(string.format('Tag not found: %s', tag)) - else - goto_tag(match.path, match.excmd) - end -end - -local function tselect_cmd(tag) - local matches = get_matches(tag, get_path()) - if matches == nil then - vis:info(string.format('Tag not found: %s', tag)) - else - local keys = {} - for i = 1, #matches do - table.insert(keys, matches[i].desc) - end - - local command = string.format( - [[echo -e "%s" | vis-menu -p "Choose tag:"]], table.concat(keys, [[\n]])) - - local status, output = - vis:pipe(vis.win.file, {start = 0, finish = 0}, command) - - if status ~= 0 then - vis:info('Command failed') - return - end - - local choice = string.match(output, '(.*)\n') - for i = 1, #matches do - local match = matches[i] - if match.desc == choice then - goto_tag(match.path, match.excmd) - break - end - end - end -end - -vis:command_register("tag", function(argv, force, win, selection, range) - if #argv == 1 then - tag_cmd(argv[1]) - end -end) - -vis:command_register("tselect", function(argv, force, win, selection, range) - if #argv == 1 then - tselect_cmd(argv[1]) - end -end) - -vis:command_register("pop", function(argv, force, win, selection, range) - pop_pos() -end) - -vis:map(vis.modes.NORMAL, '<C-]>', function(keys) - local query = get_query() - if query ~= nil then - tag_cmd(query) - end - return 0 -end) - -vis:map(vis.modes.NORMAL, 'g<C-]>', function(keys) - local query = get_query() - if query ~= nil then - tselect_cmd(query) - end - return 0 -end) - -vis:map(vis.modes.NORMAL, '<C-t>', function(keys) - pop_pos() - return 0 -end) diff --git a/.config/vis/plugins/cursors.lua b/.config/vis/plugins/cursors.lua @@ -1,58 +0,0 @@ -local module = {} -local cursors = {} -module.path = os.getenv('HOME') .. '/.cursors' - -function apply_cursor_pos(win) - if win.file == nil or win.file.path == nil then return end - local pos = cursors[win.file.path] - if pos == nil then return end - win.selection.pos = tonumber(pos) - vis:feedkeys("zz") -end - -function file_exists(path) - local f = io.open(path) - if f == nil then return false - else f:close() return true - end -end - -function read_cursors() - cursors = {} - local f = io.open(module.path) - if f == nil then return end - for line in f:lines() do - for k, v in string.gmatch(line, '(.+)%s(%d+)') do - cursors[k] = v - end - end - f:close() - for win in vis:windows() do - apply_cursor_pos(win) - end -end - -function write_cursors() - local f = io.open(module.path, 'w+') - if f == nil then return end - local a = {} - for k in pairs(cursors) do table.insert(a, k) end - table.sort(a) - for i,k in ipairs(a) do - f:write(string.format('%s %d\n', k, cursors[k])) - end - f:close() -end - -function set_cursor_pos(win) - if win.file == nil or win.file.path == nil then return end - if not file_exists(win.file.path) then return end - cursors[win.file.path] = win.selection.pos -end - -vis.events.subscribe(vis.events.INIT, read_cursors) -vis.events.subscribe(vis.events.WIN_OPEN, apply_cursor_pos) -vis.events.subscribe(vis.events.WIN_CLOSE, set_cursor_pos) -vis.events.subscribe(vis.events.QUIT, write_cursors) - -return module diff --git a/.config/vis/plugins/fzf-mru.lua b/.config/vis/plugins/fzf-mru.lua @@ -1,71 +0,0 @@ -local module = {} -module.fzfmru_filepath = os.getenv('HOME') .. '/.mru' -module.fzfmru_path = "fzf" -module.fzfmru_args = "" -module.fzfmru_history = 20 - -function read_mru() - local mru = {} - local f = io.open(module.fzfmru_filepath) - if f == nil then return end - for line in f:lines() do - table.insert(mru, line) - end - f:close() - - return mru -end - -function write_mru(win) - local file_path = win.file.path - local mru = read_mru() - - -- check if mru data exists - if mru == nil then mru = {} end - -- check if we opened any file - if file_path == nil then return end - -- check duplicate - if file_path == mru[1] then return end - - local f = io.open(module.fzfmru_filepath, 'w+') - if f == nil then return end - - table.insert(mru, 1, file_path) - - for i,k in ipairs(mru) do - if i > module.fzfmru_history then break end - if i == 1 or k ~= file_path then - f:write(string.format('%s\n', k)) - end - end - - f:close() -end - -vis.events.subscribe(vis.events.WIN_OPEN, write_mru) - -vis:command_register("fzfmru", function(argv, force, win, selection, range) - local command = "cat " .. module.fzfmru_filepath .. " | " .. module.fzfmru_path .. " " .. module.fzfmru_args .. " " .. table.concat(argv, " ") - - local file = io.popen(command) - local output = file:read() - local success, msg, status = file:close() - - if status == 0 then - vis:feedkeys(string.format(":e '%s'<Enter>", output)) - elseif status == 1 then - vis:info(string.format("fzf-open: No match. Command %s exited with return value %i." , command, status)) - elseif status == 2 then - vis:info(string.format("fzf-open: Error. Command %s exited with return value %i." , command, status)) - elseif status == 130 then - vis:info(string.format("fzf-open: Interrupted. Command %s exited with return value %i" , command, status)) - else - vis:info(string.format("fzf-open: Unknown exit status %i. command %s exited with return value %i" , status, command, status, status)) - end - - vis:feedkeys("<vis-redraw>") - - return true; -end) - -return module diff --git a/.config/vis/plugins/myfiletype.lua b/.config/vis/plugins/myfiletype.lua @@ -1,5 +0,0 @@ -require("plugins/filetype") - -vis.ftdetect.filetypes["julia"] = { - ext = { "%.jl$" }, -}- \ No newline at end of file diff --git a/.config/vis/plugins/snippets.lua b/.config/vis/plugins/snippets.lua @@ -1,46 +0,0 @@ --- vis-snippets: Insert predefined text snippets --- --- Usage from INSERT mode: --- Press the snipleader (default @@) and a key specified in the snippets --- table. This will insert the corresponding value string. Optionally, a --- cursor position can be specified with '<1>'. --- --- Author: Anders Damsgaard <anders@adamsgaard.dk>, adc on #vis-editor - -local snippets = { - ae = 'æ', - AE = 'Æ', - oe = 'ø', - OE = 'Ø', - aa = 'å', - AA = 'Å', - q = "\\emph{``<1>''}", - i = '\\item ', - l = '\\label{<1>}', - r = '\\ref{<1>}', - sig = '<1>\n-- \n' .. - 'Anders Damsgaard\n\n' .. - 'Academia: https://adamsgaard.dk\n' .. - 'Code: https://src.adamsgaard.dk\n' .. - 'Photography: https://andersdamsgaard.com' - } - -local snippets_leader = '@@' -snippets_cursor = '<1>' - -for k, v in pairs(snippets) do - if string.find(v, snippets_cursor) then - vis:map(vis.modes.INSERT, snippets_leader..k, - function() - _, j = string.find(v, snippets_cursor) - vis:insert(string.gsub(v, snippets_cursor, '')) - vis:feedkeys('<Escape>') - for _ = j+1, string.len(v) do - vis:feedkeys('h') - end - vis:feedkeys('i') - end) - else - vis:map(vis.modes.INSERT, snippets_leader..k, v) - end -end diff --git a/.config/vis/plugins/vis-commentary.lua b/.config/vis/plugins/vis-commentary.lua @@ -1,150 +0,0 @@ --- --- vis-commentary --- --- comment strings and matching patterns are taken from: --- https://github.com/rgieseke/textadept/blob/9906c1fcec1c33c6a83c33dc7874669b5c6113f8/modules/textadept/editing.lua --- - -local comment_string = { - actionscript='//', ada='--', ansi_c='/*|*/', antlr='//', apdl='!', apl='#', - applescript='--', asp='\'', autoit=';', awk='#', b_lang='//', bash='#', - batch=':', bibtex='%', boo='#', chuck='//', cmake='#', coffeescript='#', - context='%', cpp='//', crystal='#', csharp='//', css='/*|*/', cuda='//', - desktop='#', django='{#|#}', dmd='//', dockerfile='#', dot='//', - eiffel='--', elixir='#', erlang='%', faust='//', fish='#', forth='|\\', - fortran='!', fsharp='//', gap='#', gettext='#', gherkin='#', glsl='//', - gnuplot='#', go='//', groovy='//', gtkrc='#', haskell='--', html='<!--|-->', - icon='#', idl='//', inform='!', ini='#', Io='#', java='//', javascript='//', - json='/*|*/', jsp='//', latex='%', ledger='#', less='//', lilypond='%', - lisp=';', logtalk='%', lua='--', makefile='#', markdown='<!--|-->', matlab='#', - moonscript='--', myrddin='//', nemerle='//', nsis='#', objective_c='//', - pascal='//', perl='#', php='//', pico8='//', pike='//', pkgbuild='#', prolog='%', - props='#', protobuf='//', ps='%', pure='//', python='#', rails='#', rc='#', - rebol=';', rest='.. ', rexx='--', rhtml='<!--|-->', rstats='#', ruby='#', - rust='//', sass='//', scala='//', scheme=';', smalltalk='"|"', sml='(*)', - snobol4='#', sql='#', tcl='#', tex='%', text='', toml='#', vala='//', - vb='\'', vbscript='\'', verilog='//', vhdl='--', wsf='<!--|-->', - xml='<!--|-->', yaml='#' -} - --- escape all magic characters with a '%' -local function esc(str) - if not str then return "" end - return (str:gsub('%%', '%%%%') - :gsub('^%^', '%%^') - :gsub('%$$', '%%$') - :gsub('%(', '%%(') - :gsub('%)', '%%)') - :gsub('%.', '%%.') - :gsub('%[', '%%[') - :gsub('%]', '%%]') - :gsub('%*', '%%*') - :gsub('%+', '%%+') - :gsub('%-', '%%-') - :gsub('%?', '%%?')) -end - --- escape '%' -local function pesc(str) - if not str then return "" end - return str:gsub('%%', '%%%%') -end - -local function comment_line(lines, lnum, prefix, suffix) - if suffix ~= "" then suffix = " " .. suffix end - lines[lnum] = string.gsub(lines[lnum], - "(%s*)(.*)", - "%1" .. pesc(prefix) .. " %2" .. pesc(suffix)) -end - -local function uncomment_line(lines, lnum, prefix, suffix) - local match_str = "^(%s*)" .. esc(prefix) .. "%s?(.*)" .. esc(suffix) - lines[lnum] = table.concat(table.pack(lines[lnum]:match(match_str))) -end - -local function is_comment(line, prefix) - return (line:match("^%s*(.+)"):sub(0, #prefix) == prefix) -end - -local function toggle_line_comment(lines, lnum, prefix, suffix) - if not lines or not lines[lnum] then return end - if not lines[lnum]:match("^%s*(.+)") then return end -- ignore empty lines - if is_comment(lines[lnum], prefix) then - uncomment_line(lines, lnum, prefix, suffix) - else - comment_line(lines, lnum, prefix, suffix) - end -end - --- if one line inside the block is not a comment, comment the block. --- only uncomment, if every single line is comment. -local function block_comment(lines, a, b, prefix, suffix) - local uncomment = true - for i=a,b do - if lines[i]:match("^%s*(.+)") and not is_comment(lines[i], prefix) then - uncomment = false - end - end - - if uncomment then - for i=a,b do - if lines[i]:match("^%s*(.+)") then - uncomment_line(lines, i, prefix, suffix) - end - end - else - for i=a,b do - if lines[i]:match("^%s*(.+)") then - comment_line(lines, i, prefix, suffix) - end - end - end -end - -vis:map(vis.modes.NORMAL, "gcc", function() - local win = vis.win - local lines = win.file.lines - local lnum = win.selection.line - local col = win.selection.col - local comment = comment_string[win.syntax] - if not comment then return end - local prefix, suffix = comment:match('^([^|]+)|?([^|]*)$') - if not prefix then return end - - toggle_line_comment(lines, lnum, prefix, suffix) - win:draw() - win.selection:to(lnum, col) -- restore cursor position -end, "Toggle comment on a the current line") - -local function visual_f(i) - return function() - local win = vis.win - local r = win.selection.range - local lnum = win.selection.line -- line number of cursor - local col = win.selection.col -- column of cursor - - local comment = comment_string[win.syntax] - if not comment then return end - - local prefix, suffix = comment:match('^([^|]+)|?([^|]*)$') - if not prefix then return end - - if win.selection.anchored and r then - win.selection.pos = r.start - local a = win.selection.line - win.selection.pos = r.finish - local b = win.selection.line - i - - local lines = win.file.lines - block_comment(lines, a, b, prefix, suffix) - - win:draw() - win.selection:to(lnum, col) -- restore cursor position - vis.mode = vis.modes.NORMAL -- go to normal mode - end - end -end - -vis:map(vis.modes.VISUAL_LINE, "gc", visual_f(1), "Toggle comment on the selected lines") -vis:map(vis.modes.VISUAL, "gc", visual_f(0), "Toggle comment on the selected lines") - diff --git a/.config/vis/themes/adbasic.lua b/.config/vis/themes/adbasic.lua @@ -1,37 +0,0 @@ --- Minimal color scheme -local lexers = vis.lexers --- adbasic -lexers.STYLE_DEFAULT ='' -lexers.STYLE_NOTHING = '' -lexers.STYLE_CLASS = 'bold' -lexers.STYLE_COMMENT = 'bold' -lexers.STYLE_CONSTANT = '' -lexers.STYLE_DEFINITION = '' -lexers.STYLE_ERROR = 'fore:red' -lexers.STYLE_FUNCTION = '' -lexers.STYLE_KEYWORD = '' -lexers.STYLE_LABEL = '' -lexers.STYLE_NUMBER = '' -lexers.STYLE_OPERATOR = '' -lexers.STYLE_REGEX = '' -lexers.STYLE_STRING = '' -lexers.STYLE_PREPROCESSOR = '' -lexers.STYLE_TAG = '' -lexers.STYLE_TYPE = '' -lexers.STYLE_VARIABLE = '' -lexers.STYLE_WHITESPACE = '' -lexers.STYLE_EMBEDDED = '' -lexers.STYLE_IDENTIFIER = '' - -lexers.STYLE_LINENUMBER = '' -lexers.STYLE_LINENUMBER_CURSOR = lexers.STYLE_LINENUMBER -lexers.STYLE_CURSOR = 'reverse' -lexers.STYLE_CURSOR_PRIMARY = lexers.STYLE_CURSOR..',fore:yellow' -lexers.STYLE_CURSOR_LINE = 'underlined' -lexers.STYLE_COLOR_COLUMN = 'back:#999999' -lexers.STYLE_SELECTION = 'back:white' -lexers.STYLE_STATUS = 'fore:#555555' -lexers.STYLE_STATUS_FOCUSED = '' -lexers.STYLE_SEPARATOR = lexers.STYLE_DEFAULT -lexers.STYLE_INFO = 'yellow,bold' -lexers.STYLE_EOF = ''- \ No newline at end of file diff --git a/.config/vis/visrc.lua b/.config/vis/visrc.lua @@ -1,188 +0,0 @@ -require('vis') -require('plugins/myfiletype') -require('plugins/vis-commentary') -require('plugins/fzf-mru') -require('plugins/snippets') -require('plugins/ctags') -require('plugins/cursors') - -leader = '<Space>' - --- from https://github.com/ninewise/dotfiles/blob/master/config/vis/visrc.lua -vis:command_register("fzf", function(argv, force, cur_win, selection, range) - local out = io.popen("fzf"):read() - if out then - if argv[1] then - vis:command(string.format('e "%s"', out)) - else - vis:command(string.format('open "%s"', out)) - end - vis:feedkeys("<vis-redraw>") - end -end, 'fuzzy file search') - -vis:command_register("rg", function(argv, force, cur_win, selection, range) - local out = io.popen("irg"):read() - if out then - if argv[1] then - vis:command(string.format('e "%s"', out)) - else - vis:command(string.format('open "%s"', out)) - end - vis:feedkeys("<vis-redraw>") - end -end, 'fuzzy file-content search') - -interpreters = { - ['python'] = '!ipython --no-banner -i "$vis_filepath"', - ['lua'] = '!lua -i $vis_filepath', - ['julia'] = '!julia -i $vis_filepath', - ['latex'] = '!tmux new-window -a "latexmk -pdf -pvc -f $vis_filepath"', -} - -checkers = { - ['latex'] = '!tmux split-window -p 25 "chktex -q $vis_filepath | less"', - ['bash'] = '!tmux split-window -p 25 "shellcheck --color=never $vis_filepath | less"', -} - -spellcheckers = { - ['latex'] = '!aspell -t -c $vis_filepath', -} - -vis:command_register("prev", function(argv, force, cur_win, selection, range) - local file = io.popen('sed -n 2p ~/.mru') - local output = file:read() - local success, msg, status = file:close() - if status == 0 then - vis:feedkeys(string.format(":e '%s'<Enter>", output)) - else - vis:info('error ' .. tostring(status)) - end - vis:feedkeys('<vis-redraw>') - return true; -end, 'edit previous file') - -vis.events.subscribe(vis.events.INIT, function() - -- global configuration options - vis:command('set theme adbasic') - - vis:map(vis.modes.NORMAL, leader..'a', ':rg true<Enter>') - vis:map(vis.modes.NORMAL, leader..'A', ':rg<Enter>') - vis:map(vis.modes.NORMAL, leader..'B', ':e "$BIB"<Enter>') - vis:map(vis.modes.NORMAL, leader..'CC', ':e ~/.config/vis/visrc.lua<Enter>') - vis:map(vis.modes.NORMAL, leader..'CS', ':e ~/.config/vis/plugins/snippets.lua<Enter>') - vis:map(vis.modes.NORMAL, leader..'d', ':< date<Enter>') - vis:map(vis.modes.NORMAL, leader..'e', ':fzf true<Enter>') - vis:map(vis.modes.VISUAL, leader..'p', - function() - if vis.count then - vis:command(string.format(':|par %d', vis.count)) - else - vis:command(':|par') - end - end) - vis:map(vis.modes.NORMAL, leader..'ga', ':!git add "$vis_filepath"<Enter>') - vis:map(vis.modes.NORMAL, leader..'gc', ':!git commit -v -S<Enter>') - vis:map(vis.modes.NORMAL, leader..'gp', ':!git push<Enter>') - vis:map(vis.modes.NORMAL, leader..'l', ':set show-newline!<Enter>') - vis:map(vis.modes.NORMAL, leader..'m', ':!make<Enter>') - -- vis:map(vis.modes.NORMAL, leader..'m', ':!tmux split-window -p 25 "make"', - vis:map(vis.modes.NORMAL, leader..'n', ':set numbers!<Enter>') - vis:map(vis.modes.NORMAL, leader..'N', ':set relativenumbers!<Enter>') - vis:map(vis.modes.NORMAL, leader..'o', ':fzf<Enter>') - vis:map(vis.modes.NORMAL, leader..'p', ':< xclip -o<Enter>') - vis:map(vis.modes.NORMAL, leader..'P', ':< xclip -selection clipboard -o<Enter>') - vis:map(vis.modes.NORMAL, leader..'q', ':q<Enter>') - vis:map(vis.modes.NORMAL, leader..'Q', ':qa<Enter>') - vis:map(vis.modes.NORMAL, leader..'r', ':< scholarref ') - vis:map(vis.modes.NORMAL, leader..'t', ':!ctags -R . >/dev/null 2>&1 &<Enter>') - vis:map(vis.modes.NORMAL, leader..'T', ':e ~/doc/todo.md<Enter>') - vis:map(vis.modes.NORMAL, leader..'w', ':x/ +$/ c//<Enter>:w<Enter>') - vis:map(vis.modes.NORMAL, leader..'x', ':wq<Enter>') - vis:map(vis.modes.NORMAL, leader..'X', - function() -- mark todo item as done and append date - vis:feedkeys('f[c3l[x]<Escape>A **<Escape>h') - vis:command(':< printf "$(date +"%Y-%m-%d %H:%M")"') - vis:feedkeys('^') - end) - vis:map(vis.modes.VISUAL, leader..'y', ':> xsel -i<Enter>') - vis:map(vis.modes.VISUAL, leader..'Y', ':> xsel --clipboard -i<Enter>') - - vis:map(vis.modes.NORMAL, '<F7>', ':!sent $vis_filepath &<Enter>') - vis:map(vis.modes.NORMAL, '<Tab><Tab>', '<vis-window-next>') - vis:map(vis.modes.NORMAL, leader..'<Tab>', ':prev<Enter>') - vis:map(vis.modes.NORMAL, leader..'%', ':vsplit<Enter>') - vis:map(vis.modes.NORMAL, leader..',', ':fzfmru<Enter>') - vis:map(vis.modes.NORMAL, '] ', - function() vis:feedkeys('o<Escape><Up>') end) - vis:map(vis.modes.NORMAL, '[ ', - function() vis:feedkeys('O<Escape><Down>') end) -end) - -vis.events.subscribe(vis.events.WIN_OPEN, function(win) - -- per window configuration options - vis:command('set savemethod inplace') - vis:command('set show-tabs') - vis:command('set autoindent') - vis:command('set tabwidth 4') - vis:command('set colorcolumn 81') - - -- complete from words in current file - vis:map(vis.modes.INSERT, '<C-x><C-n>', - function() - local tmpfile = '/tmp/vis-complete' - local fp = io.popen('vis-complete --word >'..tmpfile, 'w') - fp:write(vis.win.file:content(0, vis.win.file.size)) - fp:close() - local f = io.open(tmpfile, 'r') - local output = f:read() - vis:insert(output) - f:close() - vis:feedkeys("<vis-redraw>") - end) - - -- file-type specific commands - if vis.win.syntax == 'latex' then - vis:command('set colorcolumn 0') - elseif vis.win.syntax == 'python' then - vis:command('set expandtab') - elseif vis.win.syntax == 'yaml' then - vis:command('set tabwidth 2') - vis:command('set expandtab') - end - - -- file-type specific mappings - vis:map(vis.modes.NORMAL, leader..'i', - function() - local command = interpreters[vis.win.syntax] - if command then - vis:command(command) - else - vis:info("no interpreter found for this file type") - end - return true; - end) - vis:map(vis.modes.NORMAL, leader..'c', - function() - local command = checkers[vis.win.syntax] - if command then - vis:command(command) - else - vis:info("no syntax checker found for "..vis.win.syntax) - end - return true; - end) - vis:map(vis.modes.NORMAL, leader..'s', - function() - local command = spellcheckers[vis.win.syntax] - if command then - vis:command(':w') - vis:command(command) - vis:command(':e') - else - vis:info("no spell checker found for "..vis.win.syntax) - end - return true; - end) - -end)