dotfiles

dot files
git clone git://git.rr3.xyz/dotfiles
Log | Files | Refs

commit b1c457cf6b04fc4d0186998787b675c93dd032aa
Author: Robert Russell <robertrussell.72001@gmail.com>
Date:   Wed,  6 Sep 2023 14:32:35 -0700

Initial commit

Diffstat:
A.bashrc | 22++++++++++++++++++++++
A.profile | 6++++++
A.xinitrc | 12++++++++++++
Avis/lexers/ansi_c.lua | 223+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/lexers/latex.lua | 2++
Avis/lexers/mp.lua | 169+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/lexers/suq.lua | 137+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/lexers/tex.lua | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/themes/custom.lua | 67+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/visrc.lua | 86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
10 files changed, 784 insertions(+), 0 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -0,0 +1,22 @@ +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +alias ls='ls --color=auto' +alias e=vis +alias o=zathura + +PROMPT_COMMAND='PS1EXIT=$?;' # Store previous exit code in PS1EXIT +PROMPT_COMMAND+='printf "\e[6n";' # Query cursor position (format: \e[<row>;<col>R) +PROMPT_COMMAND+='read -sd";";' # Ignore upto ";" +PROMPT_COMMAND+='read -sdR PS1COL;' # Store column number in PS1COL +PROMPT_COMMAND+='PS1="";' # Initialize PS1 +PROMPT_COMMAND+='[ ${PS1COL:-1} -ne 1 ] && PS1+="\[\e[31;1m\]◆\[\e[m\]\n";' # If current row is nonempty, add newline to PS1 +PROMPT_COMMAND+='PS1+="\[\e[36m\]\w\[\e[m\]";' # Add working directory to PS1 +PROMPT_COMMAND+='git rev-parse --git-dir >/dev/null 2>&1' # Check if inside git repo; +PROMPT_COMMAND+=' && PS1+=" \[\e[35m\] $(git branch --show-current)\[\e[m\]";' # if so, add branch name to PS1 +PROMPT_COMMAND+='PS1+=" \[\e[31m\]$PS1EXIT\[\e[m\]";' # Add previous exit code to PS1 +PROMPT_COMMAND+='PS1+="\n\[\e[32m\]▶\[\e[m\] ";' # Add actual prompt to PS1 + +PS2='\[\e[32m\]▷\[\e[m\] ' + +source ~/app/z/z.sh diff --git a/.profile b/.profile @@ -0,0 +1,6 @@ +export EDITOR=vis +export BROWSER=firefox +export PAGER=less +export PDFVIEWER=zathura +export PATH="$PATH:/home/rob/.cabal/bin:/opt/ats2/bin:/opt/idris2/bin" +export PATSHOME="/opt/ats2/lib/ats2-postiats-0.4.2" diff --git a/.xinitrc b/.xinitrc @@ -0,0 +1,12 @@ +sxkbm +xkbdw sxkbm & + +[ -f ~/.Xresources ] && xrdb -merge ~/.Xresources +xhost +local: + +while true; do statusupd; sleep 5; done & + +pipewire & +pipewire-pulse & + +exec dwm diff --git a/vis/lexers/ansi_c.lua b/vis/lexers/ansi_c.lua @@ -0,0 +1,223 @@ +local M = {_NAME = "ansi_c"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token +local any = P(1) +local oct = R"07" +local dec = R"09" +local hex = R("09", "AF", "af") +local alpha = R("AZ", "az") +local letter = alpha + dec + "_" +local word = (alpha + P"_") * letter^0 +local pm = S"+-" +local hws = S"\t " +local vws = S"\n\r" +local ws = hws + vws +local function I(s) -- Case-insensitive string match + local p = P(true) + for i = 1, #s do + local c = s:sub(i, i) + p = p * (P(c:lower()) + P(c:upper())) + end + return p +end +local function N(p, min, max) + max = max or min + return p^min - p^(max+1) +end + +local whitespace = T("whitespace", ws^1) + +local comment_keyword = T("comment_keyword", I"todo" + I"xxx" + I"fixme") +local line_comment_text = T("comment_text", (any - comment_keyword - S"\\\n" + P"\\\n" + P"\\")^1) +local line_comment = T("comment_text", P"//") * (line_comment_text + comment_keyword)^0 * T("whitespace", P"\n") +local block_comment_text = T("comment_text", (any - comment_keyword - P"*/")^1) +local block_comment = T("comment_text", P"/*") * (block_comment_text + comment_keyword)^0 * T("comment_text", P"*/") +local comment = line_comment + block_comment + +local fltlit_dec_exp = S"eE" * pm^-1 * dec^1 +local fltlit_dec = dec^1 * (P"." * dec^0 * fltlit_dec_exp^-1 + fltlit_dec_exp) + P"." * dec^1 * fltlit_dec_exp^-1 +local fltlit_hex_exp = S"pP" * pm^-1 * dec^1 +local fltlit_hex = P"0" * S"xX" * (hex^1 * (P"." * hex^0)^-1 + P"." * hex^1) * fltlit_hex_exp +local fltlit_suffix = S"fFlL" +-- local fltlit = pm^-1 * (fltlit_hex + fltlit_dec) * fltlit_suffix^-1 +local fltlit = (fltlit_hex + fltlit_dec) * fltlit_suffix^-1 + +local intlit_oct = P"0" * oct^1 +local intlit_dec = dec^1 +local intlit_hex = P"0" * S"xX" * hex^1 +local intlit_width = P"ll" + P"l" + P"LL" + P"L" +local intlit_suffix = (S"uU" * intlit_width^-1) + (intlit_width * S"uU"^-1) +-- local intlit = pm^-1 * (intlit_hex + intlit_oct + intlit_dec) * intlit_suffix^-1 +local intlit = (intlit_hex + intlit_oct + intlit_dec) * intlit_suffix^-1 + +local numlit = T("numlit", fltlit + intlit) + +local escape = T("escape", + P"\\" * S"'\"?\\abfnrtv" + + P"\\" * dec * dec^-2 + + P"\\x" * hex^1 + + P"\\u" * N(hex, 4) + + P"\\U" * N(hex, 8)) +local bad_escape = T("bad_escape", P"\\" * any) + +local charlit_text = T("charlit_text", (any - vws - S"'\\")^1) +local charlit_prefix = T("charlit_delim", P"u8" + P"u" + P"U" + P"L") +local charlit_delim = T("charlit_delim", P"'") +local charlit = charlit_prefix^-1 * charlit_delim + * (charlit_text + escape + bad_escape)^0 * charlit_delim + +local strlit_format_param = dec^1 * P"$" +local strlit_format = T("strlit_format", P"%" + * strlit_format_param^-1 + * S"-+ 0'#"^0 -- flags + * (R"19" * dec^0 + (P"*" * strlit_format_param^-1))^-1 -- width + * (P"." * (P"*" * strlit_format_param^-1 + dec^0))^-1 -- precision + * (S"Lhjltz" + P"hh" + P"ll")^-1 -- length + * S"%diuoxXeEfFgGaAcspn") -- type +local strlit_text = T("strlit_text", (any - vws - S"\"\\" - strlit_format)^1) +local strlit_prefix = T("strlit_delim", P"u8" + P"u" + P"U" + P"L") +local strlit_delim = T("strlit_delim", P"\"") +local strlit = strlit_prefix^-1 * strlit_delim + * (strlit_text + strlit_format + escape + bad_escape)^0 * strlit_delim + +local delimiter = T("delimiter", S"(){};,\\") + +local operator = T("operator", S"+-*/%!&|^~<=>?:.[]" + P"sizeof" + P"_Alignof" + P"alignof") + +local preproc_cond = T("preproc_cond", P"#") * T("whitespace", hws^0) + * T("preproc_cond", P"ifdef" + P"ifndef" + P"if" + P"elif" + P"else" + P"endif") +local preproc_def = T("preproc", P"#") * T("whitespace", hws^0) + * T("preproc", P"define") * T("whitespace", hws^0) + * (T("function", word) * #P"(" + T("identifier", word)) +local preproc_inc = T("preproc", P"#") * T("whitespace", hws^0) + * T("preproc", P"include") * ( + T("whitespace", hws^0) + * T("strlit_delim", P"<") + * T("strlit_text", (any - vws - P">")^0) + * T("strlit_delim", P">") + )^-1 +local preproc_other = T("preproc", P"#") * T("whitespace", hws^0) + * T("preproc", P"undef" + P"pragma" + P"include" + P"error" + P"warning" + P"line") +local preproc = preproc_cond + preproc_def + preproc_inc + preproc_other + T("preproc", "#") + +local keyword = T("keyword", l.word_match{ + -- Storage classes + "extern", "static", "auto", "register", "_Thread_local", + "thread_local", -- <threads.h> + + -- Type qualifiers + "const", "restrict", "volatile", "_Atomic", + + -- Function specifier + "inline", "_Noreturn", + "noreturn", -- <stdnoreturn.h> + + -- Control flow + "return", "break", "continue", "goto", + "if", "else", + "switch", "case","default", + "do", "while", "for", + + -- Misc + "typedef", "_Alignas", "_Generic", "_Static_assert", + "alignas", -- <stdalign.h> + "static_assert", -- <assert.h> + + -- GNU + "__typeof__", "typeof", + "__attribute__", + "__asm__", "asm", + + -- rcx macros + "likely", "unlikely", + "unreachable", +}) + +local constant = T("constant", l.word_match{ + -- Very special constants only. + "__DATE__", "__FILE__", "__LINE__", "__TIME__", "__func__", + "__VA_ARGS__", + "NULL", + "true", "false", -- <stdbool.h> +}) + +local type_builtin = l.word_match{ + "void", + "_Bool", "char", "int", "float", "double", + "bool", -- <stdbool.h> + "short", "long", + "signed", "unsigned", + "_Complex", "_Imaginary", + "complex", "imaginary", -- <complex.h> + "struct", "union", "enum", +} +local type_std = l.word_match{ + "ptrdiff_t", "size_t", "ssize_t", "max_align_t", "wchar_t", +} +local type_stdint = P"u"^-1 * P"int" * ((P"_least" + P"_fast")^-1 * dec^1 + P"max" + P"ptr") * P"_t" * #(any - letter) +local type_nice = P"__"^-1 * (P"v" * dec^1)^-1 * S"usif" * dec^1 * P"_t"^-1 * #(any - letter) + l.word_match{ + "schar", "uchar", "ushort", "uint", "ulong", "llong", "ullong", +} +local type_rcx = (S"iu" * (P"max" + P"ptr" + P"size") + P"rune" + P"maxalign") * #(any - letter) +local type_ = T("type", type_builtin + type_std + type_stdint + type_nice + type_rcx) + +local label = T("whitespace", hws^0) * T("label", word) * T("delimiter", P":") + +local function_ = T("function", word) * T("whitespace", ws^0) * #P"(" + +local identifier = T("identifier", word) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"numlit", numlit}, + {"charlit", charlit}, + {"strlit", strlit}, + {"delimiter", delimiter}, + {"operator", operator}, + {"preproc", preproc}, + {"keyword", keyword}, + {"constant", constant}, + {"type", type_}, + {"label", label}, + {"function", function_}, + {"identifier", identifier}, + + {"error", T("error", any)}, -- TODO: TEMP +} + +M._tokenstyles = { + whitespace = l.STYLE_WHITESPACE, + + comment_text = l.STYLE_COMMENT, + comment_keyword = l.STYLE_COMMENT_KEYWORD, + + numlit = l.STYLE_NUMBER, + + escape = l.STYLE_ESCAPE, + bad_escape = l.STYLE_ERROR, + + charlit_delim = l.STYLE_NUMBER, + charlit_text = l.STYLE_NUMBER, + + strlit_delim = l.STYLE_STRING, + strlit_text = l.STYLE_STRING, + strlit_format = l.STYLE_STRING_FORMAT, + + delimiter = l.STYLE_DELIMITER, + operator = l.STYLE_OPERATOR, + + preproc = l.STYLE_PREPROCESSOR, + preproc_cond = l.STYLE_PREPROCESSOR_CONDITIONAL, + + keyword = l.STYLE_KEYWORD, + constant = l.STYLE_CONSTANT, + ["type"] = l.STYLE_TYPE, + label = l.STYLE_LABEL, + ["function"] = l.STYLE_FUNCTION, + identifier = l.STYLE_IDENTIFIER, +} + +return M diff --git a/vis/lexers/latex.lua b/vis/lexers/latex.lua @@ -0,0 +1 @@ +tex.lua +\ No newline at end of file diff --git a/vis/lexers/mp.lua b/vis/lexers/mp.lua @@ -0,0 +1,169 @@ +local M = {_NAME = "mp"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token +local any = P(1) +local dec = R"09" +local alpha = R("AZ", "az") +local hws = S"\t " +local vws = S"\n\r" +local ws = hws + vws +local function I(s) -- Case-insensitive string match + local p = P(true) + for i = 1, #s do + local c = s:sub(i, i) + p = p * (P(c:lower()) + P(c:upper())) + end + return p +end +local function N(p, min, max) + max = max or min + return p^min - p^(max+1) +end + +local whitespace = T("whitespace", ws^1) + +local comment_keyword = T("comment_keyword", I"todo" + I"xxx" + I"fixme") +local comment_text = T("comment_text", (any - P"\n" - comment_keyword)^1) +local comment = T("comment_text", P"%") * (comment_text + comment_keyword)^0 * T("whitespace", P"\n") + +local numlit = T("numlit", (dec^0 * P".")^-1 * dec^1) + +local strlit = T("strlit", P"\"" * (any - vws - S"\"")^0 * P"\"") + +local delimiter = T("delimiter", S"()[]{};,") + +local operator = T("operator", S"<=>:+-*/.&|" + l.word_match{ + "thru", "atleast", "of", "cycle", "on", "off", + "makepen", "makepath", "penoffset", + "char", "substring", + + -- Number operators + "angle", "dir", "sind", "sin", "asin", "cosd", "cos", "acos", "tand", "tan", "atan", + "floor", "ceiling", "round", "abs", "length", "normalize", "sqrt", "mod", "div", "dotprod", + "mexp", "mlog", + "normaldeviate", "uniformdeviate", + + -- Boolean opereators + "not", "and", "or", "even", "odd", "known", "unknown", + "isnumber", "ispair", "ispath", "istransform", "isrgbcolor", "iscolor", "iscmykcolor", "isstring", "isboolean", "ispicture", "ispen", "cyclic", + + -- Transformations + "transformed", "rotated", "slanted", "reflectedabout", "shifted", "xshifted", "yshifted", "scaled", "xscaled", "yscaled", "zscaled", "rotatedaround", "rotatedabout", + "inverse", + + -- BBox operators + "ulcorner", "llcorner", "urcorner", "lrcorner", "center", "bbox", + "width", "height", "ascent", "descent", + + -- Path operators + "arclength", "arctime", "direction", "directiontime", "directionpoint", "intersectiontimes", "intersectionpoint", "point", "precontrol", "postcontrol", "reverse", "subpath", "subcycle", "cutbefore", "cutafter", "cutcycle", "tensepath", + "envelope", "turningnumber", "cw", "ccw", + + -- Pair operators + "xpart", "ypart", "xxpart", "xypart", "yxpart", "yypart", "swap", + "cyanpart", "magentapart", "yellowpart", "blackpart", + "redpart", "greenpart", "bluepart", + "greypart", "dashpart", "fontpart", "pathpart", "penpart", "textpart", + + -- Draw options + "dashed", "withpen", "withprescript", "withpostscript", "withoutcolor", "withrgbcolor", "withcolor", "withcmykcolor", "withgreyscale", +}) + +local suffix = T("suffix", P"#@" + P"@#" + P"@") + +local keyword = T("keyword", l.word_match{ + "input", "endinput", "end", "dump", "shipout", "special", + "begingroup", "endgroup", + "scantokens", "expandafter", "ea", + "let", "def", "vardef", "primarydef", "secondarydef", "tertiarydef", "enddef", + "outer", "inner", "save", "interim", "delimiters", + "show", "showdependencies", "showtoken", "showvariable", "showstats", + "errhelp", "errmessage", "message", + "batchmode", "nonstopmode", "scrollmode", "errorstopmode", + "addto", "also", "contour", "doublepath", "clip", "setbounds", + "controls", "tension", "curl", + "if", "elseif", "else", "fi", "exitif", "exitunless", + "for", "forsuffixes", "forever", "step", "until", "upto", "downto", "endfor", +}) + +local constant = T("constant", l.word_match{ + "mitered", "rounded", "beveled", "butt", "squared", + + -- Number + "eps", "epsilon", "inf", + + -- Pair + "left", "right", "up", "down", "origin", + + -- Path + "circle", "square", + + -- Transform + "id", + + -- String + "dquote", "EOF", + + -- Boolean + "true", "false", + + -- Picture + "nullpicture", + + -- Pen + "nullpen", "pencircle", "pensquare", "penrazor", "penspeck", +}) + +local type_ = T("type", l.word_match{ + "newinternal", + + -- Builtin types + "numeric", "pair", "path", "transform", "rgbcolor", "color", + "cmykcolor", "string", "boolean", "picture", "pen", + + -- Parameters + "text", "expr", "suffix", "primary", "secondary", "tertiary", + + -- r3mp aliases + "internal", "number", +}) + +local identifier = T("identifier", (alpha + P"_")^1) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"numlit", numlit}, + {"strlit", strlit}, + {"delimiter", delimiter}, + {"operator", operator}, + {"suffix", suffix}, + {"keyword", keyword}, + {"constant", constant}, + {"type", type_}, + {"identifier", identifier}, +} + +M._tokenstyles = { + whitespace = l.STYLE_WHITESPACE, + + comment_text = l.STYLE_COMMENT, + comment_keyword = l.STYLE_COMMENT_KEYWORD, + + numlit = l.STYLE_NUMBER, + + strlit = l.STYLE_STRING, + + delimiter = l.STYLE_DELIMITER, + operator = l.STYLE_OPERATOR, + suffix = l.STYLE_LABEL, -- TODO: this makes no sense + + keyword = l.STYLE_KEYWORD, + constant = l.STYLE_CONSTANT, + ["type"] = l.STYLE_TYPE, + identifier = l.STYLE_IDENTIFIER, +} + +return M diff --git a/vis/lexers/suq.lua b/vis/lexers/suq.lua @@ -0,0 +1,137 @@ +local M = {_NAME = "suq"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token + +local any = P(1) + +local dec = R"09" +local bin = R"01" +local qat = R"03" +local oct = R"07" +local hex = R("09", "AF", "af") + +local dec_ = dec + "_" +local bin_ = bin + "_" +local qat_ = qat + "_" +local oct_ = oct + "_" +local hex_ = hex + "_" + +local alpha = R("AZ", "az") +local letter = alpha + dec + "_" +local word = (alpha + P"_") * letter^0 + +local hws = S"\t " +local vws = S"\n\r" +local ws = hws + vws + +local function I(s) -- Case-insensitive string match + local p = P(true) + for i = 1, #s do + local c = s:sub(i, i) + p = p * (P(c:lower()) + P(c:upper())) + end + return p +end + +local function N(p, min, max) + max = max or min + return p^min - p^(max+1) +end + +local whitespace = T("whitespace", ws^1) + +local comment_keyword = T("comment_keyword", I"todo" + I"xxx" + I"fixme") +local comment_text = T("comment_text", (any - comment_keyword - P"\n")^1) +local comment = T("comment_text", P"\\\\") * (comment_text + comment_keyword)^0 * T("whitespace", P"\n") + +local numterm = any - letter +local function numerals(nums) + return P"_"^0 * nums^1 * (nums + "_")^0 +end +local numlit_dec = dec^1 * dec_^0 * (P"." * numerals(dec))^-1 * #numterm +local numlit_bin = P"0" * S"bB" * numerals(bin) * (P"." * numerals(bin))^-1 * #numterm +local numlit_qat = P"0" * S"qQ" * numerals(qat) * (P"." * numerals(qat))^-1 * #numterm +local numlit_oct = P"0" * S"oO" * numerals(oct) * (P"." * numerals(oct))^-1 * #numterm +local numlit_hex = P"0" * S"xX" * numerals(hex) * (P"." * numerals(hex))^-1 * #numterm +local numlit = T("numlit", numlit_dec + numlit_bin + numlit_qat + numlit_oct + numlit_hex) + +local escape = T("escape", + P"\\" * S"'\"\\nrt" + + P"\\" * hex * hex + + P"\\u" * N(hex, 4) + + P"\\U" * N(hex, 6)) +local bad_escape = T("bad_escape", P"\\" * any) + +local charlit_text = T("charlit_text", (any - S"'\\")^1) +local charlit_delim = T("charlit_delim", P"'") +local charlit = charlit_delim * (charlit_text + escape + bad_escape)^0 * charlit_delim + +local strlit_text = T("strlit_text", (any - S"\"\\")^1) +local strlit_delim = T("strlit_delim", P"\"") +local strlit = strlit_delim * (strlit_text + escape + bad_escape)^0 * strlit_delim + +local delimiter = T("delimiter", S"(){}[];,") + +local operator = T("operator", S"!%^&*-+=|:.<>?~") + +local keyword = T("keyword", l.word_match{ + "type", "fn", "match", "with", "if", "then", "else", "iff", "do", "for", "in", +}) + +local type_defs = l.word_match{ + "Unit", "Void", "Char", "Str", "Ptr", "Bool", +} +local type_cons = P"#" * #(S"({[") +local type_num = S"INF" * (dec^1 + P"size") * #(any - letter) +local type_ = T("type", type_defs + type_cons + type_num) + +local cons = T("cons", P"@" * (#(S"({[") + word)) + +local tick = P"`" * (any - S"`")^0 * P"`" +local identifier = T("identifier", word + tick) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"numlit", numlit}, + {"charlit", charlit}, + {"strlit", strlit}, + {"delimiter", delimiter}, + {"operator", operator}, + {"keyword", keyword}, + {"type", type_}, + {"cons", cons}, -- XXX + {"identifier", identifier}, + + {"error", T("error", any)}, -- TODO: TEMP +} + +M._tokenstyles = { + whitespace = l.STYLE_WHITESPACE, + + comment_text = l.STYLE_COMMENT, + comment_keyword = l.STYLE_COMMENT_KEYWORD, + + numlit = l.STYLE_NUMBER, + + escape = l.STYLE_ESCAPE, + bad_escape = l.STYLE_ERROR, + + charlit_delim = l.STYLE_NUMBER, + charlit_text = l.STYLE_NUMBER, + + strlit_delim = l.STYLE_STRING, + strlit_text = l.STYLE_STRING, + + delimiter = l.STYLE_DELIMITER, + operator = l.STYLE_OPERATOR, + + keyword = l.STYLE_KEYWORD, + ["type"] = l.STYLE_TYPE, + ["cons"] = l.STYLE_FUNCTION, -- XXX + identifier = l.STYLE_IDENTIFIER, +} + +return M diff --git a/vis/lexers/tex.lua b/vis/lexers/tex.lua @@ -0,0 +1,60 @@ +local M = {_NAME = "tex"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token +local any = P(1) +local function I(s) -- Case-insensitive string match + local p = P(true) + for i = 1, #s do + local c = s:sub(i, i) + p = p * (P(c:lower()) + P(c:upper())) + end + return p +end +local function N(p, min, max) + max = max or min + return p^min - p^(max+1) +end + +local whitespace = T("whitespace", S"\n\r\t "^1) + +local comment_keyword = T("comment_keyword", I"todo" + I"xxx" + I"fixme") +local comment_text = T("comment_text", (any - P"\n" - comment_keyword)^1) +local comment = T("comment_text", P"%") * (comment_text + comment_keyword)^0 * T("whitespace", P"\n") + +local upup = T("tex_upup", P"^^" * (N(R("09", "af"), 2) + any)) + +local delimiter = T("delimiter", S"{}") + +local math_ = T("tex_math", P"$") + +local operator = T("operator", S"^_~&" + (P"#" * (R"19" + P"#" + #P"{")) + P"---" + P"--") + +local command = T("function", P"\\") * (upup + T("function", (R("AZ", "az") + P"@")^1 + any)) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"tex_upup", upup}, + {"delimiter", delimiter}, + {"tex_math", math_}, + {"operator", operator}, + {"function", command}, +} + +M._tokenstyles = { + whitespace = l.STYLE_WHITESPACE, + + comment_text = l.STYLE_COMMENT, + comment_keyword = l.STYLE_COMMENT_KEYWORD, + + tex_upup = l.STYLE_ESCAPE, + delimiter = l.STYLE_DELIMITER, + tex_math = l.STYLE_STRING, + operator = l.STYLE_OPERATOR, + + ["function"] = l.STYLE_FUNCTION, +} + +return M diff --git a/vis/themes/custom.lua b/vis/themes/custom.lua @@ -0,0 +1,67 @@ +local l = vis.lexers + +local fg = ",fore:" +local bg = ",back:" +local bold = ",bold" +local ital = ",italics" + +-- Purposely horrendous, so that I can spot errors +local unknown = fg.."#ff0000" .. bg.."#0000ff" + +local default = "default" +local yell = "#a8c023" +local purp = "#ae81ff" +local khaki = "#d1c660" +local turq = "#008787" +local magen = "#c2215c" +local aqua = "#66D9ef" +local pink = "#ef76ca" +local lime = "#63cc12" +local lorange = "#b08070" +local dorange = "#604030" +local gray1 = "#979797" +local gray2 = "#808080" +local gray3 = "#595959" +local gray4 = "#424242" +local gray5 = "#2b2b2b" + +l.STYLE_DEFAULT = fg..default .. bg..default +l.STYLE_WHITESPACE = "" +l.STYLE_COMMENT = fg..gray2 +l.STYLE_COMMENT_KEYWORD = fg..yell .. bold +l.STYLE_NUMBER = fg..purp +l.STYLE_ESCAPE = fg..purp +l.STYLE_STRING = fg..khaki +l.STYLE_STRING_FORMAT = fg..purp +l.STYLE_REGEX = fg..khaki +l.STYLE_DELIMITER = fg..gray1 +l.STYLE_OPERATOR = fg..magen +l.STYLE_PREPROCESSOR = fg..turq +l.STYLE_PREPROCESSOR_CONDITIONAL = fg..turq .. bold +l.STYLE_KEYWORD = fg..magen .. bold +l.STYLE_CONSTANT = fg..purp +l.STYLE_TYPE = fg..aqua +l.STYLE_LABEL = fg..pink +l.STYLE_FUNCTION = fg..lime +l.STYLE_IDENTIFIER = "" +l.STYLE_VARIABLE = "" +l.STYLE_ERROR = unknown + +l.STYLE_LINENUMBER = fg..gray4 +l.STYLE_LINENUMBER_CURSOR = fg..gray3 +l.STYLE_CURSOR = bg..dorange +l.STYLE_CURSOR_PRIMARY = fg..gray5 .. bg..lorange .. bold +l.STYLE_COLOR_COLUMN = bg..gray5 +l.STYLE_SELECTION = bg..gray4 +l.STYLE_STATUS = fg..gray4 +l.STYLE_STATUS_FOCUSED = fg..gray3 .. bold +l.STYLE_EOF = fg..gray4 +l.STYLE_INFO = fg..yell + +l.STYLE_NOTHING = unknown +l.STYLE_CLASS = unknown +l.STYLE_DEFINITION = unknown +l.STYLE_TAG = unknown +l.STYLE_EMBEDDED = unknown +l.STYLE_CURSOR_LINE = unknown +l.STYLE_SEPARATOR = unknown diff --git a/vis/visrc.lua b/vis/visrc.lua @@ -0,0 +1,86 @@ +require('vis') + +-- Vis bug?: <C-M-Down> != <M-C-Down> and similarly for Up + +local modes = vis.modes +local events = vis.events + +-- Filetype-specific configuration +local ftrun = nil -- TODO +local ftcomment = nil + +events.subscribe(events.INIT, function() + vis.ftdetect.filetypes.mp = {ext = {"%.mp$"}} + vis.ftdetect.filetypes.suq = {ext = {"%.suq$"}} + vis:command("set theme custom") +end) + +events.subscribe(events.WIN_OPEN, function(win) + vis:command("set relativenumber") + vis:command("set tabwidth 4") + vis:command("set cc 80") + vis:command("set autoindent") + + -- qq to record and Q to reply + vis:command("map! normal Q @q") + + -- Indent and unindent + vis:command("map! normal <Tab> >>") + vis:command("map! normal <S-Tab> <<") + vis:command("map! visual <Tab> >") + vis:command("map! visual <S-Tab> <") + vis:command("map! visual-line <Tab> >") + vis:command("map! visual-line <S-Tab> <") + + -- Create new cursors + vis:command("map! normal <C-Up> <C-k>") + vis:command("map! normal <C-Down> <C-j>") + + -- Scroll 5 lines at a time without moving cursor + vis:command("map! normal <M-C-Up> <C-y><C-y><C-y><C-y><C-y>") + vis:command("map! normal <M-C-Down> <C-e><C-e><C-e><C-e><C-e>") + vis:command("map! insert <M-C-Up> <C-x><C-y><C-x><C-y><C-x><C-y><C-x><C-y><C-x><C-y>") + vis:command("map! insert <M-C-Down> <C-x><C-e><C-x><C-e><C-x><C-e><C-x><C-e><C-x><C-e>") + + -- Jump around block + vis:command("map! normal <S-Up> {") + vis:command("map! normal <S-Down> }") + vis:command("map! visual-line <S-Up> {") + vis:command("map! visual-line <S-Down> }") + + -- Commenting + vis:map(modes.NORMAL, "<C-/>", function() + if ftcomment == nil then + vis:info("Commenting not implemented for this filetype") + return + end + vis:command("x/") + local sel = vis.win.selection + local pos = sel.pos + vis.win.file:insert(sel.pos - sel.col + 1, ftcomment .. " ") + sel.pos = pos + #ftcomment + 1 + end) +-- vis:map(modes.NORMAL, "<C-/>", function() +-- if ftcomment == nil then +-- vis:info("Commenting not implemented for this filetype") +-- return +-- end +-- local sel = vis.win.selection +-- local pos = sel.pos +-- vis.win.file:insert(sel.pos - sel.col + 1, ftcomment .. " ") +-- sel.pos = pos + #ftcomment + 1 +-- end) +end) + +events.subscribe(events.WIN_OPEN, function(win) + local fttab = { + lua = { + comment = "--" + } + } + + local ft = fttab[win.syntax] + if ft == nil then return end + + ftcomment = ft.comment +end)