|
@@ -29,15 +29,15 @@ define [
|
|
|
|
|
|
|
|
enable: () ->
|
|
enable: () ->
|
|
|
@editor.setOptions({
|
|
@editor.setOptions({
|
|
|
- enableBasicAutocompletion: true,
|
|
|
|
|
- enableSnippets: true,
|
|
|
|
|
|
|
+ enableBasicAutocompletion: true
|
|
|
|
|
+ enableSnippets: true
|
|
|
enableLiveAutocompletion: false
|
|
enableLiveAutocompletion: false
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
commandCompleter = new CommandManager(@metadataManager)
|
|
commandCompleter = new CommandManager(@metadataManager)
|
|
|
|
|
|
|
|
SnippetCompleter = new EnvironmentManager()
|
|
SnippetCompleter = new EnvironmentManager()
|
|
|
- PackageCompleter = new PackageManager(@metadataManager)
|
|
|
|
|
|
|
+ PackageCompleter = new PackageManager(@metadataManager, Helpers)
|
|
|
|
|
|
|
|
Graphics = @graphics
|
|
Graphics = @graphics
|
|
|
Preamble = @preamble
|
|
Preamble = @preamble
|
|
@@ -46,7 +46,7 @@ define [
|
|
|
GraphicsCompleter =
|
|
GraphicsCompleter =
|
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
|
context = Helpers.getContext(editor, pos)
|
|
context = Helpers.getContext(editor, pos)
|
|
|
- {lineUpToCursor, commandFragment, lineBeyondCursor, needsClosingBrace} = context
|
|
|
|
|
|
|
+ {commandFragment, closingBrace} = context
|
|
|
if commandFragment
|
|
if commandFragment
|
|
|
match = commandFragment.match(/^~?\\(includegraphics(?:\[.*])?){([^}]*, *)?(\w*)/)
|
|
match = commandFragment.match(/^~?\\(includegraphics(?:\[.*])?){([^}]*, *)?(\w*)/)
|
|
|
if match
|
|
if match
|
|
@@ -61,9 +61,9 @@ define [
|
|
|
path = path.slice(graphicsPath.length)
|
|
path = path.slice(graphicsPath.length)
|
|
|
break
|
|
break
|
|
|
result.push {
|
|
result.push {
|
|
|
- caption: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- value: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- meta: "graphic",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{#{path}#{closingBrace}"
|
|
|
|
|
+ value: "\\#{commandName}{#{path}#{closingBrace}"
|
|
|
|
|
+ meta: "graphic"
|
|
|
score: 50
|
|
score: 50
|
|
|
}
|
|
}
|
|
|
callback null, result
|
|
callback null, result
|
|
@@ -72,7 +72,7 @@ define [
|
|
|
FilesCompleter =
|
|
FilesCompleter =
|
|
|
getCompletions: (editor, session, pos, prefix, callback) =>
|
|
getCompletions: (editor, session, pos, prefix, callback) =>
|
|
|
context = Helpers.getContext(editor, pos)
|
|
context = Helpers.getContext(editor, pos)
|
|
|
- {lineUpToCursor, commandFragment, lineBeyondCursor, needsClosingBrace} = context
|
|
|
|
|
|
|
+ {commandFragment, closingBrace} = context
|
|
|
if commandFragment
|
|
if commandFragment
|
|
|
match = commandFragment.match(/^\\(input|include){(\w*)/)
|
|
match = commandFragment.match(/^\\(input|include){(\w*)/)
|
|
|
if match
|
|
if match
|
|
@@ -83,9 +83,9 @@ define [
|
|
|
if file.id != @$scope.docId
|
|
if file.id != @$scope.docId
|
|
|
path = file.path
|
|
path = file.path
|
|
|
result.push {
|
|
result.push {
|
|
|
- caption: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- value: "\\#{commandName}{#{path}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- meta: "file",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{#{path}#{closingBrace}"
|
|
|
|
|
+ value: "\\#{commandName}{#{path}#{closingBrace}"
|
|
|
|
|
+ meta: "file"
|
|
|
score: 50
|
|
score: 50
|
|
|
}
|
|
}
|
|
|
callback null, result
|
|
callback null, result
|
|
@@ -93,7 +93,7 @@ define [
|
|
|
LabelsCompleter =
|
|
LabelsCompleter =
|
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
|
context = Helpers.getContext(editor, pos)
|
|
context = Helpers.getContext(editor, pos)
|
|
|
- {lineUpToCursor, commandFragment, lineBeyondCursor, needsClosingBrace} = context
|
|
|
|
|
|
|
+ {commandFragment, closingBrace} = context
|
|
|
if commandFragment
|
|
if commandFragment
|
|
|
refMatch = commandFragment.match(/^~?\\([a-z]*ref){([^}]*, *)?(\w*)/)
|
|
refMatch = commandFragment.match(/^~?\\([a-z]*ref){([^}]*, *)?(\w*)/)
|
|
|
if refMatch
|
|
if refMatch
|
|
@@ -102,16 +102,16 @@ define [
|
|
|
result = []
|
|
result = []
|
|
|
if commandName != 'ref' # ref is in top 100 commands
|
|
if commandName != 'ref' # ref is in top 100 commands
|
|
|
result.push {
|
|
result.push {
|
|
|
- caption: "\\#{commandName}{}",
|
|
|
|
|
- snippet: "\\#{commandName}{}",
|
|
|
|
|
- meta: "cross-reference",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{}"
|
|
|
|
|
+ snippet: "\\#{commandName}{}"
|
|
|
|
|
+ meta: "cross-reference"
|
|
|
score: 60
|
|
score: 60
|
|
|
}
|
|
}
|
|
|
for label in metadataManager.getAllLabels()
|
|
for label in metadataManager.getAllLabels()
|
|
|
result.push {
|
|
result.push {
|
|
|
- caption: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- value: "\\#{commandName}{#{label}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- meta: "cross-reference",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{#{label}#{closingBrace}"
|
|
|
|
|
+ value: "\\#{commandName}{#{label}#{closingBrace}"
|
|
|
|
|
+ meta: "cross-reference"
|
|
|
score: 50
|
|
score: 50
|
|
|
}
|
|
}
|
|
|
callback null, result
|
|
callback null, result
|
|
@@ -120,7 +120,7 @@ define [
|
|
|
ReferencesCompleter =
|
|
ReferencesCompleter =
|
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
getCompletions: (editor, session, pos, prefix, callback) ->
|
|
|
context = Helpers.getContext(editor, pos)
|
|
context = Helpers.getContext(editor, pos)
|
|
|
- {lineUpToCursor, commandFragment, lineBeyondCursor, needsClosingBrace} = context
|
|
|
|
|
|
|
+ {commandFragment, closingBrace} = context
|
|
|
if commandFragment
|
|
if commandFragment
|
|
|
citeMatch = commandFragment.match(
|
|
citeMatch = commandFragment.match(
|
|
|
/^~?\\([a-z]*cite[a-z]*(?:\[.*])?){([^}]*, *)?(\w*)/
|
|
/^~?\\([a-z]*cite[a-z]*(?:\[.*])?){([^}]*, *)?(\w*)/
|
|
@@ -134,18 +134,18 @@ define [
|
|
|
previousArgsCaption = if previousArgs.length > 8 then "…," else previousArgs
|
|
previousArgsCaption = if previousArgs.length > 8 then "…," else previousArgs
|
|
|
result = []
|
|
result = []
|
|
|
result.push {
|
|
result.push {
|
|
|
- caption: "\\#{commandName}{}",
|
|
|
|
|
- snippet: "\\#{commandName}{}",
|
|
|
|
|
- meta: "reference",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{}"
|
|
|
|
|
+ snippet: "\\#{commandName}{}"
|
|
|
|
|
+ meta: "reference"
|
|
|
score: 60
|
|
score: 60
|
|
|
}
|
|
}
|
|
|
if references.keys and references.keys.length > 0
|
|
if references.keys and references.keys.length > 0
|
|
|
references.keys.forEach (key) ->
|
|
references.keys.forEach (key) ->
|
|
|
if !(key in [null, undefined])
|
|
if !(key in [null, undefined])
|
|
|
result.push({
|
|
result.push({
|
|
|
- caption: "\\#{commandName}{#{previousArgsCaption}#{key}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- value: "\\#{commandName}{#{previousArgs}#{key}#{if needsClosingBrace then '}' else ''}",
|
|
|
|
|
- meta: "reference",
|
|
|
|
|
|
|
+ caption: "\\#{commandName}{#{previousArgsCaption}#{key}#{closingBrace}"
|
|
|
|
|
+ value: "\\#{commandName}{#{previousArgs}#{key}#{closingBrace}"
|
|
|
|
|
+ meta: "reference"
|
|
|
score: 50
|
|
score: 50
|
|
|
})
|
|
})
|
|
|
callback null, result
|
|
callback null, result
|
|
@@ -155,7 +155,7 @@ define [
|
|
|
@editor.completers = [
|
|
@editor.completers = [
|
|
|
commandCompleter
|
|
commandCompleter
|
|
|
SnippetCompleter
|
|
SnippetCompleter
|
|
|
- PackageCompleter
|
|
|
|
|
|
|
+ PackageCompleter
|
|
|
ReferencesCompleter
|
|
ReferencesCompleter
|
|
|
LabelsCompleter
|
|
LabelsCompleter
|
|
|
GraphicsCompleter
|
|
GraphicsCompleter
|
|
@@ -172,7 +172,7 @@ define [
|
|
|
cursorPosition = @editor.getCursorPosition()
|
|
cursorPosition = @editor.getCursorPosition()
|
|
|
end = change.end
|
|
end = change.end
|
|
|
context = Helpers.getContext(@editor, end)
|
|
context = Helpers.getContext(@editor, end)
|
|
|
- {lineUpToCursor, commandFragment, commandName, lineBeyondCursor, needsClosingBrace} = context
|
|
|
|
|
|
|
+ {lineUpToCursor, commandFragment} = context
|
|
|
if lineUpToCursor.match(/.*%.*/)
|
|
if lineUpToCursor.match(/.*%.*/)
|
|
|
return
|
|
return
|
|
|
lastCharIsBackslash = lineUpToCursor.slice(-1) == "\\"
|
|
lastCharIsBackslash = lineUpToCursor.slice(-1) == "\\"
|