Home Download Buy Blog Forum Support

DetectSyntax

Re: DetectSyntax

Postby sheamus on Sat Jun 30, 2012 4:36 pm

Interestingly enough, everything seems to work fine on my Mac.
sheamus
 
Posts: 19
Joined: Wed May 30, 2012 12:48 am

Re: DetectSyntax

Postby phillip.koebbe on Mon Jul 02, 2012 3:58 pm

sheamus wrote:ps - how the heck do you get notified of replies in this forum?


Sadly, you don't.

sheamus wrote:I am on W7.

Path to rails project should be all ascii, it doesn't even have spaces.


I just wanted to check. I was just dealing with a problem on Windows 7 where the username was in Russian and I was failing to get the unicode version of a directory. [There will be a fix for that later today]

sheamus wrote:I do have a config/routes.rb folder. What does it look relative to?


The logic for determining if a file belongs to a Rails project is defined in Packages/DetectSyntax/is_rails_file.py, but the gist is it starts at the folder the file is in and looks for ./config/routes.rb. If it doesn't find one, it steps up the directory structure, looking at each level along the way. It's a bit of a hack, but I couldn't think of a better way to do it at the time. If you happen to have C:\config\routes.rb for some reason, all of your .rb files could be mis-identified as Rails files. I took the chance that no one would reasonably have a config/routes.rb outside of a Rails project.

sheamus wrote: I started ST2 from start menu, then choose open recent projects. My project file lives in the root of the rails project directory.

Code: Select all
C:\Users\myname\Code\SyncCode\MyProj


I removed the settings file from my User directory, and restarted ST2. But opening a model_obj.rb file still shows Ruby syntax, as opposed to Ruby on Rails.


Are there any errors in the console when you switch to a Rails file?
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: DetectSyntax

Postby datgame on Fri Aug 24, 2012 9:11 am

Hi, for some reason {"file_name": "^wscript$"} or just "wscript" doesn't work to enable python mode, but the following with first_line works and matches things like "#!/usr/bin/env python" which often is in there.
Bug or am I doing it wrong?

{"name": "Python/Python",
"rules": [
{"first_line": ".*python.*"}]}
datgame
 
Posts: 6
Joined: Thu Aug 16, 2012 8:20 pm

Re: DetectSyntax

Postby phillip.koebbe on Sat Aug 25, 2012 1:50 am

datgame wrote:Hi, for some reason {"file_name": "^wscript$"} or just "wscript" doesn't work to enable python mode, but the following with first_line works and matches things like "#!/usr/bin/env python" which often is in there.
Bug or am I doing it wrong?

{"name": "Python/Python",
"rules": [
{"first_line": ".*python.*"}]}


The regex '^wscript$' anchors and the beginning and end, so the file_name would have to be 'wscript' to match. However, file_name in a view includes the full path to the file, so it would be /some/path/to/the/file/wscript. If you want to match a file named wscript in any location, the regex should be something like '*wscript$'. Try that and see if it works.
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: DetectSyntax

Postby phillip.koebbe on Sun Aug 26, 2012 12:41 am

Actually, I think the regex should be

.*/wscript$

I forgot the '.' and not having the slash (or the appropriate characters for whatever platform you are on) would also match

/some/path/to/anotherwscript

when you really only want to match

/some/path/to/wscript
-- Phillip

Code: Select all
while self.living? do
    mistake = Mistake.new
    self.learn_from!(mistake) unless mistake.fatal?
end
phillip.koebbe
 
Posts: 208
Joined: Tue Dec 20, 2011 4:58 pm

Re: DetectSyntax

Postby datgame on Mon Aug 27, 2012 1:20 pm

phillip.koebbe wrote:...


Thanks, ".*wscript$" works fine.

I'm on all platforms, so using explicit slashes wouldn't work, unless something handled that in sublime perhaps.
I didn't know the regex checked the whole path string.
"wscript" are build rule files for the WAF buildsystem. All python.
datgame
 
Posts: 6
Joined: Thu Aug 16, 2012 8:20 pm

Previous

Return to Plugin Announcements

Who is online

Users browsing this forum: Google [Bot] and 5 guests