Custom indentation via packages? (ex., for Lisp)


Hi all!

I’m curious if it’s possible for packages to customize code indentation?

In Lisp-like languages, proper indentation is essential, since coders don’t actually follow all those parenthesis. Lisp indentation rules are a bit different than most languages though, in that they often rely on custom rules for special forms (like let, when, etc.), or on aligning forms across lines. For example, the following snippet is correctly indented Lisp code.

(defun foo(x)
  (let* ((var nil)
         (a 2))         ;; Note alignment with above - structure is clear
    (bar var a)         ;; body of "let" traditionally has this indentation
    (+ (func-a var)
       (func-b var))))  ;; Again, correct alignment with above form

Is there an API to precisely control indentation in atom? This would be super useful (if not necessary) for codability in Lisp-like languages.

Thanks so much!


I haven’t delved too deeply into the raw editing capabilities, but I do not think there is an API like what I suspect you would need to just specify some rules to auto-indent that block of code. That said, it is all open source … so I’d suggest starting by taking a look at LanguageMode::suggestedIndentForBufferRow:


this would be good for python too


Check out the Overrides package for a solution to this problem. Being developed by @leedohm and myself, so feel free to chime in with suggestions, PRs, or otherwise.