Openframeworks and sublime 2


#21

personally, I stopped using it. After trying it over the course of 2 weeks, I didn’t really feel sublime using it, and went back to Eclipse.


#22

Did you stop because it didn’t work too well or rather because it just isn’t a fully fledged IDE? I’ll probably also stick to codelite but I’ll be showing some linux people OF soon and I thought maybe sublime is nicer to begin with just because it doesn’t have as many buttons as eclipse, C::B, etc and is therefor a little less “scary”…


#23

tbh I never seriously tried it with OF.
I was working on some python stuff at the time. the lack of codecompletion (without researching and adding some stuff from some repo) made exploring a new API pretty tedious. digging around in text files to change any preferences is pretty lame. some behavioural things also irritated me. the file overview sidebar and the multi-edit function are nice though! also, it’s much leaner than Eclipse (of course), but this happens at the expense of some features i really like (code outline, jump to last editing location, refactoring support, code completion,…)
In the end it comes down to preference, I guess. I’ll remain with Eclipse, and gedit with a terminal for simpler stuff.


#24

I’m using it quite ardently on my arch linux machine.

With sublimeclang properly set up (as described above), you actually have super fast code completion + llvm based on-the-fly syntax checking that is equal if not better than XCode4, and you can jump to method definitions and implementations using the sublimeclang shortcuts which makes it pretty sweet.

SublimeClang’s two-phase shortcuts need a bit of learning, but if you’ve used something like emacs before, that should not deter you: it’s [Alt+D, Alt+D] to jump to a method definition, for example, and [Alt+D, Alt+B] to jump back to the last position, etc. Full list of shortcuts available here: https://github.com/quarnster/SublimeClang#usage

One downside of using Sublime Text is that you have to doctor the project file by hand currently, a way to generate Sublime project files with the project generator could be super nice.

Cheers
#

Tim


#25

Thanks so much for posting your config files, Tim!

Sublime Text 2 with SublimeClang is absolutely awesome as an editor! Have tried out emacs a little and KDevelop on Linux - both are great options. However, I find the emacs experience a little rough (though I love the metakeys) and KDevelop has great support for parsing makefiles and cmake files (but is Linux only and as I’m hitting my old age, I’m getting VERY tired of learning platform specific tools :).

Great that ST2 is cross-platform. Has nice GLSL syntax highlighting, too. I guess the only thing is you’ll still have to manually step into lldb or gdb to debug if the need arises, but I’m willing to live with that.


#26

Thanks, just bought ST3 and got the Package Manager back in (loved it from ST2) installed SublimeClang via the PM.

Nooooow, I’m gonna try Tim’s build file and project files. would be neat to have a Ubuntu/SublimeText/Openframeworks setup tutorial/thread.


#27

Aemartin - awesome! You bought version 3? Keep us posted how that goes. I’m looking to upgrade to it as well, but want to be sure that SublimeClang works properly with it.


#28

@James it’s working awesome! builds quickly. @Tim’s of.sublime-build file made it much easier now I can build while coding in any .h .cpp file. Before that I had to have Makefile open only then did it build.

SublimeClang C/C++ code completion works.

I’m wondering if it’s possible to configure sublime, so you can get all the Openframeworks specific methods to auto-complete. I’m quite new to C++ from Javascript and Actionscript. So bare with me.

So happy it’s up and running will try out some familiar libs :slight_smile:


#29

@martin Great! Yeah, it’s SUPER fast and snappy, eh? The downside is the debugging side - you’ll have to work with GDB or LLDB manually to do that, but that’s an ok tradeoff.

What I love is that it’s cross-platform so you can work in it on OS X if you like as well (or Windows) - instead of using makefiles on OS X, you can just run xcodebuild.

The autocomplete should be working for all OF classes if your OF paths are set properly in your project file - have you tried setting one of those up yet?


#30

Hi!

Ive used ST2 before for HTML coding. Last night, I was editing some unfinished project in ST2, and somehow it took less time than coding in CB, which caught my attention. Do you think it is possible to write down how to setup ST2 to use with OF? I have slightly general idea what is makefile for, but really no big experience with setting up compilers and makefiles as Im ex-Processing guy…

