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

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
7d6bdd7
Begin rewrite of indentation code
axvr Apr 21, 2023
5706ea3
Double (or better) indent performance!
axvr Apr 21, 2023
5f083ff
A bit of code clean up and minor optimisations
axvr Apr 21, 2023
f4e0689
Check for maps before vectors for further performance enhancement
axvr Apr 21, 2023
2627e1c
Add fallback for when Vim was not compiled with `searchpairpos`
axvr Apr 21, 2023
4a3cab7
Fix string detection when entering a newline while in insert mode
axvr Apr 26, 2023
d1ec02c
Minor performance improvement when file contains multi-line strings
axvr Apr 26, 2023
c3047be
Mimic multi-line string/regex indent behaviour of VS Code and Emacs
axvr Apr 27, 2023
eb0463e
When `clojure_align_multiline_strings` is `-1`, no indentation
axvr Apr 27, 2023
d69008f
Update indentation options sections of the README and vim help file
axvr Apr 27, 2023
d73e408
Improve some of the comments in the indentation code
axvr Apr 27, 2023
d177b3b
Move string indent picker to a separate function
axvr Apr 27, 2023
51e6a43
Fix false positive multi-line string detection
axvr Apr 28, 2023
e573da7
EDN files are unlikely to contain many lists, so check them last
axvr Apr 28, 2023
242dc9d
Yet more string detection fixes and slight code clean up
axvr Apr 28, 2023
342f35f
Initial work on list indentation
axvr Apr 28, 2023
51f5dcb
More indentation code clean up and readability improvements
axvr Apr 28, 2023
cc9cda7
Start of a small Clojure reader for indentation w/o syntax highlighting
axvr Apr 30, 2023
ee2acc2
Completed the mini Clojure reader as the core of the indentation system
axvr Apr 30, 2023
bdbc281
Reader indent algorithm perf has surpassed the prev syntax highlight one
axvr May 1, 2023
8ee73c5
Small refactor to improve code clarity in indentation code
axvr May 1, 2023
a4beb52
Fix indentation bug during comment detection
axvr May 29, 2023
3d8197e
Fix accidental detection of backslashes as tokens
axvr Jun 10, 2023
101c9a4
Update indent comments and move `s:Conf` function to the top
axvr Jun 26, 2023
35e0234
Add basic function parameter alignment indentation
axvr Jun 26, 2023
787e1e8
Replace `clojure_align_subforms` with `clojure_indent_style`
axvr Jun 26, 2023
bfce724
Update and add a bunch of indentation tests
axvr Jun 26, 2023
a2ffcba
Fix indentation for multibyte characters
axvr Jun 26, 2023
09720fe
Switch test runner to Kaocha for nicer output
axvr Jun 26, 2023
2728db2
Only run GitHub Actions workflow once for PRs
axvr Jun 26, 2023
d51154a
Neovim does not have a `state()` function
axvr Aug 12, 2023
f3d889f
Initial work on building up macro indent rules
axvr Aug 13, 2023
bf4cf3d
Fix false-positive comment detection within strings
axvr Aug 13, 2023
caef0c5
Improve accuracy of multiline string detection for indentation
axvr Aug 13, 2023
3dbc6dd
Fix indentation when file contains multibyte characters
axvr Aug 13, 2023
5550111
Add more indent test cases
axvr Aug 13, 2023
b8aef1b
Neovim has added the `state()` function; use it if available
axvr Dec 23, 2023
b2c392d
Fix application of inline comments during indentation
axvr Dec 23, 2023
4edeef0
Add tests to check that comments don't affect indentation
axvr Dec 23, 2023
0388414
Fix indentation of `with-*` macros
axvr Dec 23, 2023
41a45d4
Update comments and add `with-in-str` indent rule
axvr Dec 23, 2023
68999ca
Improve accuracy of function operand indenting
axvr Dec 25, 2023
8f38c11
Slight code refactor and added more comments
axvr Dec 26, 2023
7e90f09
When `lispoptions` feature is available, we can enable the `lisp` option
axvr Dec 26, 2023
0b388ae
Indent some macros a bit like functions
axvr Dec 26, 2023
289352d
More indent test cases
axvr Mar 9, 2024
cefb7bc
Fix escape character detection logic
axvr Mar 10, 2024
16026f7
Simplify character column resolution
axvr Mar 10, 2024
d87f254
Add some indent rules for more built in macros
axvr Mar 10, 2024
6a3d2d3
Don't use fn arg alignment indent when a keyword is in function position
axvr Sep 22, 2024
083f554
Merge 'origin/master' into indent-forms
axvr Sep 22, 2024
f271dca
Add extra indentation test cases for records and protocols
axvr Sep 22, 2024
b86a4c0
Begin refinements to configuration options
axvr Oct 4, 2024
01edfec
Fix config option lookup
axvr Oct 4, 2024
9b5e42c
Discovered a way to put comments within dict defs in Vim script
axvr Oct 4, 2024
a41fa1b
Improve indentation in "uniform" style and undo reader conditional work
axvr Oct 5, 2024
3487e07
Update README to better cover the new indentation options
axvr Oct 5, 2024
3c5258c
Replace the old multi-line string config option
axvr Oct 5, 2024
3b4dad8
Remove the link to the #vim IRC as the link is now dead
axvr Oct 5, 2024
117b082
Fix typos and re-add the insert-mode completion info to the README
axvr Oct 5, 2024
b26db95
Update the "About" section within the Vim help doc
axvr Oct 5, 2024
c4a25c5
Update indentation section of the Vim help doc
axvr Oct 5, 2024
1742549
Improve indentation style examples in Vim help doc
axvr Oct 5, 2024
9800368
Minor documentation and comment refinements
axvr Oct 5, 2024
69a0b6f
In README, mention the replacements for each old indent config option
axvr Oct 5, 2024
058b4a7
Add indentation tests covering keywords in function position
axvr Oct 6, 2024
0a835d8
Update indent regular expressions to set the required 'magic' mode
axvr Oct 6, 2024
0d865c5
Compress comments on indent code
axvr Oct 7, 2024
052a498
Compress more comments on indent code
axvr Oct 7, 2024
55543c4
Use `<kbd>` to show keyboard shortcuts in `README.md`
axvr Oct 13, 2024
208ff9f
Improved accuracy of first function argument detection in indentation
axvr Jan 18, 2025
968340e
Slightly improve keyboard shortcut formatting in `README.md`
axvr Jan 18, 2025
082120a
Set mode in new regexprs
axvr Jan 18, 2025
161ea5f
Make `ClojureIndent()` function public
axvr Jan 19, 2025
78ecad5
Indent `with-` macros and functions like cljfmt default
axvr Jan 19, 2025
6ce7017
Run indentation tests against Vim AND Neovim
axvr Jan 25, 2025
d2f39f9
Install latest Vim and Neovim in GitHub Actions
axvr Jan 25, 2025
8e9ed28
Merge latest changes from 'origin/master'
axvr Jan 25, 2025
e5f86af
New indentation test runner
axvr Jan 26, 2025
7659541
Improve new test runner output and detect script errors
axvr Jan 26, 2025
1ea333a
Speed up indentation tests on Vim
axvr Jan 26, 2025
aae9ae8
Move `indenttime` script to `dev` folder as `time-indent`
axvr Jan 26, 2025
1883215
Update GitHub Actions
axvr Jan 26, 2025
5f995a1
Kaocha not needed anymore, so removing dependency
axvr Jan 26, 2025
f3358f3
Bump copyright year
axvr Jan 26, 2025
13ca6fe
Remove unneeded config from `clj/profile.clj`
axvr Jan 26, 2025
5b277db
Run indentation tests in Vim's silent Ex-improved mode
axvr Jan 26, 2025
d8dc8a7
Reduce indentation test runner noise and add colour output
axvr Feb 4, 2025
e50122e
GitHub Actions "annotations" feature doesn't work with colour output
axvr Feb 4, 2025
c4b8d48
Simplify indentation test runner output on GitHub Actions
axvr Feb 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reduce indentation test runner noise and add colour output
axvr committed Feb 4, 2025
commit d8dc8a77d1b7147866266c463d5f8c0b23bee494
37 changes: 25 additions & 12 deletions dev/do/test-indent
Original file line number Diff line number Diff line change
@@ -2,13 +2,26 @@

