The installation instructions currently state:
In your Emacs initialization file, add the path to your local Lean4-Mode repository to the load-path list:
(add-to-list 'load-path "~/path/to/lean4-mode")
Lean4-Mode should now already be enabled when you open a file with .lean extension.
However, following these instructions alone does not result in .lean files being opened with lean4-mode. With only the load-path added, .lean files open in fundamental-mode.
To achieve the expected behavior, it is necessary to explicitly associate the file extension and autoload the mode:
(autoload 'lean4-mode "lean4-mode" "Major mode for Lean 4." t)
(add-to-list 'auto-mode-alist '("\\.lean\\'" . lean4-mode))
The README does include the following statement:
...But you can optionally also already load Lean4-Mode on Emacs startup, e.g. in order to customize variables:
(require 'lean4-mode)
However, this is described as optional and does not imply that it is required for automatic mode activation.