add completion and spell, syntax and version checking, deft and treemacs and bibliography settings

This commit is contained in:
2020-12-05 15:08:51 +01:00
parent e7a29d6f32
commit c06aba2ba4
7 changed files with 524 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
;;; bibliography-settings.el --- bibliography settings -*- lexical-binding: t -*-
;;; Commentary:
;; settings in org-settings: org-latex-pdf-process
;; Requirements:
;; for 'biber' install linux package 'biber', for HTML export features
;; install linux package 'bibtex2html'
;; org-ref https://melpa.org/#/org-ref
;; pdf-tools
;; parsebib
;; htmlize (helm and hel-bibtex -> ivy)
;; ivy
;; ivy-bibtex (bibtex-completion (because of org-ref-ivy-cite))
;; biblio biblio-core https://melpa.org/#/biblio
;;; Code:
(use-package pdf-tools
:load-path (lambda() (concat user-emacs-directory "lisp/pdf-tools"))
:defer t ;; used by org-ref
)
(use-package biblio
:load-path (lambda() (concat user-emacs-directory "lisp/biblio"))
:defer t ;; used by org-ref
)
(use-package org-ref ;; used with some preamble defs and \printbibliography (biblatex/biber, no html export), see also ox-bibtex
:load-path (lambda() (concat user-emacs-directory "lisp/org-ref"))
:after (org)
:defer 1
:init
;; specify completion backends
(defvar org-ref-completion-library 'org-ref-ivy-cite) ;; requires ivy-bibtex, must be set before requiring org-ref otherwise helm will be loaded
:config
(setq bibtex-dialect 'biblatex) ;; biblatex also for biber
)
(use-package ox-bibtex ;; used with #+BIBLIOGRAPHY: ... (bibtex, with html export), see also org-ref
:after (org)
:defer 1
)
(provide 'bibliography-settings)
;;; bibliography-settings.el ends here

View File

@@ -0,0 +1,224 @@
;; completion-settings.el --- Completion settings -*- lexical-binding: t -*-
;;; Commentary:
;; <M-tab> alias of C-M-i
;; in general `completion-at-point' (`minibuffer.el')
;; in python-mode `anaconde-mode-complete'
;; manual https://oremacs.com/swiper/
;; org:
;; - org-insert-structure-template is bound to C-c C-,
;; - for easy-template require org-tempo or add to org-modules
;; https://orgmode.org/manual/Easy-templates.html#Easy-templates
;; Requirements:
;; amx https://melpa.org/#/?q=amx
;; ivy (instead of ido) https://elpa.gnu.org/packages/ivy.html
;; counsel https://github.com/abo-abo/swiper
;; swiper https://github.com/abo-abo/swiper
;; company https://elpa.gnu.org/packages/company.html
;; config for R see ess-settings.el
;; company-quickhelp https://github.com/company-mode/company-quickhelp
;; pos-tip
;; yasnippet
;; popup
;; yasnippet-snippets https://melpa.org/#/yasnippet-snippets
;;; Code:
(use-package amx
:defer t
:config
(setq amx-save-file (concat user-cache-directory "amx-items")))
;; in an ivy action minibuffer use M-o `ivy-dispatching-done' to see
;; valid actions.
(use-package ivy
:load-path (lambda() (concat user-emacs-directory "lisp/ivy"))
:delight (ivy-mode "") ;; Ⓘ i
:defer 0.1
;; Ivy-based interface to standard commands
:bind (
("C-s" . swiper)
("C-c C-r" . ivy-resume) ;; resumes the last Ivy-based completion.
("<f6>" . ivy-resume)
("C-c v" . ivy-push-view)
("C-c V" . ivy-pop-view)
)
:config
(ivy-mode 1)
(setq ivy-use-virtual-buffers t) ;; Add recent files and bookmarks to the ivy-switch-buffer
(setq ivy-count-format "%d/%d ") ;; Displays the current and total number in the collection in the prompt
(setq enable-recursive-minibuffers t)
(setq ivy-extra-directories nil) ;; remove ./ and ../ from list, because <tab> on them would open dird mode. default: '("../" "./")
(setq ivy-use-selectable-prompt t) ;; make the prompt line selectable. Example: create a file bar when a file barricade exists in the current directory. Also C-M-j usable
;; enable this if you want `swiper' to use it
;; (setq search-default-mode #'char-fold-to-regexp)
)
(use-package swiper
:after ivy)
(use-package counsel
:after ivy
:bind (
("M-x" . counsel-M-x)
("M-y" . counsel-yank-pop)
("C-x b" . counsel-switch-buffer)
("C-x C-f" . counsel-find-file)
("C-x C-r" . counsel-recentf)
("<f1> f" . describe-function) ;; counsel-describe-function
("<f1> v" . describe-variable) ;; counsel-describe-variable
("<f1> l" . find-library) ;; find-library works better with counsel as counsel-find-library
("<f2> i" . counsel-info-lookup-symbol)
("<f2> u" . counsel-unicode-char)
("<f2> j" . counsel-set-variable)
;; Ivy-based interface to shell and system tools
("C-c c" . counsel-compile)
("C-c g" . counsel-git)
("C-c j" . counsel-git-grep)
("C-c L" . counsel-git-log)
("C-c k" . counsel-rg) ;; 'counsel-ag 'counsel-rg
("C-c m" . counsel-linux-app)
("C-c n" . counsel-fzf)
("C-x l" . counsel-locate)
("C-c J" . counsel-file-jump)
("C-S-o" . counsel-rhythmbox)
("C-c w" . counsel-wmctrl)
;; other commands
("C-c b" . counsel-bookmark)
("C-c d" . counsel-descbinds)
("C-c o" . counsel-outline)
("C-c t" . counsel-load-theme)
("C-c F" . counsel-org-file)
:map minibuffer-local-map
("C-r" . counsel-minibuffer-history)
)
:config
;; Do not open dired for directories when using counsel-find-file
;; https://emacs.stackexchange.com/questions/33701/do-not-open-dired-for-directories-when-using-counsel-find-file
(let ((done (where-is-internal #'ivy-done ivy-minibuffer-map t))
(alt (where-is-internal #'ivy-alt-done ivy-minibuffer-map t)))
(define-key counsel-find-file-map done #'ivy-alt-done)
(define-key counsel-find-file-map alt #'ivy-done)
(define-key counsel-find-file-map (kbd "TAB") 'ivy-alt-done)
(define-key counsel-find-file-map (kbd "<tab>") 'ivy-alt-done)
;; <left> and <right> not used to be able to navigate inside the text
;; https://oremacs.com/swiper/#file-name-completion
;; ivy-done completion for file, but opens dird mode for directories
;; ivy-alt-done complete dir or open file, but without entering any character it opens dird mode
;; ivy-immediate-done no completion
))
;;(setq tab-always-indent 'complete) ;; use 'complete when auto-complete is disabled
(use-package company
:load-path (lambda() (concat user-emacs-directory "lisp/company"))
:delight (company-mode "") ;; Ⓒ c
;;:bind (("C-M-i" . company-complete))
:bind (([remap completion-at-point] . company-complete)
:map lisp-interaction-mode-map
("M-?" . (lambda () (interactive) (describe-symbol (symbol-at-point))))
:map emacs-lisp-mode-map
("M-?" . (lambda () (interactive) (describe-symbol (symbol-at-point)))))
;; see org bind below
:hook ((after-init . global-company-mode)
(minibuffer-setup . company-mode)) ;; minibuffer-setup-hook
:config
(setq company-idle-delay nil) ;; no idle completion, invoke with <M-tab>
(setq company-minimum-prefix-length 2)
(setq company-require-match nil)
(setq company-dabbrev-ignore-case nil)
(setq company-dabbrev-downcase nil)
;; https://github.com/syl20bnr/spacemacs/tree/develop/layers/%2Bcompletion/auto-completion
(defvar my-completion-menu-tab-key-behavior 'cycle
"What the TAB key should do when completion menu is active.
Possible values are `complete', `cycle' or nil.")
(setq my-completion-tab-key-behavior 'complete)
(defun my-completion-menu-set-tab-key-behavior (package)
"Bind TAB key appropriately for the given PACKAGE and value of
`my-completion-menu-tab-key-behavior'.
Possible PACKAGE values are `company'."
(cond
((eq 'company package)
(let ((map company-active-map))
(cond
((eq 'complete my-completion-menu-tab-key-behavior)
(define-key map (kbd "TAB") 'company-complete-selection)
(define-key map (kbd "<tab>") 'company-complete-selection))
((eq 'cycle my-completion-menu-tab-key-behavior)
(define-key map (kbd "TAB") 'company-complete-common-or-cycle)
(define-key map (kbd "<tab>") 'company-complete-common-or-cycle)
(define-key map (kbd "<S-tab>")
(lambda () (company-complete-common-or-cycle -1)))
(define-key map (kbd "<backtab>")
(lambda () (company-complete-common-or-cycle -1)))
)
(t
(define-key map (kbd "TAB") nil)
(define-key map (kbd "<tab>") nil)))))
(t (message "Not yet implemented for package %S" package))))
(my-completion-menu-set-tab-key-behavior 'company)
(with-eval-after-load 'org
(define-key org-mode-map [remap complete-symbol] 'company-complete)))
;; org completion with pcomplete company-capf
(defun my-org-mode-completion-hook ()
(add-hook 'completion-at-point-functions 'pcomplete-completions-at-point nil t))
(add-hook 'org-mode-hook #'my-org-mode-completion-hook)
(use-package company-quickhelp
:after company
:bind (:map company-active-map
("C-c h" . company-quickhelp-manual-begin)) ;; manually trigger the help popup, but only when company is doing its thing.
;;:config
;;(company-quickhelp-mode 1) ;; deactivated bc/ auto show is not good
)
(use-package yasnippet ;; https://elpa.gnu.org/packages/yasnippet.html
:defer 1
:delight (yas-minor-mode "") ;; Ⓨ y
;; see also variable yas-snippet-dirs, the yasnippet-snippets
;; collection dir is added via require 'yasnippet-snipets
:config
;; global
;;(yas-global-mode 1)
;; on a per-buffer basis
(yas-reload-all)
(add-hook 'prog-mode-hook #'yas-minor-mode))
;; use popup menu for yas-choose-value
(use-package popup
:after yasnippet
:bind (:map popup-menu-keymap ;; add some shotcuts in popup menu mode
("M-n" . popup-next)
("TAB" . popup-next)
("<tab>" . popup-next)
("<backtab>" . popup-previous)
("M-p" . popup-previous))
:config
(defun yas-popup-isearch-prompt (prompt choices &optional display-fn)
(when (featurep 'popup)
(popup-menu*
(mapcar
(lambda (choice)
(popup-make-item
(or (and display-fn (funcall display-fn choice))
choice)
:value choice))
choices)
:prompt prompt
;; start isearch mode immediately
:isearch t
)))
(setq yas-prompt-functions
'(yas-popup-isearch-prompt yas-maybe-ido-prompt yas-completing-prompt yas-no-prompt)))
(use-package yasnippet-snippets
:load-path (lambda() (concat user-emacs-directory "lisp/yasnippet-snippets"))
:after (yasnippet)
:defer 1)
(provide 'completion-settings)
;;; completion-settings.el ends here

18
settings/deft-settings.el Normal file
View File

@@ -0,0 +1,18 @@
;;; deft-settings.el --- deft settings -*- lexical-binding: t -*-
;;; Commentary:
;; https://melpa.org/#/deft
;; https://jblevins.org/projects/deft/
;;; Code:
(use-package deft
:bind ("C-x C-S-d" . deft-find-file)
:config
(setq deft-directory "~/Sync")
;; (setq deft-extensions '("org" "md" "txt"))
(setq deft-use-filename-as-title t)
(setq deft-use-filter-string-for-filename t)
)
(provide 'deft-settings)
;;; deft-settings.el ends here

View File

@@ -0,0 +1,97 @@
;;; spell-settings.el --- Spell settings -*- lexical-binding: t -*-
;;; Commentary:
;; https://melpa.org/#/langtool
;; https://github.com/mhayashi1120/Emacs-langtool
;; Requirements:
;; Linux package: languagetool
;; Emacs package: langtool.el
;;; Code:
(use-package langtool
:commands (langtool-check langtool-check-buffer)
:init
;; classpath where LanguageTool's jars reside
(setq langtool-java-classpath
"/usr/share/languagetool:/usr/share/java/languagetool/*")
;; LanguageTool launcher (not working with )
;;(setq langtool-bin "/usr/bin/languagetool")
:config
;;(setq langtool-default-language "en-US")
(setq langtool-mother-tongue "de")
;;(setq langtool-java-user-arguments '("-Dfile.encoding=UTF-8"))
;;(setq langtool-user-arguments ...)
;; Show LanguageTool report automatically by popup
;;(defun langtool-autoshow-detail-popup (overlays)
;; (when (require 'popup nil t)
;; ;; Do not interrupt current popup
;; (unless (or popup-instances
;; ;; suppress popup after type `C-g` .
;; (memq last-command '(keyboard-quit)))
;; (let ((msg (langtool-details-error-message overlays)))
;; (popup-tip msg)))))
;;(setq langtool-autoshow-message-function
;; 'langtool-autoshow-detail-popup)
;;https://github.com/redguardtoo/Emacs-langtool
(eval-after-load 'org-mode
'(progn
(setq langtool-generic-check-predicate
'(lambda (start end)
;; set up for `org-mode'
(let* ((begin-regexp "^[ \t]*#\\+begin_\\(src\\|html\\|latex\\|example\\|quote\\)")
(end-regexp "^[ \t]*#\\+end_\\(src\\|html\\|latex\\|example\\|quote\\)")
(case-fold-search t)
(ignored-font-faces '(org-verbatim
org-block-begin-line
org-meta-line
org-tag
org-link
org-level-1
org-document-info))
(rlt t)
ff
th
b e)
(save-excursion
(goto-char start)
;; get current font face
(setq ff (get-text-property start 'face))
(if (listp ff) (setq ff (car ff)))
;; ignore certain errors by set rlt to nil
(cond
((memq ff ignored-font-faces)
;; check current font face
(setq rlt nil))
((string-match "^ *- $" (buffer-substring (line-beginning-position) (+ start 2)))
;; dash character of " - list item 1"
(setq rlt nil))
((and (setq th (thing-at-point 'evil-WORD))
(or (string-match "^=[^=]*=[,.]?$" th)
(string-match "^\\[\\[" th)))
;; embedded cde like =w3m= or org-link [[http://google.com][google]] or [[www.google.com]]
;; langtool could finish checking before major mode prepare font face for all texts
(setq rlt nil))
(t
;; inside source block?
(setq b (re-search-backward begin-regexp nil t))
(if b (setq e (re-search-forward end-regexp nil t)))
(if (and b e (< start e)) (setq rlt nil)))))
;; (if rlt (message "start=%s end=%s ff=%s" start end ff))
rlt)))))
(eval-after-load 'prog-mode
'(progn
(unless (featurep 'flyspell) (require 'flyspell))
(setq langtool-generic-check-predicate
'(lambda (start end)
(let* ((f (get-text-property start 'face)))
(memq f flyspell-prog-text-faces))))))
)
(provide 'spell-settings)
;;; spell-settings.el ends here

View File

@@ -0,0 +1,44 @@
;;; syntax-checking-settings --- Settings file for syntax checking features
;;; Commentary:
;; Syntax checking configurations
;; Requirements:
;; - flycheck https://melpa.org/#/flycheck https://github.com/flycheck/flycheck
;; flycheck is used, because flymake supports less languages than flycheck
;; there are in place temporary files for Python, LaTeX and Emacs Lisp, see https://github.com/flycheck/flycheck/issues/92
;; if working with some kind of cloud sync systems, one may filter "flycheck_*" files
;; no activated yet:
;; https://melpa.org/#/flycheck-pos-tip require pos-tip
;;; Code:
;; do not load directly with e.g. (global-flycheck-mode) or via
;; after-init-hook while loading the init because flycheck will freeze
;; for a short while. Therefore better defer loading.
;;(require 'flycheck (concat user-emacs-directory "lisp/flycheck/flycheck.el"))
(use-package flycheck
:load-path (lambda() (concat user-emacs-directory "lisp/flycheck"))
:defer 2
:init
(setq flycheck-mode-line-prefix "𝓕") ;; Ⓕ 𝓕 ✈ f ;; other flycheck settings see syntax-checking-settings.el
(setq flycheck-mode-line '(:eval (concat (flycheck-mode-line-status-text) " ")))
:config
(setq-default flycheck-disabled-checkers '(python-flake8)) ;; disable the python-flake8 checker. This will make the next checker which is python-pylint to be used.
(setq flycheck-check-syntax-automatically '(save mode-enabled)) ;; flycheck only while saving, default is (save idle-change new-line mode-enabled)
;; flycheck-mode-line-prefix see general-settings-post.el
(setq flycheck-emacs-lisp-load-path 'inherit)
;;(add-hook 'after-init-hook #'global-flycheck-mode) ;; deactivated bc of defer
(global-flycheck-mode)
)
;; flycheck also has tooltips
;; flycheck-pos-tip shows errors under point in pos-tip popups.
;;(require 'flycheck-pos-tip)
;;(with-eval-after-load 'flycheck
;; (flycheck-pos-tip-mode))
(provide 'syntax-checking-settings)
;;; syntax-checking-settings.el ends here

View File

@@ -0,0 +1,41 @@
;; https://github.com/Alexander-Miller/treemacs
;; treemacs requires http://melpa.org/#/treemacs
;; dash
;; s.el http://melpa.org/#/s
;; f.el http://melpa.org/#/f
;; ht.el http://melpa.org/#/ht
;; ace-window.el https://elpa.gnu.org/packages/ace-window.html
;; avy.el https://elpa.gnu.org/packages/avy.html
;; pfuture.el http://melpa.org/#/pfuture
;; hydra.el https://elpa.gnu.org/packages/hydra.html
;; treemacs-magit ;; http://melpa.org/#/treemacs-magit
(use-package treemacs
:load-path (lambda() (concat user-emacs-directory "lisp/treemacs"))
:commands treemacs
:init
;; get rid of the message:
;; [Treemacs] Warning: couldnt find hl-line-modes background color for icons, falling back on unspecified-bg.
;; see https://github.com/Alexander-Miller/treemacs/issues/100
;; and https://github.com/Alexander-Miller/treemacs/commit/f62a946f0fc5db79d37fb748ab49334c4e3cbbfd
(defvar treemacs-no-load-time-warnings t)
(setq
treemacs-follow-after-init t
treemacs-sorting 'alphabetic-case-insensitive-desc
;;treemacs-width 35
;;treemacs-position 'left
;;treemacs-is-never-other-window nil
;;treemacs-silent-refresh nil
;;treemacs-indentation 2
;;treemacs-sorting 'alphabetic-desc
;;treemacs-show-hidden-files t
;;treemacs-goto-tag-strategy 'refetch-index
;;treemacs-collapse-dirs (if treemacs-python-executable 3 0)
)
;;(:map global-map ([f8] . treemacs-toggle))
)
(use-package treemacs-magit
:after (treemacs))
(provide 'treemacs-settings)
;;; treemacs-settings.el ends here

View File

@@ -0,0 +1,58 @@
;;; version-control-settings.el --- Version control settings -*- lexical-binding: t -*-
;;; Commentary:
;; IMPORTANT for magit: do not delete and change in magit-version.el
;; the version, see also git repo lisp/Makefile
;; TODO: add? https://github.com/alphapapa/magit-todos
;; Requirements:
;; magit https://melpa.org/#/magit
;; https://magit.vc/manual/magit/Installing-from-the-Git-Repository.html#Installing-from-the-Git-Repository
;; http://wikemacs.org/wiki/Magit
;; dash with-editor git-commit transient
;; git-messenger https://melpa.org/#/git-messenger
;; popup
;; orgit
;; diff-hl https://elpa.gnu.org/packages/diff-hl.html
;; (not anymore) ido-completing-read+ (now using ivy)
;; ivy
;;; Code:
(use-package magit
:load-path (lambda() (concat user-emacs-directory "lisp/magit"))
:hook (prog-mode . magit-file-mode)
:config
;; (setq magit-completing-read-function 'magit-builtin-completing-read) ;; if ivy-mode is on then it uses it otherwise set to 'ivy-completing-read
;; (setq magit-completing-read-function 'magit-ido-completing-read) ;; Use ido to checkout branches. requires ido-completing-read+
)
;; On Windows, we must use Git GUI to enter username and password
;; See: https://github.com/magit/magit/wiki/FAQ#windows-cannot-push-via-https
(when (eq window-system 'w32)
(setenv "GIT_ASKPASS" "git-gui--askpass"))
(use-package git-messenger
:after (magit)
:bind (("C-x v p" . git-messenger:popup-message))
;;:config
;;(setq git-messenger:use-magit-popup t)
)
(use-package orgit
:after (magit org)
)
(use-package diff-hl
:load-path (lambda() (concat user-emacs-directory "lisp/diff-hl"))
:hook (
((prog-mode vc-dir-mode) . turn-on-diff-hl-mode)
(magit-pre-refresh . diff-hl-magit-pre-refresh)
(magit-post-refresh . diff-hl-magit-post-refresh)
)
;;:config
;;(global-diff-hl-mode)
)
(provide 'version-control-settings)
;;; version-control-settings.el ends here