# Run Clojure.vim indentation tests.

# TODO: colour messages?
# TODO: option to enable/disable (Lua / Vim9script) versions.

C_GREEN='\033[1;32m'
C_RED='\033[1;31m'
C_YELLOW='\033[1;33m'
C_BLUE='\033[1;34m'
C_RESET='\033[0m'

log() { printf "$*$C_RESET\n"; }
logc() { log "$1$2"; }
succ() { logc "$C_GREEN" "$*"; }
warn() { logc "$C_YELLOW" "$*"; }
err() { logc "$C_RED" "$*"; }
info() { logc "$C_BLUE" "$*"; }
abort() { err "ABORT: $*"; exit 1; }

pushd "$(dirname "$0")/.."

if [ "$EDITOR" != 'vim' ] && [ "$EDITOR" != 'nvim' ]; then
echo 'ERROR: Set the "EDITOR" environment variable to "vim" or "nvim" and run again.'
exit 1
abort 'Set the "EDITOR" environment variable to "vim" or "nvim" and run again.'
fi

extra_opts=()
@@ -23,24 +36,22 @@ mkdir -p "$tmp_base_dir"
tmp_dir="$(mktemp --directory "$tmp_base_dir/XXXXXX")"
test_case_dir='tests'

test_pass() { PASSED+=("$1"); echo '::endgroup::'; }
test_pass() { PASSED+=("$1"); }
test_fail() {
FAILED+=("$1")
echo '::endgroup::'
echo "::error file=dev/$test_case_dir/$1/out.clj::Failed indent test case."
err "::error file=dev/$test_case_dir/$1/out.clj::Failed indent test case."
}
test_skip() {
SKIPPED+=("$1")
echo '::endgroup::'
echo "::warning file=dev/$test_case_dir/$1/out.clj::Skipped indent test case."
warn "::warning file=dev/$test_case_dir/$1/out.clj::Skipped indent test case."
}

