vlang / ved

1 MB text editor written in V with hardware accelerated text rendering. Compiles in <1s.
GNU General Public License v3.0
1.34k stars 78 forks source link

feat: better support for `.syntax` files #163

Closed StunxFS closed 1 year ago

StunxFS commented 1 year ago

This PR improves support for .syntax files, also adds another default size for the window (enabled with the -d small_window flag).

The .syntax files go in the syntax/ folder, which are loaded when you start ved. When a file is opened, ved searches the loaded syntaxes for a syntax that has the file extension, if found, that syntax is used, otherwise plain text is used.

The structure of a .syntax file is simple, it is a JSON file that contains the following:

{
    "name": "", // Programming language name
    "extensions": [], // File extensions used by that language
    "fmt_cmd": "", // format command. `<PATH>` can be used to get the current file path, example: `v fmt -w <PATH>`.
    "keywords": [], // List of keywords used by the language.
    "literals": [] // List of literals used by the language.
}
spytheman commented 1 year ago

I've filled https://github.com/vlang/v/issues/16845 for the CI failure/-autofree bug that was discovered.