ADD dependency management and conditional loading
This commit is contained in:
parent
4122f4784e
commit
213c8fea95
79
etc/conf.org
79
etc/conf.org
|
@ -162,10 +162,16 @@ OS is one of those in `system-type'."
|
||||||
`(when (not (eq system-type ,os)) (progn ,@body)
|
`(when (not (eq system-type ,os)) (progn ,@body)
|
||||||
(print "Skipping OS-restricted code")))
|
(print "Skipping OS-restricted code")))
|
||||||
|
|
||||||
|
(defvar nd/required-exes '()
|
||||||
|
"Running list of executables required to run various configuations.")
|
||||||
|
|
||||||
(defmacro nd/when-bin (bin &rest body)
|
(defmacro nd/when-bin (bin &rest body)
|
||||||
"Execute BODY if the program BIN exists."
|
"Execute BODY if the program BIN exists."
|
||||||
(declare (indent 1))
|
(declare (indent 1))
|
||||||
`(if (executable-find ,bin) (progn ,@body)
|
`(if (executable-find ,bin)
|
||||||
|
(progn
|
||||||
|
(setq nd/required-exes (-union '(,bin) nd/required-exes))
|
||||||
|
,@body)
|
||||||
(print (format "Executable %s not found. Skipping." ,bin))))
|
(print (format "Executable %s not found. Skipping." ,bin))))
|
||||||
|
|
||||||
(defmacro nd/time-exec (&rest body)
|
(defmacro nd/time-exec (&rest body)
|
||||||
|
@ -262,6 +268,27 @@ If FRONT is t, do to the front of current values instead of the back."
|
||||||
(--each
|
(--each
|
||||||
(where-is-internal f keymap nil nil)
|
(where-is-internal f keymap nil nil)
|
||||||
(define-key keymap it nil)))
|
(define-key keymap it nil)))
|
||||||
|
|
||||||
|
(defun nd/detect-package-manager ()
|
||||||
|
"Return the package manager being used on this OS."
|
||||||
|
(cond
|
||||||
|
;; for now only pacman...because arch is the best (TM)
|
||||||
|
((file-exists-p "/usr/bin/pacman")
|
||||||
|
'pacman)))
|
||||||
|
|
||||||
|
(defun nd/pacman-find-owner (file)
|
||||||
|
"Return the pacman packages that owns FILE.
|
||||||
|
Assumes pacman is installed and FILE is an absolute path."
|
||||||
|
(-some->> (format "pacman -Fq %s" file)
|
||||||
|
(shell-command-to-string)
|
||||||
|
(s-trim)
|
||||||
|
(s-split "\n")
|
||||||
|
(--map (replace-regexp-in-string ".*/" "" it t))
|
||||||
|
(cons file)))
|
||||||
|
|
||||||
|
(defun nd/detect-dependencies ()
|
||||||
|
"Return a list of required packages for this configuration."
|
||||||
|
(--map (nd/pacman-find-owner (format "/usr/bin/%s" it)) nd/required-exes))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** interactive
|
** interactive
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
@ -807,6 +834,7 @@ For me this means R but ess also supports S-plus, SAS, Stata, and other statisti
|
||||||
Flycheck syntax checkers
|
Flycheck syntax checkers
|
||||||
- r-lintr (install from CRAN)
|
- r-lintr (install from CRAN)
|
||||||
#+begin_src emacs-lisp
|
#+begin_src emacs-lisp
|
||||||
|
(nd/when-bin "R"
|
||||||
(defun nd/init-ess-company ()
|
(defun nd/init-ess-company ()
|
||||||
"Set the company backends for ess modes."
|
"Set the company backends for ess modes."
|
||||||
(setq-local company-backends '((company-R-objects company-R-args))))
|
(setq-local company-backends '((company-R-objects company-R-args))))
|
||||||
|
@ -842,25 +870,28 @@ Flycheck syntax checkers
|
||||||
((#'inferior-ess--start-process :around #'nd/ess-r-add-env))
|
((#'inferior-ess--start-process :around #'nd/ess-r-add-env))
|
||||||
(apply orig-fun args)))
|
(apply orig-fun args)))
|
||||||
|
|
||||||
|
(advice-add #'run-ess-r :around #'nd/ess-r-start-env)
|
||||||
|
|
||||||
|
(nd/when-bin "docker"
|
||||||
(defun nd/ess-r-setwd-maybe (orig-fun &rest args)
|
(defun nd/ess-r-setwd-maybe (orig-fun &rest args)
|
||||||
(nd/with-advice
|
(nd/with-advice
|
||||||
((#'ess-set-working-directory :override #'ignore))
|
((#'ess-set-working-directory :override #'ignore))
|
||||||
(apply orig-fun args)))
|
(apply orig-fun args)))
|
||||||
|
|
||||||
(advice-add #'run-ess-r :around #'nd/ess-r-start-env)
|
|
||||||
|
|
||||||
(advice-add #'run-ess-r :around #'nd/ess-r-setwd-maybe)
|
(advice-add #'run-ess-r :around #'nd/ess-r-setwd-maybe)
|
||||||
|
|
||||||
;; force flycheck to use the system-wide R install instead of whatever
|
;; force flycheck to use system R instead of whatever is in docker
|
||||||
;; is in docker
|
|
||||||
(defun nd/flycheck-find-exe-no-docker (orig-fun exe)
|
(defun nd/flycheck-find-exe-no-docker (orig-fun exe)
|
||||||
(if (or (equal exe "R") (s-starts-with? "R " exe))
|
(if (or (equal exe "R") (s-starts-with? "R " exe))
|
||||||
"/bin/R" (funcall orig-fun exe)))
|
"/bin/R" (funcall orig-fun exe)))
|
||||||
|
|
||||||
(advice-add #'flycheck-default-executable-find :around
|
(advice-add #'flycheck-default-executable-find :around
|
||||||
#'nd/flycheck-find-exe-no-docker)
|
#'nd/flycheck-find-exe-no-docker)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** C
|
*** C
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 0ee09480-e722-4a06-af8f-52f7dbf3f906
|
||||||
|
:END:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(defun nd/init-c-company ()
|
(defun nd/init-c-company ()
|
||||||
"Set the company backends for anaconda mode."
|
"Set the company backends for anaconda mode."
|
||||||
|
@ -869,19 +900,21 @@ Flycheck syntax checkers
|
||||||
company-irony)))
|
company-irony)))
|
||||||
|
|
||||||
;; requires clang (duh)
|
;; requires clang (duh)
|
||||||
|
(nd/when-bin "clang"
|
||||||
(use-package flycheck-clang-analyzer
|
(use-package flycheck-clang-analyzer
|
||||||
:straight t
|
:straight t
|
||||||
:after flycheck
|
:after flycheck
|
||||||
:config
|
:config
|
||||||
(flycheck-clang-analyzer-setup))
|
(flycheck-clang-analyzer-setup)))
|
||||||
|
|
||||||
;; requires cmake/llvm
|
;; requires cmake/llvm
|
||||||
|
(nd/when-bin "cmake"
|
||||||
(use-package irony
|
(use-package irony
|
||||||
:straight t
|
:straight t
|
||||||
:hook ((irony-mode . irony-cdb-autosetup-compile-options)))
|
:hook ((irony-mode . irony-cdb-autosetup-compile-options)))
|
||||||
|
|
||||||
(use-package company-irony
|
(use-package company-irony
|
||||||
:straight t)
|
:straight t))
|
||||||
|
|
||||||
(use-package company-c-headers
|
(use-package company-c-headers
|
||||||
:straight t)
|
:straight t)
|
||||||
|
@ -948,8 +981,9 @@ Anaconda (not related to the Python/R distribution?) is much lighter and easier
|
||||||
:END:
|
:END:
|
||||||
[[https://github.com/python/black][Black]] is a really nice syntax formatter. It must be externally installed to work.
|
[[https://github.com/python/black][Black]] is a really nice syntax formatter. It must be externally installed to work.
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "black"
|
||||||
(use-package blacken
|
(use-package blacken
|
||||||
:straight t)
|
:straight t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
**** pyenv
|
**** pyenv
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
@ -959,6 +993,7 @@ For isolation I use [[https://github.com/pyenv/pyenv][pyenv]] and [[https://gith
|
||||||
|
|
||||||
Note this also requires all external packages to be installed in each environement (eg ipython, black, flake8, and pylint).
|
Note this also requires all external packages to be installed in each environement (eg ipython, black, flake8, and pylint).
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "pyenv"
|
||||||
(use-package pyenv-mode
|
(use-package pyenv-mode
|
||||||
:straight t
|
:straight t
|
||||||
:after python
|
:after python
|
||||||
|
@ -968,7 +1003,7 @@ Note this also requires all external packages to be installed in each environeme
|
||||||
|
|
||||||
;; resolve symlinks when setting the pyenv, otherwise we get some
|
;; resolve symlinks when setting the pyenv, otherwise we get some
|
||||||
;; strange errors when activating a symlinked env
|
;; strange errors when activating a symlinked env
|
||||||
(advice-add #'pyenv-mode-full-path :filter-return #'file-truename)
|
(advice-add #'pyenv-mode-full-path :filter-return #'file-truename))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Ruby
|
*** Ruby
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
@ -1007,6 +1042,7 @@ Since most of these need GHCi to run properly, I added a hook to load haskell so
|
||||||
|
|
||||||
I have also found this to be much simpler and conflicting with other packages such as =dante= and =intero= (and probably =haskell-ide-engine= and friends).
|
I have also found this to be much simpler and conflicting with other packages such as =dante= and =intero= (and probably =haskell-ide-engine= and friends).
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "stack"
|
||||||
(defun nd/init-haskell-company ()
|
(defun nd/init-haskell-company ()
|
||||||
"Set the company backends for haskell mode."
|
"Set the company backends for haskell mode."
|
||||||
(setq-local company-backends
|
(setq-local company-backends
|
||||||
|
@ -1049,7 +1085,7 @@ I have also found this to be much simpler and conflicting with other packages su
|
||||||
(delight 'interactive-haskell-mode nil "haskell")
|
(delight 'interactive-haskell-mode nil "haskell")
|
||||||
|
|
||||||
;; unnecessary to see on the modeline
|
;; unnecessary to see on the modeline
|
||||||
(delight 'subword-mode nil "subword")
|
(delight 'subword-mode nil "subword"))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
**** hlint
|
**** hlint
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
@ -1057,8 +1093,9 @@ I have also found this to be much simpler and conflicting with other packages su
|
||||||
:END:
|
:END:
|
||||||
This is an additional syntax checker and requires the =hlint= binary (install through stack).
|
This is an additional syntax checker and requires the =hlint= binary (install through stack).
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "hlint"
|
||||||
(with-eval-after-load 'haskell
|
(with-eval-after-load 'haskell
|
||||||
(flycheck-add-next-checker 'haskell-stack-ghc '(t . haskell-hlint)))
|
(flycheck-add-next-checker 'haskell-stack-ghc '(t . haskell-hlint))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
**** helper functions
|
**** helper functions
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
@ -1081,8 +1118,9 @@ Other helper functions that make haskell even more fun.
|
||||||
:END:
|
:END:
|
||||||
For flycheck, install =luacheck= (from AUR on Arch).
|
For flycheck, install =luacheck= (from AUR on Arch).
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "luacheck"
|
||||||
(use-package lua-mode
|
(use-package lua-mode
|
||||||
:straight t)
|
:straight t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** TeX
|
*** TeX
|
||||||
**** AUCTeX
|
**** AUCTeX
|
||||||
|
@ -1245,6 +1283,9 @@ Overlays hex color codes with matching colors in certain modes like css and html
|
||||||
:straight t)
|
:straight t)
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** Jinja2
|
*** Jinja2
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: a38b0792-46fe-43cc-b57a-d8e3a189fdc5
|
||||||
|
:END:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package jinja2-mode
|
(use-package jinja2-mode
|
||||||
:straight t
|
:straight t
|
||||||
|
@ -1365,11 +1406,15 @@ No custom code here, but flycheck needs =sqlint= (on Arch available through the
|
||||||
:ID: ce24b075-ede6-4d6c-81db-4c6aa40e4fd0
|
:ID: ce24b075-ede6-4d6c-81db-4c6aa40e4fd0
|
||||||
:END:
|
:END:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "docker"
|
||||||
(use-package dockerfile-mode
|
(use-package dockerfile-mode
|
||||||
:straight t)
|
:straight t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** testing
|
** testing
|
||||||
*** buttercup
|
*** buttercup
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: 9539395e-98aa-4e47-b2ff-4233b63d40b1
|
||||||
|
:END:
|
||||||
Include this so I can have the docs and indentation specs handy when writing test suites
|
Include this so I can have the docs and indentation specs handy when writing test suites
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package buttercup
|
(use-package buttercup
|
||||||
|
@ -3380,12 +3425,13 @@ For some reason there is no default way to get a "print prompt." Instead one nee
|
||||||
:ID: 67e11402-a9e5-4aae-8644-0e2c4f9ad2bc
|
:ID: 67e11402-a9e5-4aae-8644-0e2c4f9ad2bc
|
||||||
:END:
|
:END:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
|
(nd/when-bin "git"
|
||||||
(use-package magit
|
(use-package magit
|
||||||
:straight t
|
:straight t
|
||||||
:config
|
:config
|
||||||
:delight auto-revert-mode
|
:delight auto-revert-mode
|
||||||
(setq magit-push-always-verify nil
|
(setq magit-push-always-verify nil
|
||||||
git-commit-summary-max-length 50))
|
git-commit-summary-max-length 50)))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
** dired
|
** dired
|
||||||
*** no confirm
|
*** no confirm
|
||||||
|
@ -4615,6 +4661,9 @@ The function keys are nice because they are almost (not always) free in every mo
|
||||||
("=" #'balance-windows :exit t))
|
("=" #'balance-windows :exit t))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
*** other
|
*** other
|
||||||
|
:PROPERTIES:
|
||||||
|
:ID: dff1f586-7231-4394-8f4c-2730dbe8a901
|
||||||
|
:END:
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
;; exchange point and marker (I never saw the use for this)
|
;; exchange point and marker (I never saw the use for this)
|
||||||
(global-unset-key (kbd "C-x C-x"))
|
(global-unset-key (kbd "C-x C-x"))
|
||||||
|
|
Loading…
Reference in New Issue