-
-
Save davestewart/11235539 to your computer and use it in GitHub Desktop.
Komodo IDE - Open Files patterns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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