mirror of
https://github.com/MaskRay/ccls.git
synced 2025-01-31 09:50:26 +00:00
Default to Chromium's format style if cquery cannot obtain it (#211)
Set the tab configuration (tab, spaces, amount) to the information provided by the LSP client.
This commit is contained in:
parent
f9aa0ef66d
commit
c5610b8d76
@ -34,15 +34,15 @@ std::vector<Replacement> ClangFormat::FormatWholeDocument() {
|
||||
llvm::Expected<FormatStyle> style =
|
||||
getStyle("file", document_filename_, "chromium");
|
||||
if (!style) {
|
||||
// If, for some reason, we cannot get a format style, use Chromium's with
|
||||
// tab configuration provided by the client editor.
|
||||
LOG_S(ERROR) << llvm::toString(style.takeError());
|
||||
return {};
|
||||
predefined_style.UseTab = insert_spaces_
|
||||
? FormatStyle::UseTabStyle::UT_Never
|
||||
: FormatStyle::UseTabStyle::UT_Always;
|
||||
predefined_style.IndentWidth = tab_size_;
|
||||
}
|
||||
|
||||
if (*style == predefined_style) {
|
||||
style->UseTab = insert_spaces_ ? FormatStyle::UseTabStyle::UT_Never
|
||||
: FormatStyle::UseTabStyle::UT_Always;
|
||||
style->IndentWidth = tab_size_;
|
||||
}
|
||||
auto format_result = reformat(*style, document_, ranges_, document_filename_);
|
||||
return std::vector<Replacement>(format_result.begin(), format_result.end());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user