run_test_case() {
test_case="$1"
in_file="$test_case_dir/$test_case/in.clj"
expected_file="$test_case_dir/$test_case/out.clj"

echo "::group::$EDITOR: $test_case"
info "> $EDITOR: $test_case"

if [ -f "$test_case_dir/$test_case/SKIP" ]; then
test_skip "$test_case"
@@ -56,7 +67,8 @@ run_test_case() {
test_cmd=('+normal! gg=G')
fi

"$EDITOR" "${extra_opts[@]}" --clean -EsNXnu test-vimrc.vim "${test_cmd[@]}" '+xall!' -- "$actual_file"
"$EDITOR" "${extra_opts[@]}" --clean -EsNXnu test-vimrc.vim \
"${test_cmd[@]}" '+xall!' -- "$actual_file"

diff --color=always -u "$expected_file" "$actual_file"

@@ -68,9 +80,10 @@ for tcase in $test_case_dir/*/; do
run_test_case "$(basename "$tcase")"
done

echo "passed: ${#PASSED[@]}, failed: ${#FAILED[@]}, skipped: ${#SKIPPED[@]}"
printf "passed: $C_GREEN%s$C_RESET, failed: $C_RED%s$C_RESET, skipped: $C_YELLOW%s$C_RESET\n" \
"${#PASSED[@]}" "${#FAILED[@]}" "${#SKIPPED[@]}"

# If none passed, or some failed, exit with error.
if [ ${#PASSED[@]} -eq 0 ] || [ ${#FAILED[@]} -gt 0 ]; then
exit 1
abort 'Failed test cases.'
fi