mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 06:03:45 +01:00
reformated data files with argument data
This commit is contained in:
+26
-93
@@ -1,88 +1,14 @@
|
||||
define [
|
||||
"./package_definitions"
|
||||
], (packageCommandMappings) ->
|
||||
noArgumentCommands = [
|
||||
'item', 'hline', 'lipsum', 'centering', 'noindent', 'textwidth', 'draw',
|
||||
'maketitle', 'newpage', 'verb', 'bibliography', 'hfill', 'par',
|
||||
'in', 'sum', 'cdot', 'ldots', 'linewidth', 'left', 'right', 'today',
|
||||
'clearpage', 'newline', 'endinput', 'tableofcontents', 'vfill',
|
||||
'bigskip', 'fill', 'cleardoublepage', 'infty', 'leq', 'geq', 'times',
|
||||
'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'varepsilon', 'zeta',
|
||||
'eta', 'theta', 'vartheta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi',
|
||||
'pi', 'varpi', 'rho', 'varrho', 'sigma', 'varsigma', 'tau', 'upsilon',
|
||||
'phi', 'varphi', 'chi', 'psi', 'omega', 'Gamma', 'Delta', 'Theta',
|
||||
'Lambda', 'Xi', 'Pi', 'Sigma', 'Upsilon', 'Phi', 'Psi', 'Omega'
|
||||
]
|
||||
singleArgumentCommands = [
|
||||
'chapter', 'usepackage', 'section', 'label', 'textbf', 'subsection',
|
||||
'vspace', 'cite', 'textit', 'documentclass', 'includegraphics', 'input',
|
||||
'emph','caption', 'ref', 'title', 'author', 'texttt', 'include',
|
||||
'hspace', 'bibitem', 'url', 'large', 'subsubsection', 'textsc', 'date',
|
||||
'footnote', 'small', 'thanks', 'underline', 'graphicspath', 'pageref',
|
||||
'section*', 'subsection*', 'subsubsection*', 'sqrt', 'text',
|
||||
'normalsize', 'footnotesize', 'Large', 'paragraph', 'pagestyle',
|
||||
'thispagestyle', 'bibliographystyle', 'hat'
|
||||
]
|
||||
doubleArgumentCommands = [
|
||||
'newcommand', 'frac', 'dfrac', 'renewcommand', 'setlength', 'href',
|
||||
'newtheorem'
|
||||
]
|
||||
tripleArgumentCommands = [
|
||||
'addcontentsline', 'newacronym', 'multicolumn'
|
||||
]
|
||||
special = ['LaTeX', 'TeX']
|
||||
"./top_hundred_snippets",
|
||||
"./package_definition_snippets"
|
||||
], (topHundred, packageCommandMappings) ->
|
||||
|
||||
rawCommands = [].concat(
|
||||
noArgumentCommands,
|
||||
singleArgumentCommands,
|
||||
doubleArgumentCommands,
|
||||
tripleArgumentCommands,
|
||||
special
|
||||
)
|
||||
rawCommands = Object.keys topHundred
|
||||
|
||||
noArgumentCommands = for cmd in noArgumentCommands
|
||||
{
|
||||
caption: "\\#{cmd}"
|
||||
snippet: "\\#{cmd}"
|
||||
meta: "cmd"
|
||||
}
|
||||
singleArgumentCommands = for cmd in singleArgumentCommands
|
||||
{
|
||||
caption: "\\#{cmd}{}"
|
||||
snippet: "\\#{cmd}{$1}"
|
||||
meta: "cmd"
|
||||
}
|
||||
doubleArgumentCommands = for cmd in doubleArgumentCommands
|
||||
{
|
||||
caption: "\\#{cmd}{}{}"
|
||||
snippet: "\\#{cmd}{$1}{$2}"
|
||||
meta: "cmd"
|
||||
}
|
||||
tripleArgumentCommands = for cmd in tripleArgumentCommands
|
||||
{
|
||||
caption: "\\#{cmd}{}{}{}"
|
||||
snippet: "\\#{cmd}{$1}{$2}{$3}"
|
||||
meta: "cmd"
|
||||
}
|
||||
special = for cmd in special
|
||||
{
|
||||
caption: "\\#{cmd}{}"
|
||||
snippet: "\\#{cmd}{}"
|
||||
meta: "cmd"
|
||||
}
|
||||
|
||||
staticCommands = [].concat(
|
||||
noArgumentCommands,
|
||||
singleArgumentCommands,
|
||||
doubleArgumentCommands,
|
||||
tripleArgumentCommands,
|
||||
special
|
||||
)
|
||||
|
||||
# packageCommandMappings = {
|
||||
# amsmath: ['holyshititworks', 'mathematics']
|
||||
# natbib: ['somebibliographystuff']
|
||||
# }
|
||||
commandSnippets = []
|
||||
for cmd, snippets of topHundred
|
||||
for snippet in snippets
|
||||
commandSnippets.push snippet
|
||||
|
||||
class Parser
|
||||
constructor: (@doc, @prefix) ->
|
||||
@@ -136,10 +62,10 @@ define [
|
||||
return realCommands
|
||||
|
||||
# Ignore single letter commands since auto complete is moot then.
|
||||
commandRegex: /\\([a-zA-Z][a-zA-Z]+)/
|
||||
commandRegex: /\\([a-zA-Z]{2,})/
|
||||
|
||||
nextCommand: () ->
|
||||
i = @doc.search(@commandRegex)
|
||||
i = @doc.search @commandRegex
|
||||
if i == -1
|
||||
return false
|
||||
else
|
||||
@@ -179,14 +105,21 @@ define [
|
||||
packages = @metadataManager.getAllPackages()
|
||||
packageCommands = []
|
||||
for pkg in packages
|
||||
if packageCommandMappings[pkg]?
|
||||
for cmd in packageCommandMappings[pkg]
|
||||
packageCommands.push {
|
||||
caption: "\\#{cmd}"
|
||||
snippet: "\\#{cmd}"
|
||||
meta: "#{pkg}-cmd"
|
||||
score: 60
|
||||
}
|
||||
commands = packageCommandMappings[pkg]
|
||||
if commands?
|
||||
for command, snippets of commands
|
||||
if command not in rawCommands
|
||||
for snippet in snippets
|
||||
packageCommands.push snippet
|
||||
# for pkg in packages
|
||||
# if packageCommandMappings[pkg]?
|
||||
# for cmd in packageCommandMappings[pkg]
|
||||
# packageCommands.push {
|
||||
# caption: "\\#{cmd}"
|
||||
# snippet: "\\#{cmd}"
|
||||
# meta: "#{pkg}-cmd"
|
||||
# score: 60
|
||||
# }
|
||||
|
||||
doc = session.getValue()
|
||||
parser = new Parser(doc, prefix)
|
||||
@@ -212,7 +145,7 @@ define [
|
||||
meta: "cmd"
|
||||
score: score
|
||||
}
|
||||
completions = completions.concat staticCommands, packageCommands
|
||||
completions = completions.concat commandSnippets, packageCommands
|
||||
|
||||
callback null, completions
|
||||
|
||||
|
||||
+1
File diff suppressed because one or more lines are too long
-1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user