A bunch more changes
This commit is contained in:
196
init.el
196
init.el
@ -474,13 +474,34 @@ With NO-EDGE, return nil if beg or end fall on the edge of the range."
|
||||
(< beg (cdr sb))
|
||||
(/= end (car sb))
|
||||
(< end (cdr sb))))))
|
||||
;; if the error happens, we aren't in as string
|
||||
;; if the error happens, we aren't in a string
|
||||
(wrong-type-argument nil))))
|
||||
(defun my/-evil-cp-region-ok-p-no-string (oldfun beg end)
|
||||
(or (my/range-inside-thing-p 'string beg end t)
|
||||
(funcall oldfun beg end)))
|
||||
(or
|
||||
(my/range-inside-thing-p 'string beg end t)
|
||||
(funcall oldfun beg end)))
|
||||
(defun my/column-num-at-pos (pos)
|
||||
"Return the column number at POS."
|
||||
(save-excursion
|
||||
(goto-char pos)
|
||||
(current-column)))
|
||||
(defun my/-evil-cp-block-ok-p-no-string (oldfun beg end)
|
||||
(when (> beg end) (cl-rotatef beg end))
|
||||
(or
|
||||
(funcall oldfun beg end)
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(let ((start-off (current-column))
|
||||
(end-off (my/column-num-at-pos end)))
|
||||
(cl-block nil
|
||||
(dotimes (_ (count-lines beg end) t)
|
||||
(let ((bol (pos-bol)))
|
||||
(unless (sp-region-ok-p (+ bol start-off)
|
||||
(+ bol end-off))
|
||||
(cl-return))
|
||||
(forward-line))))))))
|
||||
(advice-add 'sp-region-ok-p :around 'my/-evil-cp-region-ok-p-no-string)
|
||||
(advice-add 'evil-cp--balanced-block-p :around 'my/-evil-cp-region-ok-p-no-string))
|
||||
(advice-add 'evil-cp--balanced-block-p :around 'my/-evil-cp-block-ok-p-no-string))
|
||||
|
||||
;; make lisp editing nicer
|
||||
(use-package aggressive-indent
|
||||
@ -826,61 +847,125 @@ to `posframe-show' if the display is graphical."
|
||||
|
||||
;; flymake
|
||||
(use-package flymake
|
||||
:bind (:map flymake-mode-map
|
||||
("C-c e" . my/flymake-show-diagnostic-at-point)
|
||||
("C-c C-e" . consult-flymake)
|
||||
("C-x c e" . consult-flymake))
|
||||
;; :hook (emacs-lisp-mode . flymake-mode)
|
||||
:init
|
||||
(defun my/flymake-show-diagnostic-at-point ()
|
||||
(interactive)
|
||||
(when flymake-mode
|
||||
(let* ((diag (get-char-property (point) 'flymake-diagnostic))
|
||||
(diag-msg (when diag
|
||||
(apply 'concat
|
||||
(mapcar
|
||||
(lambda (msg)
|
||||
(concat "•" msg "\n"))
|
||||
(split-string (flymake--diag-text diag)
|
||||
"\n")))))
|
||||
(jinx-msg (when (jinx--get-overlays (point) (1+ (point)))
|
||||
"•misspelled word\n")))
|
||||
(unless (and (zerop (length diag-msg))
|
||||
(zerop (length jinx-msg)))
|
||||
(my/floating-tooltip " *flymake-error-posframe*"
|
||||
(concat diag-msg jinx-msg)))))))
|
||||
:config
|
||||
(require 'consult-flymake))
|
||||
|
||||
;; flycheck
|
||||
(use-package flycheck
|
||||
:hook (emacs-lisp-mode . flycheck-mode)
|
||||
:bind (:map flycheck-mode-map
|
||||
("C-c e" . my/flycheck-show-diagnostic-at-point))
|
||||
:custom
|
||||
(flycheck-indication-mode 'left-margin)
|
||||
:init
|
||||
(setq flycheck-display-errors-function nil)
|
||||
(defun my/flycheck-show-diagnostic-at-point ()
|
||||
(interactive)
|
||||
(if-let ((flycheck-mode)
|
||||
(message
|
||||
(apply 'concat
|
||||
(nconc (mapcar
|
||||
(lambda (error)
|
||||
(concat "•" (flycheck-error-message error) "\n"))
|
||||
(flycheck-overlay-errors-at (point)))
|
||||
(when (jinx--get-overlays (point) (1+ (point)))
|
||||
'("•misspelled word\n")))))
|
||||
((not (zerop (length message)))))
|
||||
(my/floating-tooltip " *flycheck-error-posframe*"
|
||||
(substring message 0 (1- (length message)))))))
|
||||
(use-package consult-flycheck
|
||||
:defer nil
|
||||
:bind (:map flycheck-mode-map
|
||||
("C-c C-e" . consult-flycheck)
|
||||
("C-x c e" . consult-flycheck)
|
||||
:map emacs-lisp-mode-map
|
||||
("C-c C-e" . consult-flycheck)
|
||||
("C-x c e" . consult-flycheck)))
|
||||
(setq flycheck-display-errors-function nil))
|
||||
(use-package consult-flycheck)
|
||||
|
||||
(defun my/diagnostic-at-point ()
|
||||
"Show the diagnostics under point."
|
||||
(interactive)
|
||||
(let ((message))
|
||||
(when-let ((flymake-mode)
|
||||
(diag (get-char-property (point) 'flymake-diagnostic)))
|
||||
(cl-callf nconc message (string-split (flymake--diag-text diag) "\n" t)))
|
||||
(when flycheck-mode
|
||||
(cl-callf nconc message
|
||||
(mapcar 'flycheck-error-message (flycheck-overlay-errors-at (point)))))
|
||||
;; jinx
|
||||
(when-let ((jinx-msg (jinx--get-overlays (point) (1+ (point)))))
|
||||
(push "misspelled word" message))
|
||||
(when message
|
||||
(my/floating-tooltip " *my-diagnostic-posframe*"
|
||||
(mapconcat (lambda (msg)
|
||||
(concat "•" msg))
|
||||
message "\n")))))
|
||||
|
||||
(defconst my/consult-flymake-flycheck-narrow
|
||||
'((?e . "Error")
|
||||
(?w . "Warning")
|
||||
(?i . "Info")
|
||||
(?n . "Info")))
|
||||
|
||||
(defun my/-consult-replace-flymake-error-level (candidates)
|
||||
"Return CANDIDATES with the flymake error level note replaced with info."
|
||||
(cl-loop for cand in candidates
|
||||
collect
|
||||
(cl-loop
|
||||
with start = nil
|
||||
for i below (length cand)
|
||||
for props = (text-properties-at i cand)
|
||||
for face = (plist-get props 'face)
|
||||
when (eq face 'compilation-info) do
|
||||
(setq start (or start i))
|
||||
else when start do
|
||||
(setf (substring cand start i)
|
||||
(propertize (string-pad "info" (- i start))
|
||||
'face (flycheck-error-level-error-list-face
|
||||
'info)))
|
||||
(cl-return cand)
|
||||
finally return cand)))
|
||||
|
||||
(defun my/consult-flymake-flycheck-candidates (&optional project)
|
||||
"Return combined candidate list for flymake and flycheck.
|
||||
With PROJECT, return the candiadeets for that project."
|
||||
(let ((had-errors))
|
||||
(prog1
|
||||
(seq-uniq
|
||||
(append
|
||||
(when-let (((bound-and-true-p flymake-mode))
|
||||
(diags (if project (flymake--project-diagnostics
|
||||
project)
|
||||
(flymake-diagnostics))))
|
||||
(setq had-errors t)
|
||||
(my/-consult-replace-flymake-error-level
|
||||
(consult-flymake--candidates diags)))
|
||||
(when (boundp 'flycheck-mode)
|
||||
(if project
|
||||
(cl-loop for buf in (project-buffers project)
|
||||
append
|
||||
(with-current-buffer buf
|
||||
(when (and flycheck-mode flycheck-current-errors)
|
||||
(setq had-errors t)
|
||||
(consult-flycheck--candidates))))
|
||||
(when (and flycheck-mode flycheck-current-errors)
|
||||
(setq had-errors t)
|
||||
(consult-flycheck--candidates))))))
|
||||
(unless had-errors
|
||||
(user-error "No errors (Flymake: %s | Flycheck: %s)"
|
||||
(cond
|
||||
((not (bound-and-true-p flymake-mode))
|
||||
"not running")
|
||||
((seq-difference (flymake-running-backends)
|
||||
(flymake-reporting-backends))
|
||||
"running")
|
||||
(t "finished"))
|
||||
(if (boundp 'flycheck-last-status-change)
|
||||
flycheck-last-status-change
|
||||
"not running"))))))
|
||||
|
||||
(defun my/consult-flymake-flycheck (&optional project)
|
||||
"Jump to flymake or flycheck error.
|
||||
With PROJECT, give diagnostics for all buffers in the current project."
|
||||
(interactive "P")
|
||||
(consult--read
|
||||
(consult--with-increased-gc
|
||||
(my/consult-flymake-flycheck-candidates
|
||||
(and project (project-current))))
|
||||
:prompt "Error: "
|
||||
:category 'flymake-flycheck-error
|
||||
:history t
|
||||
:require-match t
|
||||
:sort nil
|
||||
:narrow (consult--type-narrow my/consult-flymake-flycheck-narrow)
|
||||
:group (consult--type-group my/consult-flymake-flycheck-narrow)
|
||||
:lookup #'consult--lookup-candidate
|
||||
:state (consult--jump-state)))
|
||||
(with-eval-after-load 'flymake
|
||||
(define-key flymake-mode-map (kbd "C-c e") 'my/diagnostic-at-point)
|
||||
(define-key flymake-mode-map (kbd "C-c C-e") 'my/consult-flymake-flycheck))
|
||||
(with-eval-after-load 'flycheck
|
||||
(define-key flycheck-mode-map (kbd "C-c e") 'my/diagnostic-at-point)
|
||||
(define-key flycheck-mode-map (kbd "C-c C-e") 'my/consult-flymake-flycheck))
|
||||
(with-eval-after-load 'jinx
|
||||
(define-key jinx-mode-map (kbd "C-c e") 'my/diagnostic-at-point))
|
||||
|
||||
;; eldoc
|
||||
(use-package eldoc
|
||||
@ -948,6 +1033,9 @@ to `posframe-show' if the display is graphical."
|
||||
"--header-insertion=never" "--pch-storage=memory"
|
||||
"--function-arg-placeholders"))))
|
||||
|
||||
;; LTeX (languagetool)
|
||||
(require 'ltex-eglot)
|
||||
|
||||
;; gud
|
||||
(use-package gud
|
||||
:demand t
|
||||
@ -1226,7 +1314,8 @@ otherwise, call `bibtex-find-text'."
|
||||
:hook ((LaTeX-mode . turn-on-reftex)
|
||||
(LaTeX-mode . LaTeX-math-mode)
|
||||
(LaTeX-mode . my/-setup-LaTeX-mode)
|
||||
(LaTeX-mode . flycheck-mode))
|
||||
(LaTeX-mode . flycheck-mode)
|
||||
(LaTeX-mode . eglot-ensure))
|
||||
:bind (:map TeX-mode-map
|
||||
("C-c ?" . latex-help))
|
||||
:init
|
||||
@ -1237,6 +1326,7 @@ otherwise, call `bibtex-find-text'."
|
||||
(add-to-list 'major-mode-remap-alist '(texinfo-mode . Texinfo-mode))
|
||||
(add-to-list 'major-mode-remap-alist '(doctex-mode . docTeX-mode))
|
||||
(add-to-list 'auto-mode-alist '("/\\.latexmkrc\\'" . perl-mode))
|
||||
(add-to-list 'auto-mode-alist '("\\.[tT]e[xX]\\'" . LaTeX-mode))
|
||||
:config
|
||||
(defun my/-auctex-texdoc-setup-env (oldfun &rest args)
|
||||
(let ((process-environment process-environment)
|
||||
|
Reference in New Issue
Block a user