dotfiles

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

commit 7a56fe02cce8159568a870508811723bcec66780
parent b1c457cf6b04fc4d0186998787b675c93dd032aa
Author: Robert Russell <robert@rr3.xyz>
Date:   Sun, 22 Sep 2024 14:40:35 -0700

Update

Diffstat:
M.bashrc | 3++-
M.profile | 5++++-
M.xinitrc | 4+++-
Mvis/lexers/ansi_c.lua | 11++++++-----
Avis/lexers/caml.lua | 134+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/lexers/haskell.lua | 148+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Avis/lexers/lean.lua | 24++++++++++++++++++++++++
Mvis/visrc.lua | 5+++++
8 files changed, 326 insertions(+), 8 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -3,7 +3,8 @@ alias ls='ls --color=auto' alias e=vis -alias o=zathura +alias o=xdg-open +alias ..='cd ..' PROMPT_COMMAND='PS1EXIT=$?;' # Store previous exit code in PS1EXIT PROMPT_COMMAND+='printf "\e[6n";' # Query cursor position (format: \e[<row>;<col>R) diff --git a/.profile b/.profile @@ -2,5 +2,8 @@ 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 PATH="$PATH:/home/rob/.cabal/bin:/opt/ats2/bin:/opt/idris2/bin:/home/rob/.elan/bin:/home/rob/go/bin" export PATSHOME="/opt/ats2/lib/ats2-postiats-0.4.2" + +# opam configuration +test -r /home/rob/.opam/opam-init/init.sh && . /home/rob/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true diff --git a/.xinitrc b/.xinitrc @@ -4,9 +4,11 @@ xkbdw sxkbm & [ -f ~/.Xresources ] && xrdb -merge ~/.Xresources xhost +local: +xrandr --output DisplayPort-1 --set TearFree on + while true; do statusupd; sleep 5; done & pipewire & pipewire-pulse & - +dunst & exec dwm diff --git a/vis/lexers/ansi_c.lua b/vis/lexers/ansi_c.lua @@ -29,11 +29,11 @@ end local whitespace = T("whitespace", ws^1) -local comment_keyword = T("comment_keyword", I"todo" + I"xxx" + I"fixme") +local comment_keyword = T("comment_keyword", (I"todo" + I"xxx" + I"fixme" + I"sync" + I"fallthrough" + I"unreachable") * #(any - letter)) 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 line_comment = T("comment_text", P"//") * (line_comment_text + comment_keyword)^0 * (T("whitespace", P"\n") + P"") 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 block_comment = T("comment_text", P"/*") * (block_comment_text + comment_keyword)^0 * T("comment_text", P"*/")^-1 local comment = line_comment + block_comment local fltlit_dec_exp = S"eE" * pm^-1 * dec^1 @@ -157,7 +157,7 @@ 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{ +local type_nice = P"__"^-1 * (P"v" * dec^1)^-1 * S"usifc" * dec^1 * (P"a" * dec^1)^-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) @@ -165,7 +165,8 @@ local type_ = T("type", type_builtin + type_std + type_stdint + type_nice + type local label = T("whitespace", hws^0) * T("label", word) * T("delimiter", P":") -local function_ = T("function", word) * T("whitespace", ws^0) * #P"(" +--local function_ = T("function", word) * T("whitespace", ws^0) * #P"(" +local function_ = T("function", word) * #P"(" local identifier = T("identifier", word) diff --git a/vis/lexers/caml.lua b/vis/lexers/caml.lua @@ -0,0 +1,134 @@ +local M = {_NAME = "caml"} + +local l = require("lexer") +local P, R, S, V = lpeg.P, lpeg.R, lpeg.S, lpeg.V +local T = l.token +local any = P(1) +local bin = R"01" +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 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 whitespace = T("whitespace", ws^1) + +local comment_keyword = T("comment_keyword", (I"todo" + I"xxx" + I"fixme") * #(any - letter)) +local comment_text = T("comment_text", (any - comment_keyword - P"(*" - P"*)")^1) +local comment_open = T("comment_text", P"(*") +local comment_close = T("comment_text", P"*)") +local comment = P{comment_open * (comment_text + comment_keyword + V(1))^0 * comment_close^-1} + +local intlit_bin = P"0" * S"Bb" * bin * (bin + "_")^0 +local intlit_oct = P"0" * S"Oo" * oct * (oct + "_")^0 +local intlit_dec = dec * (dec + "_")^0 +local intlit_hex = P"0" * S"Xx" * hex * (hex + "_")^0 +local intlit_suffix = P"l" + P"L" + P"n" +local intlit = (intlit_bin + intlit_oct + intlit_dec + intlit_hex) * intlit_suffix^-1 + +-- TODO: fltlit +local numlit = T("numlit", intlit) + +local escape = + P"\\" * S"\\\"'nrtb " + + P"\\" * dec * dec * dec + + P"\\x" * hex * hex + + P"\\o" * oct * oct * oct +local bad_escape = T("bad_escape", P"\\" * any) + +local chrlit_escape = T("chrlit_escape", escape) +local chrlit_delim = T("chrlit_delim", P"'") +local chrlit_text = T("chrlit_text", any - vws - S"'\\") +local chrlit = chrlit_delim * (chrlit_text + chrlit_escape + bad_escape) + * chrlit_delim + +local strlit_escape = T("strlit_escape", + escape + P"\\u{" * hex^1 * P"}" + P"\\\n" * hws^0) +local strlit_delim = T("strlit_delim", P"\"") +local strlit_text = T("strlit_text", (any - vws - S"\"\\")^1) +local strlit = strlit_delim * (strlit_text + strlit_escape + bad_escape)^0 + * strlit_delim + +local delimiter = T("delimiter", S",;(){}") + +--[[ +local core_operator_char = S"$&*+-/=>@^|" +local operator_char = S"~!?%<:." + core_operator_char +local infix = (core_operator_char + S"%<") * operator_char^0 + + P"#" * operator_char^1 +local prefix = P"!" * operator_char^0 + S"?~" * operator_char^1 +local operator = T("operator", infix + prefix) +--]] +local operator = T("operator", S"$&*+-/=>@^|~!?%<:.#[]") + +local keyword = T("keyword", l.word_match{ + "and", "as", "assert", "asr", "begin", "class", + "constraint", "do", "done", "downto", "else", "end", + "exception", "external", "false", "for", "fun", "function", + "functor", "if", "in", "include", "inherit", "initializer", + "land", "lazy", "let", "lor", "lsl", "lsr", + "lxor", "match", "method", "mod", "module", "mutable", + "new", "nonrec", "object", "of", "open", "or", + "private", "rec", "sig", "struct", "then", "to", + "true", "try", "type", "val", "virtual", "when", + "while", "with" +}) + +local type_ = T("type", P"'" * word) + +local identifier = T("identifier", word * P"'"^0) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"numlit", numlit}, + {"chrlit", chrlit}, + {"strlit", strlit}, + {"delimiter", delimiter}, + {"operator", operator}, + {"keyword", keyword}, + {"type", type_}, + {"identifier", identifier}, + + {"error", T("error", any)}, -- TODO: TEMP +} + +M._tokenstyles = { + whitespace = l.STYLE_WHITESPACE, + + comment_keyword = l.STYLE_COMMENT_KEYWORD, + comment_text = l.STYLE_COMMENT, + + numlit = l.STYLE_NUMBER, + + bad_escape = l.STYLE_ERROR, + + chrlit_escape = l.STYLE_ESCAPE, + chrlit_delim = l.STYLE_NUMBER, + chrlit_text = l.STYLE_NUMBER, + + strlit_escape = l.STYLE_ESCAPE, + 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, + identifier = l.STYLE_IDENTIFIER, +} + +return M diff --git a/vis/lexers/haskell.lua b/vis/lexers/haskell.lua @@ -0,0 +1,148 @@ +local M = {_NAME = "haskell"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token + +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 + +-- Variables beginning with "hs_" are (subsets of) the official nonterminals in +-- the Haskell 2010 grammar of the same name. +local hs_special = S"(),;[]`{}" +local hs_whitechar = S" \t\n\r" +local hs_small = R"az" + P"_" + + P"Γ" + P"Δ" + P"Θ" + P"Λ" + P"Ξ" + P"Π" + P"Σ" + P"Φ" + P"Ψ" + P"Ω" + + P"α" + P"β" + P"γ" + P"δ" + P"ε" + P"ζ" + P"η" + P"θ" + P"ι" + P"κ" + + P"λ" + P"μ" + P"ν" + P"ξ" + P"ο" + P"π" + P"ρ" + P"σ" + P"τ" + P"υ" + + P"φ" + P"χ" + P"ψ" + P"ω" + P"ϵ" + P"ϑ" + P"ϰ" + P"ϖ" + P"ϱ" + P"ς" + + P"ϕ" +local hs_large = R"AZ" +local hs_symbol = S"!#$%&*+./<=>?@\\^|-~:" + + P"⋅" + + P"→" + P"↑" + P"←" + P"↓" + + P"⇒" + P"⇑" + P"⇐" + P"⇓" + + P"⊢" + P"⊥" + P"⊣" + P"⊤" + + P"─" + P"│" + P"┌" + P"┐" + P"└" + P"┘" + P"├" + P"┤" + P"┬" + P"┴" + P"┼" + P"╭" + P"╮" + P"╯" + P"╰" + P"╴" + P"╵" + P"╶" + P"╷" +local hs_digit = R"09" +local hs_octit = R"07" +local hs_hexit = R("09", "AF", "af") +local hs_graphic = hs_small + hs_large + hs_symbol + hs_digit + hs_special + S"\"'" +local hs_any = hs_graphic + S" \t" +local hs_ANY = hs_graphic + hs_whitechar +local letter = hs_small + hs_large + hs_digit + P"'" +local hs_reservedid = ( + P"case" + P"class" + P"data" + P"default" + P"deriving" + P"do" + P"else" + + P"foreign" + P"if" + P"import"+ P"infixl" + P"infixr" + P"infix" + + P"instance" + P"in" + P"let" + P"module" + P"newtype" + P"of" + + P"then" + P"type" + P"where" + P"_" + ) * #-letter +local hs_varid = hs_small * letter^0 - hs_reservedid +local hs_conid = hs_large * letter^0 +local hs_reservedop = + (P".." + P":" + P"::" + P"=" + P"\\" + P"<-" + P"->" + P"@" + P"~" + P"=>") * #-hs_symbol +local hs_varsym = (hs_symbol - P":") * hs_symbol^0 - hs_reservedop +local hs_consym = P":" * hs_symbol^0 - hs_reservedop +local ghc_keywords = (P"forall" + P"pattern" + P"family") * #-letter +local import_keywords = (P"qualified" + P"as" + P"hiding") * #-letter +local pragma = ( + P"INLINE" + P"NOINLINE" + P"SPECIALIZE" + P"SPECIALISE" + P"LANGUAGE" + + P"OPTIONS_GHC" + P"INCLUDE" + P"WARNING" + P"DEPRECATED" + + P"MINIMAL" + P"INLINABLE" + P"OPAQUE" + P"LINE" + P"COLUMN" + + P"RULES" + P"UNPACK" + P"NOUNPACK" + P"SOURCE" + P"COMPLETE" + + P"OVERLAPPING" + P"OVERLAPPABLE" + P"OVERLAPS" + P"INCOHERENT" + ) * #-letter + +local whitespace = T("whitespace", hs_whitechar^1) + +local comment_keyword = T("comment_keyword", (I"todo" + I"xxx" + I"fixme") * #(hs_ANY - R("09", "AZ", "az") - S"_'")) +local line_comment_text = T("comment_text", (hs_any - comment_keyword)^1) +local line_comment = T("comment_text", P"-"^2 * #(hs_ANY - hs_symbol)) * (line_comment_text + comment_keyword)^0 * (T("whitespace", P"\n") + P"") +local block_comment_text = T("comment_text", (hs_ANY - comment_keyword - P"{-" - P"-}")^1) +local block_comment = P{T("comment_text", P"{-" - P"{-#" * hs_whitechar^0 * pragma) * (block_comment_text + comment_keyword)^0 * T("comment_text", P"-}")^-1} +local comment = line_comment + block_comment + +local intlit_dec = hs_digit^1 +local intlit_oct = P"0" * S"oO" * hs_octit^1 +local intlit_hex = P"0" * S"xX" * hs_hexit^1 +local intlit = intlit_dec + intlit_oct + intlit_hex + +local fltlit_exp = S"eE" * S"+-"^-1 * hs_digit^1 +local fltlit = hs_digit^1 * (P"." * hs_digit^1 * fltlit_exp^-1 + fltlit_exp) + +local numlit = T("numlit", intlit + fltlit) + +local escape_char = S"abfnrtv\\\"'&" +local escape_ascii = P"^" * (R"AZ" + S"@[\\]^_") + -- It's important here that "SOH" precedes "SO"; it's the only ambiguous case. + + P"NUL" + P"SOH" + P"STX" + P"ETX" + P"EOT" + P"ENQ" + P"ACK" + + P"BEL" + P"BS" + P"HT" + P"LF" + P"VT" + P"FF" + P"CR" + P"SO" + P"SI" + P"DLE" + + P"DC1" + P"DC2" + P"DC3" + P"DC4" + P"NAK" + P"SYN" + P"ETB" + P"CAN" + + P"EM" + P"SUB" + P"ESC" + P"FS" + P"GS" + P"RS" + P"US" + P"SP" + P"DEL" +local escape_number = hs_digit^1 + P"o" * hs_octit^1 + P"x" * hs_hexit^1 +local escape = T("escape", P"\\" * (escape_char + escape_ascii + escape_number)) +local gap = T("escape", P"\\" * hs_whitechar^1 * P"\\") + +local chrlit_delim = T("chrlit_delim", P"'") +local chrlit_text = T("chrlit_text", hs_graphic - S"'\\" + P" ") +local chrlit = chrlit_delim * (chrlit_text + escape) * chrlit_delim + +local strlit_delim = T("strlit_delim", P"\"") +local strlit_text = T("strlit_text", (hs_graphic - S"\"\\" + P" ")^1) +local strlit = strlit_delim * (strlit_text + escape + gap)^0 * strlit_delim + +local delimiter = T("delimiter", P"{-#" + P"#-}" + hs_special) +local keyword = T("keyword", hs_reservedid + hs_reservedop + ghc_keywords + import_keywords + pragma) + +local qualifier = T("qualifier", (hs_conid * P".")^0) +local operator = qualifier * T("operator", hs_varsym + hs_consym) +local type_ = qualifier * T("type", hs_conid) +local identifier = qualifier * T("identifier", hs_varid) + +M._rules = { + {"whitespace", whitespace}, + {"comment", comment}, + {"numlit", numlit}, + {"chrlit", chrlit}, + {"strlit", strlit}, + {"delimiter", delimiter}, + {"keyword", keyword}, + {"operator", operator}, + {"type", type_}, + {"identifier", identifier}, + + {"error", T("error", P(1))}, -- 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, + + chrlit_delim = l.STYLE_NUMBER, + chrlit_text = l.STYLE_NUMBER, + + strlit_delim = l.STYLE_STRING, + strlit_text = l.STYLE_STRING, + + delimiter = l.STYLE_DELIMITER, + keyword = l.STYLE_KEYWORD, + + qualifier = l.STYLE_IDENTIFIER, + operator = l.STYLE_OPERATOR, + ["type"] = l.STYLE_TYPE, + identifier = l.STYLE_IDENTIFIER, +} + +return M diff --git a/vis/lexers/lean.lua b/vis/lexers/lean.lua @@ -0,0 +1,24 @@ +local M = {_NAME = "lean"} + +local l = require("lexer") +local P, R, S = lpeg.P, lpeg.R, lpeg.S +local T = l.token + +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 + +-- TODO + +M._rules = { +} + +M._tokenstyles = { +} + +return M diff --git a/vis/visrc.lua b/vis/visrc.lua @@ -12,6 +12,7 @@ local ftcomment = nil events.subscribe(events.INIT, function() vis.ftdetect.filetypes.mp = {ext = {"%.mp$"}} vis.ftdetect.filetypes.suq = {ext = {"%.suq$"}} + vis.ftdetect.filetypes.lean = {ext = {"%.lean$"}} vis:command("set theme custom") end) @@ -70,6 +71,10 @@ events.subscribe(events.WIN_OPEN, function(win) -- vis.win.file:insert(sel.pos - sel.col + 1, ftcomment .. " ") -- sel.pos = pos + #ftcomment + 1 -- end) + + if win.syntax == "haskell" or win.syntax == "lean" then + vis:command("set expandtab true") + end end) events.subscribe(events.WIN_OPEN, function(win)