diff --git a/.images/screen1.png b/.images/screen1.png new file mode 100644 index 0000000..04bfcc6 Binary files /dev/null and b/.images/screen1.png differ diff --git a/README.md b/README.md index 04cdfac..4079ce0 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ ## Features -- Create annotations with one keybind +- Create annotations with one keybind, and jump your cursor using `Tab`. - Defaults for multiple languages and annotation conventions - Extremely customizable and extensible - Written in lua diff --git a/docs/adding-languages.md b/docs/adding-languages.md new file mode 100644 index 0000000..03a1862 --- /dev/null +++ b/docs/adding-languages.md @@ -0,0 +1,34 @@ +# Adding Languages - Simplified + +This sections aims to simplify the languages addition, without exposing you the inner workings of neogen, but only showing you the quickest way to add support to a language. + +For this, I will do a very quick recap about the backend concepts of Neogen. Pay very attention to this, because i will explain how the defaults are, so you can use the them. + +## Backend Summary + +I will use the lua configuration file [here](../lua/neogen/configurations/lua.lua) to explain the inner workings of the backend, so feel free to open a new tab and switch to it regularly. + +### Locator + +#### Concept + +The locator is a function responsible of finding the most appropriate parent for annotation purposes + +#### Default Locator + +The default locator will fetch the node in current cursor position, and try to go to each parent node recursively until it finds a node name present in `parents[]`. + +Example (with Tree-sitter activated on the side for better comprehension): + +![](../.images/screen1.png) + +The current cursor position is located in the middle of the function (`local_variable_declaration`). + +If I generate a function annotation using neogen, the default locator will try to find the first parent node matchinf one of those: + +```lua +func = { "function", "local_function", "local_variable_declaration", "field", "variable_declaration" }, +``` + +which will be `variable_declaration`. The parent node will now be this node. +