diff options
| author | Daniel <[email protected]> | 2024-11-15 09:25:04 -0500 |
|---|---|---|
| committer | Daniel <[email protected]> | 2024-11-15 09:25:04 -0500 |
| commit | 51bd4342d70c96f150703fff8e280d59709154ed (patch) | |
| tree | 6d3bb75565430353cc96ef9d8537fb7e6a77e769 /bard-emacs-modules | |
| parent | 7d199223d7496900092ebcfc44b733f99ff017ff (diff) | |
cpp completion just works somehow
Diffstat (limited to 'bard-emacs-modules')
| -rw-r--r-- | bard-emacs-modules/bard-emacs-completion.el | 19 | ||||
| -rw-r--r-- | bard-emacs-modules/bard-emacs-prog.el | 31 |
2 files changed, 44 insertions, 6 deletions
diff --git a/bard-emacs-modules/bard-emacs-completion.el b/bard-emacs-modules/bard-emacs-completion.el index 23177d5..9fa6c21 100644 --- a/bard-emacs-modules/bard-emacs-completion.el +++ b/bard-emacs-modules/bard-emacs-completion.el @@ -71,6 +71,23 @@ (corfu-history-mode 1) (add-to-list 'savehist-additional-variables 'corfu-history))) +(use-package cape + :ensure t + :init + (add-to-list 'completion-at-point-functions #'cape-file) + (add-to-list 'completion-at-point-functions #'cape-dabbrev) + (add-to-list 'completion-at-point-functions #'cape-keyword) + (add-to-list 'completion-at-point-functions #'cape-abbrev)) + +(use-package clang-capf + :ensure t + :config + (defun bard/clang-capf-init () + "Add `clang-capf' to `completion-at-point-functions'." + (add-hook 'completion-at-point-functions #'clang-capf nil t)) + + (add-hook 'c-mode-hook #'bard/clang-capf-init)) + (use-package minibuffer :config ;;;; Completion styles @@ -151,7 +168,7 @@ ;; minimal indicator. It shows cycling, which I never want to see ;; or do. (setq embark-mixed-indicator-both nil) - (setq embark-mixed-indicator-delay 1.0) + (setq embark-mixed-indicator-delay 0.1) (setq embark-indicators '(embark-mixed-indicator embark-highlight-indicator)) (setq embark-verbose-indicator-nested nil) ; I think I don't have them, but I do not want them either (setq embark-verbose-indicator-buffer-sections '(bindings)) diff --git a/bard-emacs-modules/bard-emacs-prog.el b/bard-emacs-modules/bard-emacs-prog.el index d239c06..da3af8d 100644 --- a/bard-emacs-modules/bard-emacs-prog.el +++ b/bard-emacs-modules/bard-emacs-prog.el @@ -6,7 +6,10 @@ ;; CPP Mode (use-package emacs :config - (setq-default c-basic-offset 4)) + (setq-default c-basic-offset 4) + (setq c-default-style '((c-mode . "gnu") + (java-mode . "java") + (awk-mode . "awk")))) ;; Haskell @@ -35,9 +38,25 @@ ;; parens packages (use-package c++-mode + :ensure nil :bind (:map c++-mode-map - ("C-c C-c" . project-compile))) + ("C-c C-c" . project-compile)) + :config + (defun bard/c++-completion-or-indent () + "Complete if point is at a symbol; otherwise, indent." + (interactive) + (if (or (completion-at-point) (looking-at "\\_>")) + (completion-at-point) + (c-indent-line-or-region))) + + (defun bard/setup-c++-mode () + "Configure completion behavior for `c++-mode'." + (local-set-key (kbd "<tab>") 'bard/c++-completion-or-indent)) + + (add-hook 'c++-mode-hook #'bard/setup-c++-mode) + (add-hook 'c-mode-hook #'bard/setup-c++-mode) + ) (use-package flycheck :ensure t @@ -48,9 +67,11 @@ :ensure t :config (add-hook 'c-mode-common-hook - (lambda () - (when (derived-mode-p 'c-mode 'c++-mode 'java-mode) - (ggtags-mode 1))))) + (lambda () + (when (derived-mode-p 'c-mode 'c++-mode 'java-mode) + (ggtags-mode 1) + (setq-local imenu-create-index-function #'ggtags-build-imenu-index))) + )) (use-package compile :ensure nil |
