onivim / libvim

libvim: The core Vim editing engine as a minimal C library
https://v2.onivim.io
MIT License
691 stars 34 forks source link

feat(api): Auto-indent provider callback #208

Closed bryphe closed 4 years ago

bryphe commented 4 years ago

This adds a hook for a custom C indent provider - given the current line, the previous line, and the buffer - the indent provider returns 1 if indentation should be increased, -1 if indentation should be decreased, or 0 if it should remain the same.

This will allow us to set up Onivim 2 to hook into the indentation provider, given the indentation rules provided by VSCode extension language configuration, ie:

  "indentationRules": {
    "increaseIndentPattern": "^((?!\\/\\/).)*(\\{[^}\"'`]*|\\([^)\"'`]*|\\[[^\\]\"'`]*)$",
    "decreaseIndentPattern": "^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$"
  }