Commit 116b91209f39
Changed files (5)
config/setup-completion.el
@@ -55,62 +55,6 @@ Otherwise, use `counsel-projectile-switch-project'."
(ivy-mode 1))
))
-(use-package ivy-hydra ; Additional bindings for Ivy
- :after ivy)
-
-(use-package ivy-rich
- :after ivy
- :custom
- (ivy-virtual-abbreviate 'full
- ivy-rich-switch-buffer-align-virtual-buffer t
- ivy-rich-path-style 'abbrev)
- :config (ivy-rich-mode 1))
-
-(use-package prescient
- :custom
- (prescient-history-length 50)
- ;; (prescient-save-file "~/.emacs.d/prescient-items")
- (prescient-filter-method '(fuzzy initialism regexp))
- :config
- (prescient-persist-mode 1))
-
-;;; Default rg arguments
-;; https://github.com/BurntSushi/ripgrep
-(defconst vde/rg-arguments
- `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore'
- "--line-number" ;Line numbers
- "--smart-case"
- "--max-columns" "150" ;Emacs doesn't handle long line lengths very well
- "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME")))
- "Default rg arguments used in the functions in `counsel' and `projectile' packages.")
-
-(use-package ivy-prescient
- :after (prescient ivy)
- :custom
- (ivy-prescient-sort-commands
- '(:not swiper ivy-switch-buffer counsel-switch-buffer))
- (ivy-prescient-retain-classic-highlighting t)
- (ivy-prescient-enable-filtering t)
- (ivy-prescient-enable-sorting t)
- :config
- (defun prot/ivy-prescient-filters (str)
- "Specify an exception for `prescient-filter-method'.
-
-This new rule can be used to tailor the results of individual
-Ivy-powered commands, using `ivy-prescient-re-builder'."
- (let ((prescient-filter-method '(literal regexp)))
- (ivy-prescient-re-builder str)))
-
- (setq ivy-re-builders-alist
- '((counsel-rg . prot/ivy-prescient-filters)
- (counsel-grep . prot/ivy-prescient-filters)
- (counsel-yank-pop . prot/ivy-prescient-filters)
- (swiper . prot/ivy-prescient-filters)
- (swiper-isearch . prot/ivy-prescient-filters)
- (swiper-all . prot/ivy-prescient-filters)
- (t . ivy-prescient-re-builder)))
- (ivy-prescient-mode 1))
-
(use-package counsel
:after ivy
:custom
@@ -235,6 +179,7 @@ repository, then the corresponding root is used instead."
;https://github.com/abo-abo/swiper/issues/427
))))
+
(use-package company
:commands global-company-mode
:init
@@ -269,115 +214,174 @@ repository, then the corresponding root is used instead."
company-etags
company-keywords)))
-(use-package company-prescient
- :ensure company
- :after (company prescient)
- :config
- (company-prescient-mode 1))
+;;; Default rg arguments
+;; https://github.com/BurntSushi/ripgrep
+(defconst vde/rg-arguments
+ `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore'
+ "--line-number" ;Line numbers
+ "--smart-case"
+ "--max-columns" "150" ;Emacs doesn't handle long line lengths very well
+ "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME")))
+ "Default rg arguments used in the functions in `counsel' and `projectile' packages.")
-(use-package company-emoji
- :ensure company
- :config
- (add-to-list 'company-backends 'company-emoji))
-(use-package lsp-mode
- :commands (lsp lsp-deferred)
- :custom
- (lsp-enable-file-watchers nil)
- (lsp-gopls-staticcheck t)
- (lsp-gopls-complete-unimported t)
- (lsp-eldoc-render-all nil)
- (lsp-enable-snippet nil)
- (lsp-enable-links nil)
- (lsp-enable-folding nil)
- (lsp-enable-completion-at-point nil) ;; company-lsp takes care of it ?
- (lsp-diagnostic-package :none)
- (lsp-restart 'auto-restart)
- (lsp-ui-sideline-enable nil)
- (lsp-ui-sideline-show-hover nil)
- (lsp-ui-sideline-delay 2.0)
- (lsp-ui-doc-enable nil)
- (lsp-ui-doc-max-width 30)
- (lsp-ui-doc-max-height 15)
- (lsp-document-highlight-delay 2.0)
- (lsp-auto-guess-root t)
- (lsp-ui-flycheck-enable nil)
- ;; @see https://github.com/emacs-lsp/lsp-mode/pull/1498
- ;; and read code related to auto configure
- ;; require clients could be slow and that's only thing auto configure
- ;; could do for me. Manual loading of client is faster.
- (lsp-auto-configure nil)
- (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
- :config
- ;; don't ping LSP lanaguage server too frequently
- (defvar lsp-on-touch-time 0)
- (defadvice lsp-on-change (around lsp-on-change-hack activate)
- ;; don't run `lsp-on-change' too frequently
- (when (> (- (float-time (current-time))
- lsp-on-touch-time) 30) ;; 30 seconds
- (setq lsp-on-touch-time (float-time (current-time)))
- ad-do-it))
- :hook ((go-mode . lsp-deferred)
- (python-mode . lsp-deferred)))
+(if *sys/full*
+ (progn
+ (use-package ivy-rich
+ :after ivy
+ :custom
+ (ivy-virtual-abbreviate 'full
+ ivy-rich-switch-buffer-align-virtual-buffer t
+ ivy-rich-path-style 'abbrev)
+ :config (ivy-rich-mode 1))
-;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
-;; https://github.com/emacs-lsp/lsp-ui
-(use-package lsp-ui
- :after lsp-mode
- ;;:hook ((lsp-mode . lsp-ui-mode)
- ;; (lsp-ui-mode . lsp-ui-peek-mode))
- :config
- (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
- (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
+ (use-package prescient
+ :custom
+ (prescient-history-length 50)
+ ;; (prescient-save-file "~/.emacs.d/prescient-items")
+ (prescient-filter-method '(fuzzy initialism regexp))
+ :config
+ (prescient-persist-mode 1))
-;;Set up before-save hooks to format buffer and add/delete imports.
-;;Make sure you don't have other gofmt/goimports hooks enabled.
-(defun lsp-go-install-save-hooks ()
- (add-hook 'before-save-hook #'lsp-format-buffer t t)
- (add-hook 'before-save-hook #'lsp-organize-imports t t))
-(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
-(with-eval-after-load "company"
- (use-package company-lsp
- :after lsp-mode
- :config
- (push 'company-lsp company-backends)))
+ (use-package ivy-prescient
+ :after (prescient ivy)
+ :custom
+ (ivy-prescient-sort-commands
+ '(:not swiper ivy-switch-buffer counsel-switch-buffer))
+ (ivy-prescient-retain-classic-highlighting t)
+ (ivy-prescient-enable-filtering t)
+ (ivy-prescient-enable-sorting t)
+ :config
+ (defun prot/ivy-prescient-filters (str)
+ "Specify an exception for `prescient-filter-method'.
-(with-eval-after-load "projectile"
- (defun my-set-projectile-root ()
- (when lsp--cur-workspace
- (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
- (add-hook 'lsp-before-open-hook #'my-set-projectile-root))
+This new rule can be used to tailor the results of individual
+Ivy-powered commands, using `ivy-prescient-re-builder'."
+ (let ((prescient-filter-method '(literal regexp)))
+ (ivy-prescient-re-builder str)))
-(use-package dap-mode
- :after lsp-mode
- :bind (:map dap-mode-map
- ([f9] . dap-debug)
- ;; ([f9] . dap-continue)
- ;; ([S-f9] . dap-disconnect)
- ;; ([f10] . dap-next)
- ;; ([f11] . dap-step-in)
- ;; ([S-f11] . dap-step-out)
- ([C-f9] . dap-hide/show-ui))
- :hook (dap-stopped-hook . (lambda (arg) (call-interactively #'dap-hydra)))
- :config
- ;; FIXME: Create nice solution instead of a hack
- (defvar dap-hide/show-ui-hidden? t)
- (defun dap-hide/show-ui ()
- "Hide/show dap ui. FIXME"
- (interactive)
- (if dap-hide/show-ui-hidden?
- (progn
- (setq dap-hide/show-ui-hidden? nil)
- (dap-ui-locals)
- (dap-ui-repl))
- (dolist (buf '("*dap-ui-inspect*" "*dap-ui-locals*" "*dap-ui-repl*" "*dap-ui-sessions*"))
- (when (get-buffer buf)
- (kill-buffer buf)))
- (setq dap-hide/show-ui-hidden? t)))
+ (setq ivy-re-builders-alist
+ '((counsel-rg . prot/ivy-prescient-filters)
+ (counsel-grep . prot/ivy-prescient-filters)
+ (counsel-yank-pop . prot/ivy-prescient-filters)
+ (swiper . prot/ivy-prescient-filters)
+ (swiper-isearch . prot/ivy-prescient-filters)
+ (swiper-all . prot/ivy-prescient-filters)
+ (t . ivy-prescient-re-builder)))
+ (ivy-prescient-mode 1))
- (dap-mode)
- (dap-ui-mode)
- (dap-tooltip-mode))
+ (use-package company-prescient
+ :ensure company
+ :after (company prescient)
+ :config
+ (company-prescient-mode 1))
+
+ (use-package company-emoji
+ :ensure company
+ :config
+ (add-to-list 'company-backends 'company-emoji))
+
+ (use-package lsp-mode
+ :commands (lsp lsp-deferred)
+ :custom
+ (lsp-enable-file-watchers nil)
+ (lsp-gopls-staticcheck t)
+ (lsp-gopls-complete-unimported t)
+ (lsp-eldoc-render-all nil)
+ (lsp-enable-snippet nil)
+ (lsp-enable-links nil)
+ (lsp-enable-folding nil)
+ (lsp-enable-completion-at-point nil) ;; company-lsp takes care of it ?
+ (lsp-diagnostic-package :none)
+ (lsp-restart 'auto-restart)
+ (lsp-ui-sideline-enable nil)
+ (lsp-ui-sideline-show-hover nil)
+ (lsp-ui-sideline-delay 2.0)
+ (lsp-ui-doc-enable nil)
+ (lsp-ui-doc-max-width 30)
+ (lsp-ui-doc-max-height 15)
+ (lsp-document-highlight-delay 2.0)
+ (lsp-auto-guess-root t)
+ (lsp-ui-flycheck-enable nil)
+ ;; @see https://github.com/emacs-lsp/lsp-mode/pull/1498
+ ;; and read code related to auto configure
+ ;; require clients could be slow and that's only thing auto configure
+ ;; could do for me. Manual loading of client is faster.
+ (lsp-auto-configure nil)
+ (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
+ :config
+ ;; don't ping LSP lanaguage server too frequently
+ (defvar lsp-on-touch-time 0)
+ (defadvice lsp-on-change (around lsp-on-change-hack activate)
+ ;; don't run `lsp-on-change' too frequently
+ (when (> (- (float-time (current-time))
+ lsp-on-touch-time) 30) ;; 30 seconds
+ (setq lsp-on-touch-time (float-time (current-time)))
+ ad-do-it))
+ :hook ((go-mode . lsp-deferred)
+ (python-mode . lsp-deferred)))
+
+ ;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
+ ;; https://github.com/emacs-lsp/lsp-ui
+ (use-package lsp-ui
+ :after lsp-mode
+ ;;:hook ((lsp-mode . lsp-ui-mode)
+ ;; (lsp-ui-mode . lsp-ui-peek-mode))
+ :config
+ (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
+ (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
+
+ ;;Set up before-save hooks to format buffer and add/delete imports.
+ ;;Make sure you don't have other gofmt/goimports hooks enabled.
+ (defun lsp-go-install-save-hooks ()
+ (add-hook 'before-save-hook #'lsp-format-buffer t t)
+ (add-hook 'before-save-hook #'lsp-organize-imports t t))
+ (add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
+
+ (with-eval-after-load "company"
+ (use-package company-lsp
+ :after lsp-mode
+ :config
+ (push 'company-lsp company-backends)))
+
+ (with-eval-after-load "projectile"
+ (defun my-set-projectile-root ()
+ (when lsp--cur-workspace
+ (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
+ (add-hook 'lsp-before-open-hook #'my-set-projectile-root))
+
+ (use-package dap-mode
+ :after lsp-mode
+ :bind (:map dap-mode-map
+ ([f9] . dap-debug)
+ ;; ([f9] . dap-continue)
+ ;; ([S-f9] . dap-disconnect)
+ ;; ([f10] . dap-next)
+ ;; ([f11] . dap-step-in)
+ ;; ([S-f11] . dap-step-out)
+ ([C-f9] . dap-hide/show-ui))
+ :hook (dap-stopped-hook . (lambda (arg) (call-interactively #'dap-hydra)))
+ :config
+ ;; FIXME: Create nice solution instead of a hack
+ (defvar dap-hide/show-ui-hidden? t)
+ (defun dap-hide/show-ui ()
+ "Hide/show dap ui. FIXME"
+ (interactive)
+ (if dap-hide/show-ui-hidden?
+ (progn
+ (setq dap-hide/show-ui-hidden? nil)
+ (dap-ui-locals)
+ (dap-ui-repl))
+ (dolist (buf '("*dap-ui-inspect*" "*dap-ui-locals*" "*dap-ui-repl*" "*dap-ui-sessions*"))
+ (when (get-buffer buf)
+ (kill-buffer buf)))
+ (setq dap-hide/show-ui-hidden? t)))
+
+ (dap-mode)
+ (dap-ui-mode)
+ (dap-tooltip-mode))
+
+ ))
(provide 'setup-completion)
config/setup-docker.el
@@ -1,5 +1,6 @@
;;; -*- lexical-binding: t; -*-
(use-package dockerfile-mode ; Edit docker's Dockerfiles
+ :unless *sys/full*
:mode ("Dockerfile\\'" . dockerfile-mode))
;; I have a bunch of different 'profiles' for kubernetes by different cluster so
config/setup-org.el
@@ -86,7 +86,6 @@
(setq fill-column 90)
(auto-revert-mode)
(auto-fill-mode)
- (flyspell-mode)
(org-indent-mode)
(smartparens-mode)))
emacs.org
@@ -50,7 +50,15 @@
pre-compile, without the need to load =org= first. It also means that I can add code
pieces in there that won't be /tangle/, like usage example ; and I also can use this to
generate any additional file I need, whatever the programming language they are written
-in.
+in. [[https://protesilaos.com/][Protesilaos Stavrou]] is not my only source, here are some others:
+
++ https://gitlab.com/ndw/dotfiles
++ https://github.com/MatthewZMD/.emacs.d
++ https://github.com/alhassy/emacs.d
++ https://github.com/chmouel/emacs-config
++ https://github.com/seagle0128/.emacs.d
++ https://github.com/hlissner/doom-emacs
++ http://doc.norang.ca/org-mode.html
** Why using GNU/Emacs ?
:PROPERTIES:
@@ -139,7 +147,7 @@
You should have received a copy of the GNU General Public License
along with this file. If not, see <http://www.gnu.org/licenses/>.
-* TODO Base settings
+* Base settings
:PROPERTIES:
:CUSTOM_ID: h:e483cc48-eb2d-42a7-93ca-3e1a37fa6a7c
:END:
@@ -411,10 +419,52 @@
#+begin_src emacs-lisp :tangle init.el
(defun vde/el-load-dir (dir)
- "Load el files from the given folder"
- (let ((files (directory-files dir nil "\.el$")))
- (while files
- (load-file (concat dir (pop files))))))
+ "Load el files from the given folder"
+ (let ((files (directory-files dir nil "\.el$")))
+ (while files
+ (load-file (concat dir (pop files))))))
+
+(defun vde/short-hostname ()
+ "Return hostname in short (aka wakasu.local -> wakasu)"
+ (string-match "[0-9A-Za-z-]+" system-name)
+ (substring system-name (match-beginning 0) (match-end 0)))
+#+end_src
+
+Let's define some constants early, based on the system, and the environment, to be able to
+use those later on to skip some package or change some configuration accordingly.
+
+#+begin_src emacs-lisp :tangle init.el
+(defconst *sys/gui*
+ (display-graphic-p)
+ "Are we running on a GUI Emacs ?")
+(defconst *sys/linux*
+ (eq system-type 'gnu/linux)
+ "Are we running on a GNU/Linux system?")
+(defconst *sys/mac*
+ (eq system-type 'darwin)
+ "Are we running on a Mac system?")
+(defconst *sys/root*
+ (string-equal "root" (getenv "USER"))
+ "Are you a ROOT user?")
+(defconst *nix*
+ (executable-find "nix")
+ "Do we have nix? (aka are we running in NixOS or a system using nixpkgs)")
+(defconst *rg*
+ (executable-find "rg")
+ "Do we have ripgrep?")
+(defconst *gcc*
+ (executable-find "gcc")
+ "Do we have gcc?")
+(defconst *git*
+ (executable-find "git")
+ "Do we have git?")
+
+(defvar *sys/full*
+ (member (vde/short-hostname) '("naruhodo")) ; "wakasu" <- put wakasu back in
+ "Is it a full system ?")
+(defvar *sys/light*
+ (not *sys/full*)
+ "Is it a light system ?")
#+end_src
Now, in order to load ~lisp~ and ~config~ files, it's just a matter of calling this
@@ -429,16 +479,14 @@
entirely sure why yet butโฆ)
#+begin_src emacs-lisp :tangle init.el
-(defun vde/short-hostname ()
- "Return hostname in short (aka wakasu.local -> wakasu)"
- (string-match "[0-9A-Za-z-]+" system-name)
- (substring system-name (match-beginning 0) (match-end 0)))
-
(if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
(load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))
#+end_src
*** Remove built-in =org-mode=
+:PROPERTIES:
+:CUSTOM_ID: h:9462c0d7-03be-4231-8f22-ce1a04be32b1
+:END:
I want to make sure I am using the installed version of =orgmode= (from my org
configuration) instead of the built-in one. To do that safely, let's remove the built-in
@@ -453,7 +501,6 @@
load-path))
#+end_src
-
** ~PATH~'s customization
:PROPERTIES:
:header-args: :tangle config/00-paths.el
@@ -889,7 +936,6 @@
(setq fill-column 90)
(auto-revert-mode)
(auto-fill-mode)
- (flyspell-mode)
(org-indent-mode)
(smartparens-mode)))
#+end_src
@@ -1863,74 +1909,6 @@
;;; init.el ends here
#+end_src
-*** ~setup-browser.el~
-:PROPERTIES:
-:CUSTOM_ID: h:271aa865-f85d-4e6e-9283-4a2fb457328a
-:END:
-
-#+begin_src emacs-lisp :tangle config/setup-browser.el
-;;; -*- lexical-binding: t; -*-
-(use-package shr
- :commands (eww
- eww-browse-url)
- :config
- (setq shr-use-fonts nil
- shr-use-colors nil
- shr-max-image-proportion 0.2
- shr-width (current-fill-column)
- browse-url-browser-function 'browse-url-generic))
-
-(use-package shr-tag-pre-highlight
- :after shr
- :config
- (add-to-list 'shr-external-rendering-functions
- '(pre . shr-tag-pre-highlight))
- (when (version< emacs-version "26")
- (with-eval-after-load 'eww
- (advice-add 'eww-display-html :around
- 'eww-display-html--override-shr-external-rendering-functions))))
-
-(use-package eww
- :defer t
- :init
- (setq browse-url-browser-function
- '((".*google.*maps.*" . browse-url-generic)
- ;; Github goes to firefox, but not gist
- ("http.*\/\/github.com" . browse-url-generic)
- ("http.*\/\/github.io" . browse-url-generic)
- ("http.*\/\/gitlab.com" . browse-url-generic)
- ("http.*\/\/gitlab.io" . browse-url-generic)
- ("groups.google.com" . browse-url-generic)
- ("docs.google.com" . browse-url-generic)
- ("melpa.org" . browse-url-generic)
- ("build.*\.elastic.co" . browse-url-generic)
- (".*-ci\.elastic.co" . browse-url-generic)
- ("internal-ci\.elastic\.co" . browse-url-generic)
- ("zendesk\.com" . browse-url-generic)
- ("salesforce\.com" . browse-url-generic)
- ("stackoverflow\.com" . browse-url-generic)
- ("apache\.org\/jira" . browse-url-generic)
- ("thepoachedegg\.net" . browse-url-generic)
- ("zoom.us" . browse-url-generic)
- ("blujeans.com" . browse-url-generic)
- ("t.co" . browse-url-generic)
- ("twitter.com" . browse-url-generic)
- ("\/\/a.co" . browse-url-generic)
- ("youtube.com" . browse-url-generic)
- ("amazon.com" . browse-url-generic)
- ("slideshare.net" . browse-url-generic)
- ("." . browse-url-generic)))
- (setq shr-external-browser 'browse-url-generic)
- (setq browse-url-generic-program (executable-find "firefox"))
- (add-hook 'eww-mode-hook #'toggle-word-wrap)
- (add-hook 'eww-mode-hook #'visual-line-mode)
- :config
- (define-key eww-mode-map "o" 'eww)
- (define-key eww-mode-map "O" 'eww-browse-with-external-browser))
-
-(provide 'setup-browser)
-#+end_src
-
*** ~setup-buffers.el~
:PROPERTIES:
:CUSTOM_ID: h:98200f45-7379-42e7-be0d-7db52cd950c8
@@ -2226,62 +2204,6 @@
(ivy-mode 1))
))
-(use-package ivy-hydra ; Additional bindings for Ivy
- :after ivy)
-
-(use-package ivy-rich
- :after ivy
- :custom
- (ivy-virtual-abbreviate 'full
- ivy-rich-switch-buffer-align-virtual-buffer t
- ivy-rich-path-style 'abbrev)
- :config (ivy-rich-mode 1))
-
-(use-package prescient
- :custom
- (prescient-history-length 50)
- ;; (prescient-save-file "~/.emacs.d/prescient-items")
- (prescient-filter-method '(fuzzy initialism regexp))
- :config
- (prescient-persist-mode 1))
-
-;;; Default rg arguments
-;; https://github.com/BurntSushi/ripgrep
-(defconst vde/rg-arguments
- `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore'
- "--line-number" ;Line numbers
- "--smart-case"
- "--max-columns" "150" ;Emacs doesn't handle long line lengths very well
- "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME")))
- "Default rg arguments used in the functions in `counsel' and `projectile' packages.")
-
-(use-package ivy-prescient
- :after (prescient ivy)
- :custom
- (ivy-prescient-sort-commands
- '(:not swiper ivy-switch-buffer counsel-switch-buffer))
- (ivy-prescient-retain-classic-highlighting t)
- (ivy-prescient-enable-filtering t)
- (ivy-prescient-enable-sorting t)
- :config
- (defun prot/ivy-prescient-filters (str)
- "Specify an exception for `prescient-filter-method'.
-
-This new rule can be used to tailor the results of individual
-Ivy-powered commands, using `ivy-prescient-re-builder'."
- (let ((prescient-filter-method '(literal regexp)))
- (ivy-prescient-re-builder str)))
-
- (setq ivy-re-builders-alist
- '((counsel-rg . prot/ivy-prescient-filters)
- (counsel-grep . prot/ivy-prescient-filters)
- (counsel-yank-pop . prot/ivy-prescient-filters)
- (swiper . prot/ivy-prescient-filters)
- (swiper-isearch . prot/ivy-prescient-filters)
- (swiper-all . prot/ivy-prescient-filters)
- (t . ivy-prescient-re-builder)))
- (ivy-prescient-mode 1))
-
(use-package counsel
:after ivy
:custom
@@ -2406,6 +2328,7 @@
;https://github.com/abo-abo/swiper/issues/427
))))
+
(use-package company
:commands global-company-mode
:init
@@ -2440,116 +2363,175 @@
company-etags
company-keywords)))
-(use-package company-prescient
- :ensure company
- :after (company prescient)
- :config
- (company-prescient-mode 1))
+;;; Default rg arguments
+;; https://github.com/BurntSushi/ripgrep
+(defconst vde/rg-arguments
+ `("--no-ignore-vcs" ;Ignore files/dirs ONLY from `.ignore'
+ "--line-number" ;Line numbers
+ "--smart-case"
+ "--max-columns" "150" ;Emacs doesn't handle long line lengths very well
+ "--ignore-file" ,(expand-file-name ".ignore" (getenv "HOME")))
+ "Default rg arguments used in the functions in `counsel' and `projectile' packages.")
-(use-package company-emoji
- :ensure company
- :config
- (add-to-list 'company-backends 'company-emoji))
-(use-package lsp-mode
- :commands (lsp lsp-deferred)
- :custom
- (lsp-enable-file-watchers nil)
- (lsp-gopls-staticcheck t)
- (lsp-gopls-complete-unimported t)
- (lsp-eldoc-render-all nil)
- (lsp-enable-snippet nil)
- (lsp-enable-links nil)
- (lsp-enable-folding nil)
- (lsp-enable-completion-at-point nil) ;; company-lsp takes care of it ?
- (lsp-diagnostic-package :none)
- (lsp-restart 'auto-restart)
- (lsp-ui-sideline-enable nil)
- (lsp-ui-sideline-show-hover nil)
- (lsp-ui-sideline-delay 2.0)
- (lsp-ui-doc-enable nil)
- (lsp-ui-doc-max-width 30)
- (lsp-ui-doc-max-height 15)
- (lsp-document-highlight-delay 2.0)
- (lsp-auto-guess-root t)
- (lsp-ui-flycheck-enable nil)
- ;; @see https://github.com/emacs-lsp/lsp-mode/pull/1498
- ;; and read code related to auto configure
- ;; require clients could be slow and that's only thing auto configure
- ;; could do for me. Manual loading of client is faster.
- (lsp-auto-configure nil)
- (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
- :config
- ;; don't ping LSP lanaguage server too frequently
- (defvar lsp-on-touch-time 0)
- (defadvice lsp-on-change (around lsp-on-change-hack activate)
- ;; don't run `lsp-on-change' too frequently
- (when (> (- (float-time (current-time))
- lsp-on-touch-time) 30) ;; 30 seconds
- (setq lsp-on-touch-time (float-time (current-time)))
- ad-do-it))
- :hook ((go-mode . lsp-deferred)
- (python-mode . lsp-deferred)))
+(if *sys/full*
+ (progn
+ (use-package ivy-rich
+ :after ivy
+ :custom
+ (ivy-virtual-abbreviate 'full
+ ivy-rich-switch-buffer-align-virtual-buffer t
+ ivy-rich-path-style 'abbrev)
+ :config (ivy-rich-mode 1))
-;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
-;; https://github.com/emacs-lsp/lsp-ui
-(use-package lsp-ui
- :after lsp-mode
- ;;:hook ((lsp-mode . lsp-ui-mode)
- ;; (lsp-ui-mode . lsp-ui-peek-mode))
- :config
- (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
- (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
+ (use-package prescient
+ :custom
+ (prescient-history-length 50)
+ ;; (prescient-save-file "~/.emacs.d/prescient-items")
+ (prescient-filter-method '(fuzzy initialism regexp))
+ :config
+ (prescient-persist-mode 1))
-;;Set up before-save hooks to format buffer and add/delete imports.
-;;Make sure you don't have other gofmt/goimports hooks enabled.
-(defun lsp-go-install-save-hooks ()
- (add-hook 'before-save-hook #'lsp-format-buffer t t)
- (add-hook 'before-save-hook #'lsp-organize-imports t t))
-(add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
-(with-eval-after-load "company"
- (use-package company-lsp
- :after lsp-mode
- :config
- (push 'company-lsp company-backends)))
+ (use-package ivy-prescient
+ :after (prescient ivy)
+ :custom
+ (ivy-prescient-sort-commands
+ '(:not swiper ivy-switch-buffer counsel-switch-buffer))
+ (ivy-prescient-retain-classic-highlighting t)
+ (ivy-prescient-enable-filtering t)
+ (ivy-prescient-enable-sorting t)
+ :config
+ (defun prot/ivy-prescient-filters (str)
+ "Specify an exception for `prescient-filter-method'.
-(with-eval-after-load "projectile"
- (defun my-set-projectile-root ()
- (when lsp--cur-workspace
- (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
- (add-hook 'lsp-before-open-hook #'my-set-projectile-root))
+This new rule can be used to tailor the results of individual
+Ivy-powered commands, using `ivy-prescient-re-builder'."
+ (let ((prescient-filter-method '(literal regexp)))
+ (ivy-prescient-re-builder str)))
-(use-package dap-mode
- :after lsp-mode
- :bind (:map dap-mode-map
- ([f9] . dap-debug)
- ;; ([f9] . dap-continue)
- ;; ([S-f9] . dap-disconnect)
- ;; ([f10] . dap-next)
- ;; ([f11] . dap-step-in)
- ;; ([S-f11] . dap-step-out)
- ([C-f9] . dap-hide/show-ui))
- :hook (dap-stopped-hook . (lambda (arg) (call-interactively #'dap-hydra)))
- :config
- ;; FIXME: Create nice solution instead of a hack
- (defvar dap-hide/show-ui-hidden? t)
- (defun dap-hide/show-ui ()
- "Hide/show dap ui. FIXME"
- (interactive)
- (if dap-hide/show-ui-hidden?
- (progn
- (setq dap-hide/show-ui-hidden? nil)
- (dap-ui-locals)
- (dap-ui-repl))
- (dolist (buf '("*dap-ui-inspect*" "*dap-ui-locals*" "*dap-ui-repl*" "*dap-ui-sessions*"))
- (when (get-buffer buf)
- (kill-buffer buf)))
- (setq dap-hide/show-ui-hidden? t)))
+ (setq ivy-re-builders-alist
+ '((counsel-rg . prot/ivy-prescient-filters)
+ (counsel-grep . prot/ivy-prescient-filters)
+ (counsel-yank-pop . prot/ivy-prescient-filters)
+ (swiper . prot/ivy-prescient-filters)
+ (swiper-isearch . prot/ivy-prescient-filters)
+ (swiper-all . prot/ivy-prescient-filters)
+ (t . ivy-prescient-re-builder)))
+ (ivy-prescient-mode 1))
- (dap-mode)
- (dap-ui-mode)
- (dap-tooltip-mode))
+ (use-package company-prescient
+ :ensure company
+ :after (company prescient)
+ :config
+ (company-prescient-mode 1))
+
+ (use-package company-emoji
+ :ensure company
+ :config
+ (add-to-list 'company-backends 'company-emoji))
+
+ (use-package lsp-mode
+ :commands (lsp lsp-deferred)
+ :custom
+ (lsp-enable-file-watchers nil)
+ (lsp-gopls-staticcheck t)
+ (lsp-gopls-complete-unimported t)
+ (lsp-eldoc-render-all nil)
+ (lsp-enable-snippet nil)
+ (lsp-enable-links nil)
+ (lsp-enable-folding nil)
+ (lsp-enable-completion-at-point nil) ;; company-lsp takes care of it ?
+ (lsp-diagnostic-package :none)
+ (lsp-restart 'auto-restart)
+ (lsp-ui-sideline-enable nil)
+ (lsp-ui-sideline-show-hover nil)
+ (lsp-ui-sideline-delay 2.0)
+ (lsp-ui-doc-enable nil)
+ (lsp-ui-doc-max-width 30)
+ (lsp-ui-doc-max-height 15)
+ (lsp-document-highlight-delay 2.0)
+ (lsp-auto-guess-root t)
+ (lsp-ui-flycheck-enable nil)
+ ;; @see https://github.com/emacs-lsp/lsp-mode/pull/1498
+ ;; and read code related to auto configure
+ ;; require clients could be slow and that's only thing auto configure
+ ;; could do for me. Manual loading of client is faster.
+ (lsp-auto-configure nil)
+ (lsp-prefer-flymake nil) ; Use flycheck instead of flymake
+ :config
+ ;; don't ping LSP lanaguage server too frequently
+ (defvar lsp-on-touch-time 0)
+ (defadvice lsp-on-change (around lsp-on-change-hack activate)
+ ;; don't run `lsp-on-change' too frequently
+ (when (> (- (float-time (current-time))
+ lsp-on-touch-time) 30) ;; 30 seconds
+ (setq lsp-on-touch-time (float-time (current-time)))
+ ad-do-it))
+ :hook ((go-mode . lsp-deferred)
+ (python-mode . lsp-deferred)))
+
+ ;; lsp-ui: This contains all the higher level UI modules of lsp-mode, like flycheck support and code lenses.
+ ;; https://github.com/emacs-lsp/lsp-ui
+ (use-package lsp-ui
+ :after lsp-mode
+ ;;:hook ((lsp-mode . lsp-ui-mode)
+ ;; (lsp-ui-mode . lsp-ui-peek-mode))
+ :config
+ (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
+ (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references))
+
+ ;;Set up before-save hooks to format buffer and add/delete imports.
+ ;;Make sure you don't have other gofmt/goimports hooks enabled.
+ (defun lsp-go-install-save-hooks ()
+ (add-hook 'before-save-hook #'lsp-format-buffer t t)
+ (add-hook 'before-save-hook #'lsp-organize-imports t t))
+ (add-hook 'go-mode-hook #'lsp-go-install-save-hooks)
+
+ (with-eval-after-load "company"
+ (use-package company-lsp
+ :after lsp-mode
+ :config
+ (push 'company-lsp company-backends)))
+
+ (with-eval-after-load "projectile"
+ (defun my-set-projectile-root ()
+ (when lsp--cur-workspace
+ (setq projectile-project-root (lsp--workspace-root lsp--cur-workspace))))
+ (add-hook 'lsp-before-open-hook #'my-set-projectile-root))
+
+ (use-package dap-mode
+ :after lsp-mode
+ :bind (:map dap-mode-map
+ ([f9] . dap-debug)
+ ;; ([f9] . dap-continue)
+ ;; ([S-f9] . dap-disconnect)
+ ;; ([f10] . dap-next)
+ ;; ([f11] . dap-step-in)
+ ;; ([S-f11] . dap-step-out)
+ ([C-f9] . dap-hide/show-ui))
+ :hook (dap-stopped-hook . (lambda (arg) (call-interactively #'dap-hydra)))
+ :config
+ ;; FIXME: Create nice solution instead of a hack
+ (defvar dap-hide/show-ui-hidden? t)
+ (defun dap-hide/show-ui ()
+ "Hide/show dap ui. FIXME"
+ (interactive)
+ (if dap-hide/show-ui-hidden?
+ (progn
+ (setq dap-hide/show-ui-hidden? nil)
+ (dap-ui-locals)
+ (dap-ui-repl))
+ (dolist (buf '("*dap-ui-inspect*" "*dap-ui-locals*" "*dap-ui-repl*" "*dap-ui-sessions*"))
+ (when (get-buffer buf)
+ (kill-buffer buf)))
+ (setq dap-hide/show-ui-hidden? t)))
+
+ (dap-mode)
+ (dap-ui-mode)
+ (dap-tooltip-mode))
+
+ ))
(provide 'setup-completion)
#+end_src
@@ -2723,6 +2705,7 @@
#+begin_src emacs-lisp :tangle config/setup-docker.el
;;; -*- lexical-binding: t; -*-
(use-package dockerfile-mode ; Edit docker's Dockerfiles
+ :unless *sys/full*
:mode ("Dockerfile\\'" . dockerfile-mode))
;; I have a bunch of different 'profiles' for kubernetes by different cluster so
init.el
@@ -92,19 +92,51 @@
(load vde/custom-file 'no-error 'no-message))
(defun vde/el-load-dir (dir)
- "Load el files from the given folder"
- (let ((files (directory-files dir nil "\.el$")))
- (while files
- (load-file (concat dir (pop files))))))
-
-(add-to-list 'load-path (concat user-emacs-directory "lisp/"))
-(vde/el-load-dir (concat user-emacs-directory "/config/"))
+ "Load el files from the given folder"
+ (let ((files (directory-files dir nil "\.el$")))
+ (while files
+ (load-file (concat dir (pop files))))))
(defun vde/short-hostname ()
"Return hostname in short (aka wakasu.local -> wakasu)"
(string-match "[0-9A-Za-z-]+" system-name)
(substring system-name (match-beginning 0) (match-end 0)))
+(defconst *sys/gui*
+ (display-graphic-p)
+ "Are we running on a GUI Emacs ?")
+(defconst *sys/linux*
+ (eq system-type 'gnu/linux)
+ "Are we running on a GNU/Linux system?")
+(defconst *sys/mac*
+ (eq system-type 'darwin)
+ "Are we running on a Mac system?")
+(defconst *sys/root*
+ (string-equal "root" (getenv "USER"))
+ "Are you a ROOT user?")
+(defconst *nix*
+ (executable-find "nix")
+ "Do we have nix? (aka are we running in NixOS or a system using nixpkgs)")
+(defconst *rg*
+ (executable-find "rg")
+ "Do we have ripgrep?")
+(defconst *gcc*
+ (executable-find "gcc")
+ "Do we have gcc?")
+(defconst *git*
+ (executable-find "git")
+ "Do we have git?")
+
+(defvar *sys/full*
+ (member (vde/short-hostname) '("naruhodo")) ; "wakasu" <- put wakasu back in
+ "Is it a full system ?")
+(defvar *sys/light*
+ (not *sys/full*)
+ "Is it a light system ?")
+
+(add-to-list 'load-path (concat user-emacs-directory "lisp/"))
+(vde/el-load-dir (concat user-emacs-directory "/config/"))
+
(if (file-exists-p (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el")))
(load-file (downcase (concat user-emacs-directory "/hosts/" (vde/short-hostname) ".el"))))