clojurelighttable

How to smart-indent files automatically on save in Light Table


I would like to save nicely formatted Clojure code. Eclipse can format code every time a file is saved. It would be nice to have the same in Light Table. Manually, I can do it by selecting all (ctrl+a), then running (ctrl+space) Editor: Smart indent line(s). Is there a way to do it automatically every time a file is saved?


Solution

  • You can override key bindings for save in Settings: User keymap like:

    {:+ {:editor {"ctrl-s" [:editor.select-all
                            :smart-indent-selection
                            :editor.selection.clear
                            :save]}}}
    

    But you will lost cursor position (it will jump to the end of file). This can be handled with Marks plugin. Install the plugin and add command :lt.plugins.marks/jump-to-large-move-mark onto last position of commands vector.