Skip to content

Conversation

@rly
Copy link

@rly rly commented Jun 12, 2020

As far as I can tell, local commands (plugins) cannot be assigned to atom commands for the purpose of keymapping. For example, it would be nice to be able to map the "compile" command to a keyboard shortcut. This PR adds an optional field to the command body called "action" that specifies the name to associate with the command for use in the keymap.

Example in the command plugin index.coffee:

  "compile":
    "description": "Compiles the currently opened C/C++ file using g++."
    "command": (state, args)->
      [cut]
      state.exec "#{COMPILER_NAME} #{COMPILER_FLAGS} \"#{SOURCE_FILE}\" -o \"#{TARGET_FILE}\" #{ADDITIONAL_FLAGS}", args, state
      return ""
    "action": "run-compile"

And in the keymap atp.cson or Atom user keymap:

'.platform-darwin atom-workspace':
  [cut]
  'ctrl-`': 'atom-terminal-panel:toggle'
  'ctrl-shift-c': 'atom-terminal-panel:run-compile'

The key combo "ctrl-shift-c" would then run the "compile" command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant