67 lines
2.3 KiB
EmacsLisp
67 lines
2.3 KiB
EmacsLisp
|
;;; base-ctags.el --- Configuracíón de TAGS -*- lexical-binding: t -*-
|
||
|
|
||
|
;; Author: kj <webmaster@outcontrol.net>
|
||
|
;; URL: https://git.kj2.me/kj/confi-emacs-actual
|
||
|
|
||
|
;;; Commentary:
|
||
|
|
||
|
;;; Code:
|
||
|
|
||
|
;; Ctags IDE on the True Editor
|
||
|
;; @see https://github.com/universal-ctags/citre#quick-start
|
||
|
|
||
|
(use-package citre
|
||
|
:defer t
|
||
|
:straight t
|
||
|
:diminish
|
||
|
:bind (("C-x c j" . citre-jump+)
|
||
|
("C-x c k" . citre-jump-back)
|
||
|
("C-x c p" . citre-peek)
|
||
|
("C-x c a" . citre-ace-peek)
|
||
|
("C-x c u" . citre-update-this-tags-file))
|
||
|
:init
|
||
|
(require 'citre-config)
|
||
|
(setq citre-auto-enable-citre-mode-modes '(prog-mode))
|
||
|
:config
|
||
|
(with-no-warnings
|
||
|
(with-eval-after-load 'projectile
|
||
|
(setq citre-project-root-function #'projectile-project-root))
|
||
|
|
||
|
;; Integrate with `lsp-mode' and `eglot'
|
||
|
(define-advice xref--create-fetcher (:around (fn &rest args) fallback)
|
||
|
(let ((fetcher (apply fn args))
|
||
|
(citre-fetcher
|
||
|
(let ((xref-backend-functions '(citre-xref-backend t)))
|
||
|
(ignore xref-backend-functions)
|
||
|
(apply fn args))))
|
||
|
(lambda ()
|
||
|
(or (with-demoted-errors "%s, fallback to citre"
|
||
|
(funcall fetcher))
|
||
|
(funcall citre-fetcher)))))
|
||
|
|
||
|
(defun lsp-citre-capf-function ()
|
||
|
"A capf backend that tries lsp first, then Citre."
|
||
|
(let ((lsp-result (pcase centaur-lsp
|
||
|
('lsp-mode
|
||
|
(and (fboundp #'lsp-completion-at-point)
|
||
|
(lsp-completion-at-point)))
|
||
|
('eglot
|
||
|
(and (fboundp #'eglot-completion-at-point)
|
||
|
(eglot-completion-at-point))))))
|
||
|
(if (and lsp-result
|
||
|
(try-completion
|
||
|
(buffer-substring (nth 0 lsp-result)
|
||
|
(nth 1 lsp-result))
|
||
|
(nth 2 lsp-result)))
|
||
|
lsp-result
|
||
|
(citre-completion-at-point))))
|
||
|
|
||
|
(defun enable-lsp-citre-capf-backend ()
|
||
|
"Enable the lsp + Citre capf backend in current buffer."
|
||
|
(add-hook 'completion-at-point-functions #'lsp-citre-capf-function nil t))
|
||
|
|
||
|
(add-hook 'citre-mode-hook #'enable-lsp-citre-capf-backend)))
|
||
|
|
||
|
(provide 'base-ctags)
|
||
|
;;; base-ctags.el ends here
|