From cf5bcb5a58d4acb4964c2c74cbf719ee04b73a67 Mon Sep 17 00:00:00 2001 From: Therk <43972622+Therrk@users.noreply.github.com> Date: Mon, 6 Feb 2023 13:23:57 -0500 Subject: [PATCH 1/3] fixed tex snippets, now micro can actually detect them --- micro-snippets-plugin/snippets/tex.snippets | 193 ++++++++++++-------- 1 file changed, 112 insertions(+), 81 deletions(-) diff --git a/micro-snippets-plugin/snippets/tex.snippets b/micro-snippets-plugin/snippets/tex.snippets index 68ac5d0..e14eb65 100644 --- a/micro-snippets-plugin/snippets/tex.snippets +++ b/micro-snippets-plugin/snippets/tex.snippets @@ -1,235 +1,249 @@ #PREAMBLE #newcommand -snippet nc \newcommand +snippet nc \newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}} ${0} #usepackage -snippet up \usepackage +snippet up \usepackage[${1:options}]{${2:package}} ${0} #newunicodechar -snippet nuc \newunicodechar +snippet nuc \newunicodechar{${1}}{${2:\ensuremath}${3:tex-substitute}}} ${0} #DeclareMathOperator -snippet dmo \DeclareMathOperator +snippet dmo \DeclareMathOperator{${1}}{${2}} ${0} #DOCUMENT # \begin{}...\end{} -snippet begin \begin{} ... \end{} block +snippet begin \begin{${1:env}} ${0:${VISUAL}} \end{$1} # Tabular -snippet tab tabular (or arbitrary) environment +snippet tab \begin{${1:tabular}}{${2:c}} ${0:${VISUAL}} \end{$1} -snippet thm thm (or arbitrary) environment with optional argument +snippet thm \begin[${1:author}]{${2:thm}} ${0:${VISUAL}} \end{$2} -snippet center center environment +snippet center \begin{center} ${0:${VISUAL}} \end{center} # Align(ed) -snippet ali align(ed) environment +snippet ali \begin{align${1:ed}} \label{eq:${2}} ${0:${VISUAL}} \end{align$1} # Gather(ed) -snippet gat gather(ed) environment +snippet gat \begin{gather${1:ed}} ${0:${VISUAL}} \end{gather$1} # Equation -snippet eq equation environment +snippet eq \begin{equation} ${0:${VISUAL}} \end{equation} # Equation -snippet eql Labeled equation environment +snippet eql \begin{equation} \label{eq:${2}} ${0:${VISUAL}} \end{equation} # Equation -snippet eq* unnumbered equation environment +snippet eq* \begin{equation*} ${0:${VISUAL}} \end{equation*} # Unnumbered Equation -snippet \ unnumbered equation: \[ ... \] +snippet \ \[ ${0:${VISUAL}} \] # Equation array -snippet eqnarray eqnarray environment +snippet eqnarray \begin{eqnarray} ${0:${VISUAL}} \end{eqnarray} # Label -snippet lab \label +snippet lab \label{${1:eq:}${2:fig:}${3:tab:}${0}} # Enumerate -snippet enum enumerate environment +snippet enum \begin{enumerate} \item ${0} \end{enumerate} -snippet enuma enumerate environment +snippet enuma \begin{enumerate}[(a)] \item ${0} \end{enumerate} -snippet enumi enumerate environment +snippet enumi \begin{enumerate}[(i)] \item ${0} \end{enumerate} # Itemize -snippet itemize itemize environment +snippet itemize \begin{itemize} \item ${0} \end{itemize} -snippet item \item +snippet item \item ${1:${VISUAL}} # Description -snippet desc description environment +snippet desc \begin{description} \item[${1}] ${0} \end{description} # Endless new item -snippet ]i \item (recursive) +snippet ]i \item ${1} ${0:]i} # Matrix -snippet mat smart matrix environment +snippet mat \begin{${1:p/b/v/V/B/small}matrix} ${0:${VISUAL}} \end{$1matrix} # Cases -snippet cas cases environment +snippet cas \begin{cases} ${1:equation}, &\text{ if }${2:case}\\ ${0:${VISUAL}} \end{cases} # Split -snippet spl split environment +snippet spl \begin{split} ${0:${VISUAL}} \end{split} # Part -snippet part document \part +snippet part \part{${1:part name}} % (fold) \label{prt:${2:$1}} ${0} % part $2 (end) # Chapter -snippet cha \chapter +snippet cha \chapter{${1:chapter name}} \label{cha:${2:$1}} ${0} # Section -snippet sec \section +snippet sec \section{${1:section name}} \label{sec:${2:$1}} ${0} # Section without number -snippet sec* \section* +snippet sec* \section*{${1:section name}} \label{sec:${2:$1}} ${0} # Sub Section -snippet sub \subsection +snippet sub \subsection{${1:subsection name}} \label{sub:${2:$1}} ${0} # Sub Section without number -snippet sub* \subsection* +snippet sub* \subsection*{${1:subsection name}} \label{sub:${2:$1}} ${0} # Sub Sub Section -snippet subs \subsubsection +snippet subs \subsubsection{${1:subsubsection name}} \label{ssub:${2:$1}} ${0} # Sub Sub Section without number -snippet subs* \subsubsection* +snippet subs* \subsubsection*{${1:subsubsection name}} \label{ssub:${2:$1}} ${0} # Paragraph -snippet par \paragraph +snippet par \paragraph{${1:paragraph name}} \label{par:${2:$1}} ${0} # Sub Paragraph -snippet subp \subparagraph +snippet subp \subparagraph{${1:subparagraph name}} \label{subp:${2:$1}} ${0} -snippet ni \noindent +snippet ni \noindent ${0} #References -snippet itd description \item +snippet itd \item[${1:description}] ${0:item} -snippet figure reference to a figure +#Reference to a figure +snippet figure ${1:Figure}~\ref{${2:fig:}} -snippet table reference to a table +#Reference to a table +snippet table ${1:Table}~\ref{${2:tab:}} -snippet listing reference to a listing +#Reference to a listing +snippet listing ${1:Listing}~\ref{${2:list}} -snippet section reference to a section +#Reference to a section +snippet section ${1:Section}~\ref{sec:${2}} ${0} -snippet page reference to a page +#Reference to a page +snippet page ${1:page}~\pageref{${2}} ${0} -snippet index \index +#\index +snippet index \index{${1:index}} ${0} #Citations -snippet citen \citen +snippet citen \citen{${1}} ${0} # natbib citations -snippet citep \citep +snippet citep \citep{${1}} ${0} -snippet citet \citet +snippet citet \citet{${1}} ${0} -snippet cite \cite[]{} +snippet cite \cite[${1}]{${2}} ${0} -snippet citea \citeauthor +snippet citea \citeauthor{${1}} ${0} -snippet citey \citeyear +snippet citey \citeyear{${1}} ${0} -snippet fcite \footcite[]{} +snippet fcite \footcite[${1}]{${2}}${0} #Formating text: italic, bold, underline, small capital, emphase .. -snippet it italic text +snippet it \textit{${0:${VISUAL:text}}} -snippet bf bold face text +snippet bf \textbf{${0:${VISUAL:text}}} -snippet under underline text +snippet under \underline{${0:${VISUAL:text}}} -snippet emp emphasize text +snippet emp \emph{${0:${VISUAL:text}}} -snippet sc small caps text +snippet sc \textsc{${0:${VISUAL:text}}} #Choosing font -snippet sf sans serife text +#Sans serife +snippet sf \textsf{${0:${VISUAL:text}}} -snippet rm roman font text +#Roman font text +snippet rm \textrm{${0:${VISUAL:text}}} -snippet tt typewriter (monospace) text +#Typewriter (monospace) text +snippet tt \texttt{${0:${VISUAL:text}}} #Math font -snippet mf mathfrak +#Mathfrak +snippet mf \mathfrak{${0:${VISUAL:text}}} -snippet mc mathcal +#Mathcal +snippet mc \mathcal{${0:${VISUAL:text}}} -snippet ms mathscr +#Mathscr +snippet ms \mathscr{${0:${VISUAL:text}}} #misc -snippet ft \footnote +#\footnote +snippet ft \footnote{${0:${VISUAL:text}}} -snippet fig figure environment (includegraphics) +#Figure environment (includegraphics) +snippet fig \begin{figure} \begin{center} \includegraphics[scale=${1}]{Figures/${2}} @@ -238,7 +252,8 @@ snippet fig figure environment (includegraphics) \label{fig:${4}} \end{figure} ${0} -snippet tikz figure environment (tikzpicture) +#Figure environment (tikzpicture) +snippet tikz \begin{figure} \begin{center} \begin{tikzpicture}[scale=${1:1}] @@ -250,31 +265,40 @@ snippet tikz figure environment (tikzpicture) \end{figure} ${0} #math -snippet stackrel \stackrel{}{} +#\stackrel{}{} +snippet stackrel \stackrel{${1:above}}{${2:below}} ${0} -snippet frac \frac{}{} +#\frac{}{} +snippet frac \frac{${1:num}}{${2:denom}} ${0} -snippet sum \sum^{}_{} +#\sum^{}_{} +snippet sum \sum^{${1:n}}_{${2:i=1}} ${0} -snippet lim \lim_{} +#\lim_{} +snippet lim \lim_{${1:n \to \infty}} ${0} -snippet frame frame environment +#Frame environment +snippet frame \begin{frame}[${1:t}]{${2:title}} ${0:${VISUAL}} \end{frame} -snippet block block environment +Block environment +snippet block \begin{block}{${1:title}} ${0:${VISUAL}} \end{block} -snippet alert alertblock environment +#Alertblock environment +snippet alert \begin{alertblock}{${1:title}} ${0:${VISUAL}} \end{alertblock} -snippet example exampleblock environment +#Exampleblock environment +snippet example \begin{exampleblock}{${1:title}} ${0:${VISUAL}} \end{exampleblock} -snippet col2 two-column environment +#Two-column environment +snippet col2 \begin{columns} \begin{column}{0.5\textwidth} ${1} @@ -283,20 +307,27 @@ snippet col2 two-column environment ${0} \end{column} \end{columns} -snippet \{ \{ \} +#\{ \} +snippet \{ \\{ ${0} \\} #delimiter -snippet lr left right +#Left right +snippet lr \left${1} ${0} \right$1 -snippet lr( left( right) +#Left( right) +snippet lr( \left( ${0} \right) -snippet lr| left| right| +#Left| right| +snippet lr| \left| ${0} \right| -snippet lr{ left\{ right\} +#Left\{ right\} +snippet lr{ \left\\{ ${0} \right\\} -snippet lr[ left[ right] +#Left[ right] +snippet lr[ \left[ ${0} \right] -snippet lra langle rangle +#Langle rangle +snippet lra \langle ${0} \rangle # Code listings snippet lst From 29ef7890325e840a27a825b2a2ac8fd67af8bd37 Mon Sep 17 00:00:00 2001 From: Therk <43972622+Therrk@users.noreply.github.com> Date: Mon, 6 Feb 2023 15:32:26 -0500 Subject: [PATCH 2/3] fixed snippets only wordCursor only considering spaces, and not all whitespace as word end --- micro-snippets-plugin/snippets.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/micro-snippets-plugin/snippets.lua b/micro-snippets-plugin/snippets.lua index d5d71b3..e960c20 100644 --- a/micro-snippets-plugin/snippets.lua +++ b/micro-snippets-plugin/snippets.lua @@ -284,16 +284,20 @@ local function CursorWord(bp) local c = bp.Cursor local x = c.X-1 -- start one rune before the cursor local result = "" + local debug = io.open("debug","a") while x >= 0 do local r = util.RuneStr(c:RuneUnder(x)) - if (r == " ") then -- IsWordChar(r) then + if (r:match("^%s")) then -- IsWordChar(r) then break else + debug:write(r.. "\n") result = r .. result end x = x-1 end + debug:close() + return result end From 66c6f906e3661cfada045a56744df533a9377808 Mon Sep 17 00:00:00 2001 From: Therk <43972622+Therrk@users.noreply.github.com> Date: Tue, 7 Feb 2023 10:23:21 -0500 Subject: [PATCH 3/3] removed debug logging --- micro-snippets-plugin/snippets.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/micro-snippets-plugin/snippets.lua b/micro-snippets-plugin/snippets.lua index e960c20..3ad9389 100644 --- a/micro-snippets-plugin/snippets.lua +++ b/micro-snippets-plugin/snippets.lua @@ -284,19 +284,16 @@ local function CursorWord(bp) local c = bp.Cursor local x = c.X-1 -- start one rune before the cursor local result = "" - local debug = io.open("debug","a") while x >= 0 do local r = util.RuneStr(c:RuneUnder(x)) if (r:match("^%s")) then -- IsWordChar(r) then break else - debug:write(r.. "\n") result = r .. result end x = x-1 end - debug:close() return result end