ALSchwalm / janet-mode

A major mode for the janet programming language: https://janet-lang.org/
GNU General Public License v3.0
47 stars 14 forks source link

This fixes issue where struct/table keys were terribly misaligned in janet code #6

Closed ahungry closed 4 years ago

ahungry commented 4 years ago

Fixes the poor alignment of struct/table keys

ALSchwalm commented 4 years ago

Thanks for the pull request. Can you provide an example what what this changes? The current code seems to produce reasonable indentation in many cases, at least. For example from the docs:

(def my-struct {:key1 2
                :key2 4})

(def my-struct2 (struct
                 :key1 2
                 :key2 4))

Is indented the same as it is shown in the docs.

ahungry commented 4 years ago

If you call (indent-sexp) on a top level map, I was getting odd alignment:

{:x 1
    :y 2
}
ahungry commented 4 years ago

It happens with indent-sexp, the tab based alignment was fine, but align-sexp calls the lisp-indent, which is redefined to be a special alignment in clojure mode, but was missing here

ahungry commented 4 years ago

(The program i use that often invokes align-sexp, as its an odd one to call by hand, is lispy)

ahungry commented 4 years ago

Its because indent-sexp would calculate the offset according to how elisp/common lisp/scheme would handle indentation:

(list :x 1
      :y 2)

where it makes sense to disregard the first thing-at-point after the data structure start