Documentation
Commentary
f90-ts-mode is a major mode for editing Fortran 90/2003 (and newer) source
files, based on Emacs's built-in tree-sitter support (requires Emacs 30+)
Recently changed, added or improved:
[06-2026] Defcustom group f90-ts-comment added.
[06-2026] Indentation of lines after a structure beginning line with
statement label fixed.
[06-2026] Indentation within and after preprocessor blocks fixed.
[06-2026] Trailing blank part "\\(\\s-+\\|$\\)" in defcustom regexps
`f90-ts-comment-prefix-regexp' and `f90-ts-openmp-prefix-regexp'
removed from the defcustom definitions and added as
`f90-ts-comment-prefix-separator-regexp'. If the regexp
variables have been customized, please adjust.
Features:
- Almost all statements up to F2023
- Syntax highlighting
- Indentation of lines, regions, multiline statements and structure blocks
- Alignment for multiline statements with rotation and other options
- Smart end completion
- Configurable leading ampersand and statement label positions
- Breaking and joining continued lines
- (Un)commenting regions with configurable prefixes and indentation rules
- Special comments like doc strings and separators
(syntax highlighting and indentation options)
- Keyword highlighting in comments (like TODO, Remark etc.)
- OpenMP and preprocessor directives
- Coarray keywords and statements
- Region selection based on tree-sitter nodes
- Imenu and a Fortran menu in the menu bar
- Navigation (defun, things, Xref, side panel tree)
Features can be found by the fortran menu or a transient popup bound
to the key C-c C-f.
Installation requires the tree-sitter Fortran grammar, which can be found at
https://github.com/stadelmanma/tree-sitter-fortran
Basic setup with use-package:
(use-package f90-ts-mode
:mode ("\\.f90\\'" . f90-ts-mode))
See the README and MANUAL at https://github.com/mscfd/emacs-f90-ts-mode
for full documentation on options, keybindings, etc.
Bugs and features:
https://github.com/mscfd/emacs-f90-ts-mode/issues
Note: Emacs must be linked against tree-sitter 0.25.x at runtime.
Emacs does not yet support 0.26, though support is in development and this
restriction may soon be obsolete.
Moreover the grammar should also be compiled against tree-sitter 0.25.x,
though it seems that grammar files generated by 0.26 work as well.
The pregenerated grammar files in the master branch of
https://github.com/mscfd/tree-sitter-fortran are built against 0.25.10
and ready to use, if there are problems with the official repository.
For details see MANUAL at https://github.com/mscfd/emacs-f90-ts-mode
Consumers
Reverse Dependencies
No reverse dependencies recorded.