For font-lock, I think it may work with tree-sitter like this: 1. After openning a file, parse the whole buffer with tree-sitter. We get a syntax tree from tree-sitter. 2. Get the syntax nodes with ts_node_descendant_for_point_range and fontify the buffer text in the visible region or whole buffer. 3. After each modification of buffer text, make a copy of the syntax tree as the new one. Update the new one with the modification. 4. Get the changed range and changed nodes list by comparing the old and new syntax trees. Then free the old syntax tree. 5. Update the text properties in the changed range. 6. Goto 3