GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||
GeezerVison is showing github.com — Rewrite indentation code by axvr · Pull Request #31 · clojure-vim/clojure.vim Conversation
|
|
I've been experimenting with a custom algorithm as per the check list item above. This version eliminates all syntax highlight checks (and therefore no longer requires the various hacks to make those checks work) plus it is approx the same speed as my first rewrite attempt and uses about the same amount of code. However the core benefits of this version is that it works when syntax highlighting is switched off, and eliminates the performance bottle neck of syntax highlight checks. This means that it will be possible to write a version of the algorithm in Vim9 script, to get another significant performance improvement! (Maintaining both a legacy Vim script and Vim9 script versions should be feasible due to how much simpler this is than the original implementation.) TL;DR: I'll push a new version to this branch soon which will be:
Once this branch is feature complete, I'll share benchmarks comparing it to the original as is on |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Not complete yet, but getting there.
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.)
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.
There was an error while loading. Please reload this page.
|
Performance benchmarks as of current change (+ unpushed Vim9 version). This is measuring the time to reindent a whole file on a Macbook Pro 2021, so expect much more noticable performance gains on slower hardware. 🚀
(I'll share new benchmarks (and the full reports generated by Vim) once this branch is feature complete, although I don't expect it to change much.) Even with the Vim9 implementation in the code too (not pushed yet, still figuring out how best to integrate it in a maintainable way), we can expect the file size of Regarding Neovim, until Vim9 script support is added, the "New (legacy)" code will be used. If anyone would like to volunteer to write a Lua implementation of this code for Neovim please open an issue and we can discuss how to integrate it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Previously backslashes were accidentally detected as tokens by the indentation tokeniser. This meant that character literals, would break indentation of everything after them.
Avoids screen flickering during test execution.
|
FYI, the
Multi-line lists that start with a non-symbol are currently indented with 2 instead of 1 space. E.g. (ns namespace (:require [clojure.set :as s])) The final line is indented 1 space because if indent_style ==# 'uniform' | return base_indent + 1 | endif Not sure the best way way for this to check if the first list item is a symbol or not. 🤔 I wrote this for #21 before I realized this rewrite was being done. It's a pattern that will match symbols, adapted from the tree-sitter grammar. (Though it may be easier to just special case non-symbols as first list item.) local suffixonly = ":#'0-9\\/" -- not allowed as first character local forbidden = { [[\[\]\n\r\t \\]], -- brackets, whitespace, slashes '(){}"@~^;`,', -- parens, braces, special characters suffixonly, } local prefix = string.format("[^%s]", table.concat(forbidden)) local suffix = string.format([[\(%s\|[%s]\)*]], prefix, suffixonly) local symbol = prefix .. suffix |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for raising this @garrett-hopper. I'll add it to my list and try to fix it soon. (Yet more mildly irritating rules in the common Clojure indentation styles 😆 😭) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Apologies to anyone waiting patiently for this to be merged. I haven't managed to find much time to dedicate to this and each time I come back to it, it requires a lot of context reloading as the standard Clojure indentation styles are shockingly all very complicated (contrary to Clojure itself) and to implement them efficiently in Vim script is forever painful. Currently what exists in this branch is IMO already far superior to what is currently on the
I hope to get round to the first 4 soon, but can't make any promises on when I will do so. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Pretty exciting! Thanks for shepherding this! I've been using this branch exclusively since you opened the PR and I'm quite pleased with it. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Bug report: defining protocol methods in (defrecord Example [a b c] MyProto (method1 [this d e f] (+ a b c d e f))) becomes (defrecord Example [a b c] MyProto (method1 [this d e f] (+ a b c d e f))) It looks like there's tests covering this, so I'm not sure what's wrong. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[Bug] incorrect indentation for curly braces with=
Compatibility with tree-sitter
Question: is there a way to configure Tonsky's indentation rule?
Improve indent performance
Add unit tests
There was an error while loading. Please reload this page.