├── .gitignore ├── CHANGELOG.mx ├── Misc ├── OpenInSublimeText.gif └── OpenInSublimeTextMenu.png ├── OpenInSublimeText.xcodeproj └── project.pbxproj ├── OpenInSublimeText ├── BumpBuild.sh ├── DVTFoundation.h ├── DVTKit.h ├── IDEFoundation.h ├── IDEKit.h ├── NSTextStorage+VimOperation.h ├── NSTextStorage+VimOperation.m ├── OSTOpenInSublimeText.h ├── OSTOpenInSublimeText.m ├── OSTUtil.h ├── OSTUtil.m ├── OpenInSublimeText-Info.plist ├── OpenInSublimeText-Prefix.pch ├── XVimStringBuffer.h └── en.lproj │ └── InfoPlist.strings └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X 2 | *.DS_Store 3 | 4 | # Xcode 5 | *.pbxuser 6 | *.mode1v3 7 | *.mode2v3 8 | *.perspectivev3 9 | *.xcuserstate 10 | project.xcworkspace/ 11 | xcuserdata/ 12 | 13 | # Generated files 14 | *.o 15 | *.pyc 16 | 17 | #Python modules 18 | MANIFEST 19 | dist/ 20 | build/ 21 | 22 | # Backup files 23 | *~.nib 24 | \#*# 25 | .#* 26 | docset-installed.txt 27 | 28 | 29 | ## ANDROID 30 | # built application files 31 | *.apk 32 | *.ap_ 33 | 34 | # files for the dex VM 35 | *.dex 36 | 37 | # Java class files 38 | *.class 39 | 40 | # generated files 41 | bin/ 42 | gen/ 43 | 44 | # Local configuration file (sdk path, etc) 45 | local.properties 46 | 47 | # IVY 48 | ivy.jar 49 | Command/distrib/jars/*-ui-*.jar 50 | Command/distrib/zips 51 | Command/lib/noexternaljar 52 | Command/lib/test 53 | Command/lib/withexternaljar 54 | -------------------------------------------------------------------------------- /CHANGELOG.mx: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## [Unreleased][unreleased] 6 | ### Added 7 | - 8 | 9 | ## [1.4.3] - 2015-12-31 10 | ### Added 11 | - Support for Xcode 7.2 12 | 13 | ## [1.4.1] - 2015-07-09 14 | ### Added 15 | - DVTPlugInCompatibilityUUIDs for Xcode 6.4 and 7 beta 16 | 17 | ## [1.4.2] - 2015-10-28 18 | ### Added 19 | - Support for Xcode through 7.1 20 | 21 | ## [1.4.0] - 2015-06-05 22 | ### Added 23 | - Support for Xcode 6.3.2 24 | 25 | ## [1.3.0] - 2015-05-29 26 | ### Added 27 | - subl invocation uses --new-window flag 28 | 29 | ## [1.2.0] - 2015-04-27 30 | ### Added 31 | - Sublime Text 2 Support 32 | 33 | ## [1.1.0] - 2015-04-19 34 | ### Added 35 | - Xcode 6 support -------------------------------------------------------------------------------- /Misc/OpenInSublimeText.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanmeisters/Xcode-Plugin-Open-Sublime-Text/e710b0f2f41150c1b891b3168f28bb4da7ef4cb6/Misc/OpenInSublimeText.gif -------------------------------------------------------------------------------- /Misc/OpenInSublimeTextMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ryanmeisters/Xcode-Plugin-Open-Sublime-Text/e710b0f2f41150c1b891b3168f28bb4da7ef4cb6/Misc/OpenInSublimeTextMenu.png -------------------------------------------------------------------------------- /OpenInSublimeText.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9425046019C951C700C01AF5 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9425045F19C951C700C01AF5 /* AppKit.framework */; }; 11 | 9425046219C951C700C01AF5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9425046119C951C700C01AF5 /* Foundation.framework */; }; 12 | 9425046819C951C700C01AF5 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9425046619C951C700C01AF5 /* InfoPlist.strings */; }; 13 | 9425046B19C951C700C01AF5 /* OSTOpenInSublimeText.m in Sources */ = {isa = PBXBuildFile; fileRef = 9425046A19C951C700C01AF5 /* OSTOpenInSublimeText.m */; }; 14 | 942B6A1A19C96EE00093E988 /* IDEFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 942B6A1819C96EDF0093E988 /* IDEFoundation.framework */; }; 15 | 942B6A1B19C96EE00093E988 /* IDEKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 942B6A1919C96EE00093E988 /* IDEKit.framework */; }; 16 | 942B6A2419C974B60093E988 /* OSTUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 942B6A2319C974B60093E988 /* OSTUtil.m */; }; 17 | 942B6A2719C975B90093E988 /* DVTFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 942B6A2519C975B90093E988 /* DVTFoundation.framework */; }; 18 | 942B6A2819C975B90093E988 /* DVTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 942B6A2619C975B90093E988 /* DVTKit.framework */; }; 19 | 94BFCA4019CE577A00EA7232 /* NSTextStorage+VimOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = 94BFCA3F19CE577A00EA7232 /* NSTextStorage+VimOperation.m */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXFileReference section */ 23 | 9422F5CE19CF7BD3006F70FA /* BumpBuild.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = BumpBuild.sh; sourceTree = ""; }; 24 | 9425045C19C951C700C01AF5 /* OpenInSublimeText.xcplugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenInSublimeText.xcplugin; sourceTree = BUILT_PRODUCTS_DIR; }; 25 | 9425045F19C951C700C01AF5 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 26 | 9425046119C951C700C01AF5 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 27 | 9425046519C951C700C01AF5 /* OpenInSublimeText-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OpenInSublimeText-Info.plist"; sourceTree = ""; }; 28 | 9425046719C951C700C01AF5 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 29 | 9425046919C951C700C01AF5 /* OSTOpenInSublimeText.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OSTOpenInSublimeText.h; sourceTree = ""; }; 30 | 9425046A19C951C700C01AF5 /* OSTOpenInSublimeText.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = OSTOpenInSublimeText.m; sourceTree = ""; }; 31 | 9425046C19C951C700C01AF5 /* OpenInSublimeText-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "OpenInSublimeText-Prefix.pch"; sourceTree = ""; }; 32 | 942B6A1819C96EDF0093E988 /* IDEFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IDEFoundation.framework; path = ../../../../Applications/Xcode.app/Contents/Frameworks/IDEFoundation.framework; sourceTree = ""; }; 33 | 942B6A1919C96EE00093E988 /* IDEKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IDEKit.framework; path = ../../../../Applications/Xcode.app/Contents/Frameworks/IDEKit.framework; sourceTree = ""; }; 34 | 942B6A1C19C9705A0093E988 /* IDEFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDEFoundation.h; sourceTree = ""; }; 35 | 942B6A1D19C9705A0093E988 /* IDEKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IDEKit.h; sourceTree = ""; }; 36 | 942B6A2219C974B60093E988 /* OSTUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSTUtil.h; sourceTree = ""; }; 37 | 942B6A2319C974B60093E988 /* OSTUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OSTUtil.m; sourceTree = ""; }; 38 | 942B6A2519C975B90093E988 /* DVTFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTFoundation.framework; path = ../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework; sourceTree = ""; }; 39 | 942B6A2619C975B90093E988 /* DVTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DVTKit.framework; path = ../../../../Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework; sourceTree = ""; }; 40 | 942B6A2919C976160093E988 /* DVTFoundation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DVTFoundation.h; sourceTree = ""; }; 41 | 942B6A2A19C976160093E988 /* DVTKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DVTKit.h; sourceTree = ""; }; 42 | 94BFCA3E19CE577A00EA7232 /* NSTextStorage+VimOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSTextStorage+VimOperation.h"; sourceTree = ""; }; 43 | 94BFCA3F19CE577A00EA7232 /* NSTextStorage+VimOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSTextStorage+VimOperation.m"; sourceTree = ""; }; 44 | 94BFCA4119CE596400EA7232 /* XVimStringBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XVimStringBuffer.h; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 9425045919C951C700C01AF5 /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | 942B6A1A19C96EE00093E988 /* IDEFoundation.framework in Frameworks */, 53 | 942B6A2719C975B90093E988 /* DVTFoundation.framework in Frameworks */, 54 | 942B6A2819C975B90093E988 /* DVTKit.framework in Frameworks */, 55 | 9425046019C951C700C01AF5 /* AppKit.framework in Frameworks */, 56 | 942B6A1B19C96EE00093E988 /* IDEKit.framework in Frameworks */, 57 | 9425046219C951C700C01AF5 /* Foundation.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | /* End PBXFrameworksBuildPhase section */ 62 | 63 | /* Begin PBXGroup section */ 64 | 9425045319C951C600C01AF5 = { 65 | isa = PBXGroup; 66 | children = ( 67 | 9425046319C951C700C01AF5 /* OpenInSublimeText */, 68 | 9425045E19C951C700C01AF5 /* Frameworks */, 69 | 9425045D19C951C700C01AF5 /* Products */, 70 | ); 71 | sourceTree = ""; 72 | }; 73 | 9425045D19C951C700C01AF5 /* Products */ = { 74 | isa = PBXGroup; 75 | children = ( 76 | 9425045C19C951C700C01AF5 /* OpenInSublimeText.xcplugin */, 77 | ); 78 | name = Products; 79 | sourceTree = ""; 80 | }; 81 | 9425045E19C951C700C01AF5 /* Frameworks */ = { 82 | isa = PBXGroup; 83 | children = ( 84 | 942B6A2519C975B90093E988 /* DVTFoundation.framework */, 85 | 942B6A2619C975B90093E988 /* DVTKit.framework */, 86 | 942B6A1819C96EDF0093E988 /* IDEFoundation.framework */, 87 | 942B6A1919C96EE00093E988 /* IDEKit.framework */, 88 | 9425045F19C951C700C01AF5 /* AppKit.framework */, 89 | 9425046119C951C700C01AF5 /* Foundation.framework */, 90 | ); 91 | name = Frameworks; 92 | sourceTree = ""; 93 | }; 94 | 9425046319C951C700C01AF5 /* OpenInSublimeText */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | 94BFCA4119CE596400EA7232 /* XVimStringBuffer.h */, 98 | 94BFCA3E19CE577A00EA7232 /* NSTextStorage+VimOperation.h */, 99 | 94BFCA3F19CE577A00EA7232 /* NSTextStorage+VimOperation.m */, 100 | 9425046919C951C700C01AF5 /* OSTOpenInSublimeText.h */, 101 | 9425046A19C951C700C01AF5 /* OSTOpenInSublimeText.m */, 102 | 942B6A2219C974B60093E988 /* OSTUtil.h */, 103 | 942B6A2319C974B60093E988 /* OSTUtil.m */, 104 | 942B6A2119C974230093E988 /* Headers */, 105 | 9425046419C951C700C01AF5 /* Supporting Files */, 106 | ); 107 | path = OpenInSublimeText; 108 | sourceTree = ""; 109 | }; 110 | 9425046419C951C700C01AF5 /* Supporting Files */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 9422F5CE19CF7BD3006F70FA /* BumpBuild.sh */, 114 | 9425046619C951C700C01AF5 /* InfoPlist.strings */, 115 | 9425046519C951C700C01AF5 /* OpenInSublimeText-Info.plist */, 116 | 9425046C19C951C700C01AF5 /* OpenInSublimeText-Prefix.pch */, 117 | ); 118 | name = "Supporting Files"; 119 | sourceTree = ""; 120 | }; 121 | 942B6A2119C974230093E988 /* Headers */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 942B6A1C19C9705A0093E988 /* IDEFoundation.h */, 125 | 942B6A2919C976160093E988 /* DVTFoundation.h */, 126 | 942B6A2A19C976160093E988 /* DVTKit.h */, 127 | 942B6A1D19C9705A0093E988 /* IDEKit.h */, 128 | ); 129 | name = Headers; 130 | sourceTree = ""; 131 | }; 132 | /* End PBXGroup section */ 133 | 134 | /* Begin PBXNativeTarget section */ 135 | 9425045B19C951C700C01AF5 /* OpenInSublimeText */ = { 136 | isa = PBXNativeTarget; 137 | buildConfigurationList = 9425046F19C951C700C01AF5 /* Build configuration list for PBXNativeTarget "OpenInSublimeText" */; 138 | buildPhases = ( 139 | 9425045819C951C700C01AF5 /* Sources */, 140 | 9422F5D019CF7BEE006F70FA /* Increment Build Number */, 141 | 9425045919C951C700C01AF5 /* Frameworks */, 142 | 9425045A19C951C700C01AF5 /* Resources */, 143 | ); 144 | buildRules = ( 145 | ); 146 | dependencies = ( 147 | ); 148 | name = OpenInSublimeText; 149 | productName = OpenInSublimeText; 150 | productReference = 9425045C19C951C700C01AF5 /* OpenInSublimeText.xcplugin */; 151 | productType = "com.apple.product-type.bundle"; 152 | }; 153 | /* End PBXNativeTarget section */ 154 | 155 | /* Begin PBXProject section */ 156 | 9425045419C951C700C01AF5 /* Project object */ = { 157 | isa = PBXProject; 158 | attributes = { 159 | CLASSPREFIX = OST; 160 | LastUpgradeCheck = 0700; 161 | ORGANIZATIONNAME = "Ryan M"; 162 | }; 163 | buildConfigurationList = 9425045719C951C700C01AF5 /* Build configuration list for PBXProject "OpenInSublimeText" */; 164 | compatibilityVersion = "Xcode 3.2"; 165 | developmentRegion = English; 166 | hasScannedForEncodings = 0; 167 | knownRegions = ( 168 | en, 169 | ); 170 | mainGroup = 9425045319C951C600C01AF5; 171 | productRefGroup = 9425045D19C951C700C01AF5 /* Products */; 172 | projectDirPath = ""; 173 | projectRoot = ""; 174 | targets = ( 175 | 9425045B19C951C700C01AF5 /* OpenInSublimeText */, 176 | ); 177 | }; 178 | /* End PBXProject section */ 179 | 180 | /* Begin PBXResourcesBuildPhase section */ 181 | 9425045A19C951C700C01AF5 /* Resources */ = { 182 | isa = PBXResourcesBuildPhase; 183 | buildActionMask = 2147483647; 184 | files = ( 185 | 9425046819C951C700C01AF5 /* InfoPlist.strings in Resources */, 186 | ); 187 | runOnlyForDeploymentPostprocessing = 0; 188 | }; 189 | /* End PBXResourcesBuildPhase section */ 190 | 191 | /* Begin PBXShellScriptBuildPhase section */ 192 | 9422F5D019CF7BEE006F70FA /* Increment Build Number */ = { 193 | isa = PBXShellScriptBuildPhase; 194 | buildActionMask = 2147483647; 195 | files = ( 196 | ); 197 | inputPaths = ( 198 | ); 199 | name = "Increment Build Number"; 200 | outputPaths = ( 201 | ); 202 | runOnlyForDeploymentPostprocessing = 0; 203 | shellPath = /bin/sh; 204 | shellScript = OpenInSublimeText/BumpBuild.sh; 205 | }; 206 | /* End PBXShellScriptBuildPhase section */ 207 | 208 | /* Begin PBXSourcesBuildPhase section */ 209 | 9425045819C951C700C01AF5 /* Sources */ = { 210 | isa = PBXSourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | 942B6A2419C974B60093E988 /* OSTUtil.m in Sources */, 214 | 94BFCA4019CE577A00EA7232 /* NSTextStorage+VimOperation.m in Sources */, 215 | 9425046B19C951C700C01AF5 /* OSTOpenInSublimeText.m in Sources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXSourcesBuildPhase section */ 220 | 221 | /* Begin PBXVariantGroup section */ 222 | 9425046619C951C700C01AF5 /* InfoPlist.strings */ = { 223 | isa = PBXVariantGroup; 224 | children = ( 225 | 9425046719C951C700C01AF5 /* en */, 226 | ); 227 | name = InfoPlist.strings; 228 | sourceTree = ""; 229 | }; 230 | /* End PBXVariantGroup section */ 231 | 232 | /* Begin XCBuildConfiguration section */ 233 | 9425046D19C951C700C01AF5 /* Debug */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 238 | CLANG_CXX_LIBRARY = "libc++"; 239 | CLANG_ENABLE_MODULES = YES; 240 | CLANG_ENABLE_OBJC_ARC = YES; 241 | CLANG_WARN_BOOL_CONVERSION = YES; 242 | CLANG_WARN_CONSTANT_CONVERSION = YES; 243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 249 | COPY_PHASE_STRIP = NO; 250 | ENABLE_TESTABILITY = YES; 251 | GCC_C_LANGUAGE_STANDARD = gnu99; 252 | GCC_DYNAMIC_NO_PIC = NO; 253 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 254 | GCC_OPTIMIZATION_LEVEL = 0; 255 | GCC_PREPROCESSOR_DEFINITIONS = ( 256 | "DEBUG=1", 257 | "$(inherited)", 258 | ); 259 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 260 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 261 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 262 | GCC_WARN_UNDECLARED_SELECTOR = YES; 263 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 264 | GCC_WARN_UNUSED_FUNCTION = YES; 265 | GCC_WARN_UNUSED_VARIABLE = YES; 266 | MACOSX_DEPLOYMENT_TARGET = 10.9; 267 | ONLY_ACTIVE_ARCH = YES; 268 | SDKROOT = macosx; 269 | }; 270 | name = Debug; 271 | }; 272 | 9425046E19C951C700C01AF5 /* Release */ = { 273 | isa = XCBuildConfiguration; 274 | buildSettings = { 275 | ALWAYS_SEARCH_USER_PATHS = NO; 276 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 277 | CLANG_CXX_LIBRARY = "libc++"; 278 | CLANG_ENABLE_MODULES = YES; 279 | CLANG_ENABLE_OBJC_ARC = YES; 280 | CLANG_WARN_BOOL_CONVERSION = YES; 281 | CLANG_WARN_CONSTANT_CONVERSION = YES; 282 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 283 | CLANG_WARN_EMPTY_BODY = YES; 284 | CLANG_WARN_ENUM_CONVERSION = YES; 285 | CLANG_WARN_INT_CONVERSION = YES; 286 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 287 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 288 | COPY_PHASE_STRIP = YES; 289 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 290 | ENABLE_NS_ASSERTIONS = NO; 291 | GCC_C_LANGUAGE_STANDARD = gnu99; 292 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 293 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 294 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 295 | GCC_WARN_UNDECLARED_SELECTOR = YES; 296 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 297 | GCC_WARN_UNUSED_FUNCTION = YES; 298 | GCC_WARN_UNUSED_VARIABLE = YES; 299 | MACOSX_DEPLOYMENT_TARGET = 10.9; 300 | SDKROOT = macosx; 301 | }; 302 | name = Release; 303 | }; 304 | 9425047019C951C700C01AF5 /* Debug */ = { 305 | isa = XCBuildConfiguration; 306 | buildSettings = { 307 | COMBINE_HIDPI_IMAGES = YES; 308 | DEPLOYMENT_LOCATION = YES; 309 | DSTROOT = "$(HOME)"; 310 | FRAMEWORK_SEARCH_PATHS = ( 311 | "$(inherited)", 312 | "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Frameworks", 313 | "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/SharedFrameworks", 314 | ); 315 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 316 | GCC_PREFIX_HEADER = "OpenInSublimeText/OpenInSublimeText-Prefix.pch"; 317 | INFOPLIST_FILE = "OpenInSublimeText/OpenInSublimeText-Info.plist"; 318 | INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; 319 | PRODUCT_BUNDLE_IDENTIFIER = "io.rhm.${PRODUCT_NAME:rfc1034identifier}"; 320 | PRODUCT_NAME = "$(TARGET_NAME)"; 321 | WRAPPER_EXTENSION = xcplugin; 322 | }; 323 | name = Debug; 324 | }; 325 | 9425047119C951C700C01AF5 /* Release */ = { 326 | isa = XCBuildConfiguration; 327 | buildSettings = { 328 | COMBINE_HIDPI_IMAGES = YES; 329 | DEPLOYMENT_LOCATION = YES; 330 | DSTROOT = "$(HOME)"; 331 | FRAMEWORK_SEARCH_PATHS = ( 332 | "$(inherited)", 333 | "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Frameworks", 334 | "$(SYSTEM_APPS_DIR)/Xcode.app/Contents/SharedFrameworks", 335 | ); 336 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 337 | GCC_PREFIX_HEADER = "OpenInSublimeText/OpenInSublimeText-Prefix.pch"; 338 | INFOPLIST_FILE = "OpenInSublimeText/OpenInSublimeText-Info.plist"; 339 | INSTALL_PATH = "/Library/Application Support/Developer/Shared/Xcode/Plug-ins"; 340 | PRODUCT_BUNDLE_IDENTIFIER = "io.rhm.${PRODUCT_NAME:rfc1034identifier}"; 341 | PRODUCT_NAME = "$(TARGET_NAME)"; 342 | WRAPPER_EXTENSION = xcplugin; 343 | }; 344 | name = Release; 345 | }; 346 | /* End XCBuildConfiguration section */ 347 | 348 | /* Begin XCConfigurationList section */ 349 | 9425045719C951C700C01AF5 /* Build configuration list for PBXProject "OpenInSublimeText" */ = { 350 | isa = XCConfigurationList; 351 | buildConfigurations = ( 352 | 9425046D19C951C700C01AF5 /* Debug */, 353 | 9425046E19C951C700C01AF5 /* Release */, 354 | ); 355 | defaultConfigurationIsVisible = 0; 356 | defaultConfigurationName = Release; 357 | }; 358 | 9425046F19C951C700C01AF5 /* Build configuration list for PBXNativeTarget "OpenInSublimeText" */ = { 359 | isa = XCConfigurationList; 360 | buildConfigurations = ( 361 | 9425047019C951C700C01AF5 /* Debug */, 362 | 9425047119C951C700C01AF5 /* Release */, 363 | ); 364 | defaultConfigurationIsVisible = 0; 365 | defaultConfigurationName = Release; 366 | }; 367 | /* End XCConfigurationList section */ 368 | }; 369 | rootObject = 9425045419C951C700C01AF5 /* Project object */; 370 | } 371 | -------------------------------------------------------------------------------- /OpenInSublimeText/BumpBuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # BumpBuild.sh 4 | # Light 5 | # 6 | # Created by Ryan Meisters on 6/18/14. 7 | # Copyright (c) 2014 COD. All rights reserved. 8 | 9 | bN=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") 10 | bN=$((bN += 1)) 11 | bN=$(printf "%d" $bN) 12 | /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $bN" "$INFOPLIST_FILE" -------------------------------------------------------------------------------- /OpenInSublimeText/NSTextStorage+VimOperation.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSTextStorage+VimOperation.h 3 | // XVim 4 | // 5 | // Created by Suzuki Shuichiro on 7/30/13. 6 | // 7 | // 8 | 9 | 10 | //#import "XVimMotion.h" 11 | //#import "XVimDefs.h" 12 | //#import "XVimTextStoring.h" 13 | 14 | //typedef enum { 15 | // XVimSortOptionReversed = 1, 16 | // XVimSortOptionRemoveDuplicateLines = 1 << 1, 17 | // XVimSortOptionNumericSort = 1 << 2, 18 | // XVimSortOptionIgnoreCase = 1 << 3 19 | //} XVimSortOptions; 20 | 21 | /** 22 | VimOperation category on NSTextStorage 23 | Adds Vim-like functionality to NSTextStorage. 24 | **/ 25 | 26 | 27 | 28 | #pragma mark Term Definitions 29 | /** 30 | * Note that the terms here are not the same definition as Cocoa or Xcode classes uses. 31 | * 32 | * "Character" 33 | * Character is a one unichar value. (any value including tabs,spaces) 34 | * 35 | * "EOF" 36 | * EOF is the position at the end of document(text). 37 | * If we have NSTextView with string "abc" the EOF is just AFTER the 'c'. 38 | * The index of EOF is 3 in this case ( index is 0 based ). 39 | * What we have to think about is a cursor can be on the EOF(when the previous letter is newline) but characterAtIndex: with index of EOF cause an exception. 40 | * We have to be careful about it when calculate and find the position of some motions. 41 | * 42 | * "Newline" 43 | * Newline is defined as "unichar determined by isNewline function". Usually "\n" or "\r". 44 | * 45 | * "Line" 46 | * Line is a sequence of characters terminated by newline or EOF. "Line" includes the last newline character. 47 | * 48 | * "Blankline" 49 | * Blankline is a line which has only newline or EOF. In other words, it is newline character or EOF after newline character. 50 | * 51 | * "Last of Line(LOL)" 52 | * Last of line is the last character of a line EXCLUDING newline character. 53 | * This means that blankline does NOT have an Last of line. 54 | * 55 | * "First of Line(FOL)" 56 | * First of line is the first character of a line excluding newline character. 57 | * This means that blankline does NOT have a First of line. 58 | * 59 | * "First Nonblank of Line" 60 | * First Nonblank of Line is the first printable character in a line. 61 | * 62 | * "End of Line(EOL)" 63 | * End of Line is newline or EOF character at the end of a line. 64 | * A line always has an EOL. 65 | * 66 | * "Beginning of Line (BOL)" 67 | * First character of a line including newline and EOF 68 | * 69 | **/ 70 | 71 | /** 72 | * Line number starts from 1. 73 | * Column number starts from 0. 74 | **/ 75 | 76 | @interface NSTextStorage (VimOperation) // 77 | 78 | - (NSUInteger)xvim_columnOfIndex:(NSUInteger)index; 79 | 80 | #pragma mark Definitions 81 | 82 | // Determine if the position specified with "index" is EOF. 83 | //- (BOOL) isEOF:(NSUInteger)index; 84 | // 85 | //// Determine if the position specified with "index" is LOL. 86 | //- (BOOL) isLOL:(NSUInteger)index; 87 | // 88 | //// Determine if the position specified with "index" is EOL. 89 | //- (BOOL) isEOL:(NSUInteger)index; 90 | // 91 | //// Determine if the position is a beginning of line 92 | //- (BOOL) isBOL:(NSUInteger)index; 93 | // 94 | //// Determine if the position specified with "index" is newline. 95 | //- (BOOL) isNewline:(NSUInteger)index; 96 | // 97 | //// Determine if the position specified with "index" is white space. 98 | //- (BOOL) isWhitespace:(NSUInteger)index; 99 | // 100 | //// Determine if the position is on the last line in the document 101 | //- (BOOL) isLastLine:(NSUInteger)index; 102 | // 103 | //// Determine if the position is non blank character 104 | //// EOF is a blank character 105 | //- (BOOL) isNonblank:(NSUInteger)index; 106 | // 107 | ///** 108 | // * Determine if the position specified with "index" is blankline. 109 | // * Blankline is one of followings 110 | // * - Newline after Newline. Ex. The second '\n' in "abc\n\nabc" is a blankline. First one is not. 111 | // * - Newline at begining of the document. 112 | // * - EOF after Newline. Ex. The index 4 of "abc\n" is blankline. Note that index 4 is exceed the string length. But the cursor can be there. 113 | // * - EOF of 0 sized document. 114 | // **/ 115 | //- (BOOL) isBlankline:(NSUInteger)index; 116 | // 117 | ///** 118 | // * Determine if the position specified with "index" is valid cursor position in normal mode. 119 | // * Valid position is followings 120 | // * - Non newline characters. 121 | // * - Blankline( including EOF after newline ) 122 | // **/ 123 | //- (BOOL) isValidCursorPosition:(NSUInteger)index; 124 | // 125 | //#pragma mark Vim operation related methods 126 | // 127 | //- (NSUInteger)prev:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 128 | //- (NSUInteger)next:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt info:(XVimMotionInfo*)info; 129 | // 130 | ///** 131 | // * Returns the position when a cursor goes to upper line. 132 | // * @param index the position of the cursor 133 | // * @param column the desired position of the column in previous line 134 | // * @param count number of repeat 135 | // * @param opt currntly nothing is supported 136 | // * @return The position to move to. If the current index is on the first line it returns 0 137 | // * 138 | // * "column" may be greater then number of characters in the current line. 139 | // * Assume that you have following text. 140 | // * abcd 141 | // * ef 142 | // * 12345678 143 | // * When a cursor at character "4" goes up cursor will go at "f". 144 | // * When a cursor goes up agein it should got at d. (This is default Vim motion) 145 | // * To keep the column position you have to specifi the "column" argument. 146 | // * 147 | // **/ 148 | //- (NSUInteger)prevLine:(NSUInteger)index column:(NSUInteger)column count:(NSUInteger)count option:(MOTION_OPTION)opt; 149 | // 150 | ///** 151 | // * See prevLine's description for meaning of arguments 152 | // **/ 153 | //- (NSUInteger)nextLine:(NSUInteger)index column:(NSUInteger)column count:(NSUInteger)count option:(MOTION_OPTION)opt; 154 | // 155 | ///** 156 | // * Returns position of the head of count words forward and an info structure that handles the end of word boundaries. 157 | // * @param index 158 | // * @param count 159 | // * @param option MOTION_OPTION_NONE or BIGWORD 160 | // * @param info This is used with special cases explaind above such as 'cw' or 'w' crossing over the newline. 161 | // **/ 162 | //- (NSUInteger)wordsForward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt info:(XVimMotionInfo*)info; 163 | // 164 | // 165 | //- (NSUInteger)wordsBackward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 166 | //- (NSUInteger)endOfWordsForward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; //e,E 167 | //- (NSUInteger)endOfWordsBackward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; //ge,gE 168 | //- (NSUInteger)sentencesForward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 169 | //- (NSUInteger)sentencesBackward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 170 | //- (NSUInteger)paragraphsForward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 171 | //- (NSUInteger)paragraphsBackward:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 172 | //- (NSUInteger)nextCharacterInLine:(NSUInteger)index count:(NSUInteger)count character:(unichar)character option:(MOTION_OPTION)opt; 173 | //- (NSUInteger)prevCharacterInLine:(NSUInteger)index count:(NSUInteger)count character:(unichar)character option:(MOTION_OPTION)opt; 174 | // 175 | //// Search starts from 'index+1' to the end of the string 176 | //- (NSRange)searchRegexForward:(NSString*)regex from:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 177 | //// Search starts from 'index-1' to the beginning of the string 178 | //- (NSRange)searchRegexBackward:(NSString*)regex from:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 179 | // 180 | // 181 | ///** 182 | // * This does all the work need to do with vim '%' motion. 183 | // * Find match pair character in the line and find the corresponding pair. 184 | // * Returns NSNotFound if not found. 185 | // **/ 186 | //- (NSUInteger)positionOfMatchedPair:(NSUInteger)pos; 187 | // 188 | //#pragma mark Text Object 189 | //// TODO: Following code should be rewritten 190 | //- (NSRange) currentWord:(NSUInteger)index count:(NSUInteger)count option:(MOTION_OPTION)opt; 191 | //// The following code is from xVim by WarWithinMe. 192 | //// These will be integreted into NSTextView category. 193 | // 194 | //// ======================= 195 | //// Return the location of the start of indentation on current line. '^' 196 | //NSInteger xv_caret(NSString *string, NSInteger index); 197 | //// Return the beginning of line location. '0' 198 | //NSInteger xv_0(NSString *string, NSInteger index); 199 | // 200 | //// Unlike vim, this function won't ignore indent before the current character 201 | //// even if what is '{' 202 | //NSRange xv_current_block(NSString *string, NSUInteger index, NSUInteger repeatCount, BOOL inclusive, char what, char other); 203 | //NSRange xv_current_quote(NSString *string, NSUInteger index, NSUInteger repeatCount, BOOL inclusive, char what); 204 | // 205 | //// Find char in current line. 206 | //// Return the current index if nothing found. 207 | //// If inclusive is YES : 208 | //// 'fx' returns the index after 'x' 209 | //// 'Fx' returns the index before 'x' 210 | //NSInteger xv_findChar(NSString *string, NSInteger index, int repeatCount, char command, unichar what, BOOL inclusive); 211 | // 212 | // 213 | // 214 | //#pragma mark Conversions 215 | ///** 216 | // * Returns nearest valid cursor position for normal mode. 217 | // * This is usually convert cursor position on newline to previous character since 218 | // * a cursor can not be on a newline charaster if its not blankline 219 | // **/ 220 | //- (NSUInteger)convertToValidCursorPositionForNormalMode:(NSUInteger)index; 221 | // 222 | //#pragma mark undo 223 | //- (void)xvim_undoCursorPos:(NSNumber*)num; 224 | @end 225 | -------------------------------------------------------------------------------- /OpenInSublimeText/NSTextStorage+VimOperation.m: -------------------------------------------------------------------------------- 1 | //// 2 | //// NSTextStorage+VimOperation.m 3 | //// XVim 4 | //// 5 | //// Created by Suzuki Shuichiro on 7/30/13. 6 | //// 7 | //// 8 | // 9 | #import 10 | #import "XVimStringBuffer.h" 11 | 12 | #import "NSTextStorage+VimOperation.h" 13 | 14 | @implementation NSTextStorage (VimOperation) 15 | 16 | - (NSString *)xvim_string 17 | { 18 | return self.string; 19 | } 20 | 21 | - (NSUInteger)xvim_tabWidth 22 | { 23 | return 8; 24 | } 25 | 26 | - (NSRange)xvim_indexRangeForLineAtIndex:(NSUInteger)index newLineLength:(NSUInteger *)newLineLength 27 | { 28 | 29 | NSString *string = self.xvim_string; 30 | NSUInteger len = self.length; 31 | NSUInteger end, contentEnd; 32 | 33 | if (index > len) { 34 | index = len; 35 | } 36 | 37 | [string getLineStart:&index end:&end contentsEnd:&contentEnd forRange:NSMakeRange(index, 0)]; 38 | if (newLineLength) *newLineLength = contentEnd - end; 39 | return NSMakeRange(index, contentEnd - index); 40 | } 41 | 42 | static NSUInteger xvim_sb_count_columns(xvim_string_buffer_t *sb, NSUInteger tabWidth) 43 | { 44 | NSUInteger col = 0; 45 | 46 | if (!xvim_sb_at_end(sb)) { 47 | do { 48 | if (xvim_sb_peek(sb) == '\t') { 49 | col += tabWidth; 50 | if (tabWidth) col -= col % tabWidth; 51 | } else { 52 | col++; 53 | } 54 | } while (xvim_sb_next(sb)); 55 | } 56 | 57 | return col; 58 | } 59 | 60 | - (NSUInteger)xvim_columnOfIndex:(NSUInteger)index 61 | { 62 | NSRange range = [self xvim_indexRangeForLineAtIndex:index newLineLength:NULL]; 63 | xvim_string_buffer_t sb; 64 | 65 | if (index < NSMaxRange(range)) { 66 | range.length = index - range.location; 67 | } 68 | if (range.length == 0) { 69 | return 0; 70 | } 71 | 72 | xvim_sb_init(&sb, self.xvim_string, range.location, range); 73 | return xvim_sb_count_columns(&sb, self.xvim_tabWidth); 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /OpenInSublimeText/OSTOpenInSublimeText.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSTOpenInSublimeText.h 3 | // OSTOpenInSublimeText 4 | // 5 | // Created by Ryan Meisters on 9/16/14. 6 | // Copyright (c) 2014 Ryan M. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OSTOpenInSublimeText : NSObject 12 | 13 | @end -------------------------------------------------------------------------------- /OpenInSublimeText/OSTOpenInSublimeText.m: -------------------------------------------------------------------------------- 1 | // 2 | // OSTOpenInSublimeText.m 3 | // OSTOpenInSublimeText 4 | // 5 | // Created by Ryan Meisters on 9/16/14. 6 | // Copyright (c) 2014 Ryan M. All rights reserved. 7 | // 8 | 9 | #import "OSTOpenInSublimeText.h" 10 | 11 | #import "OSTUtil.h" 12 | #import "IDEKit.h" 13 | 14 | #import "NSTextStorage+VimOperation.h" 15 | 16 | typedef struct OSTCursorLocation { 17 | NSUInteger line; 18 | NSUInteger column; 19 | }CursorLocation; 20 | 21 | static OSTOpenInSublimeText *sharedPlugin; 22 | 23 | static NSString * const kOSTMenuItemTitle = @"Open In Sublime Text"; 24 | 25 | @interface OSTOpenInSublimeText() 26 | 27 | @property (nonatomic, strong) NSBundle *bundle; 28 | 29 | @property (nonatomic, strong) NSTimer *menuConfigTimer; 30 | 31 | @property (nonatomic) dispatch_queue_t queue; 32 | 33 | @end 34 | 35 | @implementation OSTOpenInSublimeText 36 | 37 | + (void)pluginDidLoad:(NSBundle *)plugin { 38 | 39 | static dispatch_once_t onceToken; 40 | 41 | NSString *currentApplicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"]; 42 | 43 | if ([currentApplicationName isEqual:@"Xcode"]) { 44 | dispatch_once(&onceToken, ^{ 45 | sharedPlugin = [[self alloc] initWithBundle:plugin]; 46 | }); 47 | } 48 | } 49 | 50 | - (void)dealloc { 51 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 52 | } 53 | 54 | - (id)initWithBundle:(NSBundle *)plugin { 55 | if (self = [super init]) { 56 | // reference to plugin's bundle, for resource acccess 57 | self.bundle = plugin; 58 | 59 | [self registerForNotifications]; 60 | } 61 | return self; 62 | } 63 | 64 | #pragma mark - Notifications 65 | 66 | - (void) registerForNotifications { 67 | 68 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil]; 69 | } 70 | 71 | - (void) windowDidBecomeKey:(NSNotification *)notification { 72 | 73 | [self setupMenuIfNeeded]; 74 | } 75 | 76 | #pragma mark - OST Menu Item Setup 77 | 78 | - (void) setupMenuIfNeeded { 79 | 80 | NSMenu *editorMenu = [[[NSApp mainMenu] itemWithTitle:@"Editor"] submenu]; 81 | 82 | // Add the menu item if it isn't there already 83 | if (![editorMenu itemWithTitle:kOSTMenuItemTitle]) { 84 | [self addOSTMenuItemToMenu:editorMenu]; 85 | } 86 | } 87 | 88 | - (void) addOSTMenuItemToMenu:(NSMenu *)menu { 89 | 90 | [menu addItem:[NSMenuItem separatorItem]]; 91 | NSMenuItem *ostMenuItem = [[NSMenuItem alloc] initWithTitle:kOSTMenuItemTitle action:@selector(menuItemClicked) keyEquivalent:@"s"]; 92 | [ostMenuItem setTarget:self]; 93 | [menu addItem:ostMenuItem]; 94 | } 95 | 96 | - (void) menuItemClicked { 97 | [self openCurrentFileWithSublimeTextAtLocation:[self currentCursorLocation]]; 98 | } 99 | 100 | 101 | #pragma mark - Open In Sublime Text 102 | 103 | - (void) openCurrentFileWithSublimeTextAtLocation:(CursorLocation)location { 104 | 105 | self.queue = dispatch_queue_create("io.rhm.OpenInSublimeText", NULL); 106 | 107 | NSString *path = [NSString stringWithFormat:@"%@:%lu:%lu", [self currentFilePath],location.line, location.column]; 108 | 109 | dispatch_async(self.queue, ^{ 110 | 111 | NSLog(@"OST: Openning %@ in Sublime Text", path); 112 | 113 | NSTask *task = [[NSTask alloc] init]; 114 | 115 | task.launchPath = @"/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl"; // Sublime Text 3 116 | 117 | if(![[NSFileManager defaultManager] isExecutableFileAtPath:task.launchPath]) 118 | { 119 | task.launchPath = @"/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl"; // Sublime Text 2 120 | } 121 | 122 | task.arguments = @[path, @"--wait", @"--new-window"]; 123 | 124 | task.terminationHandler = ^(NSTask *aTask){ 125 | // dispatch_async(dispatch_get_main_queue(), ^{ 126 | 127 | // }); 128 | }; 129 | 130 | [task launch]; 131 | [task waitUntilExit]; 132 | }); 133 | } 134 | 135 | #pragma mark - Utility 136 | 137 | - (NSString *) currentFilePath { 138 | 139 | IDEEditorArea *area = OSTLastActiveEditorArea(); 140 | 141 | IDEEditorContext *context = area.lastActiveEditorContext; 142 | 143 | IDEEditor *editor = context.editor; 144 | 145 | IDEEditorDocument *doc = editor.document; 146 | 147 | NSURL *url = doc.fileURL; 148 | 149 | return url.path; 150 | } 151 | 152 | - (CursorLocation) currentCursorLocation { 153 | 154 | CursorLocation location; 155 | 156 | id docView = OSTLastActiveSourceView(); 157 | NSLog(@"OST: Document view class -- %@", [docView class]); 158 | 159 | if ([docView isKindOfClass:[DVTSourceTextView class]]) { 160 | 161 | DVTSourceTextView *view = (DVTSourceTextView *)docView; 162 | 163 | NSInteger cursorIndex = [[[view selectedRanges] objectAtIndex:0] rangeValue].location; 164 | 165 | location.line = [view _currentLineNumber]; 166 | 167 | location.column = [view.textStorage xvim_columnOfIndex:cursorIndex]; 168 | } 169 | 170 | return location; 171 | } 172 | 173 | 174 | @end 175 | -------------------------------------------------------------------------------- /OpenInSublimeText/OSTUtil.h: -------------------------------------------------------------------------------- 1 | // 2 | // OSTUtil.h 3 | // OpenInSublimeText 4 | // 5 | // Created by Ryan Meisters on 9/17/14. 6 | // Copyright (c) 2014 Ryan M. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class IDEWorkspaceWindowController; 12 | @class IDEWorkspaceTabController; 13 | @class IDEEditorArea; 14 | @class DVTSourceTextView; 15 | 16 | IDEWorkspaceWindowController* OSTLastActiveWindowController(void); 17 | IDEWorkspaceTabController* OSTLastActiveWorkspaceTabController(void); 18 | IDEEditorArea* OSTLastActiveEditorArea(void); 19 | DVTSourceTextView* OSTLastActiveSourceView(void); 20 | 21 | @interface OSTUtil : NSObject 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /OpenInSublimeText/OSTUtil.m: -------------------------------------------------------------------------------- 1 | // 2 | // OSTUtil.m 3 | // OpenInSublimeText 4 | // 5 | // Created by Ryan Meisters on 9/17/14. 6 | // Copyright (c) 2014 Ryan M. All rights reserved. 7 | // 8 | // Borrowed from XVim Xcode Plugin :) 9 | 10 | #import "OSTUtil.h" 11 | #import "DVTFoundation.h" 12 | #import "DVTKit.h" 13 | #import "IDEKit.h" 14 | 15 | 16 | IDEWorkspaceWindowController* OSTLastActiveWindowController(){ 17 | 18 | static IDEWorkspaceWindowController* workspace; 19 | 20 | if ([[IDEWorkspaceWindow class] respondsToSelector:@selector(lastActiveWorkspaceWindow)]) 21 | { 22 | //for Xcode6.3 23 | workspace = [IDEWorkspaceWindow performSelector:@selector(lastActiveWorkspaceWindow)]; 24 | } 25 | else if([[IDEWorkspaceWindow class] respondsToSelector:@selector(lastActiveWorkspaceWindowController)]) 26 | { 27 | workspace = [IDEWorkspaceWindow performSelector:@selector(lastActiveWorkspaceWindowController)]; 28 | } 29 | 30 | return workspace; 31 | } 32 | 33 | IDEWorkspaceTabController* OSTLastActiveWorkspaceTabController(){ 34 | return [OSTLastActiveWindowController() activeWorkspaceTabController]; 35 | } 36 | 37 | IDEEditorArea* OSTLastActiveEditorArea(){ 38 | return [OSTLastActiveWindowController() editorArea]; 39 | } 40 | 41 | DVTSourceTextView* OSTLastActiveSourceView(){ 42 | return [[[[OSTLastActiveEditorArea() lastActiveEditorContext] editor] mainScrollView] documentView]; 43 | } 44 | 45 | @implementation OSTUtil 46 | 47 | 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /OpenInSublimeText/OpenInSublimeText-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | BNDL 19 | CFBundleShortVersionString 20 | 1.4.3 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 79 25 | DVTPlugInCompatibilityUUIDs 26 | 27 | 1637F4D5-0B27-416B-A78D-498965D64877 28 | AD68E85B-441B-4301-B564-A45E4919A6AD 29 | A2E4D43F-41F4-4FB9-BB94-7177011C9AED 30 | 37B30044-3B14-46BA-ABAA-F01000C27B63 31 | 63FC1C47-140D-42B0-BB4D-A10B2D225574 32 | C4A681B0-4A26-480E-93EC-1218098B9AA0 33 | FEC992CC-CA4A-4CFD-8881-77300FCB848A 34 | 992275C1-432A-4CF7-B659-D84ED6D42D3F 35 | A16FF353-8441-459E-A50C-B071F53F51B7 36 | 9F75337B-21B4-4ADC-B558-F9CADF7073A7 37 | 8DC44374-2B35-4C57-A6FE-2AD66A36AAD9 38 | E969541F-E6F9-4D25-8158-72DC3545A6C6 39 | AABB7188-E14E-4433-AD3B-5CD791EAD9A3 40 | 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 41 | CC0D0F4F-05B3-431A-8F33-F84AFCB2C651 42 | 0420B86A-AA43-4792-9ED0-6FE0F2B16A13 43 | 7265231C-39B4-402C-89E1-16167C4CC990 44 | F41BD31E-2683-44B8-AE7F-5F09E919790E 45 | ACA8656B-FEA8-4B6D-8E4A-93F4C95C362C 46 | 47 | NSPrincipalClass 48 | OSTOpenInSublimeText 49 | XC4Compatible 50 | 51 | XC5Compatible 52 | 53 | XC6Compatible 54 | 55 | XCGCReady 56 | 57 | XCPluginHasUI 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /OpenInSublimeText/OpenInSublimeText-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | -------------------------------------------------------------------------------- /OpenInSublimeText/XVimStringBuffer.h: -------------------------------------------------------------------------------- 1 | // 2 | // XVimStringBuffer.h 3 | // XVim 4 | // 5 | // Created by John AppleSeed on 16/11/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | /** @brief structure used for fast search in an NSString 12 | * 13 | * This has complex invariants: 14 | * - b_index is always > 0 unless at the beginning of the allowed range 15 | * - if b_len < sizeof(buffer) buffer[b_len] is XVimInvalidChar 16 | * 17 | * Those allow peek_next() and peek_prev() to be fast and well defined 18 | * 19 | * Thisis a c-ish interface, so following Apple recent trend, 20 | * APIs are in small caps. 21 | */ 22 | typedef struct xvim_string_buffer_s { 23 | NSString *__unsafe_unretained s; 24 | NSUInteger s_min; // min index within s to clip enumeration to 25 | NSUInteger s_max; // max index within s to clip enumeration to 26 | NSUInteger s_index; // index of buffer[0] in s 27 | NSUInteger b_index; // index in buffer being read 28 | NSUInteger b_len; // number of characters read in buffer 29 | unichar buffer[64]; 30 | } xvim_string_buffer_t; 31 | 32 | #define XVimInvalidChar ((unichar)-1) 33 | 34 | NS_INLINE NSUInteger _xvim_sb_size(void) 35 | { 36 | return sizeof(((xvim_string_buffer_t *)NULL)->buffer) / sizeof(unichar); 37 | } 38 | 39 | NS_INLINE void _xvim_sb_load(xvim_string_buffer_t *sb) 40 | { 41 | NSUInteger len = MIN(sb->s_max - sb->s_index, _xvim_sb_size()); 42 | 43 | sb->b_len = len; 44 | NSCAssert(sb->b_len <= _xvim_sb_size(), @"b_len is bogus"); 45 | if (len > 0) { 46 | [sb->s getCharacters:sb->buffer range:NSMakeRange(sb->s_index, len)]; 47 | } 48 | if (len < _xvim_sb_size()) { 49 | sb->buffer[len] = XVimInvalidChar; 50 | } 51 | } 52 | 53 | /* returns NO if at end */ 54 | NS_INLINE void xvim_sb_init(xvim_string_buffer_t *sb, NSString *s, NSUInteger index, NSRange forRange) 55 | { 56 | sb->s = s; 57 | sb->s_min = forRange.location; 58 | sb->s_max = sb->s_min + forRange.length; 59 | 60 | NSCAssert(index >= sb->s_min && index <= sb->s_max, @"bad caller"); 61 | 62 | if (forRange.length < _xvim_sb_size() || index < (_xvim_sb_size()/2) || index - (_xvim_sb_size()/2) < (NSInteger)sb->s_min) { 63 | sb->s_index = sb->s_min; 64 | } else if (index + _xvim_sb_size() >= sb->s_max) { 65 | sb->s_index = sb->s_max - _xvim_sb_size() + 1; 66 | } else { 67 | sb->s_index = index - _xvim_sb_size() / 2; 68 | } 69 | sb->b_index = index - sb->s_index; 70 | _xvim_sb_load(sb); 71 | } 72 | 73 | NS_INLINE NSUInteger xvim_sb_index(xvim_string_buffer_t *sb) 74 | { 75 | return sb->s_index + sb->b_index; 76 | } 77 | 78 | NS_INLINE NSRange xvim_sb_range_to_start(xvim_string_buffer_t *sb) 79 | { 80 | return NSMakeRange(sb->s_min, xvim_sb_index(sb) - sb->s_min); 81 | } 82 | 83 | NS_INLINE NSRange xvim_sb_range_to_end(xvim_string_buffer_t *sb) 84 | { 85 | return NSMakeRange(xvim_sb_index(sb), sb->s_max - xvim_sb_index(sb)); 86 | } 87 | 88 | NS_INLINE unichar xvim_sb_peek_prev(xvim_string_buffer_t *sb) 89 | { 90 | return sb->b_index > 0 ? XVimInvalidChar : sb->buffer[sb->b_index]; 91 | } 92 | 93 | NS_INLINE unichar xvim_sb_peek(xvim_string_buffer_t *sb) 94 | { 95 | return sb->buffer[sb->b_index]; 96 | } 97 | 98 | NS_INLINE BOOL xvim_sb_at_start(xvim_string_buffer_t *sb) 99 | { 100 | return sb->b_index == 0; 101 | } 102 | 103 | NS_INLINE BOOL xvim_sb_at_end(xvim_string_buffer_t *sb) 104 | { 105 | return xvim_sb_peek(sb) == XVimInvalidChar; 106 | } 107 | 108 | /* returns NO when at end of string */ 109 | NS_INLINE BOOL xvim_sb_next(xvim_string_buffer_t *sb) 110 | { 111 | if (xvim_sb_at_end(sb)) { 112 | return NO; 113 | } 114 | sb->b_index++; 115 | if (sb->b_index < sb->b_len) { 116 | return YES; 117 | } 118 | if (sb->b_len < _xvim_sb_size()) { 119 | return NO; 120 | } 121 | sb->s_index += _xvim_sb_size() / 2; 122 | sb->b_index = _xvim_sb_size() / 2; 123 | _xvim_sb_load(sb); 124 | return sb->b_index < sb->b_len; 125 | } 126 | 127 | /* returns NO when at beggining of string */ 128 | NS_INLINE BOOL xvim_sb_prev(xvim_string_buffer_t *sb) 129 | { 130 | if (sb->b_index > 1) { 131 | sb->b_index--; 132 | return YES; 133 | } 134 | 135 | NSUInteger diff = MIN(sb->s_index - sb->s_min, _xvim_sb_size() / 2); 136 | if (diff > 0) { 137 | sb->s_index -= diff; 138 | sb->b_index = diff; 139 | _xvim_sb_load(sb); 140 | return YES; 141 | } 142 | 143 | if (sb->b_index > 0) { 144 | sb->b_index--; 145 | } 146 | return NO; 147 | } 148 | 149 | /* skips chars until end of string or peek_next() not in set */ 150 | NS_INLINE BOOL xvim_sb_skip_forward(xvim_string_buffer_t *sb, NSCharacterSet *set) 151 | { 152 | if (!xvim_sb_at_end(sb)) { 153 | do { 154 | if (![set characterIsMember:xvim_sb_peek(sb)]) { 155 | return YES; 156 | } 157 | } while (xvim_sb_next(sb)); 158 | } 159 | 160 | return NO; 161 | } 162 | 163 | /* skips chars until end of string or peek_next() in set */ 164 | NS_INLINE BOOL xvim_sb_find_forward(xvim_string_buffer_t *sb, NSCharacterSet *set) 165 | { 166 | if (!xvim_sb_at_end(sb)) { 167 | do { 168 | if ([set characterIsMember:xvim_sb_peek(sb)]) { 169 | return YES; 170 | } 171 | } while (xvim_sb_next(sb)); 172 | } 173 | 174 | return NO; 175 | } 176 | 177 | /* go back until start of string or peek_prev() not in set */ 178 | NS_INLINE BOOL xvim_sb_skip_backward(xvim_string_buffer_t *sb, NSCharacterSet *set) 179 | { 180 | if (!xvim_sb_at_start(sb)) { 181 | do { 182 | if (![set characterIsMember:xvim_sb_peek_prev(sb)]) { 183 | return YES; 184 | } 185 | } while (xvim_sb_prev(sb)); 186 | } 187 | 188 | return NO; 189 | } 190 | 191 | /* go back until start of string or peek_prev() not in set */ 192 | NS_INLINE BOOL xvim_sb_find_backward(xvim_string_buffer_t *sb, NSCharacterSet *set) 193 | { 194 | if (!xvim_sb_at_start(sb)) { 195 | do { 196 | if ([set characterIsMember:xvim_sb_peek_prev(sb)]) { 197 | return YES; 198 | } 199 | } while (xvim_sb_prev(sb)); 200 | } 201 | 202 | return NO; 203 | } 204 | -------------------------------------------------------------------------------- /OpenInSublimeText/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Xcode Open In Sublime Text 2 | ============================== 3 | 4 | ![Open In Sublime Text](https://raw.githubusercontent.com/ryanmeisters/Xcode-Plugin-Open-Sublime-Text/master/Misc/OpenInSublimeText.gif) 5 | 6 | Open In Sublime Text is a simple xcode plugin to quickly open a source file in Sublime Text from Xcode. Of course, you can just drag the file from the Xcode navigator onto the Sublime Text icon in your dock, but that's a lot of work. This plugin adds a `Open In Sublime Text` menu item to Xcode's Editor menu, which can be easily mapped to a convenient keyboard shortcut. 7 | 8 | ![Open In Sublime Text Editor Menu](https://raw.githubusercontent.com/ryanmeisters/Xcode-Plugin-Open-Sublime-Text/master/Misc/OpenInSublimeTextMenu.png) 9 | 10 | 11 | # Installation 12 | 1. Install the plugin. This can be done in 2 ways: 13 | 14 | 1. Install [Alcatraz](http://alcatraz.io) and search for `OpenInSublimeText`, or 15 | 2. Clone this repository, open `OpenInSublimeText.xcodeproj`, build, and restart xcode (This automatically installs the plugin at `~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/OpenInSublimeText.xcplugin`) 16 | 2. Assign a keyboard shortcut to `Open In Sublime Text` for Xcode in the OSX Keyboard System Preferences. 17 | 18 | ----- 19 | Supports Xcode 5 up to Xcode 8 beta 6, Sublime Text 2, Sublime Text 3 20 | 21 | ### Known Limitations 22 | - This plugin assumes that Sublime Text is installed in the Applications folder, i.e. `/Applications/Sublime Text.app` or `/Applications/Sublime Text 2.app`. 23 | - If both Sublime Text 2 and Sublime Text 3 are installed, Sublime Text 3 is used. 24 | --------------------------------------------------------------------------------