Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Commit

Permalink
support "$" prefix for autocompletions
Browse files Browse the repository at this point in the history
  • Loading branch information
outsideris committed Dec 3, 2017
1 parent 0b7679c commit f0719b8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ module.exports =

getJavascriptCompletions: ({ prefix, editor, bufferPosition }) ->
completions = []
prefix = @getPrefix(editor, bufferPosition)
for idx, tag of @completions.javascript
completions.push({ text: tag, type: 'angularjs' })
completions.push({ text: tag, type: 'angularjs', replacementPrefix: prefix })
completions

getPreviousAttribute: (editor, bufferPosition) ->
Expand All @@ -100,5 +101,15 @@ module.exports =

attributePattern.exec(editor.getTextInRange([[bufferPosition.row, 0], [bufferPosition.row, quoteIndex]]))?[1]

getPrefix: (editor, bufferPosition) ->
# Whatever your prefix regex might be
regex = /\$?[\w0-9_-]+$/

# Get the text for the line up to the triggered buffer position
line = editor.getTextInRange([[bufferPosition.row, 0], bufferPosition])

# Match the regex to the line, and return the match
line.match(regex)?[0] or ''

firstCharsEqual = (str1, str2) ->
str1[0].toLowerCase() is str2[0].toLowerCase()

0 comments on commit f0719b8

Please sign in to comment.