pkg update and first config fix

org-brain not working, add org-roam
This commit is contained in:
2022-12-19 23:02:34 +01:00
parent 02b3e07185
commit 82f05baffe
885 changed files with 356098 additions and 36993 deletions

View File

@@ -2,7 +2,7 @@
;;
;; Author: Vitalie Spinu
;; Maintainer: Vitalie Spinu
;; Copyright (C) 2013-2019, Vitalie Spinu
;; Copyright (C) 2013-2022 Free Software Foundation, Inc.
;; Version: 0.1
;; URL: https://github.com/polymode/polymode
;; Keywords: emacs
@@ -181,12 +181,154 @@ are passed to ORIG-FUN."
(pm-apply-protected orig-fun args))
(apply orig-fun args)))
;;; LSP (lsp-mode and eglot)
;;
;; Emacs modifications `after-change-functions' to LSP insertions
;; https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_didChange
;;
;; INSERT: (50 56 0) means insert 6 chars starting at pos 50
;; {"range": {"start": {"line": 1, "character": 0},
;; "end" : {"line": 1, "character": 0}},
;; "text": "insert"}
;;
;; DELETE: (50 50 6) means delete 6 chars starting at pos 50
;; {"range": {"start": {"line": 1, "character": 0},
;; "end" : {"line": 1, "character": 6}},
;; "text": ""}
;;
;; REPLACE: (50 60 6) means delete 6 chars starting at pos 50, and replace
;; them with 10 chars
;; {"range": {"start": {"line": 1, "character": 0},
;; "end" : {"line": 1, "character": 6}},
;; "text": "new-insert"}
;;
;; INSERT:
;; before-change:(obeg,oend)=(50,50)
;; after-change:(nbeg,nend,olen)=(50,56,0)
;;
;; DELETE:
;; before-change:(obeg,oend)=(50,56)
;; after-change:(nbeg,nend,len)=(50,50,6)
;;
;; REPLACE:
;; before-change:(obeg,oend)=(50,56)
;; lsp-on-change:(nbeg,nend,olen)=(50,60,6)
(defun pm--lsp-text-document-content-change-event (beg end len)
"Make a TextDocumentContentChangeEvent body for BEG to END, of length LEN."
(if (zerop len)
;; insertion
(pm--lsp-change-event beg end (buffer-substring-no-properties beg end))
(if (pm--lsp-simple-change-p beg len)
(let ((end-pos pm--lsp-before-change-end-position)
(text (buffer-substring-no-properties beg end)))
;; if beg == end deletion, otherwise replacement
(pm--lsp-change-event beg end-pos text))
(pm--lsp-full-change-event))))
(defvar-local pm--lsp-before-change-end-position nil)
(defun pm--lsp-position (pos)
(save-restriction
(widen)
(save-excursion
(goto-char pos)
(let ((char (if (eq pm/chunkmode (nth 3 (pm-innermost-span pos)))
(- (point) (line-beginning-position))
0)))
(list :line (1- (line-number-at-pos pos))
:character char)))))
(defun pm--lsp-change-event (beg end text)
(list
:range (list
:start (if (listp beg) beg (pm--lsp-position beg))
:end (if (listp end) end (pm--lsp-position end)))
:text text))
(defun pm--lsp-full-change-event ()
(list :text (pm--lsp-text)))
(defun pm--lsp-text (&optional beg end)
(save-restriction
(widen)
(setq beg (or beg (point-min)))
(setq end (or end (point-max)))
(let ((cmode major-mode)
(end-eol (save-excursion (goto-char end)
(point-at-eol)))
line-acc acc)
(pm-map-over-modes
(lambda (sbeg send)
(let ((beg1 (max sbeg beg))
(end1 (min send end))
(rem))
(if (eq cmode major-mode)
(progn
(when (eq sbeg beg1)
;; first line of mode; use line-acc
(setq acc (append line-acc acc))
(setq line-acc nil))
;; if cur-mode follows after end on same line, accumulate the
;; last line but not the actual text
(when (< beg1 end)
(push (buffer-substring-no-properties beg1 end1) acc)))
(goto-char beg1)
(if (<= end1 (point-at-eol))
(when (< beg1 end1) ; don't accumulate on last line
(push (make-string (- end1 beg1) ? ) line-acc))
(while (< (point-at-eol) end1)
(push "\n" acc)
(forward-line 1))
(setq line-acc (list (make-string (- end1 (point)) ? )))))))
beg end-eol)
(apply #'concat (reverse acc)))))
;; We cannot compute original change location when modifications are complex
;; (aka multiple changes are combined). In those cases we send an entire
;; document.
(defun pm--lsp-simple-change-p (beg len)
"Non-nil if the after change BEG and LEN match before change range."
(let ((bcr (pm--prop-get :before-change-range)))
(and (eq beg (car bcr))
(eq len (- (cdr bcr) (car bcr))))))
;; advises
(defun polymode-lsp-buffer-content (orig-fun)
(if (and polymode-mode pm/polymode)
(pm--lsp-text)
(funcall orig-fun)))
(defun polymode-lsp-change-event (orig-fun beg end len)
(if (and polymode-mode pm/polymode)
(pm--lsp-text-document-content-change-event beg end len)
(funcall orig-fun beg end len)))
(defvar-local polymode-lsp-integration t)
(with-eval-after-load "lsp-mode"
(when polymode-lsp-integration
(add-to-list 'polymode-run-these-after-change-functions-in-other-buffers 'lsp-on-change)
;; (add-to-list 'polymode-run-these-before-change-functions-in-other-buffers 'lsp-before-change)
;; FIXME: add auto-save?
(add-to-list 'polymode-run-these-before-save-functions-in-other-buffers 'lsp--before-save)
(dolist (sym '(lsp-lens--after-save lsp-on-save))
(add-to-list 'polymode-run-these-after-save-functions-in-other-buffers sym))
;; (add-to-list 'polymode-move-these-minor-modes-from-old-buffer 'lsp-headerline-breadcrumb-mode)
(pm-around-advice 'lsp--buffer-content #'polymode-lsp-buffer-content)
(pm-around-advice 'lsp--text-document-content-change-event #'polymode-lsp-change-event)))
;; (advice-remove 'lsp--buffer-content #'polymode-lsp-buffer-content)
;; (advice-remove 'lsp--text-document-content-change-event #'polymode-lsp-change-event)
;;; Flyspel
(defun pm--flyspel-dont-highlight-in-chunkmodes (beg end _poss)
(or (car (get-text-property beg :pm-span))
(car (get-text-property end :pm-span))))
(add-hook 'flyspell-incorrect-hook
#'pm--flyspel-dont-highlight-in-chunkmodes nil t)
;;; C/C++/Java
(pm-around-advice 'c-before-context-fl-expand-region #'pm-override-output-cons)
@@ -333,8 +475,8 @@ This is done by modifying `uniquify-buffer-base-name' to `pm--core-buffer-name'.
(null buffer-undo-tree))
(setq buffer-undo-tree (make-undo-tree))))
(eval-after-load 'undo-tree
'(add-hook 'polymode-init-inner-hook 'polymode-init-undo-tree-maybe))
(with-eval-after-load 'undo-tree
(add-hook 'polymode-init-inner-hook #'polymode-init-undo-tree-maybe))
;;; EVIL
@@ -348,8 +490,8 @@ This is done by modifying `uniquify-buffer-base-name' to `pm--core-buffer-name'.
(with-current-buffer new-buffer
(evil-change-state old-state))))))
(eval-after-load 'evil-core
'(add-hook 'polymode-after-switch-buffer-hook 'polymode-switch-buffer-keep-evil-state-maybe))
(with-eval-after-load 'evil-core
(add-hook 'polymode-after-switch-buffer-hook #'polymode-switch-buffer-keep-evil-state-maybe))
;;; HL line
@@ -365,8 +507,8 @@ This is done by modifying `uniquify-buffer-base-name' to `pm--core-buffer-name'.
(hl-line-unhighlight))
(when global-hl-line-mode
(global-hl-line-unhighlight))))
(eval-after-load 'hl-line
'(add-hook 'polymode-after-switch-buffer-hook 'polymode-switch-buffer-hl-unhighlight))
(with-eval-after-load 'hl-line
(add-hook 'polymode-after-switch-buffer-hook #'polymode-switch-buffer-hl-unhighlight))
;;; YAS