Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight Build Output Panel of Sublime Text 2

How do I highlight the error lines in the Build Output Panel of Sublime Text 2? I have some lines in the output like this:

This is just a message
Warning: <C:\Path\File.ext:12> WarningMessage ORANGE
Error  : <C:\Path\File.ext:34> ErrorMessage RED

How do I colour the Error and Warning lines? I have setup my custom .sublime-build "file_regex" key to detect them for doubleclick, but don't see how to style the matches.

like image 590
Adamarla Avatar asked Jun 05 '13 10:06

Adamarla


1 Answers

This is possible. It takes a bit of work, but I have done it at least on Linux.

Step 1

Copy the Packages/Default/exec.py to your User directory (or the Plugin directory if you are building a plugin). I changed the name of the .py file to correlate with the Build file, but I do not think this is strictly necessary.

Step 2

Change the run method of the ExecCommand class to call your syntax file and color scheme. I added these around line 117 in the current build, just above the line that has:

self.output_view.settings().set("result_file_regex", file_regex)

I added in the following lines.

self.output_view.settings().set("color_scheme", "Packages/Color/Color.tmTheme")
self.output_view.set_syntax_file("Packages/Scheme/Scheme.tmLanguage")

Where Packages/Color/Color.tmTheme is the color scheme definition file you are seeking and where Packages/Sheme/Scheme.tmLanguage is the syntax definition file you are wanting to integrate.

Step 3

Update your .sublime-build file to call the custom file you modified above with the following call:

"target":      ["Packages", "User", "NewExecFile.py"]

Note: The following will not work:

"target":      ["Packages/User/NewExecFile.py"]

unless you were to update the NewExecFile.py to call the target field without joining with file separators.

I'm on Linux, so you'd obviously need to update for windows. But it is working like a charm for me. I now have a build function which returns results that match the color scheme I use for development.

References:

  • Sublime Unofficial Docs
  • Sublime Forum Question
like image 135
Casey Kuhlman Avatar answered Oct 19 '22 03:10

Casey Kuhlman