[clangd-dev] textDocument/onTypeFormatting and live indentation.
Sam McCall via clangd-dev
clangd-dev at lists.llvm.org
Fri Sep 7 06:25:41 PDT 2018
We've had some discussion in the past about the right way for clang-format
to support live-formatting cases.
IIRC clang-format doesn't have any current logic specific to this, instead
having "format these ranges". That mode works well for formatting only
changed lines and similar cases, but it may or may not be the right model
for format-as-you-type.
In particular I don't think this model will ever give you useful
autoindent, because if you were *checking in the code* instead of
continuing to type, you'd want the leading spaces gone.
So we'd probably need to either:
- add a new "as-you-type" mode or entrypoint in clang-format's core, and
carefully decide what new features it needs and how they should interact
with clang-format's existing model, or
- hack something together outside of clang-format's core (possibly reusing
its parser)
My sense is that the first is likely to give better results, e.g. in the
reformatting braces cases the cursor/indentation and braces may interact.
Either way it might make sense to provide the result as a clang-format API,
rather than building the logic inside clangd directly.
On Thu, Sep 6, 2018 at 8:27 PM Alex L via clangd-dev <
clangd-dev at lists.llvm.org> wrote:
> Hi,
>
> I would like to implement clang-format aware newline indentation in
> Clangd. It looks like Clangd only supports '}' trigger character for the
> 'onTypeFormatting' request. Would it make sense to extend it to support the
> newline character, and to insert appropriate indentation instead of
> reformatting the range in that case?
>
> Cheers,
> Alex
> _______________________________________________
> clangd-dev mailing list
> clangd-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20180907/a8090b6e/attachment.html>
More information about the clangd-dev
mailing list