You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
379 lines
12 KiB
EmacsLisp
379 lines
12 KiB
EmacsLisp
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
|
|
|
|
;; Place your private configuration here! Remember, you do not need to run 'doom
|
|
;; sync' after modifying this file!
|
|
|
|
|
|
;; Some functionality uses this to identify you, e.g. GPG configuration, email
|
|
;; clients, file templates and snippets.
|
|
(setq user-full-name "Kuba Orlik"
|
|
user-mail-address "kontakt@kuba-orlik.name")
|
|
|
|
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
|
|
;; are the three important ones:
|
|
;;
|
|
;; + `doom-font'
|
|
;; + `doom-variable-pitch-font'
|
|
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
|
|
;; presentations or streaming.
|
|
;;
|
|
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
|
|
;; font string. You generally only need these two:
|
|
;; (setq doom-font (font-spec :family "monospace" :size 12 :weight 'semi-light)
|
|
;; doom-variable-pitch-font (font-spec :family "sans" :size 13))
|
|
|
|
;; There are two ways to load a theme. Both assume the theme is installed and
|
|
;; available. You can either set `doom-theme' or manually load a theme with the
|
|
;; `load-theme' function. This is the default:
|
|
(setq doom-font (font-spec :family "Fira Code" :size 12))
|
|
(setq doom-theme 'doom-solarized-light)
|
|
|
|
;; If you use `org' and don't want your org files in the default location below,
|
|
;; change `org-directory'. It must be set before org loads!
|
|
(setq org-directory "~/org/")
|
|
|
|
;; This determines the style of line numbers in effect. If set to `nil', line
|
|
;; numbers are disabled. For relative line numbers, set this to `relative'.
|
|
(setq display-line-numbers-type t)
|
|
|
|
|
|
;; Here are some additional functions/macros that could help you configure Doom:
|
|
;;
|
|
;; - `load!' for loading external *.el files relative to this one
|
|
;; - `use-package!' for configuring packages
|
|
;; - `after!' for running code after a package has loaded
|
|
;; - `add-load-path!' for adding directories to the `load-path', relative to
|
|
;; this file. Emacs searches the `load-path' when you load packages with
|
|
;; `require' or `use-package'.
|
|
;; - `map!' for binding new keys
|
|
;;
|
|
;; To get information about any of these functions/macros, move the cursor over
|
|
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
|
|
;; This will open documentation for it, including demos of how they are used.
|
|
;;
|
|
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
|
|
;; they are implemented.
|
|
|
|
(setq +mu4e-backend 'offlineimap)
|
|
|
|
(setf lexical-binding t)
|
|
(defun kuba/generate-mu4-context (key_ category_ name_ addresses_ fullname_ smtp-server_ smtp-port_ smtp-user_ smtp-stream-type_ inbox-prefix_)
|
|
"NAME is the name in offlineimap directory"
|
|
(let (
|
|
(key key_)
|
|
(category category_)
|
|
(name name_)
|
|
(addresses addresses_)
|
|
(fullname fullname_)
|
|
(smtp-server smtp-server_)
|
|
(smtp-port smtp-port_)
|
|
(smtp-user smtp-user_)
|
|
(smtp-stream-type smtp-stream-type_)
|
|
(inbox-prefix inbox-prefix_)
|
|
)
|
|
(message "!!! addresses %S" addresses)
|
|
(make-mu4e-context
|
|
:name (concat key "-" name)
|
|
:enter-func (lambda () (mu4e-message (concat "Entering " name " context")))
|
|
:leave-func (lambda () (setq mu4e-maildir-list nil) (mu4e-message (concat "Leaving " name " context")))
|
|
:match-func (lambda (msg)
|
|
(when msg (some
|
|
(lambda (any) any)
|
|
(mapcar (lambda (addr) (or (mu4e-message-contact-field-matches msg :to addr) (mu4e-message-contact-field-matches msg :cc addr))) addresses))))
|
|
:vars (list
|
|
`(user-mail-address . ,(car addresses))
|
|
`(user-full-name . ,fullname)
|
|
`(mu4e-compose-signature . ,fullname)
|
|
`(org-msg-signature . ,(concat "#+begin_signature
|
|
--
|
|
" fullname " \\\\
|
|
#+end_signature"))
|
|
`(mu4e-drafts-folder . ,(concat "/" name "/" inbox-prefix "Drafts"))
|
|
`(mu4e-sent-folder . ,(concat "/" name "/" inbox-prefix "Sent"))
|
|
`(mu4e-trash-folder . ,(concat "/" name "/" inbox-prefix "Trash"))
|
|
`(mu4e-refile-folder . ,(lambda (msg)
|
|
(or
|
|
(some
|
|
'identity
|
|
(mapcar (lambda (addr)
|
|
(cond
|
|
((mu4e-message-contact-field-matches msg :to addr) (concat "/" name "/" inbox-prefix "Archives"))
|
|
((mu4e-message-contact-field-matches msg :from addr) (concat "/" name "/" inbox-prefix "Sent"))
|
|
(t nil)
|
|
)
|
|
)
|
|
addresses
|
|
)
|
|
)
|
|
(concat "/" name "/" inbox-prefix "Archives")
|
|
)
|
|
))
|
|
`(smtpmail-smtp-server . ,smtp-server)
|
|
`(smtpmail-smtp-service . ,smtp-port)
|
|
`(smtpmail-smtp-user . ,smtp-user)
|
|
`(smtpmail-stream-type . ,smtp-stream-type)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defun kuba/setup-mu4e-accounts (deflist)
|
|
(setq mu4e-contexts (mapcar (lambda (def) (apply 'kuba/generate-mu4-context def)) deflist))
|
|
(setq mu4e-user-mail-address-list (apply 'append (mapcar (lambda (def) (nth 3 def)) deflist)))
|
|
(push (list (concat "(" (mapconcat 'identity (mapcar (lambda (def) (concat "maildir:/" (nth 2 def) "/INBOX")) deflist) " OR ") ") and not maildir:/kontakt@jakub/INBOX") "Merged inbox" 109) mu4e-bookmarks)
|
|
(-each
|
|
(seq-group-by (lambda (def) (nth 1 def)) deflist)
|
|
(lambda (defgroup) (push (list (mapconcat 'identity (mapcar (lambda (def) (concat "maildir:/" (nth 2 def) "/INBOX")) (-slice defgroup 1)) " OR ") (nth 0 defgroup) (aref (nth 0 defgroup) 0)) mu4e-bookmarks))
|
|
)
|
|
)
|
|
|
|
(load "~/.doom.d/mu4e-accounts")
|
|
|
|
(defun mu4e-compose-new-ask-context ()
|
|
(interactive)
|
|
(mu4e-context-switch)
|
|
(mu4e-compose)
|
|
)
|
|
|
|
(custom-set-faces!
|
|
'(mu4e-header-face :inherit 'font-lock-keyword-face :weight normal)
|
|
'(mu4e-replied-face :inherit 'mu4e-header-face :slant italic)
|
|
'(mu4e-replied-face :inherit 'mu4e-header-face :slant italic)
|
|
'(mu4e-unread-face :inherit 'font-lock-keyword-face)
|
|
'(mu4e-header-marks-face :inherit 'font-lock-preprocessor-face)
|
|
'(mu4e-header-highlight-face :inherit 'hl-line :underline t :extend t)
|
|
'(org-headline-done :inherit 'org-headline-todo :foreground "#268BD2")
|
|
)
|
|
|
|
|
|
(after! mu4e
|
|
(setq mu4e-update-interval 20)
|
|
(mu4e-alert-enable-mode-line-display)
|
|
(setq mu4e-alert-interesting-mail-query (concat (mu4e-get-bookmark-query ?m) " and flag:unread"))
|
|
)
|
|
|
|
;; to fix the highlight in mu4e disappearing (https://github.com/hlissner/emacs-doom-themes/issues/504):
|
|
|
|
(after! hl-line
|
|
(setq hl-line-sticky-flag t
|
|
global-hl-line-sticky-flag t)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;; ORG
|
|
|
|
(defun sync-org ()
|
|
(interactive)
|
|
(org-save-all-org-buffers)
|
|
(message "downloading inbox...")
|
|
;; (org-mobile-pull)
|
|
(shell-command "/home/kuba/bin/inbox-download.sh")
|
|
;; (org-mobile-push)
|
|
(shell-command "notify-send \"org-sync finished\" --icon=ok")
|
|
(find-file "~/org/inbox.org")
|
|
(revert-buffer 1 1)
|
|
)
|
|
|
|
|
|
(map! :g "C-c c m s" #'sync-org)
|
|
|
|
(defun kuba/open-org-main ()
|
|
(interactive)
|
|
(find-file "~/org/main.org")
|
|
)
|
|
|
|
(defun kuba/open-org-inbox ()
|
|
(interactive)
|
|
(find-file "~/org/inbox.org")
|
|
)
|
|
|
|
(defun kuba/open-notes ()
|
|
(interactive)
|
|
(find-file "~/Nextcloud/Notes")
|
|
)
|
|
|
|
|
|
(map! :g "M-1" #'kuba/open-org-main)
|
|
(map! :g "M-3" #'kuba/open-org-inbox)
|
|
(map! :g "M-4" #'kuba/open-notes)
|
|
(map! :g "M-c" #'org-capture)
|
|
|
|
|
|
(after! org
|
|
(setq org-capture-templates
|
|
'(("t" "Inbox item" entry
|
|
(file "~/org/inbox.org")
|
|
"* TODO %?
|
|
CREATED: %U")
|
|
("T" "Inbox item with Capture Target" entry
|
|
(file "~/org/inbox.org")
|
|
"* TODO %? (link)
|
|
%a")
|
|
("s" "test" entry
|
|
(file "~/org/inbox.org")
|
|
"* TODO %a %?")))
|
|
(setq org-agenda-start-day "-0d")
|
|
(setq org-hide-leading-stars nil)
|
|
(setq org-startup-indented nil)
|
|
(setq org-startup-folded t)
|
|
(setq org-refile-targets
|
|
(quote
|
|
(("/home/kuba/org/ideas.org" :maxlevel . 2)
|
|
("/home/kuba/org/main.org" :level . 2)
|
|
("/home/kuba/org/main.org" :level . 3)
|
|
("/home/kuba/org/entertainment.org" :level . 1))))
|
|
(require 'org-mu4e)
|
|
(add-hook 'org-store-link-functions 'org-mu4e-store-link)
|
|
(add-hook 'org-capture-after-finalize-hook #'org-save-all-org-buffers)
|
|
(add-hook 'org-capture-after-refile-insert-hook #'org-save-all-org-buffers)
|
|
(add-hook 'org-after-todo-state-change-hook #'org-save-all-org-buffers)
|
|
)
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;; spell-fu
|
|
|
|
(after! spell-fu
|
|
(global-spell-fu-mode 0)
|
|
(add-hook 'org-mode-hook
|
|
(lambda ()
|
|
(setq spell-fu-faces-exclude '(org-meta-line org-link org-code))
|
|
(spell-fu-mode 0)))
|
|
)
|
|
|
|
(defun lang-pl ()
|
|
(interactive)
|
|
(setq ispell-dictionary "pl_PL")
|
|
(setq langtool-default-language "pl-PL")
|
|
)
|
|
|
|
(defun lang-en ()
|
|
(interactive)
|
|
(setq ispell-dictionary "en_US")
|
|
(setq langtool-default-language "en-US")
|
|
)
|
|
|
|
(map! :g "C-c t g" #'writegood-mode)
|
|
|
|
(map! :g "C-c L c" #'langtool-check)
|
|
(map! :g "C-c L d" #'langtool-check-done)
|
|
(map! :g "C-c L l e" #'lang-en)
|
|
(map! :g "C-c L l p" #'lang-pl)
|
|
;;;; popup
|
|
|
|
|
|
;;disable hiding modeline in popups
|
|
;; (plist-put +popup-defaults :modeline t)
|
|
|
|
;;;;;;;;;;;;;;; prettier
|
|
|
|
;; (after! prettier-js
|
|
;; (add-hook 'js2-mode-hook 'prettier-js-mode)
|
|
;; (add-hook 'web-mode-hook 'prettier-js-mode)
|
|
;; (add-hook 'typescript-mode-hook 'prettier-js-mode)
|
|
;; )
|
|
|
|
|
|
;;;; file editing shortcuts
|
|
|
|
(map! :g "C-a" #'move-beginning-of-line)
|
|
(remove-hook 'doom-first-buffer-hook #'smartparens-global-mode)
|
|
|
|
|
|
(after! flycheck
|
|
(setq! flycheck-check-syntax-automatically
|
|
(if (string= (system-name) "kuba-desktop")
|
|
'(save idle-change new-line mode-enabled idle-buffer-switch)
|
|
'(save mode-enabled idle-buffer-switch)
|
|
)))
|
|
|
|
|
|
(setq +format-on-save-enabled-modes
|
|
'(mhtml-mode
|
|
html-mode
|
|
;; typescript-mode
|
|
;; js2-mode
|
|
;; web-mode
|
|
))
|
|
|
|
;; (set-formatter! 'web-mode 'prettier-prettify)
|
|
|
|
(add-hook 'after-init-hook #'global-prettier-mode)
|
|
(add-hook 'web-mode-hook #'prettier-mode)
|
|
(add-hook 'css-mode-hook #'prettier-mode)
|
|
(add-hook 'typescript-mode-hook #'prettier-mode)
|
|
|
|
(fset 'sm
|
|
(kmacro-lambda-form [return ?\C-s ?i ?d ?e ?n ?\C-e 134217794 ?\M-w ?\M-c ?T ?Z ?g ?ł ?o ?s ?z ?e ?n ?i ?e ? ?# ?\C-y ?\C-c ?\C-w ?Z ?g ?ł ?o return ?r ?\M-: ?\( ?s ?l ?e ?e ?p ?- ?f ?o ?r ? ?0 ?. ?1 ?\) return] 0 "%d"))
|
|
|
|
|
|
;; (defun org-agenda-skip-if-scheduled-later ()
|
|
;; "If this function returns nil, the current match should not be skipped.
|
|
;; Otherwise, the function must return a position from where the search
|
|
;; should be continued."
|
|
;; (ignore-errors
|
|
;; (let ((subtree-end (save-excursion (org-end-of-subtree t)))
|
|
;; (scheduled-seconds
|
|
;; (time-to-seconds
|
|
;; (org-time-string-to-time
|
|
;; (org-entry-get nil "SCHEDULED"))))
|
|
;; (now (time-to-seconds (current-time))))
|
|
;; (and scheduled-seconds
|
|
;; (>= scheduled-seconds now)
|
|
;; subtree-end))))
|
|
|
|
(defun mu4e-copy-message-at-point (&optional dir)
|
|
"Copy message at point to somewhere else as <date>_<subject>.eml."
|
|
(interactive)
|
|
(let* ((msg (mu4e-message-at-point))
|
|
(target (format "%s_%s.eml"
|
|
(format-time-string "%F" (mu4e-message-field msg :date))
|
|
(or (mu4e-message-field msg :subject) "No subject"))))
|
|
(copy-file
|
|
(mu4e-message-field msg :path)
|
|
(format "%s/%s" (or dir (read-directory-name "Copy message to: ")) target) 1)))
|
|
|
|
|
|
(after! lsp-mode
|
|
(message "after LSP!")
|
|
(setq! lsp-log-io nil)
|
|
(lsp-register-client
|
|
(make-lsp-client :new-connection (lsp-tramp-connection '("typescript-language-server" "--stdio"))
|
|
:major-modes '(typescript-mode)
|
|
:remote? t
|
|
:server-id 'ts-remote))
|
|
(lsp-register-client
|
|
(make-lsp-client :new-connection (lsp-stdio-connection '("typescript-language-server" "--stdio"))
|
|
:major-modes '(typescript-mode)
|
|
:server-id 'ts-ls-better))
|
|
|
|
(setq company-idle-delay 0.5)
|
|
;; (lsp-register-client
|
|
;; (make-lsp-client :new-connection (lsp-tramp-connection '("javascript-typescript-langserver"))
|
|
;; :major-modes '(typescript-mode)
|
|
;; :remote? t
|
|
;; :server-id 'jsts-remote))
|
|
)
|
|
|
|
(defun remote-prettier ()
|
|
"Run prettier on a remote file"
|
|
(interactive)
|
|
(let ((filename buffer-file-name))
|
|
(shell-command (concat "prettier -w " (file-remote-p buffer-file-name 'localname)))
|
|
(kill-buffer (buffer-name))
|
|
(find-file filename)
|
|
)
|
|
)
|
|
|
|
(defun reopen-file ()
|
|
"kills the buffer and reopens the file"
|
|
(interactive)
|
|
(let ((filename buffer-file-name))
|
|
(kill-buffer (buffer-name))
|
|
(find-file filename)
|
|
)
|
|
)
|