textmate / swift.tmbundle

TextMate support for Swift
72 stars 30 forks source link

Bundle Does Not Work In Atom & Sublime Text #29

Closed dominicap closed 6 years ago

dominicap commented 7 years ago

When trying to use this bundle in Atom or Sublime, it does not work.

In Atom, after converting the package through Atom’s package manager with the command, apm init --package language-swift --convert https://github.com/textmate/swift.tmbundle, moving it to Atom's packages directory and opening a swift file, I receive a “Uncaught Error: invalid pattern in look-behind” and I cannot type at all in the file.

In Sublime Text 2, after moving the bundle to the packages directory, I receive a "Error loading syntax file "Packages/swift.tmbundle/Syntaxes/Swift.tmLanguage”: Unexpected capture value" and syntax highlighting, snippets etc. do not work.

In Sublime Text 3, after moving the bundle to the packages directory, Sublime does not even acknowledge the package.

It would be appreciated if this could be addressed as it is, as far as I can tell, the most complete and up to date package for swift support in other textmate and other editors.

jtbandes commented 7 years ago

Can you tell which regular expressions are causing the problem?

infininight commented 7 years ago

@dominicap The Atom syntax format is almost entirely compatible, there is only some minor regex syntax differences that can easily be worked around. So this is something we can correct if someone can narrow down the rule that is at fault.

Sublime is not going to work. It does not support TextMate 2 grammars, there are vast differences and it is not something we will be correcting.

dominicap commented 7 years ago

@jtbandes Atom does not explicitly state which line/expression causes the problem. However, I narrowed it down to the following snippet of code in Swift.tmLanguage:

<dict>
    <key>match</key>
    <string>(?&lt;=\bProcess\.|\bCommandLine\.)(arguments|argc|unsafeArgv)</string>
    <key>name</key>
    <string>support.variable.swift</string>
</dict>

This is the converted CoffeeScript version. If this segment is commented out, errors are not thrown

{
  match: "(?<=\\bProcess\\.|\\bCommandLine\\.)(arguments|argc|unsafeArgv)"
  name: "support.variable.swift"
}
svanimpe commented 6 years ago

Visual Studio Code also crashes on that same regular expression. There seem to be minor incompatibilities between the versions of Onigurama used in these editors.

The issue seems to be the word break \b in the look-behind pattern. If I remove that, the pattern is accepted (although it won't work as intended). Does anyone know if this should be valid?

jtbandes commented 6 years ago

I think I simply forgot to close this issue. The problem should be fixed now!