Code style
Object-Orientation
Most of the modules are written object oriented. This decision was made because it's way easier to create new instances of the things and associate data with them.
The tables of which the modules consist should be named with uppercase letters
(e.g. Menu
). This should be done in the definition and when using them.
Instances should use lowercase letters.
Functions
You should always write functions in the form of
[local] function <name>(<parameters>)
as opposed to
[local <name> = function(<parameters>)
. The first notation provides the
advantage that you can directly jump to it's definition and you won't get
multiple results (the name and the anonymous function).
Comments and annotations
Add annotations to every public function of a module (e.g. with neogen) and add comments explaining what the code does. We'd like to have code which would be understandable for outsiders. Also try to add annotations and descriptions to local functions but this isn't as important as public ones
Format
For The annotations we use LuaCATS
style. For types don't use a space after the ---
marker. For comments you
should. Check the annotations in lua/care/types/
for examples.
Types
We have files for types which are located in lua/care/types/
written using
lua-ls annotations. They are prefixed with care.
. As often as possible we
should try to use the lsp.*
types which are in neovim core.
Developer docs are autogenerated from these types.