2021-12-15 06:16:22 -08:00
|
|
|
;;; lang/fortran/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
;;
|
|
|
|
;;; Packages
|
|
|
|
|
|
|
|
(use-package! f90
|
|
|
|
:defer t
|
|
|
|
:config
|
|
|
|
;; --- Compilation --- ;;
|
|
|
|
;; Used by `compile' (SPC c c)
|
2022-08-12 20:29:19 +02:00
|
|
|
(let ((cmd (cond ((modulep! +intel) "ifort ")
|
2022-04-02 16:30:37 -07:00
|
|
|
(t "gfortran "))))
|
|
|
|
(setq-hook! 'f90-mode-hook
|
|
|
|
compile-command cmd
|
|
|
|
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn))
|
2021-12-15 06:16:22 -08:00
|
|
|
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
|
|
|
|
|
|
|
|
;; --- LSP Configuration --- ;;
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +lsp)
|
2021-12-15 06:16:22 -08:00
|
|
|
(setq lsp-clients-fortls-args '("--enable_code_actions" "--hover_signature"))
|
2022-03-24 02:19:52 +01:00
|
|
|
(add-hook 'f90-mode-local-vars-hook #'lsp! 'append))
|
2021-12-15 06:16:22 -08:00
|
|
|
|
|
|
|
;; --- 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)
|
2022-03-19 08:02:36 -07:00
|
|
|
(:prefix ("g" . "gfortran")
|
|
|
|
:desc "compile" "c" #'+fortran/gfortran-compile
|
|
|
|
:desc "run" "r" #'+fortran/gfortran-run)
|
|
|
|
:desc "build" "b" #'+fortran/build
|
|
|
|
:desc "run" "r" #'+fortran/run)
|
2022-03-05 16:35:13 -08:00
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +intel)
|
2022-04-12 19:51:22 -07:00
|
|
|
(map! :map f90-mode-map
|
|
|
|
:localleader
|
|
|
|
(:prefix ("i" . "ifort")
|
|
|
|
:desc "compile" "c" #'+fortran/ifort-compile
|
|
|
|
:desc "run" "r" #'+fortran/ifort-run)))
|
|
|
|
|
2022-03-05 16:35:13 -08:00
|
|
|
(easy-menu-define f90-menu f90-mode-map "Simpler menu for F90 mode."
|
2022-03-06 12:05:12 -08:00
|
|
|
`("F90"
|
|
|
|
["Compile" +fortran/build :active t :help "Compile the Project"]
|
|
|
|
["Run" +fortran/run :active t :help "Run the Executable"]
|
|
|
|
["Test" +fortran/fpm-test :active (+fortran--fpm-toml) :help "Run the Unit Tests"])))
|
2021-12-15 06:16:22 -08:00
|
|
|
|
|
|
|
(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)
|
2022-08-12 20:29:19 +02:00
|
|
|
(let ((cmd (cond ((modulep! +intel) "ifort ")
|
2022-04-12 19:51:22 -07:00
|
|
|
(t "gfortran -std=legacy "))))
|
|
|
|
(setq-hook! 'fortran-mode-hook
|
|
|
|
compile-command cmd
|
|
|
|
compilation-buffer-name-function #'+fortran-compilation-buffer-name-fn))
|
2021-12-15 06:16:22 -08:00
|
|
|
(set-popup-rule! "^\\*fortran-compilation" :side 'right :size 0.5 :quit t)
|
|
|
|
|
|
|
|
;; --- Keybindings --- ;;
|
|
|
|
(map! :map fortran-mode-map
|
|
|
|
:localleader
|
2022-03-19 08:02:36 -07:00
|
|
|
(:prefix ("g" . "gfortran")
|
|
|
|
:desc "compile" "c" #'+fortran/gfortran-compile
|
|
|
|
:desc "run" "r" #'+fortran/gfortran-run))
|
2022-03-05 16:35:13 -08:00
|
|
|
|
2022-08-12 20:29:19 +02:00
|
|
|
(when (modulep! +intel)
|
2022-04-12 19:51:22 -07:00
|
|
|
(map! :map fortran-mode-map
|
|
|
|
:localleader
|
|
|
|
(:prefix ("i" . "ifort")
|
|
|
|
:desc "compile" "c" #'+fortran/ifort-compile
|
|
|
|
:desc "run" "r" #'+fortran/ifort-run)))
|
|
|
|
|
2022-03-05 16:35:13 -08:00
|
|
|
(easy-menu-define fortran-menu fortran-mode-map "Simpler menu for Fortran mode."
|
2022-03-19 08:02:36 -07:00
|
|
|
'("Fortran"
|
2022-04-12 19:51:22 -07:00
|
|
|
["Compile" +fortran/build :active t :help "Compile with Project"]
|
|
|
|
["Run" +fortran/run :active t :help "Run the Executable"])))
|