Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TristinDavis/e29e433abc0ee972ad24b085ece03a76 to your computer and use it in GitHub Desktop.
Save TristinDavis/e29e433abc0ee972ad24b085ece03a76 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