Skip to content

Instantly share code, notes, and snippets.

@rafdls
Forked from jasongilman/atom_clojure_setup.md
Created October 21, 2017 07:13
Show Gist options
  • Select an option

  • Save rafdls/d38b7db16579b65f3944cba6678b181b to your computer and use it in GitHub Desktop.

Select an option

Save rafdls/d38b7db16579b65f3944cba6678b181b to your computer and use it in GitHub Desktop.

Revisions

  1. @jasongilman jasongilman revised this gist Mar 10, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -52,7 +52,7 @@ Enabled Checkboxes: auto pretty print, auto scroll, display executed code, enabl

    * Enabled: checked
    * Strict: unchecked
    * Indentation Forms: `try, catch, finally, let, are, /^def.*/, fn, cond, if, if-let, for, /when.*/, testing, doseq, dotimes, loop, ns`
    * Indentation Forms: `try, catch, finally, /^let/, are, /^def/, fn, cond, condp, /^if.*/, /.*\/for/, for, for-all, /^when.*/, testing, doseq, dotimes, ns, routes, GET, POST, PUT, DELETE, extend-protocol, loop, do, case, with-bindings, checking, with-open`
    * Keybindings Enable: unchecked

    ## Atom Settings
  2. @jasongilman jasongilman revised this gist Feb 8, 2017. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -40,6 +40,10 @@ This is the built in package that comes with Atom for the Clojure Grammar. I fin

    Everything else is left at the default.

    ### bracket-matcher

    Change autocomplete characters to `(), [], {}, "", “”, ‘’, «», ‹›` This disables closing of single quotes and back ticks.

    ### Proto REPL

    Enabled Checkboxes: auto pretty print, auto scroll, display executed code, enable completions, prefer lein, all the refresh check boxes, show inline results, use clojure syntax.
  3. @jasongilman jasongilman revised this gist Sep 9, 2016. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions init.coffee
    Original file line number Diff line number Diff line change
    @@ -41,5 +41,10 @@ atom.commands.add 'atom-text-editor', 'jason:indent-top-sexp', ->
    maintainingCursorPosition ->
    editor = atom.workspace.getActiveTextEditor()
    range = protoRepl.EditorUtils.getCursorInClojureTopBlockRange(editor)
    # Work around a lisp paredit bug where it can't indent a range if selected from the very beginning of the file
    start = range.start
    if start.column == 0 && start.row == 0
    start.column = 1

    editor.setSelectedScreenRange(range)
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:indent')
  4. @jasongilman jasongilman revised this gist Aug 10, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -19,7 +19,7 @@ These are the ones I install related to Clojure development.

    * [proto-repl](https://github.com/jasongilman/proto-repl) - Clojure REPL, autocompletion, etc.
    * [proto-repl-charts](https://github.com/jasongilman/proto-repl-charts) - Graphs and Charts
    * ink - Proto REPL dependency used for inline display.
    * ink - Proto REPL dependency used for inline display and the REPL output.
    * tool-bar - Proto REPL uses this to display a tool bar with options.
    * Parinfer - Handles parentheses and general Lisp editing.
    * lisp-paredit - Used only for proper indentation on newline and indenting blocks of code. (Hopefully Parinfer will handle all of these in the future)
  5. @jasongilman jasongilman revised this gist Jun 6, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -64,7 +64,7 @@ These are main Atom Settings related to Clojure that are different than the defa
    Atom has a place for custom styles. Place the following in your styles.less. This disables unbalanced lisp-paredit parentheses indicators in the REPL.

    ```Less
    atom-text-editor::shadow .proto-repl-repl .lisp-syntax-error .region {
    .proto-repl-repl::shadow .lisp-syntax-error .region {
    background-color: rgba(0, 0, 0, 0) !important;
    }
    ```
  6. @jasongilman jasongilman revised this gist Jun 5, 2016. 1 changed file with 10 additions and 0 deletions.
    10 changes: 10 additions & 0 deletions atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -59,6 +59,16 @@ These are main Atom Settings related to Clojure that are different than the defa
    * Scroll Past End: checked
    * Due to [this autocomplete issue](https://github.com/atom/autocomplete-plus/issues/680) there is a lot of flashing from the autocomplete window that pops up. Scrolling down farther usually resolves the issue.

    ## styles.less

    Atom has a place for custom styles. Place the following in your styles.less. This disables unbalanced lisp-paredit parentheses indicators in the REPL.

    ```Less
    atom-text-editor::shadow .proto-repl-repl .lisp-syntax-error .region {
    background-color: rgba(0, 0, 0, 0) !important;
    }
    ```

    ## init.coffee and keymap.cson

    The files included in this gist init.coffee and keymap.cson contain additional settings for Atom. You can paste their contents in the files after opening them in Atom.
  7. @jasongilman jasongilman revised this gist May 17, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -56,6 +56,8 @@ Enabled Checkboxes: auto pretty print, auto scroll, display executed code, enabl
    These are main Atom Settings related to Clojure that are different than the default.

    * Auto Indent On Paste: unchecked
    * Scroll Past End: checked
    * Due to [this autocomplete issue](https://github.com/atom/autocomplete-plus/issues/680) there is a lot of flashing from the autocomplete window that pops up. Scrolling down farther usually resolves the issue.

    ## init.coffee and keymap.cson

  8. @jasongilman jasongilman revised this gist Mar 9, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,8 @@ The [Atom documentation](https://atom.io/docs) is excellent. It's highly worth r

    These are the ones I install related to Clojure development.

    * proto-repl - Clojure REPL, autocompletion, etc.
    * proto-repl-charts - Graphs and Charts
    * [proto-repl](https://github.com/jasongilman/proto-repl) - Clojure REPL, autocompletion, etc.
    * [proto-repl-charts](https://github.com/jasongilman/proto-repl-charts) - Graphs and Charts
    * ink - Proto REPL dependency used for inline display.
    * tool-bar - Proto REPL uses this to display a tool bar with options.
    * Parinfer - Handles parentheses and general Lisp editing.
  9. @jasongilman jasongilman revised this gist Mar 9, 2016. 1 changed file with 16 additions and 1 deletion.
    17 changes: 16 additions & 1 deletion atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,18 @@

    This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

    ## Packages Installed
    ## Install Atom

    [Download Atom](https://atom.io/)

    The [Atom documentation](https://atom.io/docs) is excellent. It's highly worth reading the flight manual.

    ## Install Java and Leiningen

    * [Java](http://www.oracle.com/technetwork/java/javase/downloads/index.html)
    * [Leiningen](http://leiningen.org/)

    ## Install These Packages

    These are the ones I install related to Clojure development.

    @@ -45,3 +56,7 @@ Enabled Checkboxes: auto pretty print, auto scroll, display executed code, enabl
    These are main Atom Settings related to Clojure that are different than the default.

    * Auto Indent On Paste: unchecked

    ## init.coffee and keymap.cson

    The files included in this gist init.coffee and keymap.cson contain additional settings for Atom. You can paste their contents in the files after opening them in Atom.
  10. @jasongilman jasongilman renamed this gist Mar 9, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  11. @jasongilman jasongilman created this gist Mar 8, 2016.
    45 changes: 45 additions & 0 deletions init.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    # These add some convenience commands for cutting, copying, pasting, deleting, and indenting Lisp expressions.

    # Applies the function f and then reverts the cursor positions back to their original location
    maintainingCursorPosition = (f)->
    editor = atom.workspace.getActiveTextEditor()
    currSelected = editor.getSelectedBufferRanges()
    f()
    editor.setSelectedScreenRanges(currSelected)

    # Cuts the current block of lisp code.
    atom.commands.add 'atom-text-editor', 'jason:cut-sexp', ->
    editor = atom.workspace.getActiveTextEditor()
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:up-sexp')
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:expand-selection')
    atom.commands.dispatch(atom.views.getView(editor), 'core:cut')

    # Copies the current block of lisp code.
    atom.commands.add 'atom-text-editor', 'jason:copy-sexp', ->
    maintainingCursorPosition ->
    editor = atom.workspace.getActiveTextEditor()
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:up-sexp')
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:expand-selection')
    atom.commands.dispatch(atom.views.getView(editor), 'core:copy')

    # Pastes over current block of lisp code.
    atom.commands.add 'atom-text-editor', 'jason:paste-sexp', ->
    editor = atom.workspace.getActiveTextEditor()
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:up-sexp')
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:expand-selection')
    atom.commands.dispatch(atom.views.getView(editor), 'core:paste')

    # Deletes the current block of lisp code.
    atom.commands.add 'atom-text-editor', 'jason:delete-sexp', ->
    editor = atom.workspace.getActiveTextEditor()
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:up-sexp')
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:expand-selection')
    atom.commands.dispatch(atom.views.getView(editor), 'core:delete')

    # Indents the top level sexp.
    atom.commands.add 'atom-text-editor', 'jason:indent-top-sexp', ->
    maintainingCursorPosition ->
    editor = atom.workspace.getActiveTextEditor()
    range = protoRepl.EditorUtils.getCursorInClojureTopBlockRange(editor)
    editor.setSelectedScreenRange(range)
    atom.commands.dispatch(atom.views.getView(editor), 'lisp-paredit:indent')
    38 changes: 38 additions & 0 deletions keymap.cson
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    # Allows using enter to select an autocomplete suggestion.
    '.platform-darwin atom-text-editor[data-grammar~="clojure"].autocomplete-active':
    'enter': 'autocomplete-plus:confirm'

    '.platform-darwin atom-text-editor[data-grammar~="clojure"]':

    # Indent the current selection
    'cmd-i': 'lisp-paredit:indent'

    # Expand the selection up a block
    'ctrl-shift-m': 'lisp-paredit:expand-selection'

    # Provides proper indentation when enter is pressed. (I disable normal lisp-paredit keybindings)
    'enter': 'lisp-paredit:newline'

    # Helpers for cutting, copying, pasting, deleting, and indenting a Clojure code
    'cmd-shift-x': 'jason:cut-sexp'
    'cmd-shift-c': 'jason:copy-sexp'
    'cmd-shift-v': 'jason:paste-sexp'
    'cmd-shift-delete': 'jason:delete-sexp'
    'cmd-shift-d': 'jason:delete-sexp'
    'cmd-shift-i': 'jason:indent-top-sexp'


    # Miscellaneous helpers. Less applicable to clojure code. (optional)
    '.platform-darwin atom-workspace atom-text-editor':
    'alt-up': 'editor:move-line-up'
    'alt-down': 'editor:move-line-down'
    'cmd-alt-down': 'editor:duplicate-lines'
    'cmd-d': 'editor:delete-line'
    'ctrl-s':'tree-view:toggle'
    'cmd-e': 'find-and-replace:select-next'
    'cmd-alt-ctrl-w': 'editor:toggle-soft-wrap'
    'alt-backspace': 'editor:delete-to-previous-word-boundary'
    'alt-delete': 'editor:delete-to-next-word-boundary'
    'ctrl-d': 'proto-repl:exit-repl'
    'cmd-l': 'go-to-line:toggle'
    'ctrl-l': 'proto-repl:clear-repl'
    47 changes: 47 additions & 0 deletions my_atom_clojure_setup.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    # Atom Clojure Setup

    This describes how I setup Atom for an ideal Clojure development workflow. This fixes indentation on newlines, handles parentheses, etc. The keybinding settings for enter (in keymap.cson) are important to get proper newlines with indentation at the right level. There are other helpers in init.coffee and keymap.cson that are useful for cutting, copying, pasting, deleting, and indenting Lisp expressions.

    ## Packages Installed

    These are the ones I install related to Clojure development.

    * proto-repl - Clojure REPL, autocompletion, etc.
    * proto-repl-charts - Graphs and Charts
    * ink - Proto REPL dependency used for inline display.
    * tool-bar - Proto REPL uses this to display a tool bar with options.
    * Parinfer - Handles parentheses and general Lisp editing.
    * lisp-paredit - Used only for proper indentation on newline and indenting blocks of code. (Hopefully Parinfer will handle all of these in the future)
    * highlight-selected - highlights selected keywords throughout an editor.
    * set-syntax - Easily change syntax with the command palette.

    ## Package Settings

    ### language-clojure

    This is the built in package that comes with Atom for the Clojure Grammar. I find the default settings bad for the way that I work. I recommend changing them to the following.

    * Auto Indent: unchecked
    * Auto Indent On Paste: unchecked
    * Non Word Characters: \()"':,;~@#$%^&{}[]`
    * Scroll Past End: checked
    * Tab Length: 1

    Everything else is left at the default.

    ### Proto REPL

    Enabled Checkboxes: auto pretty print, auto scroll, display executed code, enable completions, prefer lein, all the refresh check boxes, show inline results, use clojure syntax.

    ### lisp-paredit

    * Enabled: checked
    * Strict: unchecked
    * Indentation Forms: `try, catch, finally, let, are, /^def.*/, fn, cond, if, if-let, for, /when.*/, testing, doseq, dotimes, loop, ns`
    * Keybindings Enable: unchecked

    ## Atom Settings

    These are main Atom Settings related to Clojure that are different than the default.

    * Auto Indent On Paste: unchecked