{"id":13465278,"url":"https://github.com/swift-emacs/swift-mode","last_synced_at":"2025-04-05T06:10:08.614Z","repository":{"id":17638903,"uuid":"20443295","full_name":"swift-emacs/swift-mode","owner":"swift-emacs","description":"Emacs support for Apple's Swift programming language.","archived":false,"fork":false,"pushed_at":"2024-02-17T06:44:06.000Z","size":986,"stargazers_count":363,"open_issues_count":6,"forks_count":47,"subscribers_count":20,"default_branch":"master","last_synced_at":"2024-05-02T15:17:12.942Z","etag":null,"topics":["elisp","emacs","emacs-lisp","emacs-mode","swift","swift-programming-language"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swift-emacs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-06-03T13:17:03.000Z","updated_at":"2024-06-19T02:53:09.961Z","dependencies_parsed_at":"2023-02-10T10:16:05.323Z","dependency_job_id":"29ba3cac-bbbf-4c4e-bb8c-6581fc6b72ae","html_url":"https://github.com/swift-emacs/swift-mode","commit_stats":null,"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-emacs%2Fswift-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-emacs%2Fswift-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-emacs%2Fswift-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swift-emacs%2Fswift-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swift-emacs","download_url":"https://codeload.github.com/swift-emacs/swift-mode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247294541,"owners_count":20915340,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elisp","emacs","emacs-lisp","emacs-mode","swift","swift-programming-language"],"created_at":"2024-07-31T15:00:25.619Z","updated_at":"2025-04-05T06:10:08.594Z","avatar_url":"https://github.com/swift-emacs.png","language":"Emacs Lisp","funding_links":[],"categories":["Editor Support","Emacs Lisp","Emacs [🔝](#readme)","Guides and Learning"],"sub_categories":["Emacs"],"readme":"[![License GPL 3][badge-license]][copying]\n[![Run Tests][badge-run-test]][action-run-test]\n[![MELPA](https://melpa.org/packages/swift-mode-badge.svg)](https://melpa.org/#/swift-mode)\n[![MELPA](https://stable.melpa.org/packages/swift-mode-badge.svg)](https://melpa.org/#/swift-mode)\n\n# swift-mode\n\nMajor-mode for Apple's [Swift programming language](https://developer.apple.com/swift/).\n\n## Installation\n\nInstall `swift-mode` package from MELPA.\n\nTo install without MELPA, download [latest release](https://github.com/swift-emacs/swift-mode/releases) and execute `M-x package-install-file` for the .tar archive.\n\n## Features\n\n- Font Lock\n- Indentation\n\n  ```swift\n  switch foo {\n  case let .P1(x)\n         where\n           x \u003e 0,\n       let .P2(x)\n         where\n           x \u003e 0:\n      bar()\n        .then { x in\n            return baz(x)\n        }\n        .then {(\n                 x,\n                 y\n               ) in\n            return moo(x + y)\n        }\n  }\n\n  // Hanging brace\n  let x = [\n    1,\n    2,\n    3\n  ]\n\n  // Brace on its own line\n  let y =\n    [\n      1,\n      2,\n      3\n    ]\n\n  // Utrecht style\n  let z =\n    [ 1\n    , 2\n    , 3\n    ]\n  ```\n- `forward-sexp`\n- `beginning-of-defun`, `end-of-defun`, `mark-defun`, and `narrow-to-defun`.\n- `beginning-of-sentence`, `end-of-sentence`, `kill-sentence`, `backward-kill-sentence`, `mark-sentence`, and `narrow-to-sentence`.\n  A sentence is a statement outside comments or strings, or an ordinal sentence inside comments or strings.\n- `indent-new-comment-line`\n- [Imenu](https://www.gnu.org/software/emacs/manual/html_node/emacs/Imenu.html)\n- Running Swift REPL in a buffer (`M-x run-swift`)\n- Build Swift module (`M-x swift-mode:build-swift-module`)\n- Build iOS app (`M-x swift-mode:build-ios-app`)\n- Running debugger on Swift module (`M-x swift-mode:debug-swift-module`)\n- Running debugger on iOS app in simulator or device (`M-x swift-mode:debug-ios-app`)\n  ([`ios-deploy`](https://github.com/ios-control/ios-deploy) is required to debug on device).\n\nThis package does not provide flycheck. See [flycheck-swift](https://github.com/swift-emacs/flycheck-swift).\n\n## Limitations\n\nSome syntax constructs removed from Swift 3.0 are not supported:\n\n- C-style for-loop: `for var i = 1; i \u003c 10; i++ { }`\n- Multiple assignments in single `if let`:\n  ```swift\n  if let x = x,\n         y = y {\n  }\n  ```\n\n  Use multiple `let` instead:\n  ```swift\n  if let x = x,\n     let y = y {\n  }\n  ```\n\nIndentation may not accurate. For example, `foo(Bar \u003c A, B \u003e (c))` can be indented like either\n```swift\nfoo(Bar \u003c A,\n    B \u003e (c)) // Passing two Boolean arguments to foo\n```\nor\n```swift\nfoo(Bar \u003c A,\n          B \u003e (c)) // Passing a new Bar with two type arguments and a value\n```\nThe Swift compiler disambiguates this case using tokens after `\u003e`, but those tokens may not available at editing time. We use some heuristic for this.\n\nAnother example is difficulty of handling of colons. We have to pair all `?` and `:` of conditional operators to decide indentation of the below snippet. This is a future work.\n\n```swift\nswitch foo {\n  case let P(x) where x is Foo? ? a ? b : c ?? d : e ? f : g :\n    h ? i?.j() : k()\n}\n\nswitch foo {\n  case let P(x) where (x is Foo?) ? (a ? b : c ?? d) : (e ? f : g) :\n    h ? i?.j() : k()\n}\n```\n\nYet another difficult case is consistency of blocks. We want to indent method chains like this:\n```swift\nvar x = foo\n  .then { x in\n      aaa\n  }\n  .then { x in\n      aaa\n  }\n```\n\nwhile we also want to indent the body of `if` like this:\n\n```swift\nif anotherVeryLongVariableName\n     .veryLongPropertyName {\n    aaa\n}\n```\n\nThat is, we have to indent the closing brace with offset if it is a part of expressions while it should be aligned with the beginning of the statement/declaration if it is a part of a statement/declaration.\n\nThen, how should we indent the following code when the cursor is before `@`?\n\n```swift\nvar x = foo\n  .bar {\n    @\n```\n\nThis could be\n```swift\nvar x = foo\n  .bar {\n    @abc willSet {\n        aaa\n    }\n}\n// property declaration\n```\nor\n```swift\nvar x = foo\n  .bar {\n      @abc var x = 1\n      x\n  }\n// property initialization\n```\n\nBoth are syntactically correct code. We cannot handle this case properly. This is also a future work.\n\nOther example is regex literals and custom operators.  The following example is valid Swift code with regex literals and custom operators.\n\n```swift\nlet x = /^/ /^/ /^/\n```\n\nWe parse them as regex literals rather than custom operators for now.\n\n\n## Hacking\n\nTo build the package locally, run `make package`.\n\nTo install the built package, run `make install`.\n\nTo run tests, run `make test`.\n\nFor other commands, run `make help`.\n\n## Related projects\n\n- [Official swift-mode.el by Apple](https://github.com/apple/swift/blob/master/utils/swift-mode.el): Seems still in very early stage for now. We cannot contribute to it due to the license incompatibility.\n- [sourcekit-lsp](https://github.com/apple/sourcekit-lsp): Language Server Protocol implementation for Swift and C-based languages.\n- [lsp-sourcekit](https://github.com/emacs-lsp/lsp-sourcekit): Emacs client for lsp-sourcekit.\n- [swift-helpful](https://github.com/danielmartin/swift-helpful): Shows documentation about Swift keywords, attributes, and API.\n- [company-sourcekit](https://github.com/nathankot/company-sourcekit): Completion for Swift projects via SourceKit with the help of SourceKitten.\n- [flycheck-swift](https://github.com/swift-emacs/flycheck-swift): Flycheck extensions for Swift.\n- [swift-playground-mode](https://gitlab.com/michael.sanders/swift-playground-mode): Emacs support for Swift playgrounds.\n- [swift-format](https://github.com/apple/swift-format): Formatter for Swift by Apple (`swift format` command).\n- [SwiftRewriter](https://github.com/inamiy/SwiftRewriter): Formatter for Swift using SwiftSyntax.\n- [SwiftFormat](https://github.com/nicklockwood/SwiftFormat): Formatter for Swift.\n\n## Contributing\n\nYes, please do! See [CONTRIBUTING](./CONTRIBUTING.md) for guidelines.\n\n## Acknowledgements\n\nThe REPL code is based on [js-comint](http://js-comint-el.sourceforge.net/).\n\nThanks to the following original developer and users for their contributions:\n\n- [@chrisbarrett](https://github.com/chrisbarrett) (Chris Barrett)\n- [@ap4y](https://github.com/ap4y) (Arthur Evstifeev)\n- [@bbatsov](https://github.com/bbatsov) (Bozhidar Batsov)\n- [@ckruse](https://github.com/ckruse) (Christian Kruse)\n- [@syohex](https://github.com/syohex) (Syohei Yoshida)\n- [@uk-ar](https://github.com/uk-ar) (Yuuki Arisawa)\n- [@msanders](https://github.com/msanders) (Michael Sanders)\n\nYou can find a [full list of those people here](https://github.com/swift-emacs/swift-mode/graphs/contributors).\n\nThanks to [@purcell](https://github.com/purcell) (Steve Purcell) for advices on the code and arrangement for merging `swift3-mode` and `swift-mode`.\n\n## License\n\nGPLv3. See [COPYING][] for details. Copyright (C) 2014-2021 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev.\n\n[badge-license]: https://img.shields.io/badge/license-GPL_3-green.svg\n[badge-run-test]: https://github.com/swift-emacs/swift-mode/workflows/Run%20Tests/badge.svg\n[action-run-test]: https://github.com/swift-emacs/swift-mode/actions?query=workflow%3A%22Run+Tests%22\n[COPYING]: ./COPYING\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-emacs%2Fswift-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswift-emacs%2Fswift-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswift-emacs%2Fswift-mode/lists"}