initial commit
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
ls.add_snippets("lua", {
|
||||
s("hello", {
|
||||
t('print("hello '),
|
||||
i(1),
|
||||
t(' world")')
|
||||
}),
|
||||
|
||||
s("if", {
|
||||
t('if '),
|
||||
i(1, "true"),
|
||||
t(' then '),
|
||||
i(2),
|
||||
t(' end')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,284 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
ls.add_snippets("markdown", {
|
||||
s("date", {
|
||||
t("# "), f(function() return os.date("%y-%m-%d") end, {}),
|
||||
t({ "", "- " }),
|
||||
}),
|
||||
|
||||
-- s({
|
||||
-- trig = [[\v(https?://(?:www\.)?([-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b[-a-zA-Z0-9()@:%_\+.~#?&//=]*))]],
|
||||
-- regTrig = true,
|
||||
-- wordTrig = false,
|
||||
-- },
|
||||
-- fmt("[{}]({})", {
|
||||
-- f(function(_, snip) return snip.captures[2] end),
|
||||
-- f(function(_, snip) return snip.captures[1] end),
|
||||
-- })
|
||||
-- ),
|
||||
|
||||
s({
|
||||
trig = [[%f[%S](https?://([^/%s]+[^%s]*))]],
|
||||
regTrig = true,
|
||||
wordTrig = false,
|
||||
}, fmt("[{}]({})", {
|
||||
-- link text → host
|
||||
f(function(_, snip) return snip.captures[2] end),
|
||||
-- link target → full url
|
||||
f(function(_, snip) return snip.captures[1] end),
|
||||
}))
|
||||
|
||||
|
||||
})
|
||||
-- local ls = require('luasnip')
|
||||
-- local fmt = require('luasnip.extras.fmt').fmt
|
||||
-- local fmta = require('luasnip.extras.fmt').fmta
|
||||
-- local rep = require('luasnip.extras').rep
|
||||
-- local dl = require('luasnip.extras').dynamic_lambda
|
||||
-- local l = require('luasnip.extras').lambda
|
||||
-- local autosnippet = ls.extend_decorator.apply(s, { snippetType = 'autosnippet' })
|
||||
|
||||
-- -- some shorthands...
|
||||
-- local s = ls.snippet
|
||||
-- local n = ls.snippet_node
|
||||
-- local t = ls.text_node
|
||||
-- local i = ls.insert_node
|
||||
-- local f = ls.function_node
|
||||
-- local c = ls.choice_node
|
||||
-- local d = ls.dynamic_node
|
||||
|
||||
-- ls.config.set_config({
|
||||
-- history = true,
|
||||
-- -- treesitter-hl has 100, use something higher (default is 200).
|
||||
-- ext_base_prio = 200,
|
||||
-- -- minimal increase in priority.
|
||||
-- ext_prio_increase = 1,
|
||||
-- enable_autosnippets = true,
|
||||
-- store_selection_keys = '<Tab>',
|
||||
-- })
|
||||
|
||||
-- vim.keymap.set({ 'i', 's' }, '<C-l>', function()
|
||||
-- if ls.choice_active() then ls.change_choice(1) end
|
||||
-- end)
|
||||
|
||||
-- vim.keymap.set({ 'i', 's' }, '<C-h>', function()
|
||||
-- if ls.choice_active() then ls.change_choice(-1) end
|
||||
-- end)
|
||||
|
||||
-- local function get_line_iter(str)
|
||||
-- if str:sub(-1) ~= '\n' then str = str .. '\n' end
|
||||
|
||||
-- return str:gmatch('(.-)\n')
|
||||
-- end
|
||||
-- local function box_trim_lines(str)
|
||||
-- local new_str = ''
|
||||
|
||||
-- for line in get_line_iter(str) do
|
||||
-- line = line:gsub('^%s+', '')
|
||||
-- line = string.gsub(line, '%s+$', '')
|
||||
-- new_str = new_str .. '\n' .. line
|
||||
-- end
|
||||
|
||||
-- return new_str
|
||||
-- end
|
||||
|
||||
-- -- local return_filename = function()
|
||||
-- -- return vim.fn.fnamemodify(vim.fn.expand('%'), ':p')
|
||||
-- -- end
|
||||
|
||||
-- local return_filename = function()
|
||||
-- -- return vim.fn.fnamemodify(vim.fn.expand('%'), ':p')
|
||||
-- local filename = vim.fn.fnamemodify(vim.fn.expand('%'), ':p')
|
||||
-- local home_dir = vim.fn.expand('~')
|
||||
-- if filename:sub(1, #home_dir) == home_dir then filename = '~/' .. filename:sub(#home_dir + 2) end
|
||||
-- return filename
|
||||
-- end
|
||||
|
||||
-- local date = function() return { os.date('%Y-%m-%d') } end
|
||||
|
||||
-- local fulldate = function() return { os.date('%a, %b %Y/%m/%d - %H:%M:%S') } end
|
||||
|
||||
-- -- lua print(os.date("%a, %b %Y/%m/%d - %H:%M:%S"))
|
||||
|
||||
-- local get_visual = function(args, parent)
|
||||
-- if #parent.snippet.env.SELECT_RAW > 0 then
|
||||
-- return sn(nil, i(1, parent.snippet.env.SELECT_RAW))
|
||||
-- else -- If SELECT_RAW is empty, return a blank insert node
|
||||
-- return sn(nil, i(1))
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- local filename = function() return { vim.fn.expand('%:p') } end
|
||||
|
||||
-- local clipboard = function() return { vim.fn.getreg('+') } end
|
||||
|
||||
-- -- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
|
||||
-- local function bash(_, _, command)
|
||||
-- local file = io.popen(command, 'r')
|
||||
-- local res = {}
|
||||
-- for line in file:lines() do
|
||||
-- table.insert(res, line)
|
||||
-- end
|
||||
-- return res
|
||||
-- end
|
||||
|
||||
-- local function get_port_snip(args)
|
||||
-- if #args < 1 and not args[1][1] then return n(nil, t('hello world')) end
|
||||
|
||||
-- local type = args[1][1]
|
||||
-- local indent = ' '
|
||||
|
||||
-- if type == 'NodePort' or type == 'LoadBalancer' then
|
||||
-- return n(
|
||||
-- nil,
|
||||
-- fmt(
|
||||
-- box_trim_lines([[
|
||||
-- - port: {}
|
||||
-- {}targetPort: {}
|
||||
-- {}nodePort: {}
|
||||
-- ]]),
|
||||
-- {
|
||||
-- i(1, '30000'),
|
||||
-- indent,
|
||||
-- i(2, '80'),
|
||||
-- indent,
|
||||
-- i(3, '30000'),
|
||||
-- }
|
||||
-- )
|
||||
-- )
|
||||
-- end
|
||||
|
||||
-- if type == 'ClusterIP' then
|
||||
-- return n(
|
||||
-- nil,
|
||||
-- fmt(
|
||||
-- [[
|
||||
-- - port: {}
|
||||
-- {}targetPort: {}
|
||||
-- ]],
|
||||
-- {
|
||||
-- i(1, '30000'),
|
||||
-- indent,
|
||||
-- i(2, '80'),
|
||||
-- }
|
||||
-- )
|
||||
-- )
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- ls.add_snippets(nil, {
|
||||
|
||||
-- markdown = {
|
||||
-- s({
|
||||
-- trig = 'link',
|
||||
-- namr = 'markdown_link [selection]',
|
||||
-- dscr = 'Create markdown link [txt](url) Select description + TAB',
|
||||
-- }, {
|
||||
-- t('['),
|
||||
-- i(1),
|
||||
-- t(']('),
|
||||
-- d(2, get_visual),
|
||||
-- t(')'),
|
||||
-- i(0),
|
||||
-- }),
|
||||
|
||||
-- s({
|
||||
-- trig = 't',
|
||||
-- namr = 'check list',
|
||||
-- desc = 'Create item of a checklist',
|
||||
-- }, fmt('- [{}] {}', { c(2, { t(' '), t('-'), t('') }), i(1, 'task') })),
|
||||
|
||||
-- autosnippet(
|
||||
-- {
|
||||
-- trig = 'qw',
|
||||
-- name = 'trig',
|
||||
-- dscr = 'inline code',
|
||||
-- },
|
||||
-- fmt(
|
||||
-- [[
|
||||
-- `<>` <>
|
||||
-- ]],
|
||||
-- { d(1, get_visual), i(0) },
|
||||
-- { delimiters = '<>' }
|
||||
-- )
|
||||
-- ),
|
||||
|
||||
-- s({
|
||||
-- trig = 'code',
|
||||
-- namr = 'markdown_code_fenced',
|
||||
-- desc = 'code backsticks',
|
||||
-- priority = 2000,
|
||||
-- }, {
|
||||
-- t('```'),
|
||||
-- i(1, 'Lang'),
|
||||
-- t({ '', '' }),
|
||||
-- d(2, get_visual),
|
||||
-- t({ '', '```', '' }),
|
||||
-- i(0),
|
||||
-- }),
|
||||
|
||||
-- s({
|
||||
-- trig = 'meta',
|
||||
-- namr = 'Metadata',
|
||||
-- dscr = 'Yaml metadata format for markdown',
|
||||
-- }, {
|
||||
-- t({ '---', 'title: ' }),
|
||||
-- i(1, 'note_title'),
|
||||
-- t({ '', 'author: ' }),
|
||||
-- i(2, 'author'),
|
||||
-- t({ '', 'date: ' }),
|
||||
-- f(date, {}),
|
||||
-- t({ '', 'cathegories: [' }),
|
||||
-- i(3, ''),
|
||||
-- t({ ']', 'lastmod: ' }),
|
||||
-- f(date, {}),
|
||||
-- t({ '', 'tags: [' }),
|
||||
-- i(4),
|
||||
-- t({ ']', 'comments: true', '---', '' }),
|
||||
-- i(0),
|
||||
-- }),
|
||||
|
||||
-- s({
|
||||
-- trig = '_skel',
|
||||
-- namr = 'File_skeleton',
|
||||
-- dscr = 'File header (dynamic)',
|
||||
-- }, {
|
||||
-- t({ '---', 'File: ' }),
|
||||
-- f(return_filename, {}),
|
||||
-- t({ '', 'Last Change: ' }),
|
||||
-- f(fulldate, {}),
|
||||
-- t({ '', 'tags: [' }),
|
||||
-- i(1),
|
||||
-- t({ ']', '---', '' }),
|
||||
-- i(0),
|
||||
-- }),
|
||||
-- },
|
||||
-- })
|
||||
@@ -0,0 +1,79 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
ls.add_snippets("nix", {
|
||||
s("flake-devshell", fmta([[
|
||||
{
|
||||
description = "A flake indeed";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||
in {
|
||||
packages.x86_64-linux = {
|
||||
hello = pkgs.hello;
|
||||
default = pkgs.hello;
|
||||
};
|
||||
|
||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||
packages = [
|
||||
pkgs.hello
|
||||
pkgs.zsh
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export SHELL=${pkgs.zsh}/bin/zsh
|
||||
exec $SHELL
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
<>
|
||||
]], {i(1)}, {
|
||||
indent_string = ""
|
||||
})),
|
||||
|
||||
s("nix-default", fmta([[
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
<>
|
||||
}
|
||||
]], {i(1)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
|
||||
})
|
||||
@@ -0,0 +1,801 @@
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local isn = ls.indent_snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local events = require("luasnip.util.events")
|
||||
local ai = require("luasnip.nodes.absolute_indexer")
|
||||
local extras = require("luasnip.extras")
|
||||
local l = extras.lambda
|
||||
local rep = extras.rep
|
||||
local p = extras.partial
|
||||
local m = extras.match
|
||||
local n = extras.nonempty
|
||||
local dl = extras.dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local conds = require("luasnip.extras.expand_conditions")
|
||||
local postfix = require("luasnip.extras.postfix").postfix
|
||||
local types = require("luasnip.util.types")
|
||||
local parse = require("luasnip.util.parser").parse_snippet
|
||||
local ms = ls.multi_snippet
|
||||
local k = require("luasnip.nodes.key_indexer").new_key
|
||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
||||
|
||||
ls.filetype_extend("plaintex", {"tex"})
|
||||
|
||||
local get_visual = function(args, parent)
|
||||
if (#parent.snippet.env.LS_SELECT_RAW > 0) then
|
||||
return sn(nil, i(1, parent.snippet.env.LS_SELECT_RAW))
|
||||
else -- If LS_SELECT_RAW is empty, return a blank insert node
|
||||
return sn(nil, i(1))
|
||||
end
|
||||
end
|
||||
|
||||
local in_mathzone = function()
|
||||
-- The `in_mathzone` function requires the VimTeX plugin
|
||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
||||
end
|
||||
|
||||
-- exampe of a multiline snippet
|
||||
|
||||
-- ls.add_snippets("tex", {
|
||||
-- s("template", fmta([[
|
||||
-- <> <>
|
||||
-- ]], {i(1), i(0)}, {
|
||||
-- indent_string = ""
|
||||
-- }))
|
||||
-- })
|
||||
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("template", fmta([[
|
||||
\documentclass[11pt]{article}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{listings}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{parskip}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{bookmark}
|
||||
\usepackage[linguistics]{forest}
|
||||
\usepackage{tikz}
|
||||
\usepackage{float}
|
||||
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsthm}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{enumitem}
|
||||
|
||||
\usepackage{import}
|
||||
\usepackage{pdfpages}
|
||||
\usepackage{transparent}
|
||||
\usepackage{xcolor}
|
||||
|
||||
\newtheorem{all}{Theorem}[section]
|
||||
\newtheorem{corollary}[all]{Corollary}
|
||||
\newtheorem{lemma}[all]{Lemma}
|
||||
\newtheorem{definition}[all]{Definition}
|
||||
\newtheorem{exercise}[all]{Exercise}
|
||||
\newtheorem{proposition}[all]{Proposition}
|
||||
\newtheorem{example}[all]{Example}
|
||||
\newtheorem{theorem}{Theorem}
|
||||
|
||||
\newenvironment{lecture}[1]{
|
||||
\t\section{\MakeUppercase{#1}}
|
||||
\t\vspace{-0.5em}
|
||||
\t\hrule
|
||||
\t\vspace{1em}
|
||||
\t\begin{list}{}{
|
||||
\t\t\setlength{\leftmargin}{1.5em}
|
||||
\t}
|
||||
\t\item[]
|
||||
}{
|
||||
\t\end{list}
|
||||
}
|
||||
|
||||
\title{<>}
|
||||
\author{Jake Ginesin}
|
||||
\date{}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
<>
|
||||
\end{document}
|
||||
]], {i(1), i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("template-math", fmta([[
|
||||
\documentclass[11pt]{article}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsthm}
|
||||
\usepackage{fullpage}
|
||||
\usepackage{listings}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{parskip}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{bookmark}
|
||||
\usepackage[linguistics]{forest}
|
||||
\usepackage{tikz}
|
||||
\usepackage{float}
|
||||
|
||||
\usepackage{enumitem}
|
||||
\usepackage{euler}
|
||||
\usepackage{libertine}
|
||||
|
||||
\usepackage{import}
|
||||
\usepackage{pdfpages}
|
||||
\usepackage{transparent}
|
||||
\usepackage{xcolor}
|
||||
|
||||
\newtheoremstyle{definitionstyle}
|
||||
{}
|
||||
{}
|
||||
{\normalfont}
|
||||
{}
|
||||
{\bfseries}
|
||||
{:}
|
||||
{0.5em}
|
||||
{}
|
||||
|
||||
\theoremstyle{definitionstyle}
|
||||
\newtheorem{definition}{Definition}[section]
|
||||
|
||||
\newtheorem{all}{Theorem}[section]
|
||||
\newtheorem{corollary}[all]{Corollary}
|
||||
\newtheorem{lemma}[all]{Lemma}
|
||||
\newtheorem{exercise}[all]{Exercise}
|
||||
\newtheorem{proposition}[all]{Proposition}
|
||||
\newtheorem{example}[all]{Example}
|
||||
\newtheorem{theorem}{Theorem}
|
||||
|
||||
\title{<>}
|
||||
\author{Jake Ginesin}
|
||||
\date{}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
<>
|
||||
\end{document}
|
||||
]], {i(1), i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("template-report", fmta([[
|
||||
\documentclass[10pt]{article}
|
||||
\usepackage{graphicx} % Required for inserting images
|
||||
\usepackage[margin=1in]{geometry}
|
||||
\usepackage[dvipsnames]{xcolor}
|
||||
\usepackage{url}
|
||||
\usepackage{amssymb}
|
||||
\usepackage{amsmath}
|
||||
\usepackage{amsthm}
|
||||
\usepackage{fullpage}
|
||||
\usepackage{listings}
|
||||
\usepackage[utf8]{inputenc}
|
||||
\usepackage{parskip}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{bookmark}
|
||||
\usepackage[linguistics]{forest}
|
||||
\usepackage{tikz}
|
||||
\usepackage{float}
|
||||
|
||||
\usepackage[minted,skins]{tcolorbox} % 'skins' needed for shadows
|
||||
|
||||
% Define a new command \rustshadowfile that replaces \rustfile
|
||||
\newtcbinputlisting{\rustshadowfile}[2][]{%
|
||||
listing engine=minted,
|
||||
minted language=rust,
|
||||
minted options={linenos, numbersep=5pt, fontsize=\footnotesize, baselinestretch=1.05},
|
||||
listing file={#2}, % The file to read
|
||||
enhanced, % Enable skins for shadows
|
||||
drop shadow, % Add the shadow
|
||||
colback=white, % Background color
|
||||
colframe=black!70, % Border color
|
||||
boxrule=0.5pt, % Border width
|
||||
arc=2pt, % Rounded corners (optional)
|
||||
listing only, % Display code only (no title bar inside box)
|
||||
#1 % Pass extra options like labels
|
||||
}
|
||||
|
||||
\newtcblisting{rustcode}[1][]{
|
||||
listing engine=minted,
|
||||
minted language=rust,
|
||||
minted options={linenos, numbersep=5pt, fontsize=\footnotesize, baselinestretch=1.05},
|
||||
enhanced,
|
||||
drop shadow, % Adds the shadow
|
||||
colback=white, % Background color
|
||||
colframe=black!70,% Border color
|
||||
boxrule=0.5pt, % Border width
|
||||
arc=2pt, % Rounded corners
|
||||
listing only, % Hides the internal tcolorbox title bar
|
||||
#1 % Allows passing extra options
|
||||
}
|
||||
|
||||
% \usepackage{enumitem}
|
||||
% \usepackage{euler}
|
||||
% \usepackage{libertine}
|
||||
|
||||
\usepackage{import}
|
||||
\usepackage{pdfpages}
|
||||
\usepackage{transparent}
|
||||
|
||||
\newtheoremstyle{definitionstyle}
|
||||
{}
|
||||
{}
|
||||
{\normalfont}
|
||||
{}
|
||||
{\bfseries}
|
||||
{:}
|
||||
{0.5em}
|
||||
{}
|
||||
|
||||
\theoremstyle{definitionstyle}
|
||||
\newtheorem{definition}{Definition}[section]
|
||||
|
||||
\newtheorem{all}{Theorem}[section]
|
||||
\newtheorem{corollary}[all]{Corollary}
|
||||
\newtheorem{lemma}[all]{Lemma}
|
||||
\newtheorem{exercise}[all]{Exercise}
|
||||
\newtheorem{proposition}[all]{Proposition}
|
||||
\newtheorem{example}[all]{Example}
|
||||
\newtheorem{theorem}{Theorem}
|
||||
|
||||
\newcommand{\namedcomment}[3]{{\sf \scriptsize \color{#2} #1: #3}}
|
||||
\newcommand{\jake}[1]{\namedcomment{jake}{red}{#1}}
|
||||
\title{<>}
|
||||
\author{Jake Ginesin \and <>}
|
||||
\date{December 5th, 1999}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
|
||||
\end{document}
|
||||
]], {i(1), i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("beamer", fmta([[
|
||||
\documentclass{beamer}
|
||||
\usetheme{metropolis} % Use metropolis theme
|
||||
\title{<>}
|
||||
\date{\today}
|
||||
\author{Jacob Ginesin}
|
||||
\institute{<>}
|
||||
\begin{document}
|
||||
\maketitle
|
||||
\section{First Section}
|
||||
\begin{frame}{First Frame}
|
||||
Hello, world!
|
||||
\end{frame}
|
||||
\end{document}
|
||||
|
||||
]], {i(1), i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("beamer", fmta([[
|
||||
\documentclass{beamer}
|
||||
\usetheme{metropolis} % Use metropolis theme
|
||||
\title{<>}
|
||||
\date{\today}
|
||||
\author{Jacob Ginesin}
|
||||
\institute{<>}
|
||||
\begin{document}
|
||||
\maketitle
|
||||
\section{First Section}
|
||||
\begin{frame}{First Frame}
|
||||
Hello, world!
|
||||
\end{frame}
|
||||
\end{document}
|
||||
|
||||
]], {i(1), i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s("bib", fmta([[
|
||||
\bibliographystyle{plain}
|
||||
\bibliography{<>}
|
||||
]], {i(0)}, {
|
||||
indent_string = ""
|
||||
}))
|
||||
})
|
||||
|
||||
|
||||
-- ----
|
||||
|
||||
|
||||
ls.add_snippets("tex", {
|
||||
s({trig = "ita", dscr = "Expands 'tii' into LaTeX's textit{} command."},
|
||||
fmta("\\textit{<>}",
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({trig = "isc"},
|
||||
fmta("\\textsc{<>}",
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
s({trig = "frac"},
|
||||
fmta(
|
||||
"\\frac{<>}{<>}",
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
}
|
||||
),
|
||||
{condition = in_mathzone} -- `condition` option passed in the snippet `opts` table
|
||||
),
|
||||
|
||||
s({trig = "it"},
|
||||
fmta(
|
||||
"\\item ",
|
||||
{}
|
||||
), {} -- `condition` option passed in the snippet `opts` table
|
||||
),
|
||||
|
||||
s({trig="eq", dscr="Expands 'eq' into an equation environment"},
|
||||
fmta(
|
||||
[[
|
||||
\begin{equation*}
|
||||
<>
|
||||
\end{equation*}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s({trig="align", dscr="Expands 'eq' into an equation environment"},
|
||||
fmta(
|
||||
[[
|
||||
\begin{align*}
|
||||
<>
|
||||
\end{align*}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
s({trig="beg",
|
||||
-- snippetType="autosnippet"
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{<>}
|
||||
<>
|
||||
\end{<>}
|
||||
]],
|
||||
{
|
||||
i(1),
|
||||
i(2),
|
||||
rep(1), -- this node repeats insert node i(1)
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
s({trig="href", dscr="The hyperref package's href{}{} command (for url links)"},
|
||||
fmta(
|
||||
[[\href{<>}{<>}]],
|
||||
{
|
||||
i(1, "url"),
|
||||
i(2, "display name"),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({trig="([^%a])mk",
|
||||
snippetType="autosnippet",
|
||||
wordTrig = false,
|
||||
regTrig = true
|
||||
},
|
||||
fmta(
|
||||
"<>$<>$",
|
||||
{
|
||||
f( function(_, snip) return snip.captures[1] end ),
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({trig="mk",
|
||||
snippetType="autosnippet",
|
||||
wordTrig = false,
|
||||
regTrig = true
|
||||
},
|
||||
fmta(
|
||||
"<>$<>$",
|
||||
{
|
||||
f( function(_, snip) return snip.captures[1] end ),
|
||||
d(1, get_visual),
|
||||
}
|
||||
),
|
||||
{condition = line_begin}
|
||||
),
|
||||
|
||||
s({trig="([^%a])dm",
|
||||
snippetType="autosnippet",
|
||||
wordTrig = false,
|
||||
regTrig = true
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\[
|
||||
<>
|
||||
\]
|
||||
]],
|
||||
{
|
||||
-- f( function(_, snip) return snip.captures[1] end ),
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({trig="dm",
|
||||
snippetType="autosnippet",
|
||||
wordTrig = false,
|
||||
regTrig = true
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\[
|
||||
<>
|
||||
\]
|
||||
<>
|
||||
]],
|
||||
{
|
||||
-- f( function(_, snip) return snip.captures[1] end ),
|
||||
d(1, get_visual),
|
||||
i(0)
|
||||
}
|
||||
),
|
||||
{condition = line_begin}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "^^",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"^{<>}",
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "__",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"_{<>}",
|
||||
{
|
||||
i(1),
|
||||
}
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "sec",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\section{<>}
|
||||
\label{sec:<>}
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1, "section name"),
|
||||
i(2, "section label"),
|
||||
i(3),
|
||||
}
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "sub",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\subsection{<>}
|
||||
\label{sec:<>}
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1, "section name"),
|
||||
i(2, "section label"),
|
||||
i(0),
|
||||
}
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
ms({
|
||||
common = {snippetType = "autosnippet"},
|
||||
"!=",
|
||||
{trig = "neq", snippetType = "snippet"},
|
||||
},
|
||||
fmta(
|
||||
"\\neq ",
|
||||
{}
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
ms({
|
||||
common = {snippetType = "autosnippet"},
|
||||
"<=",
|
||||
{trig = "leq", snippetType = "snippet"},
|
||||
},
|
||||
fmta(
|
||||
"\\leq ",
|
||||
{}
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
ms({
|
||||
common = {snippetType = "autosnippet"},
|
||||
">=",
|
||||
{trig = "geq", snippetType = "snippet"},
|
||||
{trig = "ge", snippetType = "snippet"},
|
||||
},
|
||||
fmta(
|
||||
"\\ge ",
|
||||
{}
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "**",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\cdot ",
|
||||
{ }
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "->",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\to ",
|
||||
{ }
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "<->",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\leftrightarrow ",
|
||||
{ }
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({trig = "rustcode"},
|
||||
fmta(
|
||||
[[
|
||||
\begin{listing}[H]
|
||||
\begin{rustcode}
|
||||
<>
|
||||
\end{rustcode}
|
||||
\end{listing}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "notin",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\not\\in ",
|
||||
{ }
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "notin",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\not\\in ",
|
||||
{ }
|
||||
),
|
||||
{condition = in_mathzone}
|
||||
),
|
||||
|
||||
s({trig="lemma"},
|
||||
fmta(
|
||||
[[
|
||||
\begin{lemma}
|
||||
<>
|
||||
\end{lemma}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s({trig="proof"},
|
||||
fmta(
|
||||
[[
|
||||
\begin{proof}
|
||||
<>
|
||||
\end{proof}
|
||||
]],
|
||||
{ i(1) }
|
||||
)
|
||||
),
|
||||
|
||||
s({trig = "bf"},
|
||||
fmta("\\textbf{<>}",
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "...",
|
||||
snippetType="autosnippet",
|
||||
},
|
||||
fmta(
|
||||
"\\ldots ",
|
||||
{ }
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "image",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\includegraphics[width=0.5\textwidth]{<>}
|
||||
\caption{<>}
|
||||
\label{fig:<>}
|
||||
\end{figure}
|
||||
<>
|
||||
]],
|
||||
{
|
||||
i(1, "image.png"),
|
||||
i(2, "A great image!"),
|
||||
i(3, "image"),
|
||||
i(0)
|
||||
}
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "enum",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{enumerate}
|
||||
\item <>
|
||||
\end{enumerate}
|
||||
]],
|
||||
{
|
||||
i(0)
|
||||
}
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
s({
|
||||
trig = "item",
|
||||
},
|
||||
fmta(
|
||||
[[
|
||||
\begin{itemize}
|
||||
\item <>
|
||||
\end{itemize}
|
||||
]],
|
||||
{
|
||||
i(0)
|
||||
}
|
||||
),
|
||||
{}
|
||||
),
|
||||
|
||||
|
||||
-- s({ trig = "!=", snippetType="autosnippet" }, fmta("\\neq ", {}), {condition = in_mathzone}),
|
||||
-- s({ trig = "<=", snippetType="autosnippet" }, fmta("\\leq ", {}), {condition = in_mathzone}),
|
||||
-- s({ trig = ">=", snippetType="autosnippet" }, fmta("\\geq ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "<<", snippetType="autosnippet" }, fmta("\\ll ", {}), {condition = in_mathzone}),
|
||||
s({ trig = ">>", snippetType="autosnippet" }, fmta("\\gg ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "~~", snippetType="autosnippet" }, fmta("\\sim ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "~=", snippetType="autosnippet" }, fmta("\\approx ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "~-", snippetType="autosnippet" }, fmta("\\simeq ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "-~", snippetType="autosnippet" }, fmta("\\backsimeq ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "-=", snippetType="autosnippet" }, fmta("\\equiv ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "=~", snippetType="autosnippet" }, fmta("\\cong ", {}), {condition = in_mathzone}),
|
||||
s({ trig = ":=", snippetType="autosnippet" }, fmta("\\definedas ", {}), {condition = in_mathzone}),
|
||||
-- s({ trig = "**", snippetType="autosnippet" }, fmta("\\cdot ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "xx", snippetType="autosnippet" }, fmta("\\times ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "!+", snippetType="autosnippet" }, fmta("\\oplus ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "!*", snippetType="autosnippet" }, fmta("\\otimes ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "NN", snippetType="autosnippet" }, fmta("\\mathbb{N} ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "ZZ", snippetType="autosnippet" }, fmta("\\mathbb{Z} ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "QQ", snippetType="autosnippet" }, fmta("\\mathbb{Q} ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "RR", snippetType="autosnippet" }, fmta("\\mathbb{R} ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "CC", snippetType="autosnippet" }, fmta("\\mathbb{C} ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "OO", snippetType="autosnippet" }, fmta("\\emptyset ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "pwr", snippetType="autosnippet" }, fmta("\\powerset ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "cc", snippetType="autosnippet" }, fmta("\\subset ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "cq", snippetType="autosnippet" }, fmta("\\subseteq ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "qq", snippetType="autosnippet" }, fmta("\\supset ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "qc", snippetType="autosnippet" }, fmta("\\supseteq ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "Nn", snippetType="autosnippet" }, fmta("\\cap ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "UU", snippetType="autosnippet" }, fmta("\\cup ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "::", snippetType="autosnippet" }, fmta("\\colon ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "AA", snippetType="autosnippet" }, fmta("\\forall ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "EE", snippetType="autosnippet" }, fmta("\\exists ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "inn", snippetType="autosnippet" }, fmta("\\in ", {}), {condition = in_mathzone}),
|
||||
-- s({ trig = "notin", snippetType="autosnippet" }, fmta("\\not\\in ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "!-", snippetType="autosnippet" }, fmta("\\lnot ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "VV", snippetType="autosnippet" }, fmta("\\lor ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "WW", snippetType="autosnippet" }, fmta("\\land ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "!W", snippetType="autosnippet" }, fmta("\\bigwedge ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "=>", snippetType="autosnippet" }, fmta("\\implies ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "=<", snippetType="autosnippet" }, fmta("\\impliedby ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "iff", snippetType="autosnippet" }, fmta("\\iff ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "->", snippetType="autosnippet" }, fmta("\\to ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "!>", snippetType="autosnippet" }, fmta("\\mapsto ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "<-", snippetType="autosnippet" }, fmta("\\gets ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "dp", snippetType="autosnippet" }, fmta("\\partial ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "-->", snippetType="autosnippet" }, fmta("\\longrightarrow ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "<->", snippetType="autosnippet" }, fmta("\\leftrightarrow ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "2>", snippetType="autosnippet" }, fmta("\\rightrightarrows ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "upar", snippetType="autosnippet" }, fmta("\\uparrow ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "dnar", snippetType="autosnippet" }, fmta("\\downarrow ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "ooo", snippetType="autosnippet" }, fmta("\\infty ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "lll", snippetType="autosnippet" }, fmta("\\ell ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "dag", snippetType="autosnippet" }, fmta("\\dagger ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "+-", snippetType="autosnippet" }, fmta("\\pm ", {}), {condition = in_mathzone}),
|
||||
s({ trig = "-+", snippetType="autosnippet" }, fmta("\\mp ", {}), {condition = in_mathzone}),
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user