From b585a02841a1b6bf41b57868f58485bec6293f0d Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Sat, 20 Jul 2024 19:02:55 -0600 Subject: [PATCH 1/2] refactor(test): Remove test.txt --- test.txt | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index 345e6ae..0000000 --- a/test.txt +++ /dev/null @@ -1 +0,0 @@ -Test From 2301b242d3eae38e217396f2d88e52ea0177ae1e Mon Sep 17 00:00:00 2001 From: Josh Peterson Date: Sat, 20 Jul 2024 19:04:49 -0600 Subject: [PATCH 2/2] feat: Update significant node types for centering - Added a refined list of significant node types across multiple languages (PHP, Lua, Go, Rust, JavaScript, Python, HTML, CSS, Bash, SQL). - The following node types were included for their relevance in centering behavior: - function - method - if_statement - for_loop - while_loop - switch_statement - case_statement - try_statement - catch_clause - finally_clause - do_statement - repeat_statement - function_declaration - class - class_declaration - method_declaration - arrow_function - generator_function - async_function - local_declaration - declaration_list - function_call - Added language-specific significant blocks: - PHP: namespace - Go: package - Rust: match_statement, impl_block, struct, enum, trait, mod - JavaScript: function_expression - Python: except_clause, def - HTML: tag, script, style - CSS: rule, media, keyframes - SQL: select_statement, insert_statement, update_statement, delete_statement, create_statement, alter_statement, drop_statement, begin_statement, commit_statement, rollback_statement. Changes to the `typewriter.commands` functions were reviewed but no modifications were necessary. --- lua/typewriter/utils/center_block_config.lua | 99 ++++++++++++-------- 1 file changed, 59 insertions(+), 40 deletions(-) diff --git a/lua/typewriter/utils/center_block_config.lua b/lua/typewriter/utils/center_block_config.lua index bff77b4..60c1d3a 100644 --- a/lua/typewriter/utils/center_block_config.lua +++ b/lua/typewriter/utils/center_block_config.lua @@ -29,60 +29,79 @@ local M = {} --- -- To disable centering for a specific node type: --- center_block_config.expand["function"] = false M.expand = { - ["comment"] = true, + -- Common significant blocks across many languages ["function"] = true, - ["body"] = true, ["method"] = true, - ["table"] = true, ["if_statement"] = true, - ["class"] = true, - ["block"] = true, - ["module"] = true, - ["namespace"] = true, - ["program"] = true, - ["source"] = true, ["for_loop"] = true, ["while_loop"] = true, - ["conditional"] = true, + ["switch_statement"] = true, + ["case_statement"] = true, ["try_statement"] = true, ["catch_clause"] = true, ["finally_clause"] = true, - ["switch_statement"] = true, - ["case_statement"] = true, - ["else_clause"] = true, ["do_statement"] = true, ["repeat_statement"] = true, - ["function_call"] = true, - ["function_definition"] = true, + ["function_declaration"] = true, + ["class"] = true, + ["class_declaration"] = true, + ["method_declaration"] = true, ["arrow_function"] = true, - ["function_expression"] = true, ["generator_function"] = true, ["async_function"] = true, - ["object"] = true, - ["array"] = true, - ["property"] = true, - ["field"] = true, - ["parameter"] = true, - ["constructor"] = true, - ["decorator"] = true, - ["import_statement"] = true, - ["export_statement"] = true, - ["try_expression"] = true, + ["local_declaration"] = true, + -- ["declaration_list"] = true, + ["function_call"] = true, + + -- Language-specific significant blocks + -- PHP + ["namespace"] = true, + + -- Lua + -- (covered by common significant blocks) + + -- Go + ["package"] = true, + + -- Rust ["match_statement"] = true, - ["enum_declaration"] = true, - ["interface_declaration"] = true, - ["type_alias"] = true, - ["variable_declaration"] = true, - ["lexical_declaration"] = true, - ["assignment"] = true, - ["expression_statement"] = true, - ["return_statement"] = true, - ["throw_statement"] = true, - ["await_expression"] = true, - ["declaration_list"] = true, - ["compound_statement"] = true, - ["method_declaration"] = true, - ["class_declaration"] = true, + ["impl_block"] = true, + ["struct"] = true, + ["enum"] = true, + ["trait"] = true, + ["mod"] = true, + + -- JavaScript + ["function_expression"] = true, + + -- Python + ["except_clause"] = true, + ["def"] = true, + + -- HTML + ["tag"] = true, + ["script"] = true, + ["style"] = true, + + -- CSS + ["rule"] = true, + ["media"] = true, + ["keyframes"] = true, + + -- Bash + -- (covered by common significant blocks) + + -- SQL + ["select_statement"] = true, + ["insert_statement"] = true, + ["update_statement"] = true, + ["delete_statement"] = true, + ["create_statement"] = true, + ["alter_statement"] = true, + ["drop_statement"] = true, + ["begin_statement"] = true, + ["commit_statement"] = true, + ["rollback_statement"] = true, } --- Get the expansion status for a given node type