#+startup : overview
* Pending task
- Set dap-mode
- Add more programming languages to LSP
- Try =eglot=
- Spell checking
- Check <https://github.com/minad/osm >
- Check =pdf-tools=
- Check =org-presentation=
- Check ESS and =project.el= problem
- Check =perspective.el=
- [[https://github.com/mclear-tools/consult-notes ][Consult Notes ]]
* Famous init files
- [[https://github.com/zamansky/dot-emacs ][The Big Zemansky ]]
- [[https://pages.sachachua.com/.emacs.d/Sacha.html ][Sacha Chua Emac's configuration ]]
- [[https://github.com/patrickt/emacs ][Patrick: GOAT init emacs ]]
- [[https://github.com/manugoyal/.emacs.d ][Manugoyal: Emacs config ]]
- [[https://github.com/daviwil/dotfiles/blob/master/Emacs.org ][System Crafters ]]
- [[https://github.com/daviwil/emacs-from-scratch/blob/master/Emacs.org ][System Crafters emacs-from-scratch ]]
- [[https://github.com/SystemCrafters/crafter-configs ][System Crafters configs compilation ]]
- [[https://github.com/oantolin/emacs-config ][Omar Antolin ]]
- [[https://bitbucket.org/hyunlee1o/dotfiles/src/main/.emacs.d/init.el ][hyunlee1o ]]
* Before this file loads
** The =early-init.el= file has been loaded.
This file inhibits =package.el= for loading packages
** The =init.el= file has been loaded
This file:
- Sets all that it's needed for =straight.el= to work as package manager
- **IMPORTANT* * Changes the =user-emacs-directory= from =~/.emacs.d= to =~/.cache/emacs= . Be careful, this has several effects, for instance your file =custom.el= will be in this directory.
- Load the =no-littering= package (see [[https://github.com/emacscollective/no-littering ][doc ]]) This package sets out to fix "the littering" by changing the values of path variables to put configuration files in =no-littering-etc-directory= (this will be =~/.cache/emacs/etc/= for this configuration) and persistent data files in =no-littering-var-directory= (for me: =~/.cache/emacs/var/= ), and by using descriptive file names and subdirectories when appropriate. This is similar to a color-theme; a "path-theme" if you will.
- Tries to install =org-mode= just to be sure to have the last release
- Loads the newer of this two files: =myconfig.org= or =myconfig.el= . In other words, if there are no new changes in =myconfig.org= it loads =myconfig.el= (it's faster)
* use-package tips
Some notes about [[https://github.com/jwiegley/use-package ][use-package ]]
- *:ensure* if true will install the package if not installed
It won't update packages. See auto-package-update for keeping all
packages up to date
- *:init* keyword to execute code *before* a package is loaded. It
accepts one or more forms, up to the next keyword
- *:config* can be used to execute code *after* a package is loaded.
In cases where loading is done lazily (see more about autoloading
below), this execution is deferred until after the autoload
occurs
- *:custom* permite configurar variables con syntaxis simplificada
- *:bind*
- *:bind-keymap*
- *:commands*
- *:mode* and *:interpreter*
- *:magic*
- *:hook* You can define hooks
- *:if*
- *:defer* En general use-package intenta aplicar lazy loading, pero
en algún paquete es necesario especificarlo explicitamente
- *:demand* Este es el contrario del anterior, para paquetes
que queremos cargar de inmediato
- *:diminish* and *:delight* changes minormode display in status line
* Personal info
#+begin_src elisp
(setq user-full-name "Sergio Alvariño"
user-mail-address "salvari@protonmail.com")
#+end_src
* Interface tweaks
** Some GUI optimizations
#+begin_src emacs-lisp
;; sets default font
(set-face-attribute 'default nil :family "Mensch" :foundry "PfEd" :height 158)
(setq inhibit-x-resources t) ; avoid problems with emacs daemon and cursor colors
(setq inhibit-startup-message t) ; Eliminate FSF startup msg
(setq frame-title-format "%b") ; Put filename in titlebar
(setq visible-bell t) ; Flash instead of beep
(set-scroll-bar-mode 'right) ; Scrollbar placement
(show-paren-mode t) ; Blinking cursor shows matching parentheses
(electric-pair-mode t) ; electric-pair-mode on
(setq column-number-mode t) ; Show column number of current cursor location
(mouse-wheel-mode t) ; wheel-mouse support
(setq fill-column 78)
(setq auto-fill-mode t) ; Set line width to 78 columns...
(setq-default indent-tabs-mode nil) ; Insert spaces instead of tabs
(setq-default tab-width 4) ; set default tab 4 spaces
(global-set-key "\r" 'newline-and-indent) ; turn autoindenting on
;(set-default 'truncate-lines t) ; Truncate lines for all buffers
(fset 'yes-or-no-p 'y-or-n-p) ; shorter messages
(setq sentence-end-double-space nil) ; only one space
; delete trailing whitespace before saving
(add-hook 'before-save-hook 'delete-trailing-whitespace)
;; Enable line numbers for some modes
(dolist (mode '(;;text-mode-hook
prog-mode-hook
conf-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 1))))
;; Override some modes which derive from the above
(dolist (mode '(org-mode-hook))
(add-hook mode (lambda () (display-line-numbers-mode 0))))
#+end_src
** Set encoding
Use utf-8 please
#+begin_src emacs-lisp
;; Set encoding
(prefer-coding-system 'utf-8)
#+end_src
** Some shortcuts
Useful shortcuts:
- Revert buffer (recargar)
- fichero org de configuración de emacs
- fichero org ppal, aquí está todo
- journal org file
- org para el blog público, ideas para el blog
- org para el blog privado
- org notes file: para tomar una nota rápida, no lo uso mucho
- phone org file: por si tomo notas en el teléfono, no lo uso mucho
#+begin_src emacs-lisp
(global-set-key (kbd "<f5 >") 'revert-buffer)
;; emacs configuration org file
(global-set-key
(kbd "\e\ec")
(lambda () (interactive) (find-file "~/.emacs.d/myconfig.org")))
;; Main org file
(global-set-key
(kbd "\e\ei")
(lambda () (interactive) (find-file "~/Dropbox/orgfiles/i.org")))
;; journal org file
(global-set-key
(kbd "\e\ej")
(lambda () (interactive) (find-file "~/Dropbox/orgfiles/journal.org")))
;; Notes file
(global-set-key
(kbd "\e\en")
(lambda () (interactive) (find-file "~/Dropbox/orgfiles/notes.org")))
;; public blog org file
(global-set-key
(kbd "\e\eb")
(lambda () (interactive) (find-file "~/Dropbox/orgfiles/b.org")))
;; private blog file
(global-set-key
(kbd "\e\ep")
(lambda () (interactive) (find-file "~/work/repos/Personal/blog/comacero_priv/content-org/blog_privado.org")))
;; phone org file
(global-set-key
(kbd "\e\eh")
(lambda () (interactive) (find-file "~/share/Mob_orgzly/phone.org")))
(global-set-key [C-tab] 'hippie-expand) ; expand
(global-set-key [C-kp-subtract] 'undo) ; [Undo]
;; (global-set-key [C-kp-multiply] 'goto-line) ; old goto line
(global-set-key [C-kp-multiply] 'consult-goto-line) ; goto line
(global-set-key [C-kp-add] 'toggle-truncate-lines) ; truncate lines
(global-set-key [C-kp-divide] 'delete-trailing-whitespace) ; delete trailing whitespace
(global-set-key [C-kp-decimal] 'completion-at-point) ; complete at point
(global-set-key [C-M-prior] 'previous-buffer) ; previous-buffer
(global-set-key [C-M-next] 'next-buffer) ; next-buffer
#+end_src
** Own map
Defines own key map
#+begin_src emacs-lisp
(define-prefix-command 'own-map)
(global-set-key (kbd "C-ñ") 'own-map)
(define-key own-map (kbd "y") 'aya-create)
(define-key own-map (kbd "e") 'aya-expand)
#+end_src
** General (a new binding system)
Have a look at [[https://github.com/noctuid/general.el#key-features ][doc ]]
#+begin_src emacs-lisp
;; (use-package general)
#+end_src
** Syntax highlight
Set maximum colors
#+begin_src emacs-lisp
(cond ((fboundp 'global-font-lock-mode) ; Turn on font-lock (syntax highlighting)
(global-font-lock-mode t) ; in all modes that support it
(setq font-lock-maximum-decoration t))) ; Maximum colors
#+end_src
** Kill buffer quick
Kill current buffer without questions
#+begin_src emacs-lisp
;;------------------------------------------------------------
;; Kill current buffer with C-Supr
(defun slv-kill-buffer ()
;; Kill default buffer without the extra emacs questions
(interactive)
(kill-buffer (buffer-name))
(set-name))
(global-set-key [C-delete] 'slv-kill-buffer)
#+end_src
** rainbow-delimiters
See fancy delimiters
#+begin_src emacs-lisp
(use-package rainbow-delimiters
:hook (prog-mode . rainbow-delimiters-mode)
)
#+end_src
** rainbow-mode
See colors in emacs
#+begin_src emacs-lisp
(use-package rainbow-mode)
#+end_src
** which-key
Some help with composed hotkeys
#+begin_src emacs-lisp
(use-package which-key
:diminish
:config
(which-key-mode)
(setq which-key-idle-delay 0.3)
)
#+end_src
** ace-windows
To jump to different windows easily
#+begin_src emacs-lisp
(use-package ace-window
:init
(global-set-key [remap other-window] 'ace-window)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0)))))
)
#+end_src
** PCRE2el
Perl Compatible Regexes
#+begin_src emacs-lisp
(use-package pcre2el
:config
(pcre-mode +1))
#+end_src
** Enable narrowing (DANGER)
C-x n ...
#+begin_src emacs-lisp
(put 'narrow-to-defun 'disabled nil)
(put 'narrow-to-page 'disabled nil)
(put 'narrow-to-region 'disabled nil)
#+end_src
** Insert-date
#+begin_src emacs-lisp
(global-set-key (kbd "C-c d") 'slv/insert-date)
(defun slv/insert-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "%Y-%m-%d")
((equal prefix '(4)) "%Y-%m-%dT%H:%M:%S%z")
((equal prefix '(16)) "%d.%m.%Y")
((equal prefix '(64)) "%c")))
(system-time-locale "es_ES"))
(insert (format-time-string format))))
(defun insert-standard-date ()
"Inserts standard date time string."
(interactive)
(insert (format-time-string "%c")))
#+end_src
* doom-modeline
A fancy modeline. Remember to execute =M-x all-the-icons-install-fonts=
See [[http://sodaware.sdf.org/notes/emacs-daemon-doom-modeline-icons/ ][this ]] for fixing icons in terminal
#+begin_src emacs-lisp
(use-package all-the-icons
)
(use-package doom-modeline
:init
(doom-modeline-mode 1)
(setq doom-modeline-icon 1) ;; this fixes icons in emacs-client
:custom
(doom-modeline-height 15)
;;(doom-modeline-icon (display-graphic-p))
)
#+end_src
* color-theme
Get some colour in your life
- [[https://emacsthemes.com/popular/index.html ][Popular themes gallery ]]
- [[https://github.com/doomemacs/themes/tree/screenshots ][Some doom-themes gallery ]]
There is no way in emacs (as far as I know) to find out the active color-theme, I'm currently using doom themes. In particular =doom-vibrant=
Try =M-x consult-theme=
#+begin_src emacs-lisp
(use-package modus-themes)
;; (load-theme 'modus-operandi t)
;; (load-theme 'modus-vivendi t)
(use-package doom-themes
:config
;; Global settings (defaults)
(setq doom-themes-enable-bold t ; if nil, bold is universally disabled
doom-themes-enable-italic t) ; if nil, italics is universally disabled
(load-theme 'doom-vibrant t)
;; Enable flashing mode-line on errors
(doom-themes-visual-bell-config)
;; Enable custom neotree theme (all-the-icons must be installed!)
(doom-themes-neotree-config)
;; or for treemacs users
(setq doom-themes-treemacs-theme "doom-colors") ; use the colorful treemacs theme
(doom-themes-treemacs-config)
;; Corrects (and improves) org-mode's native fontification.
(doom-themes-org-config)
)
;; (use-package zenburn-theme
;; :config
;; (setq zenburn-use-variable-pitch t) ;; use variable-pitch fonts for some headings and titles
;; (setq zenburn-scale-org-headlines t) ;; scale headings in org-mode
;; (setq zenburn-scale-outline-headlines t) ;; scale headings in outline-mode
;; )
#+end_src
* Completion systems
** Vertico (the choosed one)
Have a look [[https://github.com/minad/vertico ][here ]]
#+begin_src emacs-lisp
(use-package vertico
:init
(vertico-mode +1)
:config
;; Different scroll margin
;; (setq vertico-scroll-margin 0)
;; Show more candidates
;; (setq vertico-count 20)
;; Grow and shrink the Vertico minibuffer
;; (setq vertico-resize t)
;; Optionally enable cycling for `vertico-next' and `vertico-previous'.
(setq vertico-cycle t)
)
#+end_src
*** Orderless
Have a look at [[https://github.com/oantolin/orderless ][repo ]]
#+begin_src emacs-lisp
(use-package orderless
:init
(icomplete-mode)
:custom
(completion-styles '(orderless))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles partial-completion))))
)
#+end_src
*** Marginalia
Check the [[https://github.com/minad/marginalia ][doc ]]
#+begin_src emacs-lisp
(use-package marginalia
:init
(marginalia-mode +1)
:bind
(; ("M-A" . marginalia-cycle) ;; Uncomment for global bind
:map minibuffer-local-map
("M-A" . marginalia-cycle))
)
#+end_src
* Consult and Embark
Consult is a collection of programs using emacs =completing-read=
You must read [[https://github.com/minad/consult ][the doc ]]!
#+begin_src emacs-lisp
(use-package consult
:bind (("C-c h" . consult-history)
("C-c m" . consult-mode-command)
("C-c k" . consult-kmacro)
;; C-x bindings (ctl-x-map)
("C-s" . consult-line) ; orig. isearch-forward
("C-c j" . consult-imenu)
("C-x M-:" . consult-complex-command) ; orig. repeat-complex-command
("C-x b" . consult-buffer) ; orig. switch-to-buffer
:map minibuffer-local-map
("C-r" . consult-history)
)
)
#+end_src
** Embark
[[https://github.com/oantolin/embark ][The doc ]]
#+begin_src emacs-lisp
(use-package embark
:bind
(("C-+" . embark-act) ;; pick some comfortable binding
("C-;" . embark-dwim) ;; good alternative: M-.
("C-h B" . embark-bindings)) ;; alternative for `describe-bindings'
:init
;; Optionally replace the key help with a completing-read interface
(setq prefix-help-command #'embark-prefix-help-command)
:config
;; Hide the mode line of the Embark live/completions buffers
(add-to-list 'display-buffer-alist
'("\\`\\*Embark Collect \\(Live\\|Completions\\)\\* "
nil
(window-parameters (mode-line-format . none))))
)
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:after (embark consult)
:demand t ; only necessary if you have the hook below
;; if you want to have consult previews as you move around an
;; auto-updating embark collect buffer
:hook
(embark-collect-mode . consult-preview-at-point-mode))
#+end_src
* Editor Enhancements
** ace-windows
To jump to different windows easily
#+begin_src emacs-lisp
(use-package ace-window
:ensure t
:init
(global-set-key [remap other-window] 'ace-window)
(custom-set-faces
'(aw-leading-char-face
((t (:inherit ace-jump-face-foreground :height 3.0)))))
)
#+end_src
** ripgrep
[[https://github.com/dajva/rg.el ][rg repo ]]
#+begin_src emacs-lisp
(use-package rg
:bind
("C-c s" . rg-menu))
#+end_src
** Buffer management
[[https://github.com/alphapapa/bufler.el ][Bufler repo ]]
#+begin_src emacs-lisp
(use-package bufler
)
(defun slv/bufler-one-window (&optional force-refresh)
(interactive "P")
(bufler-list)
(delete-other-windows)
)
(global-set-key (kbd "C-x C-b") 'slv/bufler-one-window)
#+end_src
** Hydra
[[https://github.com/abo-abo/hydra ][Hydra repo ]]
See [[https://readingworldmagazine.com/emacs/2020-02-27-emacs-hydra-set-up-code/ ][this ]] someday
#+begin_src emacs-lisp
(use-package hydra)
#+end_src
*** Hydra for toggle
#+begin_src emacs-lisp
(global-set-key
(kbd "<f6 > t")
(defhydra hydra-toggle (:color pink)
"
_a_ abbrev-mode: %`abbrev-mode
_d_ debug-on-error: %`debug-on-error
_f_ auto-fill-mode: %`auto-fill-function
_l_ disp-line-num %`display-line-numbers-mode
_s_ flyspell-mode: %`flyspell-mode
_t_ truncate-lines: %`truncate-lines
_w_ whitespace-mode: %`global-whitespace-mode
"
("a" abbrev-mode nil)
("d" toggle-debug-on-error nil)
("f" auto-fill-mode nil)
("l" display-line-numbers-mode nil)
("s" flyspell-mode nil)
("t" toggle-truncate-lines nil)
("w" whitespace-mode nil)
("q" nil "quit"))
)
#+end_src
*** Hydra for navigation
#+begin_src emacs-lisp
(global-set-key
(kbd "<f6 > j")
(defhydra gotoline
(:pre (linum-mode 1)
:post (linum-mode -1))
"goto"
("t" (lambda () (interactive)(move-to-window-line-top-bottom 0)) "top" :column "Window")
("b" (lambda () (interactive)(move-to-window-line-top-bottom -1)) "bottom")
("m" (lambda () (interactive)(move-to-window-line-top-bottom)) "middle")
("c" recenter-top-bottom "recenter")
("s" (lambda () (interactive)(beginning-of-buffer)) "begin" :column "Buffer")
("e" (lambda () (interactive)(end-of-buffer)) "end")
("n" next-line "down" :column "Line")
("p" (lambda () (interactive) (forward-line -1)) "up")
("g" goto-line "consult-goto-line")
("i" consult-imenu "cons-imenu" :column "Header")
("o" consult-org-heading "cons-org-head")
("q" nil "quit")
)
)
#+end_src
** avy
Quick navigation to words
#+begin_src emacs-lisp
(use-package avy
:config
(avy-setup-default)
:bind(
:map own-map
("jj" . avy-goto-char)
("j2" . avy-goto-char-2)
("jw" . avy-goto-word-1)
("jl" . avy-goto-line)
)
)
#+end_src
** iedit
[[https://github.com/victorhge/iedit ][iedit ]]: Interactive edition of all ocurrences of X
#+begin_src emacs-lisp
(use-package iedit
:bind
("C-ç" . iedit-mode))
#+end_src
* Project management with projectile
- [[https://github.com/bbatsov/projectile ][Projectile in github ]]
- [[https://docs.projectile.mx/projectile/index.html ][Online doc ]]
#+begin_src emacs-lisp
(use-package projectile
:init
(projectile-global-mode)
:config
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
)
#+end_src
* perspective
Add some [[https://github.com/nex3/perspective-el ][perspective ]] to emacs
#+begin_src emacs-lisp
(use-package perspective
:init
(persp-mode)
:bind(
:map perspective-map
("b" . persp-switch-to-buffer*)))
#+end_src
* Git management
All you need for git
- [[https://github.com/magit/magit ][magit ]] interface to git from emacs (there are a lot of tutos)
- [[https://github.com/emacsorphanage/git-gutter ][git-gutter ]] See lines changed in buffer edited
- [[https://github.com/emacsmirror/git-timemachine ][git-time-machine ]] Visit previous git versions of edited buffer
#+begin_src emacs-lisp
;; dirty hack to avoid problem when pushing
(setenv "SSH_AUTH_SOCK" "/run/user/1000/keyring/ssh")
(use-package magit
:bind
("C-x g" . magit-status)
:config
(setq magit-status-margin
'(t "%Y-%m-%d %H:%M " magit-log-margin-width t 18))
)
(use-package git-gutter
:init
(global-git-gutter-mode +1)
)
(defhydra hydra-git-gutter (:body-pre (git-gutter-mode 1)
:hint nil)
"
Git gutter:
_j_ : next hunk _s_tage hunk _q_uit
_k_ : previous hunk _r_evert hunk _Q_uit and deactivate git-gutter
^ ^ _p_opup hunk
_h_ : first hunk
_l_ : last hunk set start _R_evision
"
("j" git-gutter:next-hunk)
("k" git-gutter:previous-hunk)
("h" (progn (goto-char (point-min))
(git-gutter:next-hunk 1)))
("l" (progn (goto-char (point-min))
(git-gutter:previous-hunk 1)))
("s" git-gutter:stage-hunk)
("r" git-gutter:revert-hunk)
("p" git-gutter:popup-hunk)
("R" git-gutter:set-start-revision)
("q" nil :color blue)
("Q" (progn (git-gutter-mode -1)
;; git-gutter-fringe doesn't seem to
;; clear the markup right away
(sit-for 0.1)
(git-gutter:clear))
:color blue))
(global-set-key (kbd "M-g M-g") 'hydra-git-gutter/body)
(use-package git-timemachine
)
#+end_src
* yasnippet
- [[https://github.com/joaotavora/yasnippet ][yasnippet ]] (there are many tutorials)
- [[https://github.com/abo-abo/auto-yasnippet ][auto-yasnippet ]] (disposable snippets)
- [[https://github.com/AndreaCrotti/yasnippet-snippets ][yasnippets-snippets ]]
Place your own snippets on =~/.cache/emacs/etc/yasnippet/snippets=
#+begin_src emacs-lisp
(use-package yasnippet
:init
(yas-global-mode 1)
)
(use-package auto-yasnippet
)
(use-package yasnippet-snippets
)
#+end_src
* company
Autocompletion with [[https://company-mode.github.io/ ][company ]]
*Remember* : =company-lsp= is deprecated, don't use it.
#+begin_src emacs-lisp
(use-package company
:init
(global-company-mode t)
;;(setq company-backends '((company-files company-keywords company-capf company-dabbrev-code company-etags company-dabbrev)))
:config
;; (setq company-idle-delay 0)
(setq company-idle-delay
(lambda () (if (company-in-string-or-comment) nil 0.3)))
(setq company-minimum-prefix-length 3)
;; (add-to-list 'company-backends 'company-yasnippet t)
:bind
("C-<iso-lefttab >" . company-complete-common-or-cycle)
)
#+end_src
** company-quickhelp
In case you want popup help instead of status line help
#+begin_src emacs-lisp
(use-package company-quickhelp
:config
(company-quickhelp-mode)
;; (setq company-quickhelp-delay nil) ; Uncoment to disable quickhelp (default 0.5)
)
#+end_src
* org-mode
** org-bullets
Nice bullets for org-mode
#+begin_src emacs-lisp
(use-package org-bullets
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
)
#+end_src
** Fonts for org-mode
This is only a defun will call later
This function:
- Sets the =org-mode= font (Cantarell)
- Sets org-mode headers scaling (Headers sizes)
- Sets mono fonts for code sections in =.org= files
#+begin_src emacs-lisp
(defun slv/org-font-setup ()
(dolist (face '((org-level-1 . 1.2)
(org-level-2 . 1.1)
(org-level-3 . 1.05)
(org-level-4 . 1.0)
(org-level-5 . 1.1)
(org-level-6 . 1.1)
(org-level-7 . 1.1)
(org-level-8 . 1.1)))
(set-face-attribute (car face) nil :font "Cantarell" :weight 'regular :height (cdr face)))
;; Ensure that anything that should be fixed-pitch in Org files appears that way
(set-face-attribute 'org-block nil :foreground nil :inherit 'fixed-pitch)
(set-face-attribute 'org-table nil :inherit 'fixed-pitch)
(set-face-attribute 'org-formula nil :inherit 'fixed-pitch)
(set-face-attribute 'org-code nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-table nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-verbatim nil :inherit '(shadow fixed-pitch))
(set-face-attribute 'org-special-keyword nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-meta-line nil :inherit '(font-lock-comment-face fixed-pitch))
(set-face-attribute 'org-checkbox nil :inherit 'fixed-pitch)
(set-face-attribute 'line-number nil :inherit 'fixed-pitch)
(set-face-attribute 'line-number-current-line nil :inherit 'fixed-pitch)
)
#+end_src
** Some additional tweaks for org-mode
This is only a defun for settings additional details in =org-mode=
- Make rendered LaTeX bigger (use =C-c C-x C-l= to swich the view mode)
#+begin_src emacs-lisp
(defun slv/org-tweaks-setup ()
(plist-put org-format-latex-options :scale 2) ;; Increase size of LaTeX fragment previews
(setq org-startup-indented t
org-pretty-entities t
org-hide-emphasis-markers t
org-startup-with-inline-images t
org-image-actual-width '(300))
)
#+end_src
** org-mode (configuración)
References:
- [[https://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.html ][org-agenda custom commands ]]
- [[https://orgmode.org/worg/org-tutorials/org-custom-agenda-commands.html ][org-custom-agenda commands ]]
Configuring:
- =:hook= section:
- Sets =variable-pitch-mode= on
- Sets =visual-line-mode= on, when using this mode you should avoid using =M-q= (=org-fill-paragraph= ). Just use =enter= to finish a paragraph.
- Call =slv/org-font-setup= function, this function, defined in the section above, sets the fonts for =org-mode= .
- =:custom= section:
- Sets a new =org-elipsis= symbol. This is the symbol to be used instead of =...= for folded sections
- Sets the org files directory (Dropbox for me)
- Sets a sound for =org-clock-sound=
- Sets the default notes file: =i.org=
- Disables =html postamble=
- Disables block execution confirmation for =org-babel=
- Enables default fontification, indenting and folding
- Sets the refile target file =refile= , so far only =Archive.org= , for finished tasks; but we could add more in the future.
- Sets apps for =.html= and =.pdf= (for =org-mode= exported files)
- Sets the **agenda* * options
- Definimos los ficheros de entrada para la agenda
- Definimos vistas /custom/ para la agenda **en Revisión* *
- =c= Vista simple de agenda (Próximos dias y vista de todas las taras =TODO= )
- Definimos /capture templates/ para la captura de entradas en los ficheros =.org=
- Fichero =i.org= o lo que es lo mismo: =org-default-notes-file=
- =p= captura de nuevo proyecto (básicamente una forma de agrupar tareas)
- =t= captura de tarea
- =m= tarea /enviar correo/ va a una sección especial
- =c= tarea compra, va a la sección de compras
- =l= enlace, si no hay tiempo se puede capturar aquí pero *tiene que ir a los blogs*
- =r= referencia, si no hay tiempo se puede capturar aquí pero *tiene que ir a los blogs*
- Fichero =notes.org=
- =n= añadir nota al fichero
- Fichero =b.org= , se supone que captura ideas para el blog público
- =b= añadir entrada al fichero
- Fichero =blog_privado.org= , captura de ideas para el blog privado
- Fichero =events.org=
- Fichero =historiales.org=
- Seccion =:config=
- Añadimos el módulo =org-habit= a la lista =org-modules= , este módulo habilita la visualización especial de los hábitos en las vistas de agenda
- Definimos un /advice/ para garantizar que se salvan todos los ficheros =.org= cada vez que hacemos una operación de /refile/
- Definimos la función =make-capture-frame= y una serie de advices para modificarla. Esta función se define para poder asociar un atajo de teclado del sistema a la captura de tareas de Emacs, funciona pero **pendiente de revisión* *
- Establecemos un factor de escala para la imágenes renderizadas a partir de código LaTeX en el org-mode. Por defecto son demasiado pequeñas
#+begin_src emacs-lisp
(use-package org
:hook
(org-mode . variable-pitch-mode)
(org-mode . visual-line-mode)
(org-mode . slv/org-font-setup)
:custom
(org-ellipsis " ▾")
(org-directory "~/Dropbox/orgfiles") ;; De momento ficheros en Dropbox
(org-clock-sound (concat org-directory "/sound/news-ting.wav"))
(org-default-notes-file (concat org-directory "/i.org")) ;; Fichero de notas por defecto 'I'
(org-export-html-postamble nil) ;; No queremos volcar información en el postamble al exportar html
(org-confirm-babel-evaluate nil)
(org-src-fontify-natively t)
(org-indent-mode t)
(org-startup-indented t)
(org-startup-folded (quote overview))
(org-refile-targets (quote(("~/Dropbox/orgfiles/Archive.org" :maxlevel . 1)
)))
;; org applications for html and pdf files
(org-file-apps
(append '(
("\\.pdf\\'" . "evince %s")
("\\.x?html?\\'" . "/usr/bin/firefox %s")
) org-file-apps )
)
;; Configurando org-agenda
(org-agenda-start-on-weekday nil) ;; La vista de agenda empieza en el dia de hoy
(org-agenda-files (list "~/Dropbox/orgfiles/i.org" ;; Los ficheros con entradas para la agenda
"~/Dropbox/orgfiles/b.org"
"~/Dropbox/orgfiles/notes.org"
"~/Dropbox/orgfiles/historiales.org"
"~/Dropbox/orgfiles/habits.org"
"~/work/repos/Personal/blog/comacero_priv/content-org/blog_privado.org"
;; "~/share/Mob_orgzly/phone.org"
))
;;--------------------------------------------------
;; Vistas de la agenda
(org-agenda-custom-commands
'(
("c" "Simple agenda view"
((agenda "")
(alltodo "")))
("d" "Dashboard"
((agenda "" ((org-deadline-warning-days 7)))
(todo "NEXT"
((org-agenda-overriding-header "Next Tasks")))
(todo "PROJ" ((org-agenda-overriding-header "Active Projects")))))
("n" "Next Tasks"
((todo "NEXT"
((org-agenda-overriding-header "Next Tasks"))))
)
("r" "Test queries" tags "errand"
((org-agenda-files '("~/Dropbox/orgfiles/i.org"))
(org-agenda-sorting-strategy '(priority-up effort-down))
)
)
("w" "Workflow Status"
((todo "WAIT"
((org-agenda-overriding-header "Waiting on External")
(org-agenda-files org-agenda-files)))
(todo "REVIEW"
((org-agenda-overriding-header "In Review")
(org-agenda-files org-agenda-files)))
(todo "PLAN"
((org-agenda-overriding-header "In Planning")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "BACKLOG"
((org-agenda-overriding-header "Project Backlog")
(org-agenda-todo-list-sublevels nil)
(org-agenda-files org-agenda-files)))
(todo "READY"
((org-agenda-overriding-header "Ready for Work")
(org-agenda-files org-agenda-files)))
(todo "ACTIVE"
((org-agenda-overriding-header "Active Projects")
(org-agenda-files org-agenda-files)))
(todo "COMPLETED"
((org-agenda-overriding-header "Completed Projects")
(org-agenda-files org-agenda-files))))
)
)
)
;;--------------------------------------------------
;; org-capture-templates definitions
(org-capture-templates
'(
;;--------------------
("p" "Proyecto" entry (file+headline org-default-notes-file "Proyectos")
"* %^{Descripcion} %^g\n%?"
:prepend t
:empty-lines 1)
;;--------------------
("t" "Tarea" entry (file+headline org-default-notes-file "Tareas")
"* TODO %^u %^{Descripcion} %^g
:PROPERTIES:
:Effort: %^{effort|1:00|0:05|0:15|0:30|2:00|4:00}
:Beat: %^{beat|Now|ASAP|SDM}
:END:\n %?"
:prepend t)
;;--------------------
("m" "Tarea Mail" entry (file+olp org-default-notes-file "Tareas" "Correos")
"* TODO %^{Descripcion}\n:PROPERTIES:\n:Plat: %^{plat|gmail|proton|tuta}\n:Effort: %^{effort|1:00|0:05|0:15|0:30|2:00|4:00}\n:END:\nCapturado %<%Y-%m-%d %H:%M >"
:prepend t)
;;--------------------
("c" "Compra" entry (file+headline org-default-notes-file "Compras")
"* TODO %^{Descripcion} %?\n:PROPERTIES:\n:Plat: %^{plat|unk|aliexpress|amazon|ebay}\n:Precio: %^{precio|20|50|100|200|500}\n:END:\n%<%Y-%m-%d >"
:prepend t
:empty-lines 1)
;;--------------------
("r" "Referencia" entry (file+headline org-default-notes-file "Referencias")
"* %^{Descripcion} %^g\n%?"
:prepend t
:empty-lines 1)
;;--------------------
("l" "Enlace" entry (file+headline org-default-notes-file "Enlaces")
"* [[%^{link} ][%^{Descripcion} ]]"
:prepend t)
;;--------------------
("n" "Nota" entry (file+headline "~/Dropbox/orgfiles/notes.org" "Notas")
"* %^{Descripcion} %u %^g\n%? "
:prepend t
:empty-lines 1)
;;--------------------
("s" "Slip Box" entry (file+headline "~/Dropbox/orgfiles/notes.org" "Slipbox")
"* %^{Descripcion} %u %^g\n%? "
:prepend t
:empty-lines 1)
;;--------------------
("b" "Blog Publico" entry (file+headline "~/Dropbox/orgfiles/b.org" "Pendiente")
"* TODO %^{Tareas} %^g
:PROPERTIES:
:EXPORT_FILE_NAME: %^{mdFilename}
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :summary %^{summary}
:END:
Capturado %<%Y-%m-%d %H:%M >\n%^{cuerpo}"
:empty-lines 1)
;;--------------------
("s" "Blog Privado" entry (file+headline "~/work/repos/Personal/blog/comacero_priv/content-org/blog_privado.org" "Pendiente")
"* TODO %^{Tareas} %^g
:PROPERTIES:
:EXPORT_FILE_NAME: %^{mdFilename}
:EXPORT_HUGO_CUSTOM_FRONT_MATTER: :summary %^{summary}
:END:
Capturado %<%Y-%m-%d %H:%M >\n%^{cuerpo}"
:empty-lines 1)
))
:config
;; add modules to org-modules
(add-to-list 'org-modules 'org-habit t) ;; Add org-habit for habit visualization in agenda views
(advice-add 'org-refile :after 'org-save-all-org-buffers) ;; save all org buffers after every refile operation
;;------------------------------------------
;; No tengo claro como funcionan exactamente los siguientes advices
;; Creo que se añaden para redefinir el comportamiento de la
;; captura de tareas definida en 'make-capture-frame'
(defadvice org-capture-finalize
(after delete-capture-frame activate)
"Advise capture-finalize to close the frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame))
)
(defadvice org-capture-destroy
(after delete-capture-frame activate)
"Advise capture-destroy to close the frame"
(if (equal "capture" (frame-parameter nil 'name))
(delete-frame))
)
(use-package noflet
:ensure t )
;;------------------------------
;; Define a global key on your system to emacsclient -ne "(make-capture-frame)"
(defun make-capture-frame ()
"Create a new frame and run org-capture."
(interactive)
(make-frame '((name . "capture")))
(select-frame-by-name "capture")
(delete-other-windows)
(noflet ((switch-to-buffer-other-window (buf) (switch-to-buffer buf)))
(org-capture))
)
;;-----------------------------
;; Scale up LaTeX rendered images
(plist-put org-format-latex-options :scale 4)
:bind
("\C-ca" . 'org-agenda)
("\C-cc" . 'org-capture)
)
#+end_src
** org-wild-notifier
Notifications
#+begin_src emacs-lisp
(use-package org-wild-notifier
:after org
:custom
(org-wild-notifier-notification-title "Org Wild Reminder")
(org-wild-notifier-alert-time (quote(1 10 30)))
(alert-default-style 'libnotify)
:config
(org-wild-notifier-mode 1)
)
#+end_src
** Hydra for some org-mode stuff
#+begin_src emacs-lisp
(global-set-key
(kbd "<f6 > o")
(defhydra hydra-global-org (:color blue
:hint nil)
"
^Timer^ ^Tasks Time^ ^Capture^
------------------ ---------------- ------------------
_t_ : Start _w_ : Clock-In _c_ : Capture
_s_ : Stop _o_ : Clock-Out _l_ : Last Capture
_r_ : Countdown _j_ : Clock-goto
_p_ : Insert Count
_q_ : quit
"
("t" org-timer-start)
("s" org-timer-stop)
("r" org-timer-set-timer) ; This one requires you be in an orgmode doc, as it sets the timer for the header
("p" org-timer) ; output timer value to buffer
("w" (org-clock-in)) ; used with (org-clock-persistence-insinuate) (setq org-clock-persist t)
("o" org-clock-out) ; you might also want (setq org-log-note-clock-out t)
("j" org-clock-goto) ; global visit the clocked task
("c" org-capture) ; Don't forget to define the captures you want http://orgmode.org/manual/Capture.html
("l" org-capture-goto-last-stored)
("q" nil))
)
#+end_src
** org-babel
#+begin_src emacs-lisp
(org-babel-do-load-languages
'org-babel-load-languages
'((python . t)
(emacs-lisp . t)
(shell . t)
(C . t)
(js . t)
(ditaa . t)
(dot . t)
(org . t)
(latex . t )
)
)
#+end_src
** ox-reveal (reveal.js)
See doc in [[https://github.com/yjwen/org-reveal/ ][org-reveal github ]]
Tenemos dos opciones para el =reveal.js= :
- Podemos descargarlo en nuestro sistema y acceder a la copia local
=git clone https://github.com/yjwen/org-reveal.git=
=(setq org-reveal-root "file:///d:/reveal.js")=
- Podemos hacer referencia a la versión online
=(setq org-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.6.0/")=
#+begin_src emacs-lisp
(use-package ox-reveal
:after ox
:custom
(org-reveal-root "https://cdn.jsdelivr.net/reveal.js/3.6.0/ ")
(org-reveal-mathjax t)
;(org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")
)
(use-package htmlize
:after ox)
#+end_src
** ox-hugo
- [[https://ox-hugo.scripter.co/ ][Documentation ]]
- [[https://www.kengrimes.com/ox-hugo-tutorial/ ][ox-hugo tutorial ]] by kengrimes
#+begin_src emacs-lisp
(use-package ox-hugo
:after ox)
#+end_src
** org-ql
See the [[https://github.com/alphapapa/org-ql ][github ]]
#+begin_src emacs-lisp
(use-package org-ql
:after org)
#+end_src
** org-roam
Zettelkästen on emacs (It’ s a roam translation into org-mode) Remember
you must have graphviz and sqlite3 installed in your system, dot
command and sqlite3 must be available
- [[https://www.orgroam.com/manual.html#Top ][org-roam user manual ]]
- [[https://github.com/org-roam/org-roam/wiki/Hitchhiker's-Rough-Guide-to-Org-roam-V2 ][Hitchhiker's Rough Guide to Org roam V2 ]]
- [[https://jethrokuan.github.io/org-roam-guide/ ][How I take notes... ]] (by Jethrokuan)
#+begin_src emacs-lisp
(use-package org-roam
:after org
:init
(setq org-roam-v2-ack t)
:custom
(org-roam-directory (concat org-directory "/roam"))
(org-roam-capture-templates
'(("m" "main" plain
"%?"
:if-new (file+head "main/${slug}.org"
"#+title: ${title}\n")
:immediate-finish t
:unnarrowed t)
("r" "reference" plain "%?"
:if-new
(file+head "reference/${title}.org" "#+title: ${title}\n")
:immediate-finish t
:unnarrowed t)
("a" "article" plain "%?"
:if-new
(file+head "articles/${title}.org" "#+title: ${title}\n#+filetags: :article:\n")
:immediate-finish t
:unnarrowed t)))
:config
(org-roam-setup)
(cl-defmethod org-roam-node-type ((node org-roam-node))
"Return the TYPE of NODE."
(condition-case nil
(file-name-nondirectory
(directory-file-name
(file-name-directory
(file-relative-name (org-roam-node-file node) org-roam-directory))))
(error "")))
(setq org-roam-node-display-template
(concat "${type:15} ${title:*}"
(propertize "${tags:10}" 'face 'org-tag)))
:bind (("C-c n f" . org-roam-node-find)
("C-c n g" . org-roam-graph)
("C-c n r" . org-roam-node-random)
(:map org-mode-map
(("C-c n i" . org-roam-node-insert)
("C-c n o" . org-id-get-create)
("C-c n t" . org-roam-tag-add)
("C-c n a" . org-roam-alias-add)
("C-c n l" . org-roam-buffer-toggle))))
)
#+end_src
*** consult-org-roam
This is a small collection of functions to operate org-roam with the help of consult and its live preview feature.
Have a look at [[https://github.com/jgru/consult-org-roam ][the project in github ]].
#+begin_src emacs-lisp
(use-package consult-org-roam
:after org-roam
:straight (:host github :repo "jgru/consult-org-roam")
:init
(require 'consult-org-roam)
;; Activate the minor-mode
(consult-org-roam-mode 1)
:custom
(consult-org-roam-grep-func #'consult-ripgrep)
:config
;; Eventually suppress previewing for certain functions
(consult-customize
consult-org-roam-forward-links
:preview-key (kbd "M-."))
:bind
("C-c n e" . consult-org-roam-file-find)
("C-c n b" . consult-org-roam-backlinks)
("C-c n z" . consult-org-roam-search))
#+end_src
* Cites and references
** calibredb
- [[https://github.com/chenyanming/calibredb.el ][Check github ]]
- Check Virtual Libraries
- Check commands binding
#+begin_src emacs-lisp
(use-package calibredb
:defer t
:config
(setq calibredb-root-dir "~/Biblioteca")
(setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
(setq calibredb-library-alist '(("~/Biblioteca"))))
#+end_src
** Citar
- [[https://github.com/bdarcus/citar ][Citar github ]]
#+begin_src emacs-lisp
(use-package citar
:bind (("C-c b" . citar-insert-citation)
:map minibuffer-local-map
("M-b" . citar-insert-preset))
:custom
(citar-bibliography '("~/Dropbox/bib/references.bib")))
#+end_src
* flycheck
Syntax checking for programming languages
You *must* use [[https://www.flycheck.org/en/latest/ ][flycheck ]] if you use LSP. (Flymake + LSP is hell)
#+begin_src emacs-lisp
(use-package flycheck
:config
(global-set-key (kbd "C-c f p") 'flycheck-previous-error)
(global-set-key (kbd "C-c f n") 'flycheck-next-error)
:init
(global-flycheck-mode t)
)
#+end_src
* LSP
We are using [[https://emacs-lsp.github.io/lsp-mode/ ][lsp-mode ]] but keep an eye on [[https://github.com/joaotavora/eglot ][eglot ]] as an alternative.
**WARNING* *: =lsp-company= is no longer supported
Links to check
- [[https://emacs-lsp.github.io/lsp-mode/ ][LSP-mode Home ]]
- [[https://tychoish.com/post/emacs-and-lsp-mode/ ][Tychoist: Emacs and LSP mode ]]
- [[https://vxlabs.com/2018/11/19/configuring-emacs-lsp-mode-and-microsofts-visual-studio-code-python-language-server/ ][MS lsp server with python ]]
- [[https://www.mattduck.com/lsp-python-getting-started.html ][Getting started with lsp-mode for Python ]] (good)
- [[https://www.mortens.dev/blog/emacs-and-the-language-server-protocol/ ][C++, Python, Rust ]]
- [[https://ddavis.io/posts/emacs-python-lsp/ ][Python IDE with LSP and pyenv ]] (good)
- [[https://github.com/pythonic-emacs/pyenv-mode ][pyenv-mode ]]
- [[https://www.mortens.dev/blog/emacs-and-the-language-server-protocol/ ][Morten's Dev ]] (tiene buena pinta)
- [[https://mullikine.github.io/posts/setting-up-lsp-with-emacs-attempt-2/ ][Bodacious Blog ]] (parece muy completo pero algo criptico)
- [[https://gitlab.com/nathanfurnal/dotemacs/-/snippets/2060535 ][Nathan Furnal Guide ]]
- [[https://emacs-lsp.github.io/lsp-mode/tutorials/how-to-turn-off/ ][A visual guide to LSP mode ]]
LSP mode, allows the use of Language Server Protocol for programming.
**lsp-keymap prefix remapped to "C-c l"* *
#+begin_src emacs-lisp
(use-package lsp-mode
:init
(setq lsp-keymap-prefix "C-c l")
:commands
(lsp lsp-deferred lsp-execute-code-action)
:custom
;; debug
;; set these variables for debugging lsp-mode
(lsp-print-io t)
(lsp-trace t)
(lsp-print-performance t)
;; general
;; (lsp-auto-guess-root t) ;; Probably you want to choose root interactively
;; (lsp-document-sync-method 'incremental) ;; none, full, incremental, or nil
;; (lsp-response-timeout 10)
;; let's use flycheck
(lsp-prefer-flymake nil) ;; t(flymake), nil(lsp-ui), or :none
;; (company-lsp-cache-candidates t) ;; auto, ;TODO: (always using a cache), or nil
;; (company-lsp-async t)
;; (company-lsp-enable-recompletion t)
;; (company-lsp-enable-snippet t)
;; (lsp-eldoc-render-all nil)
;; :hook
;; ((python-mode . lsp-deferred)
;; (lsp-mode . lsp-enable-which-key-integration)
;; (lsp-mode . lsp-diagnostics-modeline-mode))
;; :bind
;; ("C-c C-c" . #'lsp-execute-code-action)
;; :custom
;; (lsp-diagnostics-modeline-scope :project)
;; (lsp-file-watch-threshold 5000)
;; (lsp-enable-file-watchers nil)
;; ;(lsp-enable-which-key-integration t)
)
#+end_src
** lsp-ui
- You have to see the [[https://emacs-lsp.github.io/lsp-ui/ ][lsp-ui doc ]]
#+begin_src emacs-lisp
(use-package lsp-ui
:custom
(lsp-ui-doc-delay 0.75)
(lsp-ui-doc-max-height 200)
(lsp-ui-doc-enable t)
(lsp-ui-doc-header t)
(lsp-ui-doc-include-signature t)
(lsp-ui-doc-max-height 30)
(lsp-ui-doc-max-width 120)
(lsp-ui-doc-position (quote at-point))
(lsp-ui-doc-use-childframe t)
;;
;; ;; If this is true then you can't see the docs in terminal
;; (lsp-ui-doc-use-webkit nil)
(lsp-ui-flycheck-enable t)
;;
;; (lsp-ui-imenu-enable t)
;; (lsp-ui-imenu-kind-position (quote top))
(lsp-ui-peek-enable t)
(lsp-ui-peek-fontify 'on-demand) ;; never, on-demand, or always
(lsp-ui-peek-list-width 50)
(lsp-ui-peek-peek-height 20)
(lsp-ui-sideline-code-actions-prefix "" t)
;;
;; ;inline right flush docs
(lsp-ui-sideline-enable t)
(lsp-ui-sideline-ignore-duplicate t)
(lsp-ui-sideline-show-code-actions t)
(lsp-ui-sideline-show-diagnostics t)
(lsp-ui-sideline-show-hover t)
(lsp-ui-sideline-show-symbol t)
:after lsp-mode)
#+end_src
** lsp-treemacs
Try these commands with M-x:
- =lsp-treemacs-symbols= - Show a tree view of the symbols in the
current file
- =lsp-treemacs-references= - Show a tree view for the references of
the symbol under the cursor
- =lsp-treemacs-error-list= - Show a tree view for the diagnostic
messages in the project
#+begin_src emacs-lisp
(use-package lsp-treemacs
:after lsp)
#+end_src
** DAP mode
[[https://emacs-lsp.github.io/dap-mode/ ][DAP-mode ]] is an excellent package for bringing rich debugging
capabilities to Emacs via the Debug Adapter Protocol. You should check
out the [[https://emacs-lsp.github.io/dap-mode/page/configuration/ ][configuration docs ]] to learn how to configure the debugger for
your language. Also make sure to check out the documentation for the
debug adapter to see what configuration parameters are available to
use for your debug templates!
#+begin_src emacs-lisp
;; (use-package dap-mode
;; ;; Uncomment the config below if you want all UI panes to be hidden by default!
;; ;; :custom
;; ;; (lsp-enable-dap-auto-configure nil)
;; ;; :config
;; ;; (dap-ui-mode 1)
;; :config
;; ;; Set up Node debugging
;; (require 'dap-node)
;; (dap-node-setup) ;; Automatically installs Node debug adapter if needed
;;
;; ;; Bind `C-c l d` to `dap-hydra` for easy access
;; ;;(general-define-key
;; ;; :keymaps 'lsp-mode-map
;; ;; :prefix lsp-keymap-prefix
;; ;; "d" '(dap-hydra t :wk "debugger"))
;; )
#+end_src
** go
**WARNING* *: you need to install =gopls= in your system.
**WARNING* *: =company-go= is deprecated, don't use it
References:
- [[https://kasperdeng.github.io/2015/04/15/go-dev-env/ ][kasperdeng golang development enviroment ]]
- [[https://github.com/golang/tools/tree/master/gopls ][gopls repo ]]
- [[https://gist.github.com/psanford/b5d2689ff1565ec7e46867245e3d2c76 ][psandford/gopls configuration ]]
#+begin_src emacs-lisp
(use-package go-mode
:after lsp
:custom
;; (lsp-enable-links nil)
;; (lsp-clients-go-server-args '("--cache-style=always" "--diagnostics-style=onsave" "--format-style=goimports"))
(lsp-gopls-server-args '("--debug=localhost:6060"))
(lsp-gopls-staticcheck t)
;; (lsp-gopls-complete-unimported t)
:hook
((go-mode . lsp-deferred)
(before-save . lsp-format-buffer)
(before-save . lsp-organize-imports)
(before-save . gofmt-before-save)
)
)
#+end_src
*** go-snippets
#+begin_src emacs-lisp
(use-package go-snippets
:after go-mode
)
#+end_src
*** go-projectile
- [[https://github.com/dougm/go-projectile ][The repo ]]
#+begin_src emacs-lisp
;; (use-package go-projectile
;; :after go-mode)
#+end_src
*** go-test
#+begin_src emacs-lisp
(use-package gotest
:bind
(:map go-mode-map
("C-c a t" . #'go-test-current-test)
)
:after go-mode
)
#+end_src
** Rust
- [[https://robert.kra.hn/posts/2021-02-07_rust-with-emacs/ ][Robert Kra Emacs Rust Configuration ]]
#+begin_src emacs-lisp
(use-package rust-mode
:hook ((rust-mode . lsp)
(rust-mode . lsp-lens-mode)
)
:custom
(rust-format-on-save t)
(lsp-rust-server 'rust-analyzer))
#+end_src
** Python
We do need a Python language server installed in the developing enviroment (=pip install python-lsp-server[all]= )
- https://www.mattduck.com/lsp-python-getting-started.html
- https://www.mortens.dev/blog/emacs-and-the-language-server-protocol/index.html
- https://www.reddit.com/r/emacs/comments/ijmgtx/tip_how_to_use_a_stable_and_fast_environment_to/g3kmc7o/
*** Use latest python
Not needed if you have the right settings on your active python with =pyenv=
#+begin_src emacs-lisp
; (setq python-shell-interpreter "/usr/bin/python3.8")
; (setq py-python-command "/usr/bin/python3.8") ; maybe not needed
; (setq python-python-command "/usr/bin/python3.8") ; maybe not needed
#+end_src
*** Configure python mode
#+begin_src emacs-lisp
(use-package python-mode
:straight nil
:hook (python-mode . lsp-deferred)
;; :custom
;; (dap-python-debugger 'debugpy)
;;
;;;;; NOTE: Set these if Python 3 is called "python3" on your system!
;;;; (python-shell-interpreter "python3")
;;;; (dap-python-executable "python3")
:config
;; (require 'dap-python)
)
#+end_src
*** pyenv
Estoy cambiando de virtualenv a pyenv
Usamos =pyenv= para gestionar los /virtualenv/
- https://github.com/aiguofer/pyenv.el
- https://github.com/pythonic-emacs/pyenv-mode
- https://www.reddit.com/r/emacs/comments/ijmgtx/tip_how_to_use_a_stable_and_fast_environment_to/
#+begin_src emacs-lisp
(use-package pyenv-mode
:after python
:init
(add-to-list 'exec-path "~/.pyenv/shims")
(add-to-list 'exec-path "~/.pyenv/bin")
(setenv "WORKON_HOME" "~/.pyenv/versions/ ")
(defun projectile-pyenv-mode-set ()
"Set pyenv version matching project name."
(let ((project (projectile-project-name)))
(if (member project (pyenv-mode-versions))
(pyenv-mode-set project)
(pyenv-mode-unset))))
:config
(pyenv-mode)
:hook ((python-mode . pyenv-mode)
(projectile-switch-project . projectile-pyenv-mode-set)
)
:bind
("C-x p e" . pyenv-activate-current-project))
#+end_src
* Markdown
- [[https://leanpub.com/markdown-mode/read#intro ][Guide to Emacs Markdown mode ]]
- [[https://joostkremers.github.io/pandoc-mode/ ][Pandoc Mode Doc ]]
#+begin_src emacs-lisp
(use-package markdown-mode
:init (setq markdown-command "multimarkdown")
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode)
("\\.pdc\\'" . markdown-mode)
)
)
(use-package pandoc-mode
)
#+end_src
* Docker
#+begin_src emacs-lisp
(use-package dockerfile-mode
:config
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode))
)
(use-package docker-compose-mode
)
#+end_src
* LaTeX
[[https://www.gnu.org/software/auctex/ ][auctex ]] for latex edition
#+begin_src emacs-lisp
(use-package auctex
:mode ("\\.tex\\'" . latex-mode)
:commands (latex-mode LaTeX-mode plain-tex-mode)
:custom
(TeX-auto-save t)
(TeX-parse-self t)
(TeX-save-query nil)
(TeX-PDF-mode t)
:hook
(LaTeX-mode . LaTeX-preview-setup)
(LaTeX-mode . LaTeX-math-mode)
;; (LaTeX-mode . flyspell-mode)
(LaTeX-mode . turn-on-reftex)
)
;; Use company-auctex
(use-package company-auctex
:config
(company-auctex-init)
)
#+end_src
* web mode
- <https://web-mode.org/ >
#+begin_src emacs-lisp
(use-package web-mode
:mode
("\\.html?\\'" . web-mode)
:config
(setq web-mode-enable-auto-closing t)
(setq web-mode-enable-auto-quoting t)
(setq web-mode-enable-auto-pairing t)
:custom
(web-mode-markup-indent-offset 2)
(web-mode-css-indent-offset 2)
(web-mode-code-indent-offset 2)
(web-mode-enable-css-colorization t)
)
#+end_src
** emmet-mode
- [[https://github.com/smihica/emmet-mode ][emmet github ]]
- [[https://cestlaz.github.io/posts/using-emacs-34-ibuffer-emmet/ ][Zemansky and emmet ]]
- [[https://readingworldmagazine.com/emacs/2020-08-08-emacs-emmet-mode-yasnippet/ ][Emmet (a more complex config) ]]
#+begin_src emacs-lisp
(use-package emmet-mode
:after (web-mode css-mode sgml-mode)
:hook
(sgml-mode-hook emmet-mode) ;; Auto-start on any markup modes
(web-mode-hook emmet-mode) ;; Auto-start on any markup modes
(css-mode-hook emmet-mode) ;; enable Emmet's css abbreviation.
:bind
("C-j" . emmet-expand-line)
)
#+end_src
* ess (Emacs Speak Statistics)
You *must* have R installed in your system, otherwise this package is useless.
#+begin_src emacs-lisp
;; (use-package ess
;; :init (require 'ess-site))
#+end_src
* misc packages
** Expand region
#+begin_src emacs-lisp
(use-package expand-region
:straight (
expand-region
:type git
:host github
:repo "magnars/expand-region.el")
:config
(global-set-key (kbd "C-=") 'er/expand-region)
)
#+end_src
** EasyPG and org-crypt
Ver [[https://orgmode.org/worg/org-tutorials/encrypting-files.html ][referencia en org-mode manual ]] y [[http://www.clintonboys.com/gpg/ ][notas de Clintonboys ]]
#+begin_src emacs-lisp
(use-package epa-file
:straight nil
:config
(setq epa-file-encrypt-to '("salvari@protonmail.com"))
:custom
(epa-file-select-keys 'silent))
(use-package org-crypt
:straight nil ;; included with org-mode
:after org
:config
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
:custom
(org-crypt-key "salvari@protonmail.com"))
#+end_src
** Olivetti: distraction-free writing enviroment
#+begin_src emacs-lisp
(use-package olivetti
:init
(setq olivetti-body-width .67)
:config
(defun slv/distraction-free ()
"Distraction-free writing environment"
(interactive)
(if (equal olivetti-mode nil)
(progn
(window-configuration-to-register 1)
(delete-other-windows)
(text-scale-increase 2)
(olivetti-mode t))
(progn
(jump-to-register 1)
(olivetti-mode 0)
(text-scale-decrease 2))))
:bind
(("<f9 >" . slv/distraction-free)))
#+end_src
* elfeed
#+begin_src emacs-lisp
(use-package elfeed
:config
(setq elfeed-db-directory "~/Dropbox/elfeeddb"
elfeed-show-entry-switch 'display-buffer)
:bind
("C-x w" . elfeed )
)
(use-package elfeed-org
:config
(elfeed-org)
(setq rmh-elfeed-org-files (list "~/Dropbox/orgfiles/elfeed.org"))
)
;; (use-package elfeed-goodies
;; :ensure t
;; :config
;; (elfeed-goodies/setup)
;; )
;;
;; :bind (:map elfeed-search-mode-map
;; ("q" . bjm/elfeed-save-db-and-bury)
;; ("Q" . bjm/elfeed-save-db-and-bury)
;; ("m" . elfeed-toggle-star)
;; ("M" . elfeed-toggle-star)
;; ("j" . mz/make-and-run-elfeed-hydra)
;; ("J" . mz/make-and-run-elfeed-hydra)
;; ("b" . mz/elfeed-browse-url)
;; ("B" . elfeed-search-browse-url)
;; )
;; :config
;; (defalias 'elfeed-toggle-star
;; (elfeed-expose #'elfeed-search-toggle-all 'star))
;;
;; )
;;(use-package elfeed-goodies
;; :ensure t
;; :config
;; (elfeed-goodies/setup))
;;
;;
;;
;;
;; (defun mz/elfeed-browse-url (&optional use-generic-p)
;; "Visit the current entry in your browser using `browse-url'.
;; If there is a prefix argument, visit the current entry in the
;; browser defined by `browse-url-generic-program'."
;; (interactive "P")
;; (let ((entries (elfeed-search-selected)))
;; (cl-loop for entry in entries
;; do (if use-generic-p
;; (browse-url-generic (elfeed-entry-link entry))
;; (browse-url (elfeed-entry-link entry))))
;; (mapc #'elfeed-search-update-entry entries)
;; (unless (or elfeed-search-remain-on-entry (use-region-p))
;; ;;(forward-line)
;; )))
;;
;;
;;
;; (defun elfeed-mark-all-as-read ()
;; (interactive)
;; (mark-whole-buffer)
;; (elfeed-search-untag-all-unread))
;;
;;
;; ;;functions to support syncing .elfeed between machines
;; ;;makes sure elfeed reads index from disk before launching
;; (defun bjm/elfeed-load-db-and-open ()
;; "Wrapper to load the elfeed db from disk before opening"
;; (interactive)
;; (elfeed-db-load)
;; (elfeed)
;; (elfeed-search-update--force))
;;
;; ;;write to disk when quiting
;; (defun bjm/elfeed-save-db-and-bury ()
;; "Wrapper to save the elfeed db to disk before burying buffer"
;; (interactive)
;; (elfeed-db-save)
;; (quit-window))
;;(defun z/hasCap (s) ""
;; (let ((case-fold-search nil))
;; (string-match-p "[[:upper: ]]" s)
;; ))
;;
;;
;;(defun z/get-hydra-option-key (s)
;; "returns single upper case letter (converted to lower) or first"
;; (interactive)
;; (let ( (loc (z/hasCap s)))
;; (if loc
;; (downcase (substring s loc (+ loc 1)))
;; (substring s 0 1)
;; )))
;;
;;;; (active blogs cs eDucation emacs local misc sports star tech unread webcomics)
;;(defun mz/make-elfeed-cats (tags)
;; "Returns a list of lists. Each one is line for the hydra configuratio in the form
;; (c function hint)"
;; (interactive)
;; (mapcar (lambda (tag)
;; (let* (
;; (tagstring (symbol-name tag))
;; (c (z/get-hydra-option-key tagstring))
;; )
;; (list c (append '(elfeed-search-set-filter) (list (format "@6-months-ago +%s" tagstring) ))tagstring )))
;; tags))
;;
;;
;;
;;
;;
;;(defmacro mz/make-elfeed-hydra ()
;; `(defhydra mz/hydra-elfeed ()
;; "filter"
;; ,@(mz/make-elfeed-cats (elfeed-db-get-all-tags))
;; ("*" (elfeed-search-set-filter "@6-months-ago +star") "Starred")
;; ("M" elfeed-toggle-star "Mark")
;; ("A" (elfeed-search-set-filter "@6-months-ago") "All")
;; ("T" (elfeed-search-set-filter "@1-day-ago") "Today")
;; ("Q" bjm/elfeed-save-db-and-bury "Quit Elfeed" :color blue)
;; ("q" nil "quit" :color blue)
;; ))
;;
;;
;;
;;
;;(defun mz/make-and-run-elfeed-hydra ()
;; ""
;; (interactive)
;; (mz/make-elfeed-hydra)
;; (mz/hydra-elfeed/body))
;;
;;
;;(defun my-elfeed-tag-sort (a b)
;; (let* ((a-tags (format "%s" (elfeed-entry-tags a)))
;; (b-tags (format "%s" (elfeed-entry-tags b))))
;; (if (string= a-tags b-tags)
;; (< (elfeed-entry-date b) (elfeed-entry-date a)))
;; (string< a-tags b-tags)))
;;
;;
;;(setf elfeed-search-sort-function #'my-elfeed-tag-sort)
;;
#+end_src
* next
#+begin_src emacs-lisp
#+end_src