mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-24 16:30:58 -05:00
GNAT Project modes (`gpr-mode` and `gpr-ts-mode`) exist to handle .gpr files. These modes are now used instead of the Ada major mode. Lines may need to be re-indented when RET is pressed. This is to handle cases of incomplete syntax and ambiguity in what may be entered when an empty line is initially indented. Re-indenting after text has been entered corrects incorrectly guessed initial indentation. To accommodate this scenario, RET is remapped to `reindent-then-newline-and-indent`. Also updates documentation to reflect these changes.
72 lines
2.2 KiB
EmacsLisp
72 lines
2.2 KiB
EmacsLisp
;;; lang/ada/config.el -*- lexical-binding: t; -*-
|
|
|
|
;;
|
|
;;; Packages
|
|
|
|
(defun +ada-common-config (mode)
|
|
(when (modulep! +lsp)
|
|
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append))
|
|
|
|
(map! :map ,(intern (format "%s-map" mode))
|
|
[remap newline] #'reindent-then-newline-and-indent ; Non-Evil
|
|
:i "RET" #'reindent-then-newline-and-indent ; Evil
|
|
:localleader
|
|
:desc "Build Alire Project" "b" #'+ada/alr-build
|
|
:desc "Run Alire Project" "r" #'+ada/alr-run
|
|
:desc "Clean Alire Project" "c" #'+ada/alr-clean))
|
|
|
|
|
|
(defun +gpr-common-config (mode)
|
|
(when (modulep! +lsp)
|
|
(add-hook (intern (format "%s-local-vars-hook" mode)) #'lsp! 'append))
|
|
|
|
(map! :map ,(intern (format "%s-map" mode))
|
|
[remap newline] #'reindent-then-newline-and-indent ; Non-Evil
|
|
:i "RET" #'reindent-then-newline-and-indent)) ; Evil
|
|
|
|
|
|
(use-package! ada-mode
|
|
:defer t
|
|
:config
|
|
(+ada-common-config 'ada-mode))
|
|
|
|
|
|
(use-package! ada-ts-mode
|
|
:when (modulep! +tree-sitter)
|
|
:defer t
|
|
:init
|
|
(set-tree-sitter! 'ada-mode 'ada-ts-mode
|
|
'((ada :url "https://github.com/briot/tree-sitter-ada")))
|
|
:config
|
|
(+ada-common-config 'ada-ts-mode)
|
|
|
|
(setq ada-ts-mode-grammar-install nil) ; redundant w/ `treesit-auto-install-grammar'
|
|
|
|
;; HACK: `ada-ts-mode' sets buffer-local values for
|
|
;; `treesit-language-source-alist' and `eglot-server-program' during major
|
|
;; mode activation. This is poor ettiquite, overshadowing any user changes
|
|
;; to the global values of these variables. Not to mention, it's redundant
|
|
;; with ~set-tree-sitter!~ and ~eglot~ already handling support for
|
|
;; ada-ts-mode.
|
|
;; REVIEW: Undo buffer-local changes to these variables upstream.
|
|
(defadvice! +ada--suppress-side-effects-a (&rest _)
|
|
:after #'ada-ts-mode
|
|
(kill-local-variable 'treesit-language-source-alist)
|
|
(kill-local-variable 'eglot-server-programs)))
|
|
|
|
|
|
(use-package! gpr-mode
|
|
:defer t
|
|
:config
|
|
(+gpr-common-config 'gpr-mode))
|
|
|
|
|
|
(use-package! gpr-ts-mode
|
|
:when (modulep! +tree-sitter)
|
|
:defer t
|
|
:init
|
|
(set-tree-sitter! 'gpr-mode 'gpr-ts-mode
|
|
'((gpr :url "https://github.com/brownts/tree-sitter-gpr")))
|
|
:config
|
|
(+gpr-common-config 'gpr-ts-mode))
|