|
| 1 | +;;; me-tags.el --- Non-LSP source code tagging tools -*- lexical-binding: t; -*- |
| 2 | + |
| 3 | +;; Copyright (C) 2022-2024 Abdelhak Bougouffa |
| 4 | + |
| 5 | +;; Author: Abdelhak Bougouffa (rot13 "nobhtbhssn@srqbencebwrpg.bet") |
| 6 | + |
| 7 | +;;; Commentary: |
| 8 | + |
| 9 | +;;; Code: |
| 10 | + |
| 11 | + |
| 12 | +(use-package citre |
| 13 | + :straight t |
| 14 | + :after minemacs-first-c/c++-file |
| 15 | + :demand t |
| 16 | + :custom |
| 17 | + ;; Better (!) project root detection function |
| 18 | + (citre-project-root-function #'+citre-recursive-project-root) |
| 19 | + :init |
| 20 | + (defcustom +citre-recursive-root-project-detection-files '(".tags/" ".repo/" ".citre_root") |
| 21 | + "A list of files/directories to use as a project root markers." |
| 22 | + :type '(repeat string) |
| 23 | + :group 'minemacs-prog) |
| 24 | + |
| 25 | + (defcustom +citre-gtags-recursive-files-list t |
| 26 | + "Find files to index recursively." |
| 27 | + :type 'boolean |
| 28 | + :group 'minemacs-prog) |
| 29 | + |
| 30 | + (defcustom +citre-gtags-files-list-suffixes '("*.[chly]" "*.[ch]xx" "*.[ch]pp" "*.[ch]++" "*.cc" "*.hh") |
| 31 | + "List of filename suffixes globs to index (for extensions for example)." |
| 32 | + :type '(repeat string) |
| 33 | + :group 'minemacs-prog) |
| 34 | + |
| 35 | + (defcustom +citre-gtags-files-list-ignored-directories '("CVS" "RCS" "SCCS" ".git" ".hg" ".bzr" ".cdv" ".pc" ".svn" ".repo" "_MTN" "_darcs" "_sgbak" "debian") |
| 36 | + "List of directories to be ignored when creating the file list using `+citre-gtags-find-files-command'." |
| 37 | + :type '(repeat string) |
| 38 | + :group 'minemacs-prog) |
| 39 | + :config |
| 40 | + (defun +citre-recursive-project-root () |
| 41 | + "Search recursively until we find one of `+citre-recursive-root-project-detection-files'. |
| 42 | +Fall back to the default `citre--project-root'." |
| 43 | + (or (+directory-root-containing-file +citre-recursive-root-project-detection-files) |
| 44 | + (citre--project-root))) ; Fall back to the default detection! |
| 45 | + |
| 46 | + (defun +citre-gtags-find-files-command (&optional dir) |
| 47 | + (let* ((default-directory (or dir default-directory))) |
| 48 | + (concat |
| 49 | + "echo 'Creating list of files to index ...'\n" |
| 50 | + (find-cmd |
| 51 | + (unless +citre-gtags-recursive-files-list '(maxdepth "1")) |
| 52 | + `(prune (and (type "d") (name ,@+citre-gtags-files-list-ignored-directories))) |
| 53 | + `(iname ,@+citre-gtags-files-list-suffixes) |
| 54 | + '(type "f" "l") |
| 55 | + '(print)) |
| 56 | + " > gtags.files\n" |
| 57 | + "echo 'Creating list of files to index ... done'\n"))) |
| 58 | + |
| 59 | + (defun +citre-gtags-create-list-of-files-to-index (top-directory) |
| 60 | + "Create a list of files to index in TOP-DIRECTORY." |
| 61 | + (interactive "DCreate file list in directory: ") |
| 62 | + (let* ((default-directory top-directory)) |
| 63 | + (start-process-shell-command "+citre-gtags-files-list" "*+citre-gtags-files-list*" (+citre-gtags-find-files-command))))) |
| 64 | + |
| 65 | +(use-package citre-config |
| 66 | + :straight citre |
| 67 | + :after citre |
| 68 | + :demand t) |
| 69 | + |
| 70 | +(use-package xcscope |
| 71 | + :straight t |
| 72 | + :unless os/win |
| 73 | + :commands cscope-create-list-of-files-to-index cscope-index-files) |
| 74 | + |
| 75 | +(use-package clink |
| 76 | + :straight (:host github :repo "abougouffa/clink.el") |
| 77 | + :when (+emacs-features-p 'sqlite3) |
| 78 | + :hook (minemacs-first-c/c++-file . global-clink-mode)) |
| 79 | + |
| 80 | +(use-package rtags |
| 81 | + :straight t) |
| 82 | + |
| 83 | +(use-package rtags-xref |
| 84 | + :straight t |
| 85 | + :commands rtags-xref-enable) |
| 86 | + |
| 87 | +(use-package rscope |
| 88 | + :straight (:host github :repo "rjarzmik/rscope") |
| 89 | + :commands rscope-init rscope-regenerate-database) |
| 90 | + |
| 91 | +(use-package eopengrok |
| 92 | + :straight t |
| 93 | + :commands |
| 94 | + eopengrok-mode eopengrok-find-reference eopengrok-find-text eopengrok-find-definition eopengrok-find-custom |
| 95 | + eopengrok-jump-to-source eopengrok-create-index eopengrok-create-index-with-enable-projects |
| 96 | + :config |
| 97 | + (+nmap! :keymaps 'eopengrok-mode-map |
| 98 | + "n" #'eopengrok-next-line |
| 99 | + "p" #'eopengrok-previous-line |
| 100 | + "q" #'eopengrok-quit |
| 101 | + "RET" #'eopengrok-jump-to-source)) |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +(provide 'me-tags) |
| 106 | + |
| 107 | +;;; me-tags.el ends here |
0 commit comments