doomemacs/modules/lang/fortran/config.el
Colin Woodbury f3ddf235b5
module: add :lang fortran
* feat(fortran): account for f90 and fortran modes

* feat(fortran): initial keybindings

* feat(fortran): basic compilation

* feat(fortran): compilation popup

This customizes the name of the compilation buffer produced by the
`compile` function. We're keeping things simple; Emacs already knows how
to run compilation commands in a popup and parse the results, so let's
let it do its thing.

* feat(fortran): doctor checks

* docs(fortran): installation instructions

* feat(fortran): actual usage of fpm

* feat(fortran): configure compilation popups

* feat(fortran): improved raw gfortran usage

Although it's recommended to do everything through `fpm` to make life
easier.

* docs(fortran): backburner `+intel` for now

* feat(fortran): address PR suggestions
2021-12-15 15:16:22 +01:00

57 lines
2.1 KiB
EmacsLisp

;;; lang/fortran/config.el -*- lexical-binding: t; -*-
;;
;;; Packages
(use-package! f90
:defer t
:config
;; --- Compilation --- ;;
;; Used by `compile' (SPC c c)
(setq-hook! 'f90-mode-hook
compile-command "gfortran "
compilation-buffer-name-function #'+fortran/compilation-buffer-name)
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
;; --- LSP Configuration --- ;;
(when (featurep! +lsp)
(setq lsp-clients-fortls-args '("--enable_code_actions" "--hover_signature"))
(add-hook 'f90-mode-local-vars-hook #'lsp!))
;; --- Keybindings --- ;;
(map! :map f90-mode-map
:localleader
(:prefix ("f" . "fpm")
:desc "fpm build" "b" #'+fortran/fpm-build
:desc "fpm run" "r" #'+fortran/fpm-run
:desc "fpm test" "t" #'+fortran/fpm-test)
:desc "compile (gfortran)" "c" #'+fortran/gfortran-compile
:desc "run (gfortran)" "r" #'+fortran/gfortran-run))
(use-package! fortran
;; The `.for' extension is automatically recognized by Emacs and invokes
;; `fortran-mode', but not its capital variant `.FOR'. Many old files are
;; named the latter way, so we account for that manually here.
:mode ("\\.FOR$" . fortran-mode)
:config
;; Or else Flycheck will get very mad.
(setq flycheck-gfortran-language-standard "legacy")
;; --- Compilation --- ;;
;; Used by `compile' (SPC c c)
(setq-hook! 'fortran-mode-hook ; TODO These work for f90 but not for fortran.
compile-command "gfortran -std=legacy "
compilation-buffer-name-function #'+fortran/compilation-buffer-name)
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
;; --- LSP --- ;;
;; Strangely, the built-in flycheck support seems to give better hints than the LSP.
;; (when (featurep! +lsp)
;; (setq lsp-clients-fortls-args '("--enable_code_actions" "--hover_signature"))
;; (add-hook 'fortran-mode-local-vars-hook #'lsp!)))
;; --- Keybindings --- ;;
(map! :map fortran-mode-map
:localleader
:desc "compile (gfortran)" "c" #'+fortran/gfortran-compile
:desc "run (gfortran)" "r" #'+fortran/gfortran-run))