dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit e5efe241782f71d93d949e06e05d260e02090711
parent 2d3cc41bd143ad85eee7e43dc76d75f7b89e5352
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Wed, 17 Jun 2020 16:12:42 -0400

via: Remove commentary plugin

Diffstat:
Detc/vis/vis-commentary.lua | 150-------------------------------------------------------------------------------
Metc/vis/visrc.lua | 2--
2 files changed, 0 insertions(+), 152 deletions(-)

diff --git a/etc/vis/vis-commentary.lua b/etc/vis/vis-commentary.lua @@ -1,149 +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")- \ No newline at end of file diff --git a/etc/vis/visrc.lua b/etc/vis/visrc.lua @@ -1,7 +1,6 @@ -- load standard vis module, providing parts of the Lua API require('vis') require('ctags') -require('vis-commentary') vis.events.subscribe(vis.events.INIT, function() -- Your global configuration options @@ -12,7 +11,6 @@ end) vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- Your per window configuration options e.g. - vis:command('set number') if win.file.name ~= nil and win.file.name:match('.psm1$') then win.syntax = 'powershell'