Skip to content

Instantly share code, notes, and snippets.

@piersadrian
Created May 8, 2015 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save piersadrian/f9c32162c0829b7b4d69 to your computer and use it in GitHub Desktop.
Save piersadrian/f9c32162c0829b7b4d69 to your computer and use it in GitHub Desktop.
Atom autocomplete suggestions on tab
{Point} = require 'atom'
atom.commands.add 'atom-text-editor', 'custom:tabcomplete', (e) ->
editor = atom.workspace.getActiveTextEditor()
cursor = editor.getLastCursor()
{row, column} = cursor.getBufferPosition()
precedingCharacter = editor.getTextInBufferRange([[row, column - 1], [row, column]])
if /\S/.test(precedingCharacter)
autocomplete = atom.packages.getActivePackage('autocomplete-plus')
return unless autocomplete?
manager = autocomplete.mainModule.activate()
manager.shouldDisplaySuggestions = true
manager.findSuggestions(true)
else
e.abortKeyBinding()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment