Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite indentation code #31

Draft
wants to merge 70 commits into
base: master
Choose a base branch
from
Draft

Rewrite indentation code #31

wants to merge 70 commits into from

Commits on Apr 21, 2023

  1. Begin rewrite of indentation code

    The objectives are:
    
        1. Simplify the indentation code; previous implementation has become
           so complex it is impossible to maintain,
    
        2. Significantly improve performance; previous indentation code was
           painfully slow, (see issue #6)
    
        3. Maximum configurability; should be configured similarly to cljfmt
           and make previously impossible things possible (e.g. issue #21).
    
    As of this commit, objectives 1 and 2 have been met, but work on
    objective 3 has not yet begun.  There will continue to be further
    improvements, particularly around performance and the "what if syntax
    highlighting is disabled?" scenario.
    
    These changes will unfortunately be backwards incompatible, but
    hopefully the improved performance and API will make up for it.
    axvr committed Apr 21, 2023
    Configuration menu
    Copy the full SHA
    7d6bdd7 View commit details
    Browse the repository at this point in the history
  2. Double (or better) indent performance!

    By utilising some ugly mutable state, this change more than doubles the
    performance of the indentation code.  You can expect even further
    benefits in larger code blocks.  This should completely eliminate any
    need for the `clojure_maxlines` configuration option.
    axvr committed Apr 21, 2023
    Configuration menu
    Copy the full SHA
    5706ea3 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5f083ff View commit details
    Browse the repository at this point in the history
  4. Check for maps before vectors for further performance enhancement

    Since maps are far more likely to across multiple lines than vectors
    (and when they are they tend to be much larger, e.g. EDN files!), we can
    further optimise indentation by checking if the line is inside a map
    *before* checking it is inside a vector.
    
    (This happens because of the performance improvement made with the
    addition of the optimised `CheckPair` function.)
    axvr committed Apr 21, 2023
    Configuration menu
    Copy the full SHA
    f4e0689 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    2627e1c View commit details
    Browse the repository at this point in the history

Commits on Apr 26, 2023

  1. Configuration menu
    Copy the full SHA
    4a3cab7 View commit details
    Browse the repository at this point in the history

Commits on Apr 27, 2023

  1. Configuration menu
    Copy the full SHA
    d1ec02c View commit details
    Browse the repository at this point in the history
  2. Mimic multi-line string/regex indent behaviour of VS Code and Emacs

    The `=` operator will no longer alter the indent of lines within
    a Clojure multi-line string or regular expression.
    
    The previous behaviour was annoying for writing detailed doc-strings, as
    it made reformatting the file with `gg=G` not possible as it would screw
    up the indentation within the doc-strings.
    
    Now the behaviour matches that of VS Code and Emacs.
    axvr committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    c3047be View commit details
    Browse the repository at this point in the history
  3. When clojure_align_multiline_strings is -1, no indentation

    By setting the `clojure_align_multiline_strings` option to `-1` it will
    switch to traditional Lisp multi-line string indentation, of no indent.
    axvr committed Apr 27, 2023
    Configuration menu
    Copy the full SHA
    eb0463e View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    d69008f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    d73e408 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    d177b3b View commit details
    Browse the repository at this point in the history

Commits on Apr 28, 2023

  1. Fix false positive multi-line string detection

    Sometimes it seems that when `=`ing over a block, Vim will sometimes
    not re-highlight strings correctly until we have already ran
    `searchpairpos`.  In this case, we implement a hacky workaround which
    detects the false-positive and recovers from it.
    axvr committed Apr 28, 2023
    Configuration menu
    Copy the full SHA
    51e6a43 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e573da7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    242dc9d View commit details
    Browse the repository at this point in the history
  4. Initial work on list indentation

    Still lots to do here, this is just the initial work.
    axvr committed Apr 28, 2023
    Configuration menu
    Copy the full SHA
    342f35f View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    51f5dcb View commit details
    Browse the repository at this point in the history

Commits on Apr 30, 2023

  1. Start of a small Clojure reader for indentation w/o syntax highlighting

    Not complete yet, but getting there.
    axvr committed Apr 30, 2023
    Configuration menu
    Copy the full SHA
    cc9cda7 View commit details
    Browse the repository at this point in the history

Commits on May 1, 2023

  1. Completed the mini Clojure reader as the core of the indentation system

    Some refactoring should be possible here and further optimisations.
    Once all optimisations I can think of have been implemented, I'll try
    writing an alternate Vim9 script version.
    
    (The syntax highlight group checks used in previous implementations of
    the indentation code was the core bottleneck, so a Vim9 script version
    would not have been much faster.)
    axvr committed May 1, 2023
    Configuration menu
    Copy the full SHA
    ee2acc2 View commit details
    Browse the repository at this point in the history
  2. Reader indent algorithm perf has surpassed the prev syntax highlight one

    The performance of the new reader-like indentation algorithm has now
    surpassed the performance of my previous syntax highlighting approach
    with better accuracy and no hacky code required.
    axvr committed May 1, 2023
    Configuration menu
    Copy the full SHA
    bdbc281 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8ee73c5 View commit details
    Browse the repository at this point in the history

Commits on May 29, 2023

  1. Configuration menu
    Copy the full SHA
    a4beb52 View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2023

  1. Fix accidental detection of backslashes as tokens

    Previously backslashes were accidentally detected as tokens by the
    indentation tokeniser.  This meant that character literals, would break
    indentation of everything after them.
    axvr committed Jun 10, 2023
    Configuration menu
    Copy the full SHA
    3d8197e View commit details
    Browse the repository at this point in the history

Commits on Jun 26, 2023

  1. Configuration menu
    Copy the full SHA
    101c9a4 View commit details
    Browse the repository at this point in the history
  2. Add basic function parameter alignment indentation

    This likely still needs a lot of improvements.
    axvr committed Jun 26, 2023
    Configuration menu
    Copy the full SHA
    35e0234 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    787e1e8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    bfce724 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a2ffcba View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    09720fe View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2728db2 View commit details
    Browse the repository at this point in the history

Commits on Aug 12, 2023

  1. Configuration menu
    Copy the full SHA
    d51154a View commit details
    Browse the repository at this point in the history

Commits on Aug 13, 2023

  1. Configuration menu
    Copy the full SHA
    f3d889f View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    bf4cf3d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    caef0c5 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3dbc6dd View commit details
    Browse the repository at this point in the history
  5. Add more indent test cases

    axvr committed Aug 13, 2023
    Configuration menu
    Copy the full SHA
    5550111 View commit details
    Browse the repository at this point in the history

Commits on Dec 23, 2023

  1. Neovim has added the state() function; use it if available

    See: neovim/neovim#23576
    
    Unintentional multiline string indentation will no longer occur in
    future Neovim versions.
    axvr committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    b8aef1b View commit details
    Browse the repository at this point in the history
  2. Fix application of inline comments during indentation

    Previously indenting code containing inline comments like this:
    
        {:foo 1  ; Hello [
         :bar 2}
    
    Would have resulted in this incorrect indentation:
    
        {:foo 1  ; Hello [
                          :bar 2}
    axvr committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    b2c392d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    4edeef0 View commit details
    Browse the repository at this point in the history
  4. Fix indentation of with-* macros

    axvr committed Dec 23, 2023
    Configuration menu
    Copy the full SHA
    0388414 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    41a45d4 View commit details
    Browse the repository at this point in the history

Commits on Dec 25, 2023

  1. Improve accuracy of function operand indenting

    In the original indent script, code like this:
    
        ((foo) 1
                   3)
    
    Would be indented as this:
    
        ((foo) 1
         3)
    
    Now it is *correctly* indented as this:
    
        ((foo) 1
               3)
    axvr committed Dec 25, 2023
    Configuration menu
    Copy the full SHA
    68999ca View commit details
    Browse the repository at this point in the history

Commits on Dec 26, 2023

  1. Configuration menu
    Copy the full SHA
    8f38c11 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7e90f09 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0b388ae View commit details
    Browse the repository at this point in the history

Commits on Mar 9, 2024

  1. More indent test cases

    axvr committed Mar 9, 2024
    Configuration menu
    Copy the full SHA
    289352d View commit details
    Browse the repository at this point in the history

Commits on Mar 10, 2024

  1. Configuration menu
    Copy the full SHA
    cefb7bc View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    16026f7 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    d87f254 View commit details
    Browse the repository at this point in the history

Commits on Sep 22, 2024

  1. Don't use fn arg alignment indent when a keyword is in function position

    Fixes indentation of reader conditional macros.  May choose to remove
    this if function argument indentation is generally preferred by
    programmers when a keyword is in function position.
    axvr committed Sep 22, 2024
    Configuration menu
    Copy the full SHA
    6a3d2d3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    083f554 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f271dca View commit details
    Browse the repository at this point in the history

Commits on Oct 4, 2024

  1. Configuration menu
    Copy the full SHA
    b86a4c0 View commit details
    Browse the repository at this point in the history
  2. Fix config option lookup

    Vim script is infuriating sometimes!  Turns out that the indentation
    tests locally passed with the previous code, but failed in CI and real
    life.
    axvr committed Oct 4, 2024
    Configuration menu
    Copy the full SHA
    01edfec View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    9b5e42c View commit details
    Browse the repository at this point in the history

Commits on Oct 5, 2024

  1. Improve indentation in "uniform" style and undo reader conditional work

    When the "uniform" indent style is selected, we no longer apply other
    list indentation rules/analysis.
    
    Unfortunately the reader conditional changes broke indentation for the
    following:
    
        (ns my-ns
          (:require [clojure.string :as str]
                    [clojure.spec.alpha :as s]))
    
    Indenting it as this:
    
        (ns my-ns
          (:require [clojure.string :as str]
           [clojure.spec.alpha :as s]))
    
    Which is incorrect.
    axvr committed Oct 5, 2024
    Configuration menu
    Copy the full SHA
    a41fa1b View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    3487e07 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3c5258c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3b4dad8 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    117b082 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b26db95 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    c4a25c5 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    1742549 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    9800368 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    69a0b6f View commit details
    Browse the repository at this point in the history

Commits on Oct 6, 2024

  1. Configuration menu
    Copy the full SHA
    058b4a7 View commit details
    Browse the repository at this point in the history
  2. Update indent regular expressions to set the required 'magic' mode

    Makes indentation more robust against users toggling the `'magic'`
    option.
    axvr committed Oct 6, 2024
    Configuration menu
    Copy the full SHA
    0a835d8 View commit details
    Browse the repository at this point in the history

Commits on Oct 7, 2024

  1. Configuration menu
    Copy the full SHA
    0d865c5 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    052a498 View commit details
    Browse the repository at this point in the history

Commits on Oct 13, 2024

  1. Configuration menu
    Copy the full SHA
    55543c4 View commit details
    Browse the repository at this point in the history