diff --git a/EthanBrown.SublimeText2.WebPackages/EthanBrown.SublimeText2.WebPackages.nuspec b/EthanBrown.SublimeText2.WebPackages/EthanBrown.SublimeText2.WebPackages.nuspec new file mode 100644 index 0000000..a02c793 --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/EthanBrown.SublimeText2.WebPackages.nuspec @@ -0,0 +1,112 @@ + + + + EthanBrown.SublimeText2.WebPackages + Sublime Text 2 - Web Development Packages + 0.0.1 + Various + Ethan Brown + A number of packages helpful for auto-completion, snippets and syntax recognition of common web frameowrks and tools to increase editor productivity. + Includes a number of very useful packages for Sublime Text 2. + + Included + =========================================================================== + + - AngularJS (CoffeeScript) + https://github.com/EastPoint/Sublime-AngularJS-Coffee-Completions + + - AutoFileName + https://github.com/BoundInCode/AutoFileName + + - Chai Completions + https://github.com/pensive612/sublime-chai-full-completions + + - CoffeeComplete Plus (Autocompletion) + https://github.com/justinmahar/SublimeCSAutocompletePlus + + - DocBlockr + https://github.com/spadgos/sublime-jsdocs + + - Emmet + https://github.com/sergeche/emmet-sublime + + - Grunt + https://github.com/tvooo/sublime-grunt + + - Hayaku - tools for writing CSS faster + https://github.com/hayaku/hayaku + + - HTML5 + https://github.com/mrmartineau/HTML5 + + - jQuery + https://github.com/SublimeText/jQuery + + - LESS + https://github.com/danro/LESS-sublime + + - LiveReload + https://github.com/dz0ny/LiveReload-sublimetext2 + + - Pretty JSON + https://github.com/dzhibas/SublimePrettyJson + + - sublime-better-coffeescript + https://github.com/aponxi/sublime-better-coffeescript + + - SublimeLinter + https://github.com/SublimeLinter/SublimeLinter + Using customized version that includes CoffeeLint support from + https://github.com/Iristyle/SublimeLinter + + - Tag + https://github.com/SublimeText/Tag + + - Twitter Bootstrap Snippet + https://github.com/devtellect/sublime-twitter-bootstrap-snippets/ + + Disables + =========================================================================== + - CoffeeCompile + - CoffeeScript + - Live CSS + - LESS-build + - Sublime-HTMLPrettify + - ZenCoding + + Customized Key Bindings + =========================================================================== + https://github.com/Iristyle/SublimeKeyMap.Web + + Additional Package Preferences + =========================================================================== + SublimeLinter - Path config + SublimeGrunt - Path config + + Additional User Preferences + =========================================================================== + Rules for + - Autocompletion triggers, like . and $ in CoffeeScript + - Autocompletion commit on TAB + - ensuring 2 tab indent + - customized word_separators + + http://github.com/Iristyle/ChocolateyPackages/ + SublimeText package editor + + false + https://raw.github.com/Iristyle/ChocolateyPackages/master/SublimeText2.app/Sublime_Text.png + + + + + + + + + + + + diff --git a/EthanBrown.SublimeText2.WebPackages/tools/Package Control.sublime-settings b/EthanBrown.SublimeText2.WebPackages/tools/Package Control.sublime-settings new file mode 100644 index 0000000..e111a83 --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/tools/Package Control.sublime-settings @@ -0,0 +1,31 @@ +{ + "installed_packages": + [ + "AngularJS (CoffeeScript)", + "AutoFileName", + "Chai Completions", + "CoffeeComplete Plus (Autocompletion)", + "DocBlockr", + "Emmet", + "Grunt", + "Hayaku - tools for writing CSS faster", + "HTML5", + "jQuery", + "LESS", + "LiveReload", + "Pretty JSON", + "sublime-better-coffeescript", + "SublimeLinter", + "Tag", + "Twitter Bootstrap Snippets", + "ZZZ.EthanBrown.SublimeKeyMap.Web" + ], + "package_name_map": { + "SublimeKeyMap.Web": "ZZZ.EthanBrown.SublimeKeyMap.Web" + }, + "repositories": + [ + "https://github.com/Iristyle/SublimeKeyMap.Web", + "https://github.com/Iristyle/SublimeLinter" + ] +} diff --git a/EthanBrown.SublimeText2.WebPackages/tools/Preferences.sublime-settings b/EthanBrown.SublimeText2.WebPackages/tools/Preferences.sublime-settings new file mode 100644 index 0000000..b872db7 --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/tools/Preferences.sublime-settings @@ -0,0 +1,33 @@ +{ + "auto_complete_commit_on_tab": true, + "auto_complete_triggers": + [ + { + "characters": "<", + "selector": "text.html" + }, + { + "characters": "/", + "selector": "string.quoted.double.html,string.quoted.single.html, source.css" + }, + { + "characters": "$", + "selector": "source.coffee, source.js, source.js.embedded.html" + }, + { + "characters": ".@", + "selector": "source.coffee" + } + ], + "ignored_packages": + [ + "CoffeeCompile", + "CoffeeScript", + "Live CSS", + "LESS-build", + "Sublime-HTMLPrettify", + "ZenCoding" + ], + "tab_size": 2, + "word_separators": "./\\()\"'-:,.;<>~!@#%^&*|+=[]{}`~?" +} diff --git a/EthanBrown.SublimeText2.WebPackages/tools/SublimeGrunt.sublime-settings b/EthanBrown.SublimeText2.WebPackages/tools/SublimeGrunt.sublime-settings new file mode 100644 index 0000000..aeb3e71 --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/tools/SublimeGrunt.sublime-settings @@ -0,0 +1,5 @@ +{ + "exec_args": { + "path": "{{node_path}}" + } +} diff --git a/EthanBrown.SublimeText2.WebPackages/tools/SublimeLinter.sublime-settings b/EthanBrown.SublimeText2.WebPackages/tools/SublimeLinter.sublime-settings new file mode 100644 index 0000000..dbcf630 --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/tools/SublimeLinter.sublime-settings @@ -0,0 +1,44 @@ +{ + "sublimelinter_executable_map": + { + "javascript":"{{node_path}}", + "css":"{{node_path}}" + }, + "sublimelinter_delay": 0.5, + "sublimelinter_gutter_marks": true, + "sublimelinter_popup_errors_on_save": true, + "javascript_linter": "jshint", + // http://www.jshint.com/options/ for more info. eval *NOT* allowed + "jshint_options": + { + "indent": 0, + "evil": false, + "regexdash": true, + "browser": true, + "wsh": false, + "trailing": true, + "sub": false + }, + "coffeelint_options": + { + "no_tabs": { "level": "error" }, + "no_trailing_whitespace": { "level": "error" }, + "max_line_length": { "level": "error", "value": 80 }, + "camel_case_classes": { "level": "error" }, + "indentation": { "level": "error", "value": 2 }, + //TODO: https://github.com/clutchski/coffeelint/issues/50 + "no_implicit_braces": { "level": "ignore" }, + "no_implicit_parens": { "level": "error" }, + "no_trailing_semicolons": { "level": "error" }, + "no_plusplus": { "level": "ignore" }, + "no_throwing_strings": { "level": "error" }, + "cyclomatic_complexity": { "level": "ignore", "value": 11 }, + "line_endings": { "level": "ignore", "value": "unix" }, + "no_backticks": { "level": "error" }, + "no_stand_alone_at": { "level": "error" } + }, + // Set to true to highlight annotations + "sublimelinter_notes": true, + // The set of annotation phrases to highlight + "annotations": ["TODO", "README", "FIXME", "HACK"] +} diff --git a/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 b/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 new file mode 100644 index 0000000..127424f --- /dev/null +++ b/EthanBrown.SublimeText2.WebPackages/tools/chocolateyInstall.ps1 @@ -0,0 +1,52 @@ +$package = 'EthanBrown.SublimeText2.WebPackages' + +function Get-CurrentDirectory +{ + $thisName = $MyInvocation.MyCommand.Name + [IO.Path]::GetDirectoryName((Get-Content function:$thisName).File) +} + +# simulate the unix command for finding things in path +# http://stackoverflow.com/questions/63805/equivalent-of-nix-which-command-in-powershell +function Which([string]$cmd) +{ + Get-Command -ErrorAction "SilentlyContinue" $cmd | + Select -ExpandProperty Definition +} + +try { + . (Join-Path (Get-CurrentDirectory) 'JsonHelpers.ps1') + . (Join-Path (Get-CurrentDirectory) 'SublimeHelpers.ps1') + + $sublimeUserDataPath = Get-SublimeUserPath + $linterFileName = 'SublimeLinter.sublime-settings' + $gruntFileName = 'SublimeGrunt.sublime-settings' + $linter = Join-Path (Get-CurrentDirectory) $linterFileName + $grunt = Join-Path (Get-CurrentDirectory) $gruntFileName + + $node = (Which node) + $nodeRoot = Split-Path $node + + $escapedNode = $node -replace '\\', '\\' + ([IO.File]::ReadAllText($linter)) -replace '{{node_path}}', $escapedNode | + Out-File -FilePath (Join-Path $sublimeUserDataPath $linterFileName) -Force -Encoding ASCII + + $escapedNodeRoot = $nodeRoot -replace '\\', '\\' + ([IO.File]::ReadAllText($grunt)) -replace '{{node_path}}', $escapedNodeRoot | + Out-File -FilePath (Join-Path $sublimeUserDataPath $gruntFileName) -Force -Encoding ASCII + + $packageControl = (Join-Path (Get-CurrentDirectory) 'Package Control.sublime-settings') + Merge-PackageControlSettings -FilePath $packageControl + + $preferences = (Join-Path (Get-CurrentDirectory) 'Preferences.sublime-settings') + Merge-Preferences -FilePath $preferences + + if (Get-Process -Name sublime_text -ErrorAction SilentlyContinue) + { + Write-Warning 'Please close and re-open Sublime Text to force packages to update' + } + Write-ChocolateySuccess $package +} catch { + Write-ChocolateyFailure $package "$($_.Exception.Message)" + throw +} diff --git a/core/SublimeHelpers.ps1 b/core/SublimeHelpers.ps1 new file mode 100644 index 0000000..af7ab72 --- /dev/null +++ b/core/SublimeHelpers.ps1 @@ -0,0 +1,98 @@ +# uses functions in JsonHelpers.ps1 + +function Get-SublimePackagesPath +{ + $installPath = Join-Path $Env:ProgramFiles 'Sublime Text 2' + $settingsPath = Join-Path ([Environment]::GetFolderPath('ApplicationData')) 'Sublime Text 2' + $packagesPath = Join-Path $settingsPath 'Packages' + if (!(Test-Path $packagesPath)) { New-Item $packagesPath -Type Directory } + + return $packagesPath +} + +function Get-SublimeUserPath +{ + Join-Path (Get-SublimePackagesPath) 'User' +} + +function Merge-PackageControlSettings +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [string] + $FilePath + ) + + $root = Get-SublimeUserPath + $existingPath = Join-Path $root 'Package Control.sublime-settings' + $existingText = [IO.File]::ReadAllText($existingPath) -replace '(?m)^\s*//.*$', '' + if ([string]::IsNullOrEmpty($existingText)) { $existingText = '{}' } + + $existing = ConvertFrom-Json $existingText + Write-Verbose "Existing settings: `n`n$existingText`n`n" + + $new = ConvertFrom-Json ([IO.File]::ReadAllText($FilePath)) + + # simple arrays + 'installed_packages', 'repositories' | + ? { $new.$_ -ne $null } | + % { Merge-JsonArray -Name $_ -Destination $existing -Array $new.$_ } + + # maps + 'package_name_map' | + ? { $new.$_ -ne $null } | + % { Merge-JsonSimpleMap -Name $_ -Destination $existing -SimpleMap $new.$_ } + + $json = $existing | ConvertTo-Json -Depth 10 | ConvertFrom-UnicodeEscaped + Write-Verbose "Updated settings: `n`n$json`n" + [IO.File]::WriteAllText($existingPath, $json, [System.Text.Encoding]::ASCII) +} + +function Merge-Preferences +{ + [CmdletBinding()] + param( + [Parameter(Mandatory = $true)] + [String] + $FilePath + ) + + $root = Get-SublimeUserPath + $existingPath = Join-Path $root 'Preferences.sublime-settings' + $existingText = [IO.File]::ReadAllText($existingPath) -replace '(?m)^\s*//.*$', '' + if ([string]::IsNullOrEmpty($existingText)) { $existingText = '{}' } + + $existing = ConvertFrom-Json $existingText + Write-Verbose "Existing settings: `n`n$existingText`n`n" + + $new = ConvertFrom-Json ([IO.File]::ReadAllText($FilePath)) + + $simpleArrays = @('ignored_packages', 'indent_guide_options', 'rulers', + 'font_options', 'folder_exclude_patterns', 'file_exclude_patterns', + 'binary_file_patterns') + + $simpleArrays | + ? { $new.$_ -ne $null } | + % { Merge-JsonArray -Name $_ -Destination $existing -Array $new.$_ } + + 'auto_complete_triggers' | + ? { $new.$_ -ne $null } | + % { Merge-JsonArrayOfSimpleMap -Name $_ -Destination $existing -Array $new.$_ } + + $excluded = $simpleArrays + 'auto_complete_triggers' + $new.PSObject.Properties | + ? { $excluded -inotcontains $_.Name } | + % { + Merge-JsonNamedValue -Name $_.Name -Destination $existing -Value $_.Value + } + + # HACK: one last top level scan to ensure we don't have any single " + $existing.PSObject.Properties | + ? { $_.Value -is [String] } | + % { $_.Value = $_.Value | ConvertTo-DoubleEscapedQuotes -Name $_.Name } + + $json = $existing | ConvertTo-Json -Depth 10 | ConvertFrom-UnicodeEscaped + Write-Verbose "Updated settings: `n`n$json`n" + [IO.File]::WriteAllText($existingPath, $json, [System.Text.Encoding]::ASCII) +}