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

Fix language_htaccess using capture groups #464

Open
wants to merge 2 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
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@
"tags": [
"language"
],
"version": "0.1"
"version": "0.1.1"
},
{
"description": "Syntax for [.gitignore](https://git-scm.com/docs/gitignore), [.dockerignore](https://docs.docker.com/engine/reference/builder/#dockerignore-file) and some other `.*ignore` files",
Expand Down
12 changes: 6 additions & 6 deletions plugins/language_htaccess.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ local xml_syntax = {

syntax.add {
name = ".htaccess File",
files = { "^%.htaccess$" },
files = { PATHSEP .. "%.htaccess$" },
comment = "#",
patterns = {
-- Comments
{ pattern = "#.*\n", type = "comment" },
{ pattern = "#.*", type = "comment" },
-- Strings
{ pattern = { '"', '"', '\\' }, type = "string" },
{ pattern = { "'", "'", '\\' }, type = "string" },
Expand All @@ -187,26 +187,26 @@ syntax.add {
-- IPs
{ pattern = "%d+%.%d+%.%d+%.%d+", type = "keyword2" },
{ pattern = "%d+%.%d+%.%d+%.%d+/%d+", type = "keyword2" },
{ regex = "([a-f0-9:]+:+)+[a-f0-9]+", type = "keyword2" },
{ regex = [[(?:[a-fA-F0-9]*:)+(?:[a-fA-F0-9]+|:)(?:\/[0-9]+)?]], type = "keyword2" },
-- Emails
{ pattern = "%w+@%w+%.%w+", type = "keyword2" },
-- Rewrite option sections
{ pattern = "%f[%S]%b[]", type = "number" },
{ pattern = "%f[%S]%b[]", type = "number" },
-- XML tags
{ pattern = { "</?%w+", ">" }, type = "literal", syntax = xml_syntax },
-- Variables
{ pattern = "[%%$]%d+", type = "keyword2" },
{ pattern = "[%%$]%{[%w_:%-]+%}", type = "keyword2" },
-- Numbers
{ pattern = "A?%d+", type = "number" },
{ pattern = "A?%d+", type = "number" },
-- Operators
{ pattern = "%f[%S][!=+%-]+", type = "operator" },
-- Regex (TODO: improve this, it's pretty naive and only works on some regex)
{ pattern = "%f[^%s!]%^%S*", type = "literal" },
{ pattern = "%f[^%s!]%S*%$", type = "literal" },
{ pattern = "%f[^%s!]%b()", type = "literal" },
-- Everything else
{ pattern = "[%a_][%w_-]*", type = "symbol" },
{ pattern = "[%a_][%w_-]*", type = "symbol" },
},
symbols = symbols
}