til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as a developer

View project on GitHub

Enable syntax highlighting for configuration files

Using the defacto standard Mojolicious plugin for configuration files Mojolicious::Plugin::Config you get the standard files ending in the suffix .conf - this is a very generic name.

The configuration files are actually containing a basic Perl data structure and since this is a basic Perl data structure, you could utilize you favorite editor to do syntax highlighting of the contents, making it easier to spot stupid mistakes and fat-fingering.

You could tweak your editor to just regard .conf as Perl files, but as stated the name is pretty generic, so it might clash with other non-Perlish formats.

Luckily Mojolicious::Plugin::Config has a emminent future letting you define the default suffix to be used.

I have tweaked my editor to recognise .pconf (the p is for Perl).

So when I load the plugin, I simply have to specify the suffix:

my $config = $self->plugin('Config', { ext => 'pconf' });

Instead of:

my $config = $self->plugin('Config');

If you like me you simply add the suffix pconf to the settings for Perl. Open a Perl file or switch syntax highlighting to Perl.

Sublime Text > Preferences > Settings > Syntax Specific

Add pconf to list of extensions and you are good to go.

References