And I think I`m not the only one interested in coding in Sublime Text :wink:


#31

@james, me and a friend sat and tried to set paths for OF lib but we couldn’t make it to work.

we started a rather huge project instead, from the docs site make an ofLang.sublime-completion file that can autocomplete somewhat good (it can’t have a variable selected and detect what type it is and only autocomplete relative)

but so far it’s been really helpfull for me. we’re currently in active dev of it, but asap we’re done we’re sending it in to the Package Manager github repo, so you can install it.

if you want to use the WIP which covers most stuf, download it from

https://github.com/carlcalderon/ofLang

and place it in your sublime user Packages , and make a folder for it there.

or just wait some days and we’re done and install via Package Manger instead.


#32

^ wait, so you have to manually put the whole API of OF into a file so that sublime can do code-completion?? and you have to keep that up-to-date on every release? that strikes me as not very useful, i have to admit…


#33

Hey Martin - if you need a hand setting up the paths, I can show you really quickly over Skype if you like. It’s pretty quick to do once you’ve figured it out and works really well to get autocomplete working (for OF functions, too). Did you get SublimeClang working ok?


#34

hey all, a quick update:

I finally came round to have another look at relative paths and simplifying the sublime-project files for OS X.

The nice thing with the following prototype project file is that with a default openFrameworks setup, you just have to drop it into your app’s project folder (so that it lies next to the Xcode project) and don’t have to modify anything unless you’re using addons outside of the standard addons folder. You’ll want to rename the project file, though =)

Here is the project file:

emptyExample.sublime-project

  
  
{  
	"folders":  
	[  
		{  
			"path": "."  
		}  
	],  
	"settings":  
	{  
		"add_language_option": true,  
		"additional_language_options":  
		{  
			"c":  
			[  
			],  
			"c++":  
			[  
				"-std=c++11"  
			],  
			"objc":  
			[  
			],  
			"objc++":  
			[  
			]  
		},  
		"sublimeclang_enable_fast_completions": true,  
		"sublimeclang_options":  
		[  
		    "-std=c++11",    
			"-Wno-deprecated-declarations",  
			"-Isystem",  
			"-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/",	// this gives us access to the system headers  
			"-I../../../libs/**",			// this adds openFrameworks core  
			"-I./src/**",					// this adds local header files, if you happen to have some in a subdir of your local src directory  
			"-I../../../addons/**"  
		]  
	}  
}  
  

Note that I’m enabling c++11 extensions (this shouldn’t harm if you’re writing vanilla c++, but helps unlocking some of the sweeter features of the language if you select c++11 in Targets->Build Settings->C++ Language Dialect in XCode 4)

Note also that for simplicity’s sake, I’m including all available addons from the standard addons directory. I believe clang is clever enough only to parse the ones which are referenced in the actual code, so you shouldn’t really have a performance overhead in the IDE. You still need to add the correct addons manually in XCode, since the XCode project file is used to build the binary. Or simpler, add / generate the XCode project file using the project generator.

Note further that I’m linking against the latest OSX framework, you might want to adjust this if you - for whichever reason - have to link against 10.6 or 10.7

I’ve also updated the of.sublime-build build file, to make it a tad easier, with this, your app will be called like the basename of your .sublime-project (that’s everything before the last “.” dot in the project filename):

oF.sublime-build

  
  
{  
	"cmd": ["xcodebuild", "PRODUCT_NAME=${project_base_name}"],  
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",  
	"working_dir": "${project_path:${folder}}",  
	"selector": "source.c, source.c++",  
  
	"variants":  
	[  
		{  
			"name": "Run",  
			// "cmd": ["bash","-c", "${project_path:${folder}}/bin/${project_base_name}.app" ]  
			"cmd": ["bash","-c", "open '${project_path:${folder}}/bin/$project_base_name.app/Contents/MacOS/$project_base_name' " ]  
		}	  
	]  
}  
  

I’ll be looking into simplifying the linux workflow next

Good Luck!
#

Tim


#35

Thanks for posting this, Tim!

I’ve also been using SublimeGDB - https://github.com/quarnster/SublimeGDB (by same author as SublimeClang). Works very well so far and nice to get GDB support within Sublime :wink:

I don’t have my project config with me at the moment, but it was easy to get set up and was just the addition of 2 simple lines to your project file to add support to run with GDB debugging. Supports adding breakpoints within ST and stepping through your code, callstacks, variable inspection, etc. Definitely worth a look.

One thing I’m having trouble with is using vars like “${project_path:${folder}}” within the sublime-project files to help simplify things - have you been able to use these in sublime-project files? They work great in the build files.


#36

Hey James, the GDB approach sounds fantastic - I’d be interested to see how you config’d the project files. That’s one step closer to having an elegant multi-platform IDE for oF!

I’ve looked into these “${project_path:${folder}}” variables, but unfortunately there’s no mention of environment variables in the sublime project files docs: http://www.sublimetext.com/docs/2/projects.html

But since the file is JSON - maybe a clever JSON hack could come to the rescue? A Javascript ninja might know…

For most cases it turns out you don’t really need them, since you can specify folders and files in the project file via relative paths, which is what I did in the latest configs, assuming the standard openFrameworks path depths.

Cheers
#

Tim


#37

That’s one step closer to having an elegant multi-platform IDE for oF!
you mean other than code::blocks, right? :wink:


#38

Hey Tim - here’s the GDB config. I’ve tested it on OS X and Linux with Sublime Text 3 and seems to work well. I have to get those relative paths working - was having some trouble so just made most things absolute for now. You obviously need debug builds to run through GDB - just have to specify “Debug” after make (“cmd”: [“make”, “Debug”]) in your build file.

Let me know how the GDB functionality works out for you! There’s also a SublimeLLDB, but not sure what state it’s in.

of-Debug.sublime-build

  
  
{  
	"cmd": ["make", "Debug"],  
	"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",  
	"working_dir": "${project_path:${folder}}",  
	"selector": "source.c, source.c++",  
  
	"variants":  
	[  
		{  
			"name": "Run",  
			"cmd": ["bash","-c", "cd ${project_path:${folder}}/bin; ./$project_base_name_debug" ]  
		}  
	]  
}  
  

emptyExample.sublime-project

  
  
{  
	"folders":  
	[  
		{  
			"path": "."  
		}  
	],  
	"settings":  
	{  
		"add_language_option": true,  
		"additional_language_options":  
		{  
			"c":  
			[  
			],  
			"c++":  
			[  
			],  
			"objc":  
			[  
			],  
			"objc++":  
			[  
			]  
		},  
		"sublimeclang_enable_fast_completions": false,  
		"sublimeclang_options":  
		[  
			"-stdlib=libc++",  
			"-Isystem",  
			"-I/usr/include/c++/4.7.2/",  
			"-I/usr/include/c++/4.7.2/x86_64-unknown-linux-gnu/",    
			"-I/usr/include/c++/4.7.2/ext/",    
			"-I/usr/include/gstreamer-0.10/",    
			"-I/usr/include/glib-2.0/",    
			"-I/usr/lib/glib-2.0/include/",  
			"-I/usr/include/cairo/",  
			"-I/home/james/Development/of/of_latest/addons/**",  
			"-I/home/james/Development/of/of_latest/libs/**",  
			"-I./src/**"  
		],  
  
		"sublimegdb_workingdir": "/home/james/Development/of/of_latest/apps/myApps/emptyExample/bin",  
		"sublimegdb_commandline": "gdb --interpreter=mi emptyExample_debug"  
	}  
}  
  
  


#39

This is cool, I will have to try it soon. One question though. One feature I use all the time in codelite is the automatic implementation of (pure) virtual functions of parent classes, as well as automatic implementation of function in the cpp file (if you wrote a function in the h file, it will be added automatically to the cpp file) Do these shortcuts exist in sublime as well?


#40

Hey Philip =)

I very much doubt that you’d get these functions from “vanilla” sublime text, but I guess these could be added with the right Clang / python fu.

It’s hard to compare Sublime Text to fully fledged C++ IDEs, but as a versatile & relatively lightweight tool & as a cross-platform code editor I find it’s pretty nifty.