Skip to content

Emacs

The official LUMOS major mode for Emacs provides syntax highlighting and LSP integration via lsp-mode.

(use-package lumos-mode
:ensure t
:hook (lumos-mode . lsp-deferred))
(use-package lumos-mode
:straight (lumos-mode :type git :host github :repo "getlumos/lumos-mode")
:hook (lumos-mode . lsp-deferred))
Terminal window
# Clone the repository
git clone https://github.com/getlumos/lumos-mode ~/.emacs.d/lumos-mode
# Add to load-path
(add-to-list 'load-path "~/.emacs.d/lumos-mode")
(require 'lumos-mode)

  • Emacs 26.1+ (required)
  • lsp-mode - For LSP features
  • lumos-lsp - LSP server
    Terminal window
    cargo install lumos-lsp

  • Keywords: struct, enum, type, mod, use, pub
  • Types: Primitives, Solana types, user-defined
  • Attributes: #[solana], #[account], #[deprecated]
  • Comments: Line (//) and block (/* */)

Automatic indentation with configurable offset (default: 4 spaces).

Via lsp-mode:

  • Real-time diagnostics
  • Auto-completion
  • Hover documentation
  • Go to definition
  • Find references

(use-package lumos-mode
:ensure t
:mode "\\.lumos\\'"
:hook (lumos-mode . lsp-deferred)
:custom
(lumos-indent-offset 4))
(use-package lsp-mode
:config
(add-to-list 'lsp-language-id-configuration '(lumos-mode . "lumos"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection "lumos-lsp")
:activation-fn (lsp-activate-on "lumos")
:server-id 'lumos-lsp)))

Default keybindings (with lsp-mode):

KeyAction
M-.Go to definition
M-,Go back
M-?Find references
C-c C-rRename symbol
C-c C-aCode action

;; Indentation offset
(setq lumos-indent-offset 2)
;; LSP server command
(setq lumos-lsp-server-command "lumos-lsp")

  1. Verify lumos-lsp is installed:

    Terminal window
    lumos-lsp --version
  2. Check LSP logs:

    M-x lsp-workspace-show-log

Ensure file association:

(add-to-list 'auto-mode-alist '("\\.lumos\\'" . lumos-mode))