From 23091c9d29f575379d01b7011890da044a302433 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Mon, 20 Dec 2021 03:42:23 +0100 Subject: Highlight comments in c, cpp, cmake and llvm (#1309) Also, reuse the c injections in glsl--- runtime/queries/c/injections.scm | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 runtime/queries/c/injections.scm (limited to 'runtime/queries/c') diff --git a/runtime/queries/c/injections.scm b/runtime/queries/c/injections.scm new file mode 100644 index 00000000..321c90ad --- /dev/null +++ b/runtime/queries/c/injections.scm @@ -0,0 +1,2 @@ +((comment) @injection.content + (#set! injection.language "comment")) -- cgit v1.2.3-70-g09d2 From 5b1a628e81b7d2f198ef401d442ca7967c5a0135 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Tue, 4 Jan 2022 02:53:04 +0100 Subject: Add textobjects and indents to c and cpp (#1293) Indentation of single line statements doesn't work, i.e. for (;;) leads to for(;;) Only blocks with curly braces are indented.--- book/src/generated/lang-support.md | 4 ++-- runtime/queries/c/indents.toml | 16 ++++++++++++++++ runtime/queries/c/textobjects.scm | 13 +++++++++++++ runtime/queries/cpp/indents.toml | 17 +++++++++++++++++ runtime/queries/cpp/textobjects.scm | 7 +++++++ 5 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 runtime/queries/c/indents.toml create mode 100644 runtime/queries/c/textobjects.scm create mode 100644 runtime/queries/cpp/indents.toml create mode 100644 runtime/queries/cpp/textobjects.scm (limited to 'runtime/queries/c') diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index ee719b56..a1fbf172 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -1,11 +1,11 @@ | Language | Syntax Highlighting | Treesitter Textobjects | Auto Indent | Default LSP | | --- | --- | --- | --- | --- | | bash | ✓ | | | `bash-language-server` | -| c | ✓ | | | `clangd` | +| c | ✓ | ✓ | ✓ | `clangd` | | c-sharp | ✓ | | | | | cmake | ✓ | ✓ | ✓ | `cmake-language-server` | | comment | ✓ | | | | -| cpp | ✓ | | | `clangd` | +| cpp | ✓ | ✓ | ✓ | `clangd` | | css | ✓ | | | | | dart | ✓ | | ✓ | `dart` | | dockerfile | ✓ | | | `docker-langserver` | diff --git a/runtime/queries/c/indents.toml b/runtime/queries/c/indents.toml new file mode 100644 index 00000000..f4076e17 --- /dev/null +++ b/runtime/queries/c/indents.toml @@ -0,0 +1,16 @@ +indent = [ + "compound_statement", + "field_declaration_list", + "enumerator_list", + "parameter_list", + "init_declarator", + "case_statement", + "condition_clause", + "expression_statement", +] + +outdent = [ + "case", + "}", + "]", +] diff --git a/runtime/queries/c/textobjects.scm b/runtime/queries/c/textobjects.scm new file mode 100644 index 00000000..b0f03668 --- /dev/null +++ b/runtime/queries/c/textobjects.scm @@ -0,0 +1,13 @@ +(function_definition + body: (_) @function.inside) @function.around + +(struct_specifier + body: (_) @class.inside) @class.around + +(enum_specifier + body: (_) @class.inside) @class.around + +(union_specifier + body: (_) @class.inside) @class.around + +(parameter_declaration) @parameter.inside diff --git a/runtime/queries/cpp/indents.toml b/runtime/queries/cpp/indents.toml new file mode 100644 index 00000000..0ca2ed8b --- /dev/null +++ b/runtime/queries/cpp/indents.toml @@ -0,0 +1,17 @@ +indent = [ + "compound_statement", + "field_declaration_list", + "enumerator_list", + "parameter_list", + "init_declarator", + "case_statement", + "condition_clause", + "expression_statement", +] + +outdent = [ + "case", + "access_specifier", + "}", + "]", +] diff --git a/runtime/queries/cpp/textobjects.scm b/runtime/queries/cpp/textobjects.scm new file mode 100644 index 00000000..6e3de1a2 --- /dev/null +++ b/runtime/queries/cpp/textobjects.scm @@ -0,0 +1,7 @@ +; inherits: c + +(lambda_expression + body: (_) @function.inside) @function.around + +(class_specifier + body: (_) @class.inside) @class.around -- cgit v1.2.3-70-g09d2