Skip to content

Instantly share code, notes, and snippets.

@davestewart
Forked from Naatan/gist:9231532
Last active August 29, 2015 14:00
Show Gist options
  • Save davestewart/11235539 to your computer and use it in GitHub Desktop.
Save davestewart/11235539 to your computer and use it in GitHub Desktop.
Komodo IDE - Open Files patterns
/**
* Wildcard patterns:
*
* . - period (converts to regexp \. )
* / - folder delimiter (converts to regexp \/ )
* + - wildcard (converts to regexp .+? )
* * - wildcard (converts to regexp .*? )
*/
var patterns =
{
// Content
'Data' :'.(sql|csv|tsv|json)$',
'Documents' :'/documents/|.txt',
'Scripts' :'(/scripts|/js|.js$)',
'Styles' :'(styles|css|sass|less)/|.(css|scss|less)$',
// MVC
'Controllers' :'controllers/',
'Models' :'models/',
'Views' :'views/|.html$',
// Folder types
'Databases' :'(databases|db)/',
'Pages' :'pages/',
'Layouts' :'layouts/',
'Partials' :'partials/',
'Public' :/public\//,
// Catch-all
'All Other' :'*'
}
// convert to regexp
var arr = [];
var isWin = /^win/i.test(window.navigator.platform);
for(var name in patterns)
{
// pattern
var pattern = patterns[name];
// convert strings (wildcards) to regexps
if (typeof pattern === 'string')
{
// convert windows paths
pattern = isWin ? pattern.replace(/\//g, '\\\\') : pattern;
// convert wildcards to regexp
pattern = pattern
.replace(/\./g, '\\.')
.replace(/\+/g, '.+?')
.replace(/\*/g, '.*?');
// create the regexp
pattern = new RegExp(pattern, 'i');
}
// assign
arr.push( { name:name, pattern:pattern } );
}
// assign
ko.openfiles.groupers.byPattern.patterns = arr;
ko.openfiles.reload(true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment