Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Conf language #434

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"language_carbon": {},
"language_clojure": {},
"language_cmake": {},
"language_conf": {},
"language_containerfile": {},
"language_crystal": {},
"language_csharp": {},
Expand Down Expand Up @@ -781,6 +782,16 @@
],
"version": "0.2"
},
{
"description": "Syntax for .gitconfig, .rclone.conf and other generic configuration files based on the INI format",
"id": "language_conf",
"mod_version": "3",
"path": "plugins/language_conf.lua",
"tags": [
"language"
],
"version": "0.2"
},
{
"description": "Syntax for [Containerfile](https://github.com/containers/common/blob/main/docs/Containerfile.5.md)/[Dockerfile](https://docs.docker.com/engine/reference/builder/)",
"id": "language_containerfile",
Expand Down
46 changes: 46 additions & 0 deletions plugins/language_conf.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- mod-version:3

local syntax = require "core.syntax"

syntax.add {
name = "Conf",
files = { ".gitconfig$", ".rclone.conf$", "%.conf$" },
comment = '#',
patterns = {
{ pattern = ";.*", type = "comment" },
{ pattern = "#.*", type = "comment" },
{ pattern = { "%[", "%]" }, type = "keyword" },

{ pattern = { '"""', '"""', '\\' }, type = "string" },
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'''", "'''" }, type = "string" },
{ pattern = { "'", "'" }, type = "string" },
{ pattern = "[A-Za-z0-9_%.%-]+%s*%f[=]", type = "function" },
{ pattern = "%s+%-%-[A-Za-z0-9%-]+", type = "normal" },
-- Git
{ pattern = "HEAD", type = "literal" },
-- Rclone AWS S3 canned ACLs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if there should be multiple syntaxes at this point.

Copy link
Author

@radupotop radupotop May 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review.
Yes they could be separate syntax files, but at the same time all these conf files are very alike – just INI files with slightly different literals.

{ pattern = "private", type="literal" },
{ pattern = "public%-read", type="literal" },
{ pattern = "public%-read%-write", type="literal" },
{ pattern = "aws%-exec%-read", type="literal" },
{ pattern = "authenticated%-read", type="literal" },
{ pattern = "bucket%-owner%-read", type="literal" },
{ pattern = "bucket%-owner%-full%-control", type="literal" },
{ pattern = "log%-delivery%-write", type="literal" },
},
symbols = {
-- Git
["true"] = "literal",
["false"] = "literal",
["auto"] = "literal",
["main"] = "literal",
["master"] = "literal",
["origin"] = "literal",
["remote"] = "literal",
["local"] = "literal",
["always"] = "literal",
["format"] = "literal",
},
}