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+) 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 - Xref (buffer local) - Imenu and a Fortran menu in the menu bar - Navigation (defun, things, Xref, tree as submenu and as side panel buffer) 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 Questions and discussions: https://fortran-lang.discourse.group/t/tree-sitter-based-f90-mode-for-emacs/10746 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. To verify the setup: M-: (treesit-library-abi-version) ; should return 15 M-: (treesit-language-abi-version 'fortran) ; should return 15 in linux: ldd "emacs" | grep libtree-sitter ; should show libtree-sitter.so.0.25 in macos: otool -L "emacs" | grep tree-sitter ; expecting something like: .../tree-sitter/lib/libtree-sitter.0.dylib (compatibility version 0.0.0, current version 0.25.0) in windows: unknown how to check