-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature request: --lines
to support partial formatting
#114
Comments
This would definitely be good to have but not trivial to implement because Runic is currently completely oblivious of line numbers. Do you know what happens if the range don't cover full expressions, for example half a function?
As opposed to existing In neovim I use conform.nvim which, even if the formatters don't support range formatting, enables this by inspecting the diff, see https://github.com/stevearc/conform.nvim/blob/master/doc/advanced_topics.md#range-formatting. In my experience this works pretty well. This would probably be the simplest addition. |
Correct. I was following the design of
It only formats half the function then. The logic for that is in https://github.com/llvm/llvm-project/blob/main/clang/lib/Format/AffectedRangeManager.h and https://github.com/llvm/llvm-project/blob/main/clang/lib/Format/AffectedRangeManager.cpp |
Thats probably a good way to find what to pass to
Perhaps the simplest thing is to only format tree nodes which fall entirely inside the range. This would be similar to adding |
That seems reasonable, yes. It's not like
On the other hand, when changing e.g. an argument to a function call spanning multiple lines, it would be nice if the entire call was formatted. But maybe that's focusing too much on details here, and it'd be good to start with a simple solution first. |
One option would be to walk up the syntax tree to toplevel, but that would mean that the entire function would be formatted (but maybe that is fine). |
That's probably a little too drastic? It could mean that most of the source file gets formatted, e.g., when using a coarse, toplevel |
Yea. I think the language server approach of inserting comments would work well because I don't ever think Runic transposes comments with some other tokens. |
This patch implements the `--lines=a:b` command line argument for limiting the formatting to the line range `a:b`. Multiple ranges are supported. Close #114.
This patch implements the `--lines=a:b` command line argument for limiting the formatting to the line range `a:b`. Multiple ranges are supported. Close #114.
This patch implements the `--lines=a:b` command line argument for limiting the formatting to the line range `a:b`. Multiple ranges are supported. Closes #114.
This patch implements the `--lines=a:b` command line argument for limiting the formatting to the line range `a:b`. Multiple ranges are supported. Closes #114.
clang-format
has the following feature:This empowers
git-clang-format
, a script that's used to incrementally format a codebase by only formatting the changes one is about to commit. Would it be possible to add that to Runic too?The text was updated successfully, but these errors were encountered: