elixir-editors / emacs-elixir

Emacs major mode for Elixir
448 stars 94 forks source link

Improve speed of smie by disabling features #486

Open axelson opened 2 years ago

axelson commented 2 years ago

This PR disables the worst offenders of lookbacks that make opening large files very slow.

More testing is needed to determine if this is a worthwhile tradeoff. The main reason it is palatable is that it fixes https://github.com/elixir-editors/emacs-elixir/issues/463 and indentation isn't as important as it once was because you can simply run elixir-format (or lsp-format-buffer).

This probably isn't fit to merge as-is. At the very least we'd want to completely remove elixir-smie--semi-ends-match

Also in the future it would be very nice to replace the entire elixir-smie with https://codeberg.org/FelipeLema/tree-sitter-indent.el.git

wkirschbaum commented 2 years ago

tree-sitter-indent will require an external dependency right? it would be great to have basic indentation working without external dependencies if someone just wants to try out elixir in emacs without adding too much complexity.

forward-sexp seems to not work properly in elixir-mode, so maybe it is worth fixing that and see if indentation can be simplified. i will have a go at this this week.

axelson commented 2 years ago

@wkirschbaum that would be great :+1:

And yes tree-sitter-indent would be an external dependency.

wkirschbaum commented 2 years ago

Emacs is adding treesit which seems to be an optional compilation dependency based on the distro. After struggling with SMIE since December I did not get very far and optional dependency is good enough 😓 - gave it an honest go. treesitter can be used for indentation, fontification and navigation. Here is fontification working pretty well: https://github.com/elixir-editors/emacs-elixir/pull/495

victorolinasc commented 1 year ago

Hi @wkirschbaum ! I am curious to what would be a different approach for a major mode syntax table without tree-sitter and without SMIE. You've mentioned you´d like to do that in another issue and got me curious as how you'd go about doing that.

If you have any other modes done this way as benchmarks/inspiration that would be cool too!

In the meanwhile I might spend some more days delving into the deeps of SMIE and see if I get better results here... I think this is unlikely and probably will just spend some time here... but let's see...

wkirschbaum commented 1 year ago

@victorolinasc I spend months trying to tweak SMIE to not be in the way and could not get it right. On your question, I don't really know, but want to spend some time on it to have a look at other modes. Maybe a simpler SMIE gramamar? Not sure.