Compare commits
No commits in common. "9aba8cd8555e7c59e2be29d898d890c15f91e59d" and "2f902123a9a44ef55ba99e2e0c7d2af5e5b0d907" have entirely different histories.
9aba8cd855
...
2f902123a9
@ -2,11 +2,15 @@ vim.pack.add({ "https://github.com/zbirenbaum/copilot.lua" })
|
|||||||
|
|
||||||
require("copilot").setup({
|
require("copilot").setup({
|
||||||
suggestion = {
|
suggestion = {
|
||||||
|
enabled = true,
|
||||||
auto_trigger = true,
|
auto_trigger = true,
|
||||||
keymap = {
|
keymap = {
|
||||||
accept = "<C-l>",
|
accept = "<C-l>"
|
||||||
|
-- accept_word = false,
|
||||||
|
-- accept_line = false,
|
||||||
|
-- next = "<M-]>",
|
||||||
|
-- prev = "<M-[>",
|
||||||
|
-- dismiss = "<C-]>"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.cmd('command! Run Copilot diable')
|
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
vim.pack.add({
|
vim.pack.add({
|
||||||
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
{ src = "https://github.com/neovim/nvim-lspconfig" },
|
||||||
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
|
{ src = "https://github.com/mason-org/mason-lspconfig.nvim" },
|
||||||
@ -14,14 +13,12 @@ vim.pack.add({
|
|||||||
require("mason").setup()
|
require("mason").setup()
|
||||||
require("mason-lspconfig").setup()
|
require("mason-lspconfig").setup()
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- Diagnostic config
|
-- Diagnostic config
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({
|
||||||
virtual_text = true,
|
virtual_text = true,
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
@ -37,8 +34,8 @@ vim.api.nvim_create_autocmd("CursorHold", {
|
|||||||
source = true,
|
source = true,
|
||||||
relative = "editor",
|
relative = "editor",
|
||||||
width = 40,
|
width = 40,
|
||||||
focusable = true,
|
focusable = false,
|
||||||
focused = false,
|
-- focus = false,
|
||||||
border = "rounded",
|
border = "rounded",
|
||||||
title = "Diagnostics",
|
title = "Diagnostics",
|
||||||
header = "",
|
header = "",
|
||||||
@ -49,6 +46,15 @@ vim.api.nvim_create_autocmd("CursorHold", {
|
|||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- vim.diagnostic.handlers["quickfix"] = {
|
||||||
|
-- show = function(_, _, _, _)
|
||||||
|
-- vim.diagnostic.setqflist({ open = false })
|
||||||
|
-- end,
|
||||||
|
--
|
||||||
|
-- hide = function(_, _)
|
||||||
|
-- vim.fn.setqflist({}, 'r')
|
||||||
|
-- end
|
||||||
|
-- }
|
||||||
|
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
@ -56,7 +62,6 @@ vim.api.nvim_create_autocmd("CursorHold", {
|
|||||||
--
|
--
|
||||||
--
|
--
|
||||||
|
|
||||||
|
|
||||||
vim.o.completeopt = "menu,menuone,noinsert,fuzzy"
|
vim.o.completeopt = "menu,menuone,noinsert,fuzzy"
|
||||||
vim.api.nvim_set_keymap("i", "<C-Space>", "<C-x><C-o>", { noremap = true })
|
vim.api.nvim_set_keymap("i", "<C-Space>", "<C-x><C-o>", { noremap = true })
|
||||||
|
|
||||||
|
|||||||
@ -1,69 +0,0 @@
|
|||||||
vim.pack.add({
|
|
||||||
{ src = "https://github.com/rafamadriz/friendly-snippets" },
|
|
||||||
{ src = "https://github.com/L3MON4D3/LuaSnip" }
|
|
||||||
})
|
|
||||||
|
|
||||||
local loader = require("luasnip.loaders.from_lua")
|
|
||||||
loader.lazy_load({ paths = { "./snippets" } })
|
|
||||||
|
|
||||||
require("luasnip").config.set_config({
|
|
||||||
enable_autosnippets = true,
|
|
||||||
store_selection_keys = "<leader>v"
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.keymap.set({ "i" }, "<c-j>", function() require("luasnip").expand() end, { silent = true })
|
|
||||||
vim.keymap.set({ "i", "s" }, "<c-j>", function() require("luasnip").jump(1) end, { silent = true })
|
|
||||||
vim.keymap.set({ "i", "s" }, "<c-k>", function() require("luasnip").jump(-1) end, { silent = true })
|
|
||||||
|
|
||||||
-- TODO: Custom LSP server to supply snippets to completion
|
|
||||||
|
|
||||||
|
|
||||||
-- return {
|
|
||||||
-- {
|
|
||||||
-- "L3MON4D3/LuaSnip",
|
|
||||||
-- dependencies = {
|
|
||||||
-- {
|
|
||||||
-- 'rafamadriz/friendly-snippets'
|
|
||||||
-- }
|
|
||||||
-- },
|
|
||||||
-- version = "v2.*",
|
|
||||||
-- build = "make install_jsregexp",
|
|
||||||
-- event = {
|
|
||||||
-- "InsertEnter"
|
|
||||||
-- },
|
|
||||||
-- init = function()
|
|
||||||
-- vim.keymap.set({
|
|
||||||
-- "i"
|
|
||||||
-- }, "<c-j>", function() require("luasnip").expand() end, {
|
|
||||||
-- silent = true
|
|
||||||
-- })
|
|
||||||
-- vim.keymap.set({
|
|
||||||
-- "i",
|
|
||||||
-- "s"
|
|
||||||
-- }, "<c-j>", function() require("luasnip").jump(1) end, {
|
|
||||||
-- silent = true
|
|
||||||
-- })
|
|
||||||
-- vim.keymap.set({
|
|
||||||
-- "i",
|
|
||||||
-- "s"
|
|
||||||
-- }, "<c-k>", function() require("luasnip").jump(-1) end, {
|
|
||||||
-- silent = true
|
|
||||||
-- })
|
|
||||||
--
|
|
||||||
-- end,
|
|
||||||
-- config = function()
|
|
||||||
-- local loader = require("luasnip.loaders.from_lua")
|
|
||||||
-- loader.lazy_load({
|
|
||||||
-- paths = {
|
|
||||||
-- "./snippets"
|
|
||||||
-- }
|
|
||||||
-- })
|
|
||||||
--
|
|
||||||
-- require("luasnip").config.set_config({
|
|
||||||
-- enable_autosnippets = true,
|
|
||||||
-- store_selection_keys = "<leader>v"
|
|
||||||
-- })
|
|
||||||
-- end
|
|
||||||
-- }
|
|
||||||
-- }
|
|
||||||
--
|
|
||||||
@ -1,9 +1,5 @@
|
|||||||
{
|
{
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"LuaSnip": {
|
|
||||||
"rev": "3732756",
|
|
||||||
"src": "https://github.com/L3MON4D3/LuaSnip"
|
|
||||||
},
|
|
||||||
"alpha-nvim": {
|
"alpha-nvim": {
|
||||||
"rev": "3979b01",
|
"rev": "3979b01",
|
||||||
"src": "https://github.com/goolord/alpha-nvim"
|
"src": "https://github.com/goolord/alpha-nvim"
|
||||||
@ -20,10 +16,6 @@
|
|||||||
"rev": "2d7c2db",
|
"rev": "2d7c2db",
|
||||||
"src": "https://github.com/stevearc/dressing.nvim"
|
"src": "https://github.com/stevearc/dressing.nvim"
|
||||||
},
|
},
|
||||||
"friendly-snippets": {
|
|
||||||
"rev": "572f566",
|
|
||||||
"src": "https://github.com/rafamadriz/friendly-snippets"
|
|
||||||
},
|
|
||||||
"gruvbox.nvim": {
|
"gruvbox.nvim": {
|
||||||
"rev": "5e0a460",
|
"rev": "5e0a460",
|
||||||
"src": "https://github.com/ellisonleao/gruvbox.nvim"
|
"src": "https://github.com/ellisonleao/gruvbox.nvim"
|
||||||
|
|||||||
@ -1,83 +0,0 @@
|
|||||||
----------------
|
|
||||||
-- Abbreviations
|
|
||||||
----------------
|
|
||||||
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
local line_begin = require("luasnip.extras.expand_conditions").line_begin
|
|
||||||
|
|
||||||
|
|
||||||
-----------
|
|
||||||
-- Snippets
|
|
||||||
-----------
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
|
||||||
s({trig="()", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("("),
|
|
||||||
i(1),
|
|
||||||
t(")"),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="[]", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("["),
|
|
||||||
i(1),
|
|
||||||
t("]"),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="{}", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("{"),
|
|
||||||
i(1),
|
|
||||||
t("}"),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="<>", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("<"),
|
|
||||||
i(1),
|
|
||||||
t(">"),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="\"\"", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("\""),
|
|
||||||
i(1),
|
|
||||||
t("\""),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="''", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
{
|
|
||||||
t("'"),
|
|
||||||
i(1),
|
|
||||||
t("'"),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
} -- return
|
|
||||||
|
|
||||||
@ -1,285 +0,0 @@
|
|||||||
----------------
|
|
||||||
-- Abbreviations
|
|
||||||
----------------
|
|
||||||
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
local conds = require("luasnip.extras.expand_conditions")
|
|
||||||
|
|
||||||
---------------
|
|
||||||
-- Environments
|
|
||||||
---------------
|
|
||||||
|
|
||||||
|
|
||||||
local tex_utils = {}
|
|
||||||
|
|
||||||
tex_utils.in_mathzone = function() -- math context detection
|
|
||||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_text = function()
|
|
||||||
return not tex_utils.in_mathzone()
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_comment = function() -- comment detection
|
|
||||||
return vim.fn['vimtex#syntax#in_comment']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_env = function(name) -- generic environment detection
|
|
||||||
local is_inside = vim.fn['vimtex#env#is_inside'](name)
|
|
||||||
return (is_inside[1] > 0 and is_inside[2] > 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
return sn(nil, i(1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-----------
|
|
||||||
-- Snippets
|
|
||||||
-----------
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
|
||||||
s({trig="notes"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\documentclass[dvipsnames]{article}
|
|
||||||
|
|
||||||
\usepackage{float}
|
|
||||||
\usepackage{amsmath}
|
|
||||||
\usepackage{amsfonts}
|
|
||||||
\usepackage{mleftright}
|
|
||||||
\usepackage{bm}
|
|
||||||
\usepackage{tikz}
|
|
||||||
\usepackage{xcolor}
|
|
||||||
\usepackage{pgfplots}
|
|
||||||
\pgfplotsset{compat=newest}
|
|
||||||
|
|
||||||
\title{<>}
|
|
||||||
\author{<>}
|
|
||||||
\date{<>}
|
|
||||||
|
|
||||||
\begin{document}
|
|
||||||
\maketitle
|
|
||||||
|
|
||||||
<>
|
|
||||||
\end{document}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1, "Notes"),
|
|
||||||
i(2, "Andreas Tsouchlos"),
|
|
||||||
i(3, os.date("%d.%m.%y")),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="beg", wordTrig=true, snippetType="autosnippet", condition=conds.line_begin},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{<>}
|
|
||||||
<>
|
|
||||||
\end{<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
i(2),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="item", wordTrig=true, snippetType="autosnippet",
|
|
||||||
condition = function(line_to_cursor, matched_trigger, captures)
|
|
||||||
return tex_utils.in_env("itemize") and conds.line_begin(line_to_cursor, matched_trigger, captures)
|
|
||||||
end},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\item <>
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="item", wordTrig=true, snippetType="autosnippet", condition=conds.line_begin},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{itemize}
|
|
||||||
\item <>
|
|
||||||
\end{itemize}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="frame", wordTrig=true, snippetType="autosnippet", condition=conds.line_begin},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{frame}
|
|
||||||
\frametitle{<>}
|
|
||||||
\end{frame}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="sec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\section{<>}
|
|
||||||
\label{sec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="ssec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\subsection{<>}
|
|
||||||
\label{subsec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="sssec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\subsubsection{<>}
|
|
||||||
\label{subsubsec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="csec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
||||||
\section{<>}
|
|
||||||
\label{sec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="cssec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
%%%%%%%%%%%%%%%%
|
|
||||||
\subsection{<>}
|
|
||||||
\label{subsec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="csssec"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
%%%%%%%%
|
|
||||||
\subsubsection{<>}
|
|
||||||
\label{subsubsec:<>}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
rep(1),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
-- s({trig="()", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("("),
|
|
||||||
-- i(1),
|
|
||||||
-- t(")"),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
--
|
|
||||||
-- s({trig="[]", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("["),
|
|
||||||
-- i(1),
|
|
||||||
-- t("]"),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
--
|
|
||||||
-- s({trig="{}", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("{"),
|
|
||||||
-- i(1),
|
|
||||||
-- t("}"),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
--
|
|
||||||
-- s({trig="<>", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("<"),
|
|
||||||
-- i(1),
|
|
||||||
-- t(">"),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
--
|
|
||||||
-- s({trig="\"\"", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("\""),
|
|
||||||
-- i(1),
|
|
||||||
-- t("\""),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
--
|
|
||||||
-- s({trig="''", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
-- {
|
|
||||||
-- t("'"),
|
|
||||||
-- i(1),
|
|
||||||
-- t("'"),
|
|
||||||
-- i(0),
|
|
||||||
-- }
|
|
||||||
-- ),
|
|
||||||
|
|
||||||
|
|
||||||
} -- return
|
|
||||||
|
|
||||||
@ -1,439 +0,0 @@
|
|||||||
----------------
|
|
||||||
-- Abbreviations
|
|
||||||
----------------
|
|
||||||
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
|
|
||||||
---------------
|
|
||||||
-- Environments
|
|
||||||
---------------
|
|
||||||
|
|
||||||
|
|
||||||
local tex_utils = {}
|
|
||||||
|
|
||||||
tex_utils.in_mathzone = function() -- math context detection
|
|
||||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_text = function()
|
|
||||||
return not tex_utils.in_mathzone()
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_comment = function() -- comment detection
|
|
||||||
return vim.fn['vimtex#syntax#in_comment']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_env = function(name) -- generic environment detection
|
|
||||||
local is_inside = vim.fn['vimtex#env#is_inside'](name)
|
|
||||||
return (is_inside[1] > 0 and is_inside[2] > 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
return sn(nil, i(1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-----------
|
|
||||||
-- Snippets
|
|
||||||
-----------
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
|
||||||
s({trig="´a", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\alpha ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´b", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\beta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´g", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\gamma ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´d", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\delta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´e", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\epsilon ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´z", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\zeta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´h", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\eta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´q", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\theta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´i", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\iota ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´k", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\kappa ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´l", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\lambda ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´m", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\mu ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´n", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\nu ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´x", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\xi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´p", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\pi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´r", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\rho ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´s", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\sigma ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´t", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\tau ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´u", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\upsilon ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´f", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\phi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´c", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\chi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´y", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\psi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´w", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\omega ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´A", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Alpha ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´B", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Beta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´G", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Gamma ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´D", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Delta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´E", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Epsilon ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´Z", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Zeta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´H", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Eta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´Q", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Theta ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´I", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Iota ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´K", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Kappa ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´L", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Lambda ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´M", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Mu ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´N", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Nu ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´X", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Xi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´P", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Pi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´R", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Rho ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´S", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Sigma ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´T", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Tau ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´U", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Upsilon ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´F", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Phi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´C", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Chi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´Y", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Psi ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="´W", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Omega ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
-- Strictly speaking not greek characters, but very similar snippets
|
|
||||||
|
|
||||||
s({trig="´6", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\partial ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
} -- return
|
|
||||||
|
|
||||||
@ -1,418 +0,0 @@
|
|||||||
----------------
|
|
||||||
-- Abbreviations
|
|
||||||
----------------
|
|
||||||
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
local conds = require("luasnip.extras.expand_conditions")
|
|
||||||
|
|
||||||
|
|
||||||
---------------
|
|
||||||
-- Environments
|
|
||||||
---------------
|
|
||||||
|
|
||||||
|
|
||||||
local tex_utils = {}
|
|
||||||
|
|
||||||
tex_utils.in_mathzone = function() -- math context detection
|
|
||||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_text = function()
|
|
||||||
return not tex_utils.in_mathzone()
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_comment = function() -- comment detection
|
|
||||||
return vim.fn['vimtex#syntax#in_comment']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_env = function(name) -- generic environment detection
|
|
||||||
local is_inside = vim.fn['vimtex#env#is_inside'](name)
|
|
||||||
return (is_inside[1] > 0 and is_inside[2] > 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
return sn(nil, i(1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-----------
|
|
||||||
-- Snippets
|
|
||||||
-----------
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
|
||||||
s({trig="ali", wordTrig=true, snippetType="autosnippet", condition=conds.line_begin},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{align*}
|
|
||||||
<>
|
|
||||||
<>%
|
|
||||||
\end{align*}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
i(1, "."),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="cases"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{cases}
|
|
||||||
<>
|
|
||||||
\end{cases}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="matb"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{bmatrix}
|
|
||||||
<>
|
|
||||||
\end{bmatrix}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="matp"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{pmatrix}
|
|
||||||
<>
|
|
||||||
\end{pmatrix}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])array", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
<>\begin{array}{c}
|
|
||||||
<>
|
|
||||||
\end{array}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(0),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])int', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\int_{<>}^{<>} <> d<> ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1, "-\\infty"),
|
|
||||||
i(2, "\\infty"),
|
|
||||||
i(4),
|
|
||||||
i(3, "x"),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])prod', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\prod_{<>}^{<>} ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1, "-\\infty"),
|
|
||||||
i(2, "\\infty"),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])sum', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\sum_{<>}^{<>} ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1, "n=0"),
|
|
||||||
i(2, "N-1"),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])sqrt', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\sqrt{<>} ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])log', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\log_{<>} ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1, "2"),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig='([^%a])ln', regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\ln ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig = '([^%a])ff', regTrig = true, wordTrig = false, snippetType = "autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\frac{<>}{<>} ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
i(2)
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])mcal", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\mathcal{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])mbb", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\mathbb{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])tt", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\text{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
-- s({trig=".", snippetType="autosnippet"},
|
|
||||||
-- fmta(
|
|
||||||
-- [[\cdot ]],
|
|
||||||
-- {}
|
|
||||||
-- ),
|
|
||||||
-- {condition = tex_utils.in_mathzone}
|
|
||||||
-- ),
|
|
||||||
|
|
||||||
s({trig="$$", snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[$<>$]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])bm", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\bm{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="__", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[_{<>}]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="^^", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[^{<>}]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])oo", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\infty]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="((", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\mleft( <> \mright)]],
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="[[", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
"\\mleft[ <> \\mright]",
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="{{", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
"\\mleft\\{ <> \\mright\\}",
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="||", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
"\\lvert <> \\rvert ",
|
|
||||||
{
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])hat", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\hat{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])tld", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\tilde{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])bar", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\overline{<>}]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
i(1),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([%a])([%d])", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>_<>]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
f( function(_, snip) return snip.captures[2] end ),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="=>", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\Rightarrow ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="->", wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[\rightarrow ]],
|
|
||||||
{}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="([^%a])nab", regTrig=true, wordTrig=false, snippetType="autosnippet"},
|
|
||||||
fmta(
|
|
||||||
[[<>\nabla ]],
|
|
||||||
{
|
|
||||||
f( function(_, snip) return snip.captures[1] end ),
|
|
||||||
}
|
|
||||||
),
|
|
||||||
{condition = tex_utils.in_mathzone}
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
} -- return
|
|
||||||
|
|
||||||
@ -1,132 +0,0 @@
|
|||||||
----------------
|
|
||||||
-- Abbreviations
|
|
||||||
----------------
|
|
||||||
|
|
||||||
|
|
||||||
local ls = require("luasnip")
|
|
||||||
local s = ls.snippet
|
|
||||||
local sn = ls.snippet_node
|
|
||||||
local t = ls.text_node
|
|
||||||
local i = ls.insert_node
|
|
||||||
local f = ls.function_node
|
|
||||||
local d = ls.dynamic_node
|
|
||||||
local fmt = require("luasnip.extras.fmt").fmt
|
|
||||||
local fmta = require("luasnip.extras.fmt").fmta
|
|
||||||
local rep = require("luasnip.extras").rep
|
|
||||||
|
|
||||||
|
|
||||||
---------------
|
|
||||||
-- Environments
|
|
||||||
---------------
|
|
||||||
|
|
||||||
|
|
||||||
local tex_utils = {}
|
|
||||||
|
|
||||||
tex_utils.in_mathzone = function() -- math context detection
|
|
||||||
return vim.fn['vimtex#syntax#in_mathzone']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_text = function()
|
|
||||||
return not tex_utils.in_mathzone()
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_comment = function() -- comment detection
|
|
||||||
return vim.fn['vimtex#syntax#in_comment']() == 1
|
|
||||||
end
|
|
||||||
|
|
||||||
tex_utils.in_env = function(name) -- generic environment detection
|
|
||||||
local is_inside = vim.fn['vimtex#env#is_inside'](name)
|
|
||||||
return (is_inside[1] > 0 and is_inside[2] > 0)
|
|
||||||
end
|
|
||||||
|
|
||||||
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
|
|
||||||
return sn(nil, i(1))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
-----------
|
|
||||||
-- Snippets
|
|
||||||
-----------
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
|
||||||
|
|
||||||
|
|
||||||
s({trig="funcplot"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{figure}[H]
|
|
||||||
\centering
|
|
||||||
|
|
||||||
\begin{tikzpicture}
|
|
||||||
\begin{axis}[
|
|
||||||
domain=<>,
|
|
||||||
width=\textwidth,
|
|
||||||
height=0.75\textwidth,
|
|
||||||
]
|
|
||||||
\addplot+[mark=none, line width=1pt]
|
|
||||||
{<>};
|
|
||||||
\end{axis}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{figure}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1, "-5:5"),
|
|
||||||
i(2),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="csvplot"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{figure}[H]
|
|
||||||
\centering
|
|
||||||
|
|
||||||
\begin{tikzpicture}
|
|
||||||
\begin{axis}[
|
|
||||||
width=\textwidth,
|
|
||||||
height=0.75\textwidth,
|
|
||||||
]
|
|
||||||
\addplot+[mark=none, line width=1pt]
|
|
||||||
table[col sep=comma, x=<>, y=<>]
|
|
||||||
{<>};
|
|
||||||
\end{axis}
|
|
||||||
\end{tikzpicture}
|
|
||||||
\end{figure}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(1, "x"),
|
|
||||||
i(2, "y"),
|
|
||||||
i(3),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
s({trig="fig"},
|
|
||||||
fmta(
|
|
||||||
[[
|
|
||||||
\begin{figure}[H]
|
|
||||||
\centering
|
|
||||||
|
|
||||||
<>
|
|
||||||
|
|
||||||
\caption{<>}
|
|
||||||
\label{fig:<>}
|
|
||||||
\end{figure}
|
|
||||||
]],
|
|
||||||
{
|
|
||||||
i(0),
|
|
||||||
i(1),
|
|
||||||
i(2),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
|
|
||||||
} -- return
|
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user