Skip to content

Commit

Permalink
Merge pull request #15 from joshuadanpeterson/dev
Browse files Browse the repository at this point in the history
Add Support for Multiple Filetypes and Enhance Documentation for Typewriter.nvim
  • Loading branch information
joshuadanpeterson authored Jul 21, 2024
2 parents 98de2d7 + 3ac1032 commit 99a5a81
Show file tree
Hide file tree
Showing 5 changed files with 259 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ TODO.md
demos/typewriter_demo.gif
.github/workflows/changelog.yml
demo.txt
test.*

# Folders
scripts/*
42 changes: 41 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,50 @@
# Changelog

## [v0.6.2](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.2) (2024-07-21)
- Merge branch 'main' into dev
- docs: update CHANGELOG.md for v0.6.1 and remove duplicate entries
- docs: update CHANGELOG.md for v0.5.1 and remove duplicate entries
- Merge pull request #14 from joshuadanpeterson/dev

[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.1...v0.6.2)

## [v0.6.1](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.1) (2024-07-21)
- Merge branch 'dev' of https://github.com/joshuadanpeterson/typewriter.nvim into dev
- feat(README): Add supported filetypes/languages section to README
- docs: update CHANGELOG.md for v0.6.0 and remove duplicate entries

[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.2...v0.6.1)

## [v0.6.0](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.6.0) (2024-07-21)
- feat: Add throw_statement to Java significant blocks
- feat: Add OCaml significant node types to M.expand table for centering
- feat: Add significant node types for Zig filetype for centering
- feat: Add significant node types for C language
- feat: Add significant node types for C# in center_block_config
- feat: Add significant C++ node types to center_block_config
- feat: Add significant Swift node types to center block config
- feat: Add Dart node types to center block config
- docs(help): Update help docs
- feat: Add significant JSON node types to center_block_config
- feat: Add significant CSS node types to center_block_config.lua
- feat: Add YAML significant node types to center block config
- feat: Add significant Lua node types for centering
- feat: Add significant Rust node types for centering
- feat: Add significant Go node types for centering
- feat(gitignore): Add test files to gitignore
- feat: Add significant Python node types for centering
- feat: Add significant JavaScript node types for centering
- Merge branch 'dev' of https://github.com/joshuadanpeterson/typewriter.nvim into dev
- feat: Add significant Bash node types for centering
- docs: update CHANGELOG.md for v0.5.0 and remove duplicate entries

[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.1...v0.6.0)

## [v0.5.1](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.5.1) (2024-07-20)
- Merge pull request #14 from joshuadanpeterson/dev
- docs: update CHANGELOG.md for v0.5.0 and remove duplicate entries

[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.5.0...v0.5.1)
[Full Changelog](https://github.com/joshuadanpeterson/typewriter.nvim/compare/v0.6.0...v0.5.1)

## [v0.5.0](https://github.com/joshuadanpeterson/typewriter.nvim/tree/v0.5.0) (2024-07-20)
- Merge branch 'dev' of https://github.com/joshuadanpeterson/typewriter.nvim into dev
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,32 @@ Here is a markdown table that summarizes the commands available in Typewriter.nv

These commands allow you to control the typewriter mode in Neovim and navigate code blocks, enhancing your writing and coding experience by maintaining focus and reducing distractions. The `:TWCenter`, `:TWTop`, and `:TWBottom` commands leverage Tree-sitter to intelligently manipulate the view of your code blocks, providing a more focused and flexible coding experience.

## Supported Filetypes/Languages 🌐

Typewriter.nvim supports a variety of filetypes and languages, ensuring that your code navigation and centering experience is smooth across different programming environments. Below is a list of supported filetypes and languages. If you don't see your filetype listed, we still encourage you to download the plugin, as the common significant blocks section of the [center_block_config.lua](https://github.com/joshuadanpeterson/typewriter.nvim/blob/main/lua/typewriter/utils/center_block_config.lua) file supports many filetypes by default. If you download the plugin and it doesn't work as expected even with Treesitter installed and set up as a dependency, please open up an [issue](https://github.com/joshuadanpeterson/typewriter.nvim/issues).

- PHP
- Go
- Rust
- JavaScript
- Python
- HTML
- CSS
- Bash
- SQL
- YAML
- JSON
- Dart
- Swift
- C++
- C#
- C
- Zig
- OCaml
- Java

If you don't see your filetype supported, propose it via [issue](https://github.com/joshuadanpeterson/typewriter.nvim/issues) or a [pull request](https://github.com/joshuadanpeterson/typewriter.nvim/pulls)!

## [ZenMode and True Zen Configuration](https://github.com/joshuadanpeterson/typewriter.nvim/wiki/Integration-Guide)

### ZenMode 🧘
Expand Down
4 changes: 2 additions & 2 deletions doc/typewriter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ CHANGELOG *typewriter-changelog*

TODO *typewriter-todo*
- Potential enhancements:
- Fix issue where TWCenter centers the current line instead of the code block as per documentation.
- Resolve error with TWTop & TWBottom commands caused by an undefined function get_expand_root.
- Continue to add language support
- Add typing sounds

------------------------------------------------------------------------------
Autocommands setup for Typewriter.nvim
Expand Down
204 changes: 189 additions & 15 deletions lua/typewriter/utils/center_block_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,53 +43,134 @@ M.expand = {
["do_statement"] = true,
["repeat_statement"] = true,
["function_declaration"] = true,
["function_definition"] = true,
["class"] = true,
["class_declaration"] = true,
["method_declaration"] = true,
["arrow_function"] = true,
["generator_function"] = true,
["async_function"] = true,
["local_declaration"] = true,
-- ["declaration_list"] = true,
["declaration_list"] = true,
["function_call"] = true,
["assignment_statement"] = true,
["block"] = true,
["parameters"] = true,
["body"] = true,
["condition"] = true,
["property_name"] = true,
["integer_value"] = true,
["unit"] = true,
["plain_value"] = true,
["color_value"] = true,
["tag_name"] = true,
["string_content"] = true,
["import_declaration"] = true,
["property_declaration"] = true,
["type_identifier"] = true,
["call_expression"] = true,
["function_body"] = true,
["parameter"] = true,
["return_statement"] = true,
["identifier"] = true,
["expression_statement"] = true,
["declaration"] = true,
["argument_list"] = true,
["binary_expression"] = true,
["foreach_statement"] = true,
["init_declarator"] = true,
["preproc_include"] = true,
["constructor_declaration"] = true,
["field_declaration"] = true,

-- Language-specific significant blocks
-- PHP
["namespace"] = true,

-- Lua
-- (covered by common significant blocks)
["php_tag"] = true,

-- Go
["package"] = true,
["package_clause"] = true,
["type_declaration"] = true,
["type_spec"] = true,
["struct_type"] = true,
["selector_expression"] = true,
["short_var_declaration"] = true,
["expression_list"] = true,
["for_clause"] = true,
["initializer"] = true,
["update"] = true,
["inc_statement"] = true,
["expression_switch_statement"] = true,
["expression_case"] = true,
["default_case"] = true,
["defer_statement"] = true,
["go_statement"] = true,

-- Rust
["match_statement"] = true,
["impl_block"] = true,
["struct"] = true,
["enum"] = true,
["trait"] = true,
["mod"] = true,
["scoped_identifier"] = true,
["use_wildcard"] = true,
["primitive_type"] = true,
["pattern"] = true,
["struct_expression"] = true,
["field_initializer_list"] = true,
["shorthand_field_initializer"] = true,
["macro_invocation"] = true,
["token_tree"] = true,
["tuple_expression"] = true,
["field_expression"] = true,
["enum_variant_list"] = true,
["enum_variant"] = true,
["reference_type"] = true,
["lifetime"] = true,
["match_block"] = true,
["match_arm"] = true,
["match_pattern"] = true,
["integer_literal"] = true,
["boolean_literal"] = true,
["let_declaration"] = true,
["mutable_specifier"] = true,
["reference_expression"] = true,
["range_expression"] = true,
["compound_assignment_expr"] = true,

-- JavaScript
["lexical_declaration"] = true,
["for_in_statement"] = true,
["function_expression"] = true,

-- Python
["except_clause"] = true,
["def"] = true,
["import_statement"] = true,
["import_from_statement"] = true,
["decorated_definition"] = true,

-- HTML
["tag"] = true,
["script"] = true,
["style"] = true,
["doctype"] = true,
["element"] = true,
["start_tag"] = true,
["attribute"] = true,
["text"] = true,
["end_tag"] = true,
["style_element"] = true,
["script_element"] = true,

-- CSS
["rule"] = true,
["media"] = true,
["keyframes"] = true,
["rule_set"] = true,
["selectors"] = true,
["class_selector"] = true,
["pseudo_class_selector"] = true,
["attribute_selector"] = true,
["media_statement"] = true,
["feature_query"] = true,

-- Bash
-- (covered by common significant blocks)
["for_statement"] = true,
["while_statement"] = true,
["declaration_command"] = true,

-- SQL
["select_statement"] = true,
Expand All @@ -102,6 +183,99 @@ M.expand = {
["begin_statement"] = true,
["commit_statement"] = true,
["rollback_statement"] = true,

-- YAML
["document"] = true,
["block_node"] = true,
["block_mapping"] = true,
["block_mapping_pair"] = true,
["key: flow_node"] = true,
["value: flow_node"] = true,
["plain_scalar"] = true,
["string_scalar"] = true,
["block_sequence"] = true,
["block_sequence_item"] = true,
["block_scalar"] = true,
["integer_scalar"] = true,
["boolean_scalar"] = true,

-- JSON
["object"] = true,
["pair"] = true,
["key: string"] = true,
["value: string"] = true,
["value: object"] = true,
["value: array"] = true,
["escape_sequence"] = true,
["value: number"] = true,

-- Dart
["class_definition"] = true,
["function_signature"] = true,
["method_signature"] = true,
["import_or_export"] = true,
["constructor_signature"] = true,
["argument_part"] = true,
["local_variable_declaration"] = true,
["initialized_variable_definition"] = true,

-- Swift
["inheritance_specifier"] = true,
["class_body"] = true,

-- C++
["class_specifier"] = true,
["for_range_loop"] = true,
["string_literal"] = true,

-- C#
["using_directive"] = true,
["namespace_declaration"] = true,
["modifier"] = true,
["variable_declaration"] = true,

-- C
["parameter_list"] = true,
["parameter_declaration"] = true,
["compound_statement"] = true,
["struct_specifier"] = true,

-- Zig
["line_comment"] = true,
["Decl"] = true,
["VarDecl"] = true,
["FnProto"] = true,
["AssignExpr"] = true,
["BinaryExpr"] = true,
["Block"] = true,
["Statement"] = true,
["IfStatement"] = true,
["ForStatement"] = true,
["WhileStatement"] = true,
["SwitchExpr"] = true,
["SwitchProng"] = true,

-- OCaml
["comment"] = true,
["type_definition"] = true,
["type_binding"] = true,
["type_constructor"] = true,
["record_declaration"] = true,
["field_name"] = true,
["type_constructor_path"] = true,
["value_definition"] = true,
["let_binding"] = true,
["value_name"] = true,
["record_expression"] = true,
["application_expression"] = true,
["if_expression"] = true,
["match_expression"] = true,
["variant_declaration"] = true,
["constructor_name"] = true,
["let_expression"] = true,

-- Java-specific significant blocks
["throw_statement"] = true,
}

--- Get the expansion status for a given node type
Expand Down

0 comments on commit 99a5a81

Please sign in to comment.