Browse Source

Can now use tabs with auto-indentation in clang-files.

merge-requests/365/head
eidheim 10 years ago
parent
commit
407e0fd967
  1. 2
      src/files.h
  2. 15
      src/source_clang.cc

2
src/files.h

@ -49,7 +49,7 @@ const std::string configjson =
" \"702\": \"def:statement\",\n" " \"702\": \"def:statement\",\n"
" \"705\": \"def:comment\"\n" " \"705\": \"def:comment\"\n"
" },\n" " },\n"
" \"clang_format_style\": \"UseTab: Never, ColumnLimit: 0\" //See http://clang.llvm.org/docs/ClangFormatStyleOptions.html\n" " \"clang_format_style\": \"ColumnLimit: 0\" //IndentWidth and UseTab is set automatically. See http://clang.llvm.org/docs/ClangFormatStyleOptions.html\n"
" },\n" " },\n"
" \"keybindings\": {\n" " \"keybindings\": {\n"
" \"new_file\": \"<primary>n\",\n" " \"new_file\": \"<primary>n\",\n"

15
src/source_clang.cc

@ -926,7 +926,19 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
auto_indent=[this]() { auto_indent=[this]() {
std::string command="clang-format"; std::string command="clang-format";
command+=" -style=\"{IndentWidth: "+std::to_string(tab_size); unsigned indent_width;
std::string tab_style;
if(tab_char=='\t') {
indent_width=tab_size*8;
tab_style="UseTab: Always";
}
else {
indent_width=tab_size;
tab_style="UseTab: Never";
}
command+=" -style=\"{IndentWidth: "+std::to_string(indent_width);
if(tab_style.size()>0)
command+=", "+tab_style;
if(Singleton::Config::source()->clang_format_style!="") if(Singleton::Config::source()->clang_format_style!="")
command+=", "+Singleton::Config::source()->clang_format_style; command+=", "+Singleton::Config::source()->clang_format_style;
command+="}\""; command+="}\"";
@ -957,7 +969,6 @@ Source::ClangViewAutocomplete(file_path, project_path, language) {
scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5); scroll_to(get_buffer()->get_insert(), 0.0, 1.0, 0.5);
} }
get_source_buffer()->end_user_action(); get_source_buffer()->end_user_action();
set_tab_char_and_size(' ', tab_size); //clang-format only does basic indentation with spaces as I understand it
} }
}; };

Loading…
Cancel
Save