From b315901cbb137fd1b2f79bb9c1f10a1bef5b7f38 Mon Sep 17 00:00:00 2001 From: Daniel Ebert Date: Fri, 11 Aug 2023 12:26:27 +0200 Subject: Run indentation tests on a part of the Helix source code. Add C++ indent test file. --- helix-core/tests/data/indent/cpp.cpp | 48 +++++++++++++++++++++++++++++ helix-core/tests/data/indent/indent.rs | 1 - helix-core/tests/data/indent/languages.toml | 13 ++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 helix-core/tests/data/indent/cpp.cpp delete mode 120000 helix-core/tests/data/indent/indent.rs (limited to 'helix-core/tests/data/indent') diff --git a/helix-core/tests/data/indent/cpp.cpp b/helix-core/tests/data/indent/cpp.cpp new file mode 100644 index 00000000..6e7f3a88 --- /dev/null +++ b/helix-core/tests/data/indent/cpp.cpp @@ -0,0 +1,48 @@ +std::vector +fn_with_many_parameters(int parm1, long parm2, float parm3, double parm4, + char* parm5, bool parm6); + +std::vector +fn_with_many_parameters(int parm1, long parm2, float parm3, double parm4, + char* parm5, bool parm6) { + auto lambda = []() { + return 0; + }; + auto lambda_with_a_really_long_name_that_uses_a_whole_line + = [](int some_more_aligned_parameters, + std::string parm2) { + do_smth(); + }; + if (brace_on_same_line) { + do_smth(); + } else if (brace_on_next_line) + { + do_smth(); + } else if (another_condition) { + do_smth(); + } + else { + do_smth(); + } + if (inline_if_statement) + do_smth(); + if (another_inline_if_statement) + return [](int parm1, char* parm2) { + this_is_a_really_pointless_lambda(); + }; + + switch (var) { + case true: + return -1; + case false: + return 42; + } +} + +class MyClass : public MyBaseClass { +public: + MyClass(); + void public_fn(); +private: + super_secret_private_fn(); +} diff --git a/helix-core/tests/data/indent/indent.rs b/helix-core/tests/data/indent/indent.rs deleted file mode 120000 index 2ac16cf9..00000000 --- a/helix-core/tests/data/indent/indent.rs +++ /dev/null @@ -1 +0,0 @@ -../../../src/indent.rs \ No newline at end of file diff --git a/helix-core/tests/data/indent/languages.toml b/helix-core/tests/data/indent/languages.toml index 3206f124..fa02e451 100644 --- a/helix-core/tests/data/indent/languages.toml +++ b/helix-core/tests/data/indent/languages.toml @@ -11,3 +11,16 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "rust" source = { git = "https://github.com/tree-sitter/tree-sitter-rust", rev = "0431a2c60828731f27491ee9fdefe25e250ce9c9" } + +[[language]] +name = "cpp" +scope = "source.cpp" +injection-regex = "cpp" +file-types = ["cc", "hh", "c++", "cpp", "hpp", "h", "ipp", "tpp", "cxx", "hxx", "ixx", "txx", "ino", "C", "H"] +roots = [] +comment-token = "//" +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "cpp" +source = { git = "https://github.com/tree-sitter/tree-sitter-cpp", rev = "2d2c4aee8672af4c7c8edff68e7dd4c07e88d2b1" } -- cgit v1.2.3-70-g09d2