Sublime Forum

Apache Conf file syntax definition

#1

Here’s another syntax highlighting package I’m working on, this one for Apache Conf files, which will also work for .htaccess, .htpasswd, and .htgroups files.

ApacheConf.tmLanguage_0.1.zip (3.64 KB)

There’s still a lot of work to do on this one to cover everything. I’m testing the waters to see if there is much interest :smile:

2 Likes

#2

Thanks for this. While I don’t normally care that I’ve never had highlighting for apache files, this is definetly nice. For anyone intrested, rename the download to something like “apache-conf-filetype.sublime-package” and let it install. after restart the highlighting will be available.

Would be nice if this auto-associated itself to .htaccess and other files that are definetly apache config.

0 Likes

Syntax highlighting for Apache
#3

Hi guys
This is very useful, thank a lot!
I want to create syntax highlighting for another languge, but I can’t fount any manual for this… Can you give some advice aboout this…?

0 Likes

#4

[quote=“ERnest”]Hi guys
This is very useful, thank a lot!
I want to create syntax highlighting for another languge, but I can’t fount any manual for this… Can you give some advice aboout this…?[/quote]

I found these sites helpful:

Existing language syntaxes: svn.textmate.org/trunk/Bundles/
Documentation on creating syntax highlighting: manual.macromates.com/en/language_grammars

I ended up browsing through some existing tmLanguage files and patching something together from them.

0 Likes

#5

Micropatch so it supports comments that have spacing in front of them.

gist.github.com/342212

0 Likes

#6

Thanks for that! I’ve just installed it, very helpful indeed.

I’ve seen that you have listed .htaccess, .htpasswd etc as associated extensions, but it doesn’t seem to be working. It’s working for the .conf extension, though.

My guess is that the file association mechanism gets confused if the file name consists of nothing but the extension, as in “.htaccess”. Does anyone know a workaround?

Cheers,

Michael

0 Likes

#7

You can customize this plugin: pastie.org/private/kz8gtts0cjcvkec0d4quqa

Just add something like:

if name in ".htaccess", ".htpasswd"]: setSyntax(view, "ApacheConf")

0 Likes

#8

Works. Excellent! Thanks!

0 Likes

#9

When Sublime Text encounters a file name like “.htaccess”, it concludes that the file has no extension, and that it’s name is “.htaccess”.

The fileTypes entry in tmLanguage files, at least as interpreted by Sublime Text, can contain either extensions (without the dot) or full filenames (e.g., ‘Makefile’). To have it pick up .htaccess files, you should just need to ensure that “.htaccess” is included in the list with the leading dot.

1 Like

#10

Excellent, I thought it would be something simple like that. Here is an updated file that includes the dots and also the fix from radiosilence for comments with spaces in front of them. :smile:
ApacheConf_0.2.zip (3.77 KB)

0 Likes

#11

Is this for Sublime 1 or 2?

0 Likes

#12

There is no difference between Sublime 1 and 2 compatibility wise when it comes to syntax definitions (.tmLanguage files). Should work the same in Sublime 2 as it did in Sublime 1.

0 Likes

#13

Ok works like a charm in ST2

0 Likes

#14

Looks good! Maybe you could add it to Github?

0 Likes

#15

This is very useful - well done. I’ll second the github call - it would be great to have this in packagemanager.
Thanks
/Eoin/

0 Likes

#16

BAM

https://github.com/colinta/ApacheConf.tmLanguage

Or install via Package Control (ApacheConf.tmLanguage)

Full credit goes to original TextMate bundle, GreyWyvern, and radiosilence.

0 Likes

#17

I just caught a mistake! Apparently, this is a GreyWyvern original. I’ll update credit/authors accordingly.

0 Likes

#18

Hey guys,
Thanks @colinta for githubbing that. However I get

Package Control: Error downloading package. HTTP error 404 downloading https://nodeload.github.com/colinta/ApacheConf.tmLanguage/zipball/v1.0.0.

when I try to install via PackageManager. There doesn’t seem to be a 1.0.0 tag for the project on github so I’m guessing the repositories.json needs updating. Thanks for your time.
cheers
/Eoin/

0 Likes

#19

Thanks! Git tag mishap, accidentally tagged it as v1.0.1

Should install just fine now.

0 Likes

#20

I suggest you upload this to GitHub so it doesn’t get lost so easily and other people can contribute to it.

0 Likes