2023-01-10 02:38:06 +01:00
|
|
|
local A = require("my.abbreviations")
|
|
|
|
local scrap = require("scrap")
|
|
|
|
|
2023-11-11 06:55:14 +01:00
|
|
|
require("my.helpers.wrapMovement").enable()
|
2023-01-10 02:38:06 +01:00
|
|
|
|
|
|
|
vim.opt.conceallevel = 0
|
|
|
|
|
|
|
|
-- vim.opt.foldcolumn = "1"
|
2023-11-04 18:58:09 +01:00
|
|
|
-- vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
|
|
|
-- vim.opt.foldmethod = "expr"
|
2023-01-10 02:38:06 +01:00
|
|
|
|
2023-07-06 21:34:24 +02:00
|
|
|
-- {{{ Older functions for calculating things inside vim
|
2023-01-10 02:38:06 +01:00
|
|
|
-- vim.keymap.set("n", "<leader>lg", function()
|
|
|
|
-- if not pcall(function()
|
|
|
|
-- local a = tonumber(vim.fn.input("A: "))
|
|
|
|
-- local b = tonumber(vim.fn.input("B: "))
|
|
|
|
--
|
|
|
|
-- local g, x, y = require("my.helpers.math.mod").gcd(a, b)
|
|
|
|
--
|
|
|
|
-- vim.fn.input("Result: " .. g .. " " .. x .. " " .. y)
|
|
|
|
-- end) then vim.fn.input("No results exist") end
|
|
|
|
-- end, { buffer = true, desc = "Gcd calculator" })
|
|
|
|
--
|
|
|
|
-- vim.keymap.set("n", "<leader>li", function()
|
|
|
|
-- if not pcall(function()
|
|
|
|
-- local class = tonumber(vim.fn.input("Mod class: "))
|
|
|
|
-- local num = tonumber(vim.fn.input("Number: "))
|
|
|
|
--
|
|
|
|
-- vim.fn.input("Result: " .. require("my.helpers.math.mod").modinverse(num, class))
|
|
|
|
-- end) then vim.fn.input("No results exist") end
|
|
|
|
-- end, { buffer = true, desc = "Mod inverse calculator" })
|
2023-07-06 21:34:24 +02:00
|
|
|
-- }}}
|
2023-01-10 02:38:06 +01:00
|
|
|
|
|
|
|
local abbreviations = {
|
2023-09-18 02:15:13 +02:00
|
|
|
-- Other fancy symvols
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "tmat", "^T" }, -- Tranpose of a matrix
|
|
|
|
{ "cmat", "^*" }, -- Conjugate of a matrix
|
|
|
|
{ "sneg", "^C" }, -- Set complement
|
|
|
|
{ "ortco", "^\\bot" }, -- Orthogonal complement
|
2023-09-28 02:13:35 +02:00
|
|
|
{ "sinter", "^\\circ" }, -- Interior of a set
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "nuls", "\\varnothing" },
|
2023-01-10 02:38:06 +01:00
|
|
|
|
|
|
|
-- Basic commands
|
|
|
|
{ "mangle", "\\measuredangle" },
|
|
|
|
{ "aangle", "\\angle" },
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "sdiff", "\\setminus" },
|
|
|
|
{ "sst", "\\subset" },
|
|
|
|
{ "spt", "\\supset" },
|
|
|
|
{ "sseq", "\\subseteq" },
|
|
|
|
{ "speq", "\\supseteq" },
|
|
|
|
{ "nin", "\\not\\in" },
|
|
|
|
{ "iin", "\\in" },
|
|
|
|
{ "tto", "\\to" },
|
|
|
|
{ "land", "\\land" },
|
|
|
|
{ "lor", "\\lor" },
|
|
|
|
{ "ssin", "\\sin" },
|
|
|
|
{ "ccos", "\\cos" },
|
|
|
|
{ "ttan", "\\ttan" },
|
|
|
|
{ "ssec", "\\sec" },
|
|
|
|
{ "lln", "\\ln" },
|
|
|
|
{ "frl", "\\forall" },
|
|
|
|
{ "exs", "\\exists" },
|
|
|
|
{ "iinf", "\\infty" },
|
|
|
|
{ "ninf", "-\\infty" },
|
|
|
|
{ "nlnl", "\\pm" }, -- had this as npnp first but it was hard-ish to type
|
|
|
|
{ "ccup", "\\cup" },
|
|
|
|
{ "ccap", "\\cap" },
|
|
|
|
{ "nope", "\\bot" },
|
|
|
|
{ "yee", "\\top" },
|
|
|
|
{ "ccan", "\\cancel" },
|
|
|
|
{ "com", "\\circ" },
|
|
|
|
{ "mul", "\\cdot" },
|
|
|
|
{ "smul", "\\times" },
|
|
|
|
{ "card", "\\#" },
|
|
|
|
{ "div", "\\|" },
|
|
|
|
{ "ndiv", "\\not\\|\\:" },
|
|
|
|
{ "perp", "\\perp" },
|
|
|
|
{ "cdots", "\\cdots" }, -- center dots
|
|
|
|
{ "ldots", "\\ldots" }, -- low dots
|
2023-11-04 18:58:09 +01:00
|
|
|
{ "cldots", ",\\ldots," }, -- comma, low dots
|
2023-11-21 16:14:55 +01:00
|
|
|
{ "frac", "\\frac" }, -- fraction
|
|
|
|
{ "lim", "\\lim" }, -- Limit
|
|
|
|
{ "sup", "\\sup" }, -- supremum
|
|
|
|
{ "limsup", "\\lim\\sup" }, -- Limit of the supremum
|
|
|
|
{ "cal", "\\mathcal" }, -- Limit of the supremum
|
2023-09-18 02:15:13 +02:00
|
|
|
|
2023-10-04 17:26:06 +02:00
|
|
|
-- Decorations
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "hat", "\\hat" },
|
|
|
|
{ "bar", "\\bar" },
|
2023-10-04 17:26:06 +02:00
|
|
|
|
2023-09-18 02:15:13 +02:00
|
|
|
-- Custom commands
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "abs", "\\abs" }, -- custom abs command
|
|
|
|
{ "norm", "\\norm" }, -- custom norm command
|
|
|
|
{ "iprod", "\\iprod" }, -- custom inner product command
|
2023-07-06 21:34:24 +02:00
|
|
|
{ "diprod", "\\dprod" }, -- custom self inner product command
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "prob", "\\prob" }, -- custom probability function
|
|
|
|
{ "dist", "\\dist" }, -- custom dist function
|
2023-11-27 00:15:03 +01:00
|
|
|
{ "oball", "\\ball" }, -- custom ball function
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "diam", "\\diam" }, -- custom diam operator
|
|
|
|
{ "gen", "\\gen" }, -- custom command for group generated by element
|
|
|
|
{ "ord", "\\ordop" }, -- order of a group
|
|
|
|
{ "vsm", "\\vecspace" }, -- custom math vector space
|
2023-11-21 16:13:27 +01:00
|
|
|
{ "half", "\\half" }, -- 1/2 fraction
|
2023-01-10 02:38:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
-- Todo: convert exponents and subscripts
|
|
|
|
-- to use this more concise notation.
|
|
|
|
local abolishAbbreviations = {
|
2023-09-19 14:07:18 +02:00
|
|
|
-- {{{ General phrases
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "thrf", "therefore" },
|
|
|
|
{ "bcla", "by contradiction let's assume" },
|
|
|
|
{ "wlg", "without loss of generality" },
|
|
|
|
{ "tits", "that is to say," },
|
|
|
|
{ "wpbd", "we will prove the statement in both directions." },
|
|
|
|
{ "stam{,s}", "statement{}" },
|
2023-09-28 02:13:35 +02:00
|
|
|
{ "{ww,tt}{m,i}", "{which,this} {means,implies}" },
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "cex{,s}", "counterexample{}" },
|
|
|
|
{ "er{t,s,r}", "{transitivity,symmetry,reflexivity}" },
|
2023-09-19 14:07:18 +02:00
|
|
|
-- }}}
|
2023-10-04 17:26:06 +02:00
|
|
|
-- {{{ Exponents and subscripts:
|
|
|
|
-- {operation}{argument}
|
|
|
|
-- - operation = e (exponent) | s (subscript)
|
|
|
|
-- - argument = t{special} | {basic}
|
|
|
|
-- - basic = 0-9|n|i|t|k
|
|
|
|
-- - special =
|
|
|
|
-- - "p" => +
|
|
|
|
-- - "m" => -
|
|
|
|
-- - "i" => -1
|
|
|
|
{
|
|
|
|
"{e,s}{{0,1,2,3,4,5,6,7,8,9,n,i,t,k},t{i,m,p}}",
|
|
|
|
"{^,_}{{},{\\{-1\\},-,+}}",
|
|
|
|
options = A.no_capitalization,
|
|
|
|
},
|
|
|
|
-- }}}
|
|
|
|
-- {{{ Special chars
|
|
|
|
-- System for writing special characters which need to also be easly
|
|
|
|
-- accessible as {sub/super}scripts.
|
|
|
|
--
|
|
|
|
-- The reason epsilon and lambda are separated out from everything else in
|
|
|
|
-- the pattern is because they are the only ones where `foo` doesn't expand
|
|
|
|
-- to `\\foo` directly (so I saved some keystrokes by letting scrap.nvim
|
|
|
|
-- repeat everything for me).
|
|
|
|
{
|
2023-11-04 18:58:09 +01:00
|
|
|
"{,e,s}{{eps,lam},{star,delta,Delta,pi,tau,psi,phi,rho,sigma,alpha,beta,theta,gamma,omega,Omega}}",
|
2023-10-04 17:26:06 +02:00
|
|
|
"{,^,_}\\\\{{epsilon,lambda},{}}",
|
|
|
|
options = A.no_capitalization,
|
|
|
|
},
|
|
|
|
-- }}}
|
|
|
|
-- {{{ My own operator syntax:
|
|
|
|
-- - Any operator can be prefixed with "a" to
|
|
|
|
-- align in aligned mode
|
|
|
|
-- - Any operator can be prefixed with cr to
|
|
|
|
-- start a new line and align in aligned mode
|
|
|
|
{
|
|
|
|
"{cr,a,}{eq,neq,leq,geq,lt,gt,iff,iip,iib}",
|
|
|
|
"{\\\\\\&,&,}{=,\\neq,\\leq,\\geq,<,>,\\iff,\\implies,\\impliedby}",
|
|
|
|
options = A.no_capitalization,
|
|
|
|
},
|
|
|
|
-- }}}
|
|
|
|
-- {{{ Set symbols
|
|
|
|
-- - nats => naturals
|
|
|
|
-- - ints => integers
|
|
|
|
-- - rats => rationals
|
|
|
|
-- - irats => irationals
|
|
|
|
-- - rrea => reals
|
|
|
|
-- - comp => complex
|
|
|
|
-- - ppri => primes
|
|
|
|
-- - ffie => fields
|
|
|
|
{
|
|
|
|
"{nats,ints,rats,irats,rrea,comp,ppri,ffie}",
|
|
|
|
"\\mathbb\\{{N,Z,Q,I,R,C,P,F}\\}",
|
|
|
|
options = A.no_capitalization,
|
|
|
|
},
|
|
|
|
-- }}}
|
|
|
|
-- {{{ General function calls:
|
|
|
|
-- {function-name}{modifier?}{argument}{argument-modifier?}
|
|
|
|
--
|
|
|
|
-- - function-name = f/g/h/P
|
|
|
|
-- - modifier:
|
|
|
|
-- - d => derivative
|
|
|
|
-- - 2 => squared
|
|
|
|
-- - 3 => cubed
|
|
|
|
-- - i => inverse
|
|
|
|
-- - argument = x/y/z/a/t/i/n/k
|
|
|
|
-- - argument-modifier:
|
|
|
|
-- - n => subscript n
|
|
|
|
{
|
|
|
|
"{f,g,h,P}{d,2,3,i,}{x,y,z,a,t,i,n,k}{n,}",
|
|
|
|
"{}{',^2,^3,^\\{-1\\},}({}{_n,})",
|
|
|
|
},
|
|
|
|
-- }}}
|
2023-09-19 14:07:18 +02:00
|
|
|
-- {{{ Calculus & analysis
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "ib{p,s}", "integration by {parts,substitution}" },
|
|
|
|
{ "nb{,h}{,s}", "neighbour{,hood}{}" },
|
2023-09-19 14:07:18 +02:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Linear algebra
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "rref", "reduced row echalon form" },
|
2023-01-10 02:38:06 +01:00
|
|
|
{ "eg{va,ve,p}{,s}", "eigen{value,vector,pair}{}" },
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "mx{,s}", "matri{x,ces}" },
|
|
|
|
{ "dete{,s}", "determinant{}" },
|
|
|
|
{ "ort{n,g}", "orto{normal,gonal}" },
|
|
|
|
{ "l{in,de}", "linearly {independent,dependent}" },
|
|
|
|
{ "lcon{,s}", "linear combination{}" },
|
|
|
|
{ "vst{,s}", "vector space{}" }, -- text vector space
|
2023-04-03 03:06:51 +02:00
|
|
|
{
|
2023-11-11 06:55:14 +01:00
|
|
|
"rizz", -- ok please ignore this one 💀
|
2023-04-03 03:06:51 +02:00
|
|
|
"Riesz vector",
|
|
|
|
options = A.no_capitalization,
|
|
|
|
},
|
2023-09-19 14:07:18 +02:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Linear systems
|
2023-04-17 22:33:56 +02:00
|
|
|
-- Note: we must add the space inside the {} in order for capitalization to work!
|
2023-09-10 17:20:36 +02:00
|
|
|
{
|
|
|
|
"{{s,o,l},}deq{s,}",
|
|
|
|
"{{scalar,ordinary,linear} ,}differential equation{}",
|
|
|
|
},
|
2023-09-19 14:07:18 +02:00
|
|
|
-- }}}
|
|
|
|
-- {{{ Graph theory
|
2023-11-11 06:55:14 +01:00
|
|
|
{ "vx{,s}", "vert{ex,ices}" },
|
2023-09-19 14:07:18 +02:00
|
|
|
{ "edg{,s}", "edge{}" },
|
2023-04-17 22:33:56 +02:00
|
|
|
|
2023-01-22 01:22:38 +01:00
|
|
|
-- Graph theory function syntax:
|
|
|
|
-- gt[function]{graph}{modifier}
|
|
|
|
-- - function:
|
|
|
|
-- - basic functions: e/E/v/G/L
|
|
|
|
-- - k => connectivity
|
|
|
|
-- - a => size of the biggest stable set
|
|
|
|
-- - w => size of the biggest clique
|
|
|
|
-- - d => biggest degree
|
|
|
|
-- - c{target}{kind} => {target} {kind} chromatic number
|
|
|
|
-- - target:
|
|
|
|
-- - vertices by default
|
|
|
|
-- - e => edges
|
|
|
|
-- - kind:
|
|
|
|
-- - normal by default
|
|
|
|
-- - l => list
|
|
|
|
-- - graph:
|
|
|
|
-- - G by default
|
|
|
|
-- - s/x/y/h => S/X/Y/H
|
|
|
|
-- - modifier:
|
|
|
|
-- - a => '
|
|
|
|
-- - 1/2 => _k
|
|
|
|
{
|
|
|
|
"gt{{e,E,v,V,L},k,a,w,d,md{,e},c{,e}{,l}}{,s,h,x,y}{,a,1,2}",
|
|
|
|
"{{},\\kappa,\\alpha,\\omega,\\Delta,\\delta{,'},\\chi{,'}{,_l}}({G,S,H,X,Y}{,',_1,_2})",
|
2023-03-14 20:57:07 +01:00
|
|
|
options = A.no_capitalization,
|
2023-01-22 01:22:38 +01:00
|
|
|
},
|
2023-09-19 14:07:18 +02:00
|
|
|
-- }}}
|
2023-01-10 02:38:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
local expanded = scrap.expand_many(abolishAbbreviations)
|
|
|
|
|
2023-11-21 16:14:55 +01:00
|
|
|
-- Last I checked this contained 1229 abbreviations
|
2023-07-06 21:34:24 +02:00
|
|
|
-- print(#abbreviations + #expanded)
|
|
|
|
|
2023-01-10 02:38:06 +01:00
|
|
|
A.manyLocalAbbr(abbreviations)
|
|
|
|
A.manyLocalAbbr(expanded)
|
|
|
|
|
2023-01-22 01:22:38 +01:00
|
|
|
vim.keymap.set(
|
|
|
|
"n",
|
|
|
|
"<leader>lc",
|
|
|
|
"<cmd>VimtexCompile<cr>",
|
|
|
|
{ desc = "Compile current buffer using vimtex", buffer = true }
|
|
|
|
)
|
2023-04-17 22:33:56 +02:00
|
|
|
|
2023-04-19 22:31:43 +02:00
|
|
|
vim.opt_local.list = false -- The lsp usese tabs for formatting
|