All Projects → swift-emacs → Swift Mode

swift-emacs / Swift Mode

Licence: gpl-3.0
Emacs support for Apple's Swift programming language.

Programming Languages

swift
15916 projects
elisp
30 projects

Projects that are alternatives of or similar to Swift Mode

Nyan Mode
Nyan Cat for Emacs! Nyanyanyanyanyanyanyanyanyan!
Stars: ✭ 590 (+91.56%)
Mutual labels:  emacs, emacs-mode
Fingers.el
Modal editing minor mode for Emacs
Stars: ✭ 51 (-83.44%)
Mutual labels:  emacs, emacs-mode
Deft
Deft for Emacs
Stars: ✭ 521 (+69.16%)
Mutual labels:  emacs, emacs-mode
Writegood Mode
Minor mode for Emacs to improve English writing
Stars: ✭ 369 (+19.81%)
Mutual labels:  emacs, emacs-mode
Psc Ide Emacs
Emacs integration for PureScript's psc-ide tool.
Stars: ✭ 130 (-57.79%)
Mutual labels:  emacs, emacs-mode
Webpaste.el
webpaste.el can paste whole buffers or parts of buffers to several pastebin-like services and supports failover if one service fails.
Stars: ✭ 67 (-78.25%)
Mutual labels:  emacs, emacs-mode
Clj Refactor.el
A collection of Clojure refactoring functions for Emacs
Stars: ✭ 694 (+125.32%)
Mutual labels:  emacs, emacs-mode
Live Py Plugin
Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser
Stars: ✭ 222 (-27.92%)
Mutual labels:  emacs, emacs-mode
Emacs Solidity
The official solidity-mode for EMACS
Stars: ✭ 120 (-61.04%)
Mutual labels:  emacs, emacs-mode
Jq Mode
Emacs major mode for editing jq queries.
Stars: ✭ 70 (-77.27%)
Mutual labels:  emacs, emacs-mode
Org Msg
OrgMsg is a GNU/Emacs global minor mode mixing up Org mode and Message mode to compose and reply to emails in a Outlook HTML friendly style.
Stars: ✭ 153 (-50.32%)
Mutual labels:  emacs, emacs-mode
Zoom
Fixed and automatic balanced window layout for Emacs
Stars: ✭ 252 (-18.18%)
Mutual labels:  emacs, emacs-mode
Radian
🍉 Dotfiles that marry elegance and practicality.
Stars: ✭ 274 (-11.04%)
Mutual labels:  emacs
Company Coq
A Coq IDE build on top of Proof General's Coq mode
Stars: ✭ 297 (-3.57%)
Mutual labels:  emacs
Dotfiles
●📄 Ryan McGeary's configuration shiznit that makes him productive
Stars: ✭ 278 (-9.74%)
Mutual labels:  emacs
Rg.el
Emacs search tool based on ripgrep
Stars: ✭ 277 (-10.06%)
Mutual labels:  emacs
Themecreator
https://mswift42.github.io/themecreator/ create themes for intellij, textmate, atom, emacs, vim and gnome terminal.
Stars: ✭ 303 (-1.62%)
Mutual labels:  emacs
Vue Mode
Emacs major mode for vue.js
Stars: ✭ 290 (-5.84%)
Mutual labels:  emacs
Objed
Navigate and edit text objects with Emacs. Development on pause.
Stars: ✭ 276 (-10.39%)
Mutual labels:  emacs
Cloudmacs
Selfhost your Emacs and access it in browser
Stars: ✭ 277 (-10.06%)
Mutual labels:  emacs

License GPL 3 Run Tests MELPA MELPA

swift-mode

Major-mode for Apple's Swift programming language.

Installation

Install swift-mode package from MELPA.

To install without MELPA, download latest release and execute M-x package-install-file for the .tar archive.

Features

  • Font Lock

  • Indentation

    switch foo {
    case let .P1(x)
           where
             x > 0,
         let .P2(x)
           where
             x > 0:
        bar()
          .then { x in
              return baz(x)
          }
          .then {(
                   x,
                   y
                 ) in
              return moo(x + y)
          }
    }
    
    // Hanging brace
    let x = [
      1,
      2,
      3
    ]
    
    // Brace on its own line
    let y =
      [
        1,
        2,
        3
      ]
    
    // Utrecht style
    let z =
      [ 1
      , 2
      , 3
      ]
    
  • forward-sexp

  • beginning-of-defun, end-of-defun, mark-defun, and narrow-to-defun.

  • beginning-of-sentence, end-of-sentence, kill-sentence, backward-kill-sentence, mark-sentence, and narrow-to-sentence. A sentence is a statement outside comments or strings, or an ordinal sentence inside comments or strings.

  • indent-new-comment-line

  • Imenu

  • Running Swift REPL in a buffer (M-x run-swift)

  • Build Swift module (M-x swift-mode:build-swift-module)

  • Build iOS app (M-x swift-mode:build-ios-app)

  • Running debugger on Swift module (M-x swift-mode:debug-swift-module)

  • Running debugger on iOS app in simulator or device (M-x swift-mode:debug-ios-app) (ios-deploy is required to debug on device).

This package does not provide flycheck. See flycheck-swift.

Limitations

Some syntax constructs removed from Swift 3.0 are not supported:

  • C-style for-loop: for var i = 1; i < 10; i++ { }

  • Multiple assignments in single if let:

    if let x = x,
           y = y {
    }
    

    Use multiple let instead:

    if let x = x,
       let y = y {
    }
    

Indentation may not accurate. For example, foo(Bar < A, B > (c)) can be indented like either

foo(Bar < A,
    B > (c)) // Passing two Boolean arguments to foo

or

foo(Bar < A,
          B > (c)) // Passing a new Bar with two type arguments and a value

The Swift compiler disambiguates this case using tokens after >, but those tokens may not available at editing time. We use some heuristic for this.

Another 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.

switch foo {
  case let P(x) where x is Foo? ? a ? b : c ?? d : e ? f : g :
    h ? i?.j() : k()
}

switch foo {
  case let P(x) where (x is Foo?) ? (a ? b : c ?? d) : (e ? f : g) :
    h ? i?.j() : k()
}

Yet another difficult case is consistency of blocks. We want to indent method chains like this:

var x = foo
  .then { x in
      aaa
  }
  .then { x in
      aaa
  }

while we also want to indent the body of if like this:

if anotherVeryLongVariableName
     .veryLongPropertyName {
    aaa
}

That 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.

Then, how should we indent the following code when the cursor is before @?

var x = foo
  .bar {
    @

This could be

var x = foo
  .bar {
    @abc willSet {
        aaa
    }
}
// property declaration

or

var x = foo
  .bar {
      @abc var x = 1
      x
  }
// property initialization

Both are syntactically correct code. We cannot handle this case properly. This is also a future work.

Hacking

To build the package locally, run make package. You need Cask.

To install the built package, run make install.

To run tests, run make test.

For other commands, run make help.

Related projects

Contributing

Yes, please do! See CONTRIBUTING for guidelines.

Acknowledgements

The REPL code is based on js-comint.

Thanks to the following original developer and users for their contributions:

You can find a full list of those people here.

Thanks to @purcell (Steve Purcell) for advices on the code and arrangement for merging swift3-mode and swift-mode.

License

GPLv3. See COPYING for details. Copyright (C) 2014-2016 taku0, Chris Barrett, Bozhidar Batsov, Arthur Evstifeev.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].