Skip to content

Instantly share code, notes, and snippets.

@mngyuan
Created January 28, 2017 01:32
Show Gist options
  • Save mngyuan/9eb164cdbd4ceb0b64dda6679a698d5b to your computer and use it in GitHub Desktop.
Save mngyuan/9eb164cdbd4ceb0b64dda6679a698d5b to your computer and use it in GitHub Desktop.
ycm style completion in atom autocomplete-plus
# in keymap.cson
'atom-text-editor:not(mini).autocomplete-active':
'enter' : 'autocomplete-plus:confirm'
'tab' : 'core:move-down'
'shift-tab': 'core:move-up'
'.' : 'custom:ycm-style-complete-dot'
'(' : 'custom:ycm-style-complete-openparen'
'[' : 'custom:ycm-style-complete-opensquare'
'{' : 'custom:ycm-style-complete-opencurly'
')' : 'custom:ycm-style-complete-endparen'
']' : 'custom:ycm-style-complete-endsquare'
'}' : 'custom:ycm-style-complete-endcurly'
'"' : 'custom:ycm-style-complete-doublequote'
"'" : 'custom:ycm-style-complete-singlequote'
' ' : 'custom:ycm-style-complete-space'
';' : 'custom:ycm-style-complete-semicolon'
# and corresponding commands in init.coffee
# could be shorter if atom/atom#9209 gets made
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-dot', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('.')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-openparen', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('(')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-opensquare', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('[')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-opencurly', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('{')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-endparen', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText(')')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-endsquare', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText(']')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-endcurly', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('}')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-doublequote', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText('"')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-singlequote', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText("'")
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-space', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText(' ')
atom.commands.add 'atom-text-editor', 'custom:ycm-style-complete-semicolon', (e) ->
atom.commands.dispatch(e.currentTarget, 'autocomplete-plus:confirm')
atom.workspace.getActiveTextEditor()?.insertText(';')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment