Home

Awesome

move-mode

MELPA Stable

move-mode is an Emacs major-mode for editing smart contracts written in the Move programming language. Supports Emacs 25.1 and above (tested on Emacs for Mac OS X 25.1-1, Emacs Mac Port 28.1).

There are multiple flavors of Move (Core Move, Sui Move, etc). This mode aims to be agnostic to the flavor of Move you are writing in by offering customizations to tweak the experience.

This mode does not provide auto-complete, goto definition, or other language-server-based features out of the box, but check the LSP section for details on how to enable them using Move Analyzer.

Known Issues

Installation

Recommended: straight.el and use-package

The recommended approach is to install this package using use-package and straight.el by including the following to your init.el:

(use-package move-mode :straight t)

Just straight.el:

You can also use straight.el directly:

(straight-use-package 'move-mode)

MELPA

Or install it from MELPA with package-install, using:

M-x package-refresh-contents RET
M-x package-install RET move-mode RET

(Not Recommended) Manual Install

Or install the package completely manually, by cloning the repo and adding the following:

(add-to-list 'load-path "/path/to/move-move/repo")
(autoload 'move-mode "move-mode" nil t)
(add-to-list 'auto-mode-alist '("\\.move\\'" . move-mode))

Features

Customization

(customize-set-variable 'move-builtins
  (concat core-move-builtin-functions
          move-prover-keywords))

LSP

move-mode does not configure an LSP server for Move by default, but it is possible to integrate Move Analyzer with Emacs.

The analyzer is installed directly from its repo, via cargo:

# Move on Sui
$ cargo install --git https://github.com/MystenLabs/sui.git move-analyzer

# Generic Move Analyzer
$ cargo install --git https://github.com/move-language/move move-analyzer

The generic Move Analyzer can be modified using --feature flags passed to the install command above. The the most common one is --features "address32" option for Move flavors requiring 32-byte long addresses (e.g. Aptos Move).

A full list of supported features can be found in the [features] section of its Cargo.toml.

[!NOTE] Move Analyzer for Sui does not require feature flags.

Lsp-bridge

Once move-analyzer is installed, you can enjoy Move programming with pleasure. Lsp-bridge already provides Move language support, out of the box.

Eglot

Once move-analyzer is installed, integrating it into Eglot is as simple as adding the following configuration to your init.el:

(add-hook 'move-mode-hook #'eglot-ensure)
(add-to-list 'eglot-server-programs '(move-mode "move-analyzer"))

Eglot uses project.el (Emacs' built-in project management) to find the root of your project. It defaults to looking for the version control repository root. If you work with repositories where your Move packages are nested in sub-directories, add the following to allow Eglot to find projects by looking for Move.toml:

(defun my/move-lsp-project-root (dir)
  (and-let* (((boundp 'eglot-lsp-context))
             (eglot-lsp-context)
             (override (locate-dominating-file dir "Move.toml")))
    (cons 'Move.toml override)))

(add-hook 'project-find-functions #'my/move-lsp-project-root)
(cl-defmethod project-root ((project (head Move.toml)))
  (cdr project)))

[!NOTE] This will not affect finding project files outside of the LSP.

Lsp mode

Once move-analyzer is installed, tell lsp-mode how to find the executable:

(with-eval-after-load 'lsp-mode
  (add-to-list 'lsp-language-id-configuration '(move-mode . "move"))
  (lsp-register-client
   (make-lsp-client
    :new-connection (lsp-stdio-connection "move-analyzer")
    :activation-fn (lsp-activate-on "move")
    :priority -1
    :server-id 'move-analyzer))))

Contributing

Contributions are very welcome! If you notice a bug, try updating move-mode, and if it is still there please share a report as an issue, with:

If you are interested in working on features please take a look at current open issues for inspiration!