Enables projectile switching between C/C++ files
This commit is contained in:
153
.emacs
153
.emacs
@@ -5,49 +5,49 @@
|
|||||||
|
|
||||||
|
|
||||||
(custom-set-variables
|
(custom-set-variables
|
||||||
;; custom-set-variables was added by Custom.
|
;; custom-set-variables was added by Custom.
|
||||||
;; If you edit it by hand, you could mess it up, so be careful.
|
;; If you edit it by hand, you could mess it up, so be careful.
|
||||||
;; Your init file should contain only one such instance.
|
;; Your init file should contain only one such instance.
|
||||||
;; If there is more than one, they won't work right.
|
;; If there is more than one, they won't work right.
|
||||||
'(c-basic-offset 4)
|
'(c-basic-offset 4)
|
||||||
'(compilation-scroll-output 'first-error)
|
'(compilation-scroll-output 'first-error)
|
||||||
'(custom-safe-themes
|
'(custom-safe-themes
|
||||||
'("162201cf5b5899938cfaec99c8cb35a2f1bf0775fc9ccbf5e63130a1ea217213" "e3daa8f18440301f3e54f2093fe15f4fe951986a8628e98dcd781efbec7a46f2" "6622bb651e72d8ebd66454bd86db6c3990324243ff4325c1b6df252aba63b13e" "2f8eadc12bf60b581674a41ddc319a40ed373dd4a7c577933acaff15d2bf7cc6" "f458b92de1f6cf0bdda6bce23433877e94816c3364b821eb4ea9852112f5d7dc" "016f665c0dd5f76f8404124482a0b13a573d17e92ff4eb36a66b409f4d1da410" "13096a9a6e75c7330c1bc500f30a8f4407bd618431c94aeab55c9855731a95e1" "8b148cf8154d34917dfc794b5d0fe65f21e9155977a36a5985f89c09a9669aa0" "bf948e3f55a8cd1f420373410911d0a50be5a04a8886cabe8d8e471ad8fdba8e" "680f62b751481cc5b5b44aeab824e5683cf13792c006aeba1c25ce2d89826426" "631c52620e2953e744f2b56d102eae503017047fb43d65ce028e88ef5846ea3b" default))
|
'("162201cf5b5899938cfaec99c8cb35a2f1bf0775fc9ccbf5e63130a1ea217213" "e3daa8f18440301f3e54f2093fe15f4fe951986a8628e98dcd781efbec7a46f2" "6622bb651e72d8ebd66454bd86db6c3990324243ff4325c1b6df252aba63b13e" "2f8eadc12bf60b581674a41ddc319a40ed373dd4a7c577933acaff15d2bf7cc6" "f458b92de1f6cf0bdda6bce23433877e94816c3364b821eb4ea9852112f5d7dc" "016f665c0dd5f76f8404124482a0b13a573d17e92ff4eb36a66b409f4d1da410" "13096a9a6e75c7330c1bc500f30a8f4407bd618431c94aeab55c9855731a95e1" "8b148cf8154d34917dfc794b5d0fe65f21e9155977a36a5985f89c09a9669aa0" "bf948e3f55a8cd1f420373410911d0a50be5a04a8886cabe8d8e471ad8fdba8e" "680f62b751481cc5b5b44aeab824e5683cf13792c006aeba1c25ce2d89826426" "631c52620e2953e744f2b56d102eae503017047fb43d65ce028e88ef5846ea3b" default))
|
||||||
'(display-time-24hr-format t)
|
'(display-time-24hr-format t)
|
||||||
'(display-time-default-load-average nil)
|
'(display-time-default-load-average nil)
|
||||||
'(doom-modeline-github t)
|
'(doom-modeline-github t)
|
||||||
'(doom-modeline-indent-info t)
|
'(doom-modeline-indent-info t)
|
||||||
'(doom-modeline-minor-modes t)
|
'(doom-modeline-minor-modes t)
|
||||||
'(doom-modeline-total-line-number t)
|
'(doom-modeline-total-line-number t)
|
||||||
'(fill-column 80)
|
'(fill-column 80)
|
||||||
'(global-auto-revert-mode t)
|
'(global-auto-revert-mode t)
|
||||||
'(global-display-line-numbers-mode t)
|
'(global-display-line-numbers-mode t)
|
||||||
'(global-subword-mode t)
|
'(global-subword-mode t)
|
||||||
'(gofmt-command "goimports")
|
'(gofmt-command "goimports")
|
||||||
'(inhibit-startup-screen t)
|
'(inhibit-startup-screen t)
|
||||||
'(lisp-body-indent 4)
|
'(lisp-body-indent 4)
|
||||||
'(lisp-indent-offset 4)
|
'(lisp-indent-offset 4)
|
||||||
'(lisp-lambda-list-keyword-alignment t)
|
'(lisp-lambda-list-keyword-alignment t)
|
||||||
'(lisp-lambda-list-keyword-parameter-alignment t)
|
'(lisp-lambda-list-keyword-parameter-alignment t)
|
||||||
'(lisp-lambda-list-keyword-parameter-indentation 4)
|
'(lisp-lambda-list-keyword-parameter-indentation 4)
|
||||||
'(lisp-loop-forms-indentation 4)
|
'(lisp-loop-forms-indentation 4)
|
||||||
'(lisp-loop-keyword-indentation 4)
|
'(lisp-loop-keyword-indentation 4)
|
||||||
'(lisp-simple-loop-indentation 4)
|
'(lisp-simple-loop-indentation 4)
|
||||||
'(lisp-tag-body-indentation 4)
|
'(lisp-tag-body-indentation 4)
|
||||||
'(lisp-tag-indentation 4)
|
'(lisp-tag-indentation 4)
|
||||||
'(org-agenda-files '("~/org/1.TODO.org"))
|
'(org-agenda-files '("~/org/1.TODO.org"))
|
||||||
'(package-enable-at-startup nil)
|
'(package-enable-at-startup nil)
|
||||||
'(package-selected-packages
|
'(package-selected-packages
|
||||||
'(clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package))
|
'(clang-format+ cmake-format xterm-color dockerfile-mode web-mode prettier json-mode py-isort blacken pyvenv yaml-mode lsp-pyright ng2-mode lsp-ltex lsp-treemacs treemacs-nerd-icons treemacs-projectile treemacs lsp-ui lsp-mode which-key flycheck vterm projectile yasnippet-snippets yasnippet aggressive-indent doom-themes company-go zenburn-theme langtool smart-tabs-mode typescript-mode protobuf-mode opencl-mode glsl-mode go-mode markdown-mode srefactor irony cmake-mode company magit use-package))
|
||||||
'(safe-local-variable-values
|
'(safe-local-variable-values
|
||||||
'((vc-follow-symlinks . t)
|
'((vc-follow-symlinks . t)
|
||||||
(TeX-master . t)
|
(TeX-master . t)
|
||||||
(TeX-parse-self . t)))
|
(TeX-parse-self . t)))
|
||||||
'(system-packages-noconfirm t)
|
'(system-packages-noconfirm t)
|
||||||
'(tab-width 4)
|
'(tab-width 4)
|
||||||
'(warning-suppress-log-types '((comp)))
|
'(warning-suppress-log-types '((comp)))
|
||||||
'(whitespace-style
|
'(whitespace-style
|
||||||
'(face trailing tabs lines-tail newline space-before-tab::tab space-before-tab::space space-before-tab tab-mark)))
|
'(face trailing tabs lines-tail newline space-before-tab::tab space-before-tab::space space-before-tab tab-mark)))
|
||||||
|
|
||||||
(if (display-graphic-p)
|
(if (display-graphic-p)
|
||||||
(if (fboundp 'tool-bar-mode)
|
(if (fboundp 'tool-bar-mode)
|
||||||
@@ -511,6 +511,73 @@
|
|||||||
:test "ng test --progress=false"
|
:test "ng test --progress=false"
|
||||||
:run "ng serve"
|
:run "ng serve"
|
||||||
:test-suffix ".spec")
|
:test-suffix ".spec")
|
||||||
|
(defun atu/cmake-cc-inference (dir)
|
||||||
|
"Detects if the current root is a CMake C/C++ project"
|
||||||
|
(let ((cmakelists-file (projectile-expand-root "CMakeLists.txt" dir)))
|
||||||
|
(if (file-exists-p cmakelists-file)
|
||||||
|
(with-temp-buffer
|
||||||
|
(insert-file-contents cmakelists-file)
|
||||||
|
(goto-char (point-min))
|
||||||
|
(re-search-forward "project[[:space:]]*([^)]+\\([[:space:]]C\\(XX\\)?[[:space:]]\\)[^)]+)" nil t)
|
||||||
|
)))
|
||||||
|
)
|
||||||
|
|
||||||
|
(defun atu/cc-related-files (path)
|
||||||
|
"Returns related files path for a C/C++ file for a given path"
|
||||||
|
(let* (
|
||||||
|
(ext (file-name-extension path))
|
||||||
|
(basename (file-name-base path))
|
||||||
|
(dirpath (file-name-directory path))
|
||||||
|
(impl-rx "\\([.-]?[Ii]mp[l]?\\)$")
|
||||||
|
)
|
||||||
|
(if (member ext '("h" "hh" "hpp"))
|
||||||
|
(if (string-match impl-rx basename)
|
||||||
|
(list :other (concat dirpath
|
||||||
|
(string-replace
|
||||||
|
(match-string 1 basename)
|
||||||
|
""
|
||||||
|
basename)
|
||||||
|
"."
|
||||||
|
ext))
|
||||||
|
(list :other
|
||||||
|
(mapcar (lambda (sfx) (concat dirpath basename sfx))
|
||||||
|
(list
|
||||||
|
(concat "Imp." ext)
|
||||||
|
(concat "Impl." ext)
|
||||||
|
(concat "imp." ext)
|
||||||
|
(concat "impl." ext)
|
||||||
|
(concat ".Imp." ext)
|
||||||
|
(concat ".Impl." ext)
|
||||||
|
(concat ".imp." ext)
|
||||||
|
(concat ".impl." ext)
|
||||||
|
(concat "-Imp." ext)
|
||||||
|
(concat "-Impl." ext)
|
||||||
|
(concat "-imp." ext)
|
||||||
|
(concat "-impl." ext)
|
||||||
|
".cpp"
|
||||||
|
)))
|
||||||
|
)
|
||||||
|
(when (member ext '("c" "cc" "cpp"))
|
||||||
|
(list :other
|
||||||
|
(mapcar (lambda (sfx) (concat dirpath basename sfx))
|
||||||
|
'( ".h" ".hh" ".hpp" )))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
(projectile-register-project-type 'cmake-cc #'atu/cmake-cc-inference
|
||||||
|
:project-file "CMakeLists.txt"
|
||||||
|
:configure "cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=On"
|
||||||
|
:compile "cmake --build build"
|
||||||
|
:test "cmake --build build --target check"
|
||||||
|
:related-files-fn
|
||||||
|
(list
|
||||||
|
#'atu/cc-related-files
|
||||||
|
(projectile-related-files-fn-test-with-suffix "cpp" "Test")
|
||||||
|
(projectile-related-files-fn-test-with-suffix "cpp" "UTest")
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
(use-package vterm)
|
(use-package vterm)
|
||||||
|
|||||||
Reference in New Issue
Block a user