Difference between revisions of "Sublime Text"

(Change configuration to support ST2 Projects and parse errors)
(Add LuaLove)
Line 1: Line 1:
 
''Sublime Text is a sophisticated text editor for code, markup and prose.''
 
''Sublime Text is a sophisticated text editor for code, markup and prose.''
  
== Running love projects from Sublime Text 2  ==
+
== Autocompletition & Building with the LuaLove Package ==
 +
 
 +
Install the [https://sublime.wbond.net/packages/Lua%20Love LuaLove Package] via [https://sublime.wbond.net/installation#st2 Package Control] and modify the build system (slightly) to make running in love the default:
 +
''C:\Users\....\AppData\Roaming\Sublime Text 2\Packages\Lua Love\LuaLove.sublime-build'':
 +
 
 +
<source lang="ini">{
 +
"file_regex": "^(?:(?:\t)|(?:.+: ))(.+):([0-9]+): (.*)$",
 +
"selector": "source.lua",
 +
"shell": true,
 +
"cmd": ["love", "${project_path:${file_path:.}}"],
 +
 
 +
"variants": [
 +
{
 +
"name": "Love2D",
 +
"shell": true,
 +
"cmd": ["love", "${project_path:.}"],
 +
"osx":
 +
{
 +
"cmd": ["love $project_path"]
 +
}
 +
},
 +
{  "name": "ldoc: File",
 +
"shell": true,
 +
"cmd": ["ldoc -d $project_path/doc/$file_base_name -f markdown -t $file_base_name $file"]
 +
},
 +
{  "name": "ldoc: Project",
 +
"shell": true,
 +
"cmd": ["ldoc -d $project_path/doc -f markdown -t $project_base_name $project_path/src/"]
 +
}
 +
]
 +
}
 +
</source>
 +
 
 +
== Without Packages ==
  
 
=== On Windows ===
 
=== On Windows ===

Revision as of 02:05, 31 October 2014

Sublime Text is a sophisticated text editor for code, markup and prose.

Autocompletition & Building with the LuaLove Package

Install the LuaLove Package via Package Control and modify the build system (slightly) to make running in love the default: C:\Users\....\AppData\Roaming\Sublime Text 2\Packages\Lua Love\LuaLove.sublime-build:

{
	"file_regex": "^(?:(?:\t)|(?:.+: ))(.+):([0-9]+): (.*)$",
	"selector": "source.lua",
	"shell": true,
	"cmd": ["love", "${project_path:${file_path:.}}"],

	"variants": [
		{
			"name": "Love2D",
			"shell": true,
			"cmd": ["love", "${project_path:.}"],
			"osx":
			{
				"cmd": ["love $project_path"]
			}
		},
		{   "name": "ldoc: File",
			"shell": true,
			"cmd": ["ldoc -d $project_path/doc/$file_base_name -f markdown -t $file_base_name $file"]
		},
		{   "name": "ldoc: Project",
			"shell": true,
			"cmd": ["ldoc -d $project_path/doc -f markdown -t $project_base_name $project_path/src/"]
		}
	]
}

Without Packages

On Windows

Create a new Build System first: Tools -> Build System -> New Build System

Then paste the following code:

{
    "selector": "source.lua",
    "cmd": ["C:/Program Files/LOVE/love.exe", "${project_path:${file_path}}"],
    "shell": true,
    "file_regex": "^Error: (?:[^:]+: )?([^: ]+?):(\\d+):() ([^:]*)$"
}

Now you can use CTRL + B to run your love project. Note that this code doesn't seem to work if you have spaces in your $file_path.

On Mac

Create a new Build System first: Tools -> Build System -> New Build System

Then paste in the following code:

{
    "selector": "source.lua",
    "cmd": ["/Applications/love.app/Contents/MacOS/love", "${project_path:${file_path}}"],
    "file_regex": "^Error: (?:[^:]+: )?([^: ]+?):(\\d+):() ([^:]*)$"
}

(This is assuming that your love.app is in the Applications folder)

Now you can use CMD + B to run your love project.


Displaying live console output in Sublime Text 2

By default the console in Sublime Text will not display any output, such as print() calls, until the LOVE application has been closed.

To make the console output display live add the following code to the top of your main.lua file, or inside conf.lua:

io.stdout:setvbuf("no")

Jumping to errors

If there was an error during execution, you can use the F4 (next error) and SHIFT-F4 (previous error) to go through the errors that lua encountered.

See also