This PR updates the configuration for significant code blocks that should be centered when using Typewriter.nvim's block centering features. It refines the list of syntax tree node types considered significant across multiple programming languages, ensuring more relevant and efficient centering behavior.
Changes
Added a refined list of significant node types:
Common across many languages:
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
Language-specific significant blocks:
PHP: namespace
Go: package
Rust: match_statement, impl_block, struct, enum, trait, mod
The updated list includes node types that are generally significant in the context of navigating and centering code blocks. This ensures that the Typewriter.nvim plugin provides a more tailored and relevant experience for users working with different programming languages.
Review Notes
The typewriter.commands functions were reviewed as part of this update to ensure consistency, but no changes were necessary to these functions.
The configuration changes are backward-compatible and enhance the plugin's functionality without affecting existing workflows.
This PR also resolves issues mentioned in Issue #9.
Issue #9 Notes
The changes seem to improve the behavior but it is still slightly off in PHP files, particularly with methods. The centering seems to favor curly braces instead of the method definition.
Example from a PHP file:
public function Example(): void
{
if (false) {
throw \ErrorException('Making these functions');
} elseif (true) {
throw \ErrorException('longer so we can properly');
} elseif (true) {
throw \ErrorException('test the TWCenter command');
} elseif (true) {
throw \ErrorException('test the TWCenter command');
} else {
return;
}
}
Calling TWTop on the above method results in the definition being off-screen, which may need further fine-tuning.
Testing
Tested the updated configuration with various code samples from the supported languages to verify that significant blocks are correctly centered.
Ensured that the plugin behavior remains consistent and stable with the refined list of node types.
Description
This PR updates the configuration for significant code blocks that should be centered when using Typewriter.nvim's block centering features. It refines the list of syntax tree node types considered significant across multiple programming languages, ensuring more relevant and efficient centering behavior.
Changes
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
namespace
package
match_statement
,impl_block
,struct
,enum
,trait
,mod
function_expression
except_clause
,def
tag
,script
,style
rule
,media
,keyframes
select_statement
,insert_statement
,update_statement
,delete_statement
,create_statement
,alter_statement
,drop_statement
,begin_statement
,commit_statement
,rollback_statement
Rationale
The updated list includes node types that are generally significant in the context of navigating and centering code blocks. This ensures that the Typewriter.nvim plugin provides a more tailored and relevant experience for users working with different programming languages.
Review Notes
typewriter.commands
functions were reviewed as part of this update to ensure consistency, but no changes were necessary to these functions.Issue #9 Notes
Calling
TWTop
on the above method results in the definition being off-screen, which may need further fine-tuning.Testing