Last active
May 8, 2018 09:25
-
-
Save oshyshko/c37ead296575f2629976f55fb9fd7444 to your computer and use it in GitHub Desktop.
How to make your Atom + Haskell setup behave (almost) like IntelliJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # # | |
# How to make your Atom + Haskell setup to behave (almost) like IntelliJ: | |
# (by Oleksandr Shyshko @oshyshko <-- let me know if you want to contribute or have ideas) | |
# | |
# -------------------------------------------------------------------------- | |
# 1. Install Stack (see http://docs.haskellstack.org/ for details) | |
# | |
# $ curl -sSL https://get.haskellstack.org/ | sh | |
# $ stack update | |
# $ stack setup | |
# | |
# -------------------------------------------------------------------------- | |
# 2. Install binary deps (required by Atoms packages) | |
# | |
# $ stack install ghc-mod hlint stylish-haskell hasktags pointfree pointful | |
# | |
# -------------------------------------------------------------------------- | |
# 3. Install and run Atom | |
# | |
# - https://atom.io/ | |
# | |
# -------------------------------------------------------------------------- | |
# 4. Install Haskell plugins for Atom | |
# | |
# - Atom > Preferences > Packages > + Install > Filter packages by name > ... type "Haskell" > ... choose: | |
# - language-haskell | |
# - haskell-ghc-mod | |
# - autocomplete-haskell | |
# - ide-haskell | |
# - ide-haskell-hasktags | |
# - haskell-pointfree | |
# | |
# -------------------------------------------------------------------------- | |
# 5. Add the code bellow to your "init.coffee" (remove #s). | |
# | |
# - Atom > Init Script... | |
# | |
# ================================================= | |
# atom.commands.add 'atom-text-editor', | |
# 'editor:scroll-down': -> | |
# e = atom.workspace.getActiveTextEditor() | |
# ee = atom.views.getView(e) | |
# ee.setScrollTop( | |
# ee.getScrollTop() + e.getLineHeightInPixels()) | |
# | |
# 'editor:scroll-up': -> | |
# e = atom.workspace.getActiveTextEditor() | |
# ee = atom.views.getView(e) | |
# ee.setScrollTop( | |
# ee.getScrollTop() - e.getLineHeightInPixels()) | |
# | |
# {Point, Range} = require 'atom' | |
# | |
# # select with brackets | |
# atom.commands.add 'atom-text-editor', | |
# 'bracket-matcher:select-outside-bracket', -> | |
# return unless e = atom.workspace.getActiveTextEditor() | |
# return unless ev = atom.views.getView(e) | |
# ir = e.getSelectedBufferRange() | |
# ev.dispatchEvent(new Event("bracket-matcher:select-inside-brackets")) | |
# r = e.getSelectedBufferRange() | |
# return if ir.isEqual(r) | |
# nr = new Range(r.start.traverse(new Point(0, -1)), r.end.traverse(new Point(0, 1)) ) | |
# e.setSelectedBufferRange(nr) | |
# ================================================= | |
# | |
# - Restart Atom | |
# | |
# -------------------------------------------------------------------------- | |
# 6. Add the code bellow to your "keymap.cson". | |
# | |
# - Atom > Keymap... | |
# | |
# TODO unset: ctrl-page-up, ctrl-page-down | |
# TODO implement: ctrl-shift-j -- join lines | |
'atom-text-editor[data-grammar~="haskell"]': | |
'cmd-b': 'haskell-ghc-mod:go-to-declaration' | |
'ctrl-b': 'haskell-ghc-mod:go-to-declaration' | |
# 'ctrl-b': 'ide-haskell-hasktags:go-to-declaration' | |
# 'cmd-b': 'ide-haskell-hasktags:go-to-declaration' | |
'ctrl-alt-left': 'ide-haskell-hasktags:go-back' | |
'ctrl-n': 'ide-haskell-hasktags:show-tags' | |
# 'ctrl-alt-T': 'haskell-ghc-mod:show-type' | |
'ctrl-alt-t': 'haskell-ghc-mod:insert-type' | |
'ctrl-alt-h': 'haskell-hoogle:lookup' | |
'ctrl-alt-l': 'ide-haskell:prettify-file' | |
'f2': 'ide-haskell:next-error' | |
'shift-f2': 'ide-haskell:prev-error' | |
'ctrl-q': 'haskell-ghc-mod:show-info-fallback-to-type' | |
'ctrl-alt-i': 'haskell-ghc-mod:insert-import' | |
'atom-text-editor[data-grammar~="cabal"]': | |
'ctrl-alt-l': 'ide-haskell:prettify-file' | |
'body': | |
'ctrl-c': 'core:copy' | |
'ctrl-v': 'core:paste' | |
'ctrl-x': 'core:cut' | |
'ctrl-z': 'core:undo' | |
'ctrl-shift-z': 'core:redo' | |
'ctrl-home': 'core:move-to-top' | |
'ctrl-end': 'core:move-to-bottom' | |
'atom-workspace': | |
'ctrl-shift-f': 'project-find:show' | |
'ctrl-shift-r': 'project-find:show' | |
'ctrl-shift-n': 'fuzzy-finder:toggle-file-finder' | |
'ctrl-shift-a': 'command-palette:toggle' # Find action | |
'ctrl-1': 'tree-view:toggle' # Open corresponding tool window | |
'ctrl-2': 'ide-haskell:toggle-output' | |
'atom-text-editor': | |
'ctrl-left': 'editor:move-to-beginning-of-word' | |
'ctrl-right': 'editor:move-to-end-of-word' | |
'ctrl-shift-left': 'editor:select-to-beginning-of-word' | |
'ctrl-shift-right': 'editor:select-to-end-of-word' | |
'ctrl-down': 'editor:scroll-down' | |
'ctrl-up': 'editor:scroll-up' | |
'f3': 'find-and-replace:find-next' | |
'shift-f3': 'find-and-replace:find-previous' | |
'ctrl-[': 'bracket-matcher:go-to-matching-bracket' | |
'ctrl-]': 'bracket-matcher:go-to-matching-bracket' | |
'ctrl-{': 'bracket-matcher:select-outside-bracket' | |
'ctrl-}': 'bracket-matcher:select-outside-bracket' | |
'atom-workspace atom-text-editor:not([mini])': | |
# TODO move cursor down if one or no line was selected | |
'ctrl-/': 'editor:toggle-line-comments' | |
#'cmd-/': 'editor:toggle-line-comments' | |
'ctrl-d': 'editor:duplicate-lines' | |
'cmd-d': 'editor:duplicate-lines' | |
'ctrl-shift-j': 'editor:join-lines' | |
'ctrl-w': 'editor:select-to-next-subword-boundary' | |
'ctrl-shift-w': 'editor:select-to-previous-subword-boundary' | |
'shift-delete': 'editor:delete-line' | |
'ctrl-y': 'editor:delete-line' | |
'ctrl-shift-up': 'editor:move-line-up' | |
'ctrl-shift-down': 'editor:move-line-down' | |
'ctrl-r': 'find-and-replace:show' | |
'cmd-r': 'find-and-replace:show' | |
'alt-right': 'pane:show-next-item' | |
'alt-left': 'pane:show-previous-item' | |
'ctrl-l': 'go-to-line:toggle' | |
'ctrl-e': 'fuzzy-finder:toggle-buffer-finder' | |
'ctrl-j': 'snippets:available' | |
# -------------------------------------------------------------------------- | |
# 7. Enable autosave on window deactivation | |
# | |
# - Atom > Preferences > Packages > Filter packages by name > ... | |
# - "autosave" > Settings -> Packages -> autosave -> [v] Enabled | |
# | |
# -------------------------------------------------------------------------- | |
# 8. Create a Stack project and build it (from terminal) | |
# | |
# $ stack new hello-project | |
# $ cd hello-project | |
# $ stack build | |
# | |
# -------------------------------------------------------------------------- | |
# 9. Open the project from Atom | |
# | |
# - File > Add Project Folder ... > Choose "hello-project" | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment