342 current 2025-02-16 19:30:04 25.05.20241217.d3c42f1 6.6.66 *
This commit is contained in:
@@ -39,6 +39,10 @@
|
||||
plenary-nvim
|
||||
nvim-web-devicons
|
||||
# coc-nvim
|
||||
{
|
||||
plugin = vimtex;
|
||||
config = toLuaFile ./plugins/vimtex.lua;
|
||||
}
|
||||
{
|
||||
plugin = goyo-vim;
|
||||
config = toLuaFile ./plugins/goyo.lua;
|
||||
|
||||
42
home/programs/nvim/plugins/vimtex.lua
Normal file
42
home/programs/nvim/plugins/vimtex.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
-- Enable filetype plugins, indent, and syntax highlighting.
|
||||
vim.cmd("filetype plugin indent on")
|
||||
vim.cmd("syntax enable")
|
||||
|
||||
-- Viewer options: either with a built-in viewer method or with a generic interface.
|
||||
vim.g.vimtex_view_method = 'zathura'
|
||||
vim.g.vimtex_view_general_viewer = 'zathura'
|
||||
vim.g.vimtex_view_general_options = '--unique file:@pdf#src:@line@tex'
|
||||
|
||||
-- Set the TeX flavor and quickfix mode.
|
||||
vim.g.tex_flavor = 'latex'
|
||||
vim.g.vimtex_quickfix_mode = 0
|
||||
vim.g.vimtex_quickfix_enabled = 0
|
||||
|
||||
-- Compiler backend.
|
||||
vim.g.vimtex_compiler_method = 'latexrun'
|
||||
|
||||
-- Set the local leader (default is "\"; here we change it to comma).
|
||||
vim.g.maplocalleader = ','
|
||||
|
||||
-- Configure warnings to ignore.
|
||||
vim.g.Tex_IgnoredWarnings = [[
|
||||
Package hyperref Warning
|
||||
Token not allowed in a PDF string (Unicode)
|
||||
removing math shift
|
||||
removing superscript
|
||||
Underfull
|
||||
Overfull
|
||||
specifier changed to
|
||||
You have requested
|
||||
Missing number, treated as zero.
|
||||
There were undefined references
|
||||
Citation %.%# undefined
|
||||
Double space found.
|
||||
]]
|
||||
vim.g.Tex_IgnoreLevel = 8
|
||||
|
||||
-- Delete extra compilation files when a TeX buffer is deleted.
|
||||
vim.api.nvim_create_autocmd("BufDelete", {
|
||||
pattern = "*.tex",
|
||||
command = "silent! !latexmk -c > /dev/null 2>&1 %:p",
|
||||
})
|
||||
@@ -43,15 +43,3 @@ ls.add_snippets("lua", {
|
||||
t(' end')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
ls.add_snippets("all", {
|
||||
ms({
|
||||
common = {snippetType = "autosnippet"},
|
||||
"a",
|
||||
"b"
|
||||
}, {
|
||||
t"a or b (but autotriggered!!)"
|
||||
})
|
||||
})
|
||||
|
||||
197
home/programs/nvim/snippets/tex.lua
Normal file
197
home/programs/nvim/snippets/tex.lua
Normal file
@@ -0,0 +1,197 @@
|
||||
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{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{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({trig = "ita", dscr = "Expands 'tii' into LaTeX's textit{} command."},
|
||||
fmta("\\textit{<>}",
|
||||
{
|
||||
d(1, get_visual),
|
||||
}
|
||||
)
|
||||
),
|
||||
|
||||
|
||||
-- s({trig = "ff"},
|
||||
-- fmta(
|
||||
-- "\\frac{<>}{<>}",
|
||||
-- {
|
||||
-- i(1),
|
||||
-- i(2),
|
||||
-- }
|
||||
-- ),
|
||||
-- {condition = in_mathzone} -- `condition` option passed in the snippet `opts` table
|
||||
-- ),
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user