restart configuring in init.el only

This commit is contained in:
Vladan Popovic 2022-03-28 22:11:59 +02:00
parent f7ff8895ca
commit 77942c019c
14 changed files with 222 additions and 493 deletions

1
.gitignore vendored
View file

@ -9,3 +9,4 @@ recentf
places places
backups backups
auto-save-list auto-save-list
eln-cache/

12
LICENCE
View file

@ -1,12 +0,0 @@
Copyright (c) 2019 by Vladan Popovic <vladanovic@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

View file

@ -1,17 +0,0 @@
My custom emacs configuration
=============================
**IT'S EVIL!!!**
Tested on:
* Rust
* Elm
* Systemd
Installation
============
Clone the repository as ~/.emacs.d/ (not inside it), e.g.::
git clone https://path-to-this-repo.git ~/.emacs.d

View file

@ -1,18 +0,0 @@
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ansi-color-names-vector
["black" "#d55e00" "#009e73" "#f8ec59" "#0072b2" "#cc79a7" "#56b4e9" "white"])
'(inhibit-startup-screen t)
'(lsp-rust-analyzer-macro-expansion-method 'rustic-analyzer-macro-expand)
'(package-selected-packages
'(xref-rst which-key use-package undo-tree rustic rg pylint pygen magit lsp-ui lsp-jedi jupyter jedi helm-rg helm-lsp flycheck-rust evil elpygen elm-mode ein diminish company-jedi better-defaults auto-complete-rst))
'(rustic-lsp-server 'rust-analyzer))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

244
init.el
View file

@ -5,41 +5,233 @@
("gnu" . "https://elpa.gnu.org/packages/") ("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/"))) ("melpa" . "https://melpa.org/packages/")))
(package-initialize) (package-initialize)
;(package-refresh-contents) ;; (package-refresh-contents)
;; Use-package for civilized configuration
(unless (package-installed-p 'use-package) (unless (package-installed-p 'use-package)
(package-install 'use-package)) (package-install 'use-package))
(require 'use-package) (require 'use-package)
(setq use-package-always-ensure t) (setq use-package-always-ensure t)
(setq dotfiles-dir (setq inhibit-startup-screen t)
(file-name-directory
(or (buffer-file-name) (file-chase-links load-file-name))))
(setq modules-path (concat dotfiles-dir "modules"))
(add-to-list 'load-path modules-path) (savehist-mode 1)
(setq savehist-additional-variables '(kill-ring search-ring regexp-search-ring))
;; Emacs customization / global plugin configuration (global-set-key (kbd "C-x C-e") 'eval-region)
(require 'jenga-init)
(require 'jenga-magit) ;; yank at cursor point instead of mouse
(require 'jenga-org) (setq mouse-yank-at-point t)
(require 'jenga-ui)
(require 'jenga-python) (setq column-number-mode t)
(require 'jenga-systemd) (setq ido-use-filename-at-point nil)
;;(add-hook 'find-file-hook #'load-module) (use-package undo-fu)
;;(defun load-module () (use-package evil
;; (when (stringp buffer-file-name) :ensure t ;; install the evil package if not installed
;; (cond ((string-match "\\.elm\\'" buffer-file-name) (require 'jenga-elm)) :init ;; tweak evil's configuration before loading it
;; ((string-match "\\.py\\'" buffer-file-name) (require 'jenga-python)) (setq evil-search-module 'evil-search)
;; ((string-match "\\.rs\\'" buffer-file-name) (require 'jenga-rust)) (setq evil-ex-complete-emacs-commands nil)
;; ((string-match "\\.service\\'" buffer-file-name) (require 'jenga-systemd))))) (setq evil-vsplit-window-right t)
(setq evil-split-window-below t)
(setq evil-shift-round nil)
(setq evil-want-C-u-scroll t)
(setq evil-undo-system 'undo-fu)
:config ;; tweak evil after loading it
(evil-mode)
;; example how to map a command in normal mode (called 'normal state' in evil)
(define-key evil-normal-state-map (kbd ", w") 'evil-window-vsplit))
(setq custom-file "~/.emacs.d/custom.el") (use-package rg
(load custom-file) :config
;; ## added by OPAM user-setup for emacs / base ## 56ab50dc8996d2bb95e7856a6eddb17b ## you can edit, but keep this line (global-set-key (kbd "M-s g") 'rg)
;;(require 'opam-user-setup "~/.emacs.d/opam-user-setup.el") (global-set-key (kbd "M-s d") 'rg-dwim))
;; ## end of OPAM user-setup addition for emacs / base ## keep this line
(use-package rustic
:ensure
:bind (:map rustic-mode-map
("C-c C-c l" . flycheck-list-errors)
("C-c C-c a" . lsp-execute-code-action)
("C-c C-c r" . lsp-rename)
("C-c C-c q" . lsp-workspace-restart)
("C-c C-c Q" . lsp-workspace-shutdown)
("C-c C-c s" . lsp-rust-analyzer-status))
:config
(setq lsp-eldoc-hook nil)
(setq lsp-enable-symbol-highlighting nil)
(setq lsp-signature-auto-activate nil)
(setq rustic-flycheck-clippy-params "--message-format=json")
(setq rustic-format-on-save t)
(add-hook 'rustic-mode-hook 'rk/rustic-mode-hook))
(defun rk/rustic-mode-hook ()
;; so that run C-c C-c C-r works without having to confirm, but don't try to
;; save rust buffers that are not file visiting. Once
;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should
;; no longer be necessary.
(when buffer-file-name
(setq-local buffer-save-without-query t)))
(use-package lsp-mode
:ensure
:commands lsp
:custom
;; what to use when checking on-save. "check" is default, I prefer clippy
(lsp-rust-analyzer-cargo-watch-command "clippy")
(lsp-eldoc-render-all t)
(lsp-idle-delay 0.6)
(lsp-rust-analyzer-server-display-inlay-hints t)
:config
(add-hook 'lsp-mode-hook 'lsp-ui-mode))
(use-package lsp-ui
:ensure
:commands lsp-ui-mode
:config (setq lsp-ui-peek-enable nil)
(setq lsp-ui-doc-enable nil)
(setq lsp-ui-doc-use-childframe nil)
(setq lsp-ui-doc-header nil)
(setq lsp-ui-doc-position 'top)
(setq lsp-ui-doc-use-webkit nil)
:custom (lsp-ui-peek-always-show t)
(lsp-ui-sideline-show-hover nil)
(lsp-ui-doc-enable nil)
:bind (:map lsp-ui-mode-map
("M-." . lsp-ui-peek-find-definitions)
("M-," . lsp-ui-peek-jump-backward)
("M-r" . lsp-ui-peek-find-references)
("M-h" . lsp-ui-doc-show)
("M-l" . lsp-ui-doc-hide)
("M-j" . lsp-ui-imenu)
("M-k" . lsp-ui-sideline-apply-code-actions)))
(use-package company
:ensure
:custom
(company-idle-delay 0.5) ;; how long to wait until popup
;; (company-begin-commands nil) ;; uncomment to disable popup
:bind
(:map company-active-map
("C-n". company-select-next)
("C-p". company-select-previous)
("M-<". company-select-first)
("M->". company-select-last))
(:map company-mode-map
("<tab>". tab-indent-or-complete)
("TAB". tab-indent-or-complete)))
(use-package magit
:init)
(use-package yasnippet
:ensure
:config
(yas-reload-all)
(add-hook 'prog-mode-hook 'yas-minor-mode)
(add-hook 'text-mode-hook 'yas-minor-mode))
(defun company-yasnippet-or-completion ()
(interactive)
(or (do-yas-expand)
(company-complete-common)))
(defun check-expansion ()
(save-excursion
(if (looking-at "\\_>") t
(backward-char 1)
(if (looking-at "\\.") t
(backward-char 1)
(if (looking-at "::") t nil)))))
(defun do-yas-expand ()
(let ((yas/fallback-behavior 'return-nil))
(yas/expand)))
(defun tab-indent-or-complete ()
(interactive)
(if (minibufferp)
(minibuffer-complete)
(if (or (not yas/minor-mode)
(null (do-yas-expand)))
(if (check-expansion)
(company-complete-common)
(indent-for-tab-command)))))
(use-package flycheck :ensure)
;; Please set your themes directory to 'custom-theme-load-path
(add-to-list 'custom-theme-load-path
(file-name-as-directory "~/.emacs.d/replace-colorthemes"))
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'vim-colors t t)
(enable-theme 'vim-colors)
;(use-package doom-themes
; :ensure t
; :config
; (load-theme 'doom-acario-light t))
(define-advice evil-ex-hl-match-hook (:around (fn hl) add-priority-reset-hook)
(or (funcall fn hl)
(lambda (_ ov)
(overlay-put ov 'priority 0))))
(set-face-attribute 'default nil :height 110)
;; Disable the menu.
(tool-bar-mode -1)
;; Enable transient mark mode.
(transient-mark-mode 1)
;; Highlight paired parentheses when cursor is over one.
(show-paren-mode 1)
(setq-default display-line-numbers-type 'absolute
display-line-numbers-current-absolute t
display-line-numbers-width 4
display-line-numbers-widen t)
(add-hook 'text-mode-hook #'display-line-numbers-mode)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
(defun local/project-try-explicit (dir)
"Find a super-directory of DIR containing a root file."
(locate-dominating-file dir ".root"))
(defmethod project-root ((project string))
project)
(add-hook 'project-find-functions
#'local/project-try-explicit)
(use-package dired-sidebar
:bind (("C-x C-n" . dired-sidebar-toggle-sidebar))
:ensure t
:commands (dired-sidebar-toggle-sidebar)
:init
(add-hook 'dired-sidebar-mode-hook
(lambda ()
(unless (file-remote-p default-directory)
(auto-revert-mode))))
:config
(push 'toggle-window-split dired-sidebar-toggle-hidden-commands)
(push 'rotate-windows dired-sidebar-toggle-hidden-commands)
(setq dired-sidebar-subtree-line-prefix "__")
(setq dired-sidebar-theme 'vscode)
(setq dired-sidebar-use-term-integration t)
(setq dired-sidebar-use-custom-font t))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(custom-safe-themes
'("d268b67e0935b9ebc427cad88ded41e875abfcc27abd409726a92e55459e0d01" default))
'(package-selected-packages
'(nord-theme yasnippet use-package undo-fu tommyh-theme rustic rg material-theme lsp-ui flycheck evil dired-sidebar company)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)

View file

@ -1,24 +0,0 @@
;;;; Elm mode configuration.
(use-package elm-mode
:ensure t
:bind
("M-<tab>" . company-indent-or-complete-common)
:config
(use-package lsp-mode)
(use-package lsp-ui)
(use-package company)
(setq elm-format-on-save t
elm-tags-on-save t
elm-tags-exclude-elm-stuff nil)
(add-to-list 'company-backends 'company-elm)
(add-to-list 'auto-mode-alist '("\\.elm\\'" . elm-mode))
:hook
(after-init . global-flycheck-mode)
(elm-mode . company-mode)
(elm-mode . lsp)
(elm-mode . (lambda () (setq evil-auto-indent nil))))
(with-eval-after-load 'flycheck
'(add-hook 'flycheck-mode-hook #'flycheck-elm-setup))
(provide 'jenga-elm)

View file

@ -1,112 +0,0 @@
;; Persist command history
(savehist-mode 1)
;;;; TAGS configuration.
;; Goto tag with M-.
(global-set-key "\M-." 'etags-select-find-tag)
;; Automatically load TAGS file (if exists) when opening emacs.
(let ((my-tags-file (locate-dominating-file default-directory "TAGS")))
(when my-tags-file
(message "Loading tags file: %s" my-tags-file)
(visit-tags-table my-tags-file)))
;; Resize windows
(global-set-key (kbd "S-C-h") 'shrink-window-horizontally)
(global-set-key (kbd "S-C-l") 'enlarge-window-horizontally)
(global-set-key (kbd "S-C-j") 'shrink-window)
(global-set-key (kbd "S-C-k") 'enlarge-window)
(use-package yasnippet
:config (yas-global-mode 1))
(use-package which-key
:diminish
:config
(which-key-mode)
(which-key-setup-side-window-bottom)
(setq which-key-idle-delay 0.1))
(use-package diminish
:defer 5
:config
(diminish 'org-indent-mode))
;; Note that uniquify is builtin.
(require 'uniquify)
(setq uniquify-separator "/" ;; The separator in buffer names.
uniquify-buffer-name-style 'forward) ;; names/in/this/style
(use-package rg
:config
(global-set-key (kbd "M-s g") 'rg)
(global-set-key (kbd "M-s d") 'rg-dwim))
(use-package helm-rg)
;;;; Company configuration.
(use-package company
:ensure t
:defer t
:init (global-company-mode)
:config
(progn
(add-to-list 'completion-styles 'initials t)
(bind-key "M-<tab>" #'company-complete company-mode-map)
(setq company-tooltip-align-annotations t
tab-always-indent 'complete)
(setq company-dabbrev-downcase nil))
:diminish company-mode)
;;;; Evil mode configuration.
(use-package evil
:ensure t
:init ;; tweak evil's configuration before loading it
(setq evil-search-module 'evil-search
evil-ex-complete-emacs-commands nil
evil-vsplit-window-right t
evil-split-window-below t
evil-shift-round nil
evil-undo-system 'undo-tree
evil-want-C-u-scroll t)
:config ;; tweak evil after loading it
(use-package undo-tree)
(evil-mode)
(setq evil-want-C-u-scroll t)
(eval-after-load "evil-maps"
;; Unset Evil's "M-." keymap to enable symbol definition following.
(define-key evil-normal-state-map "\M-." nil)))
(add-hook 'evil-local-mode-hook 'turn-on-undo-tree-mode)
;;;; Heml mode configuration.
(use-package helm
:diminish
:init (helm-mode t)
:bind
("M-x" . helm-M-x)
("C-x C-f" . helm-find-files)
("C-x b" . helm-mini) ;; See buffers & recent files; more useful.
("C-x r b" . helm-filtered-bookmarks)
("C-x C-r" . helm-recentf) ;; Search for recently edited files
("C-c i" . helm-imenu)
("C-c h" . helm-command-prefix)
("C-h a" . helm-apropos)
:config
(setq helm-autoresize-max-height 0
helm-autoresize-min-height 20
helm-split-window-in-side-p t
helm-move-to-line-cycle-in-source t
helm-ff-search-library-in-sexp t
helm-scroll-amount 8
helm-ff-file-name-history-use-recentf t
helm-echo-input-in-header-line t)
(when (executable-find "firefox")
(setq helm-google-suggest-use-curl-p t)))
(setq frame-title-format
(list (format "%s %%S: %%j " (system-name))
'(buffer-file-name "%f" (dired-directory dired-directory "%b"))))
(use-package better-defaults)
(provide 'jenga-init)

View file

@ -1,5 +0,0 @@
;;;; Magit configuration.
(use-package magit
:init (setq magit-auto-revert-mode nil))
(provide 'jenga-magit)

View file

@ -1,11 +0,0 @@
;;;; Org mode configuration.
;; Enable Org mode.
(use-package org
:ensure t
:init (add-to-list 'auto-mode-alist '("\\.org$" . org-mode))
:config
(setq org-todo-keywords
'((sequence "TODO(t)" "WAIT(w@/!)" "|" "DONE(d!)" "CANCELED(c@)"))))
(provide 'jenga-org)

View file

@ -1,31 +0,0 @@
;; Python configuration.
(use-package elpy
:ensure t
:init
(elpy-enable)
:bind
("M-." . jedi:goto-definition)
("M-," . jedi:goto-definition-pop-marker)
:config
(setq python-shell-interpreter "jupyter"
python-indent-offset 4
python-shell-interpreter-args "console --simple-prompt"
python-shell-prompt-detect-failure-warning nil)
(use-package jupyter
:ensure t)
(use-package ein
:ensure t)
(use-package py-autopep8
:ensure t)
(use-package jedi
:ensure t)
;; Use IPython for REPL
(add-to-list 'python-shell-completion-native-disabled-interpreters
"jupyter")
:hook
(elpy-mode . (lambda () (highlight-indentation-mode -1)))
;; (elpy-mode . py-autopep8-enable-on-save)
(elpy-mode . flycheck-mode)
(elpy-mode . jedi:setup))
(provide 'jenga-python)

View file

@ -1,43 +0,0 @@
;;;; Rust mode configuration.
;; Add rust load hooks.
(use-package rustic
:config
(setq rustic-flycheck-clippy-params "--message-format=json"))
(use-package flycheck
:hook (prog-mode . flycheck-mode))
(use-package company
:hook (prog-mode . company-mode)
:config (setq company-tooltip-align-annotations t)
(setq company-minimum-prefix-length 1))
(use-package lsp-mode
:commands lsp
:config (require 'lsp-clients))
(use-package lsp-ui
:commands lsp-ui-mode
:config (setq lsp-ui-peek-enable t)
(setq lsp-ui-doc-enable nil)
(setq lsp-ui-doc-use-childframe t)
(setq lsp-ui-doc-header nil)
(setq lsp-ui-doc-position 'top)
(setq lsp-ui-doc-use-webkit nil)
:bind (:map lsp-ui-mode-map
("M-." . lsp-ui-peek-find-definitions)
("M-," . lsp-ui-peek-jump-backward)
("M-?" . lsp-ui-peek-find-references)
("M-h" . lsp-ui-doc-show)
("M-j" . lsp-ui-doc-hide)
("C-c u" . lsp-ui-imenu)
("C-c C-a" . lsp-ui-sideline-apply-code-actions)))
(use-package helm-lsp
:config
(define-key lsp-mode-map [remap xref-find-apropos] #'helm-lsp-workspace-symbol))
(use-package flycheck-rust
:config (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))
(provide 'jenga-rust)

View file

@ -1,13 +0,0 @@
(add-to-list 'auto-mode-alist '("\\.service\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.timer\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.target\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.mount\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.automount\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.slice\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.socket\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.path\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.netdev\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.network\\'" . conf-unix-mode))
(add-to-list 'auto-mode-alist '("\\.link\\'" . conf-unix-mode))
(provide 'jenga-systemd)

View file

@ -1,33 +0,0 @@
(add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
(load-theme 'almost-vim t)
;;
;; ===============
;; Other UI tweaks
;; ===============
;;
;; Disable the splash screen (to enable it agin, replace the t with 0).
(setq inhibit-splash-screen t)
;; Disable the menu.
(tool-bar-mode -1)
;; Enable transient mark mode.
(transient-mark-mode 1)
;; Highlight paired parentheses when cursor is over one.
(show-paren-mode 1)
(setq-default display-line-numbers-type 'absolute
display-line-numbers-current-absolute t
display-line-numbers-width 4
display-line-numbers-widen t)
(add-hook 'text-mode-hook #'display-line-numbers-mode)
(add-hook 'prog-mode-hook #'display-line-numbers-mode)
;; (set-face-attribute 'default (selected-frame) :height 85)
(setq column-number-mode t)
(setq ido-use-filename-at-point nil)
(provide 'jenga-ui)

View file

@ -1,145 +0,0 @@
;; ## added by OPAM user-setup for emacs / base ## cfd3c9b7837c85cffd0c59de521990f0 ## you can edit, but keep this line
(provide 'opam-user-setup)
;; Base configuration for OPAM
(defun opam-shell-command-to-string (command)
"Similar to shell-command-to-string, but returns nil unless the process
returned 0, and ignores stderr (shell-command-to-string ignores return value)"
(let* ((return-value 0)
(return-string
(with-output-to-string
(setq return-value
(with-current-buffer standard-output
(process-file shell-file-name nil '(t nil) nil
shell-command-switch command))))))
(if (= return-value 0) return-string nil)))
(defun opam-update-env (switch)
"Update the environment to follow current OPAM switch configuration"
(interactive
(list
(let ((default
(car (split-string (opam-shell-command-to-string "opam switch show --safe")))))
(completing-read
(concat "opam switch (" default "): ")
(split-string (opam-shell-command-to-string "opam switch list -s --safe") "\n")
nil t nil nil default))))
(let* ((switch-arg (if (= 0 (length switch)) "" (concat "--switch " switch)))
(command (concat "opam config env --safe --sexp " switch-arg))
(env (opam-shell-command-to-string command)))
(when (and env (not (string= env "")))
(dolist (var (car (read-from-string env)))
(setenv (car var) (cadr var))
(when (string= (car var) "PATH")
(setq exec-path (split-string (cadr var) path-separator)))))))
(opam-update-env nil)
(defvar opam-share
(let ((reply (opam-shell-command-to-string "opam config var share --safe")))
(when reply (substring reply 0 -1))))
(add-to-list 'load-path (concat opam-share "/emacs/site-lisp"))
;; OPAM-installed tools automated detection and initialisation
(defun opam-setup-tuareg ()
(add-to-list 'load-path (concat opam-share "/tuareg") t)
(load "tuareg-site-file"))
(defun opam-setup-add-ocaml-hook (h)
(add-hook 'tuareg-mode-hook h t)
(add-hook 'caml-mode-hook h t))
(defun opam-setup-complete ()
(if (require 'company nil t)
(opam-setup-add-ocaml-hook
(lambda ()
(company-mode)
(defalias 'auto-complete 'company-complete)))
(require 'auto-complete nil t)))
(defun opam-setup-ocp-indent ()
(opam-setup-complete)
(autoload 'ocp-setup-indent "ocp-indent" "Improved indentation for Tuareg mode")
(autoload 'ocp-indent-caml-mode-setup "ocp-indent" "Improved indentation for Caml mode")
(add-hook 'tuareg-mode-hook 'ocp-setup-indent t)
(add-hook 'caml-mode-hook 'ocp-indent-caml-mode-setup t))
(defun opam-setup-ocp-index ()
(autoload 'ocp-index-mode "ocp-index" "OCaml code browsing, documentation and completion based on build artefacts")
(opam-setup-add-ocaml-hook 'ocp-index-mode))
(defun opam-setup-merlin ()
(opam-setup-complete)
(require 'merlin)
(opam-setup-add-ocaml-hook 'merlin-mode)
(defcustom ocp-index-use-auto-complete nil
"Use auto-complete with ocp-index (disabled by default by opam-user-setup because merlin is in use)"
:group 'ocp_index)
(defcustom merlin-ac-setup 'easy
"Use auto-complete with merlin (enabled by default by opam-user-setup)"
:group 'merlin-ac)
;; So you can do it on a mac, where `C-<up>` and `C-<down>` are used
;; by spaces.
(define-key merlin-mode-map
(kbd "C-c <up>") 'merlin-type-enclosing-go-up)
(define-key merlin-mode-map
(kbd "C-c <down>") 'merlin-type-enclosing-go-down)
(set-face-background 'merlin-type-face "skyblue"))
(defun opam-setup-utop ()
(autoload 'utop "utop" "Toplevel for OCaml" t)
(autoload 'utop-minor-mode "utop" "Minor mode for utop" t)
(add-hook 'tuareg-mode-hook 'utop-minor-mode))
(defvar opam-tools
'(("tuareg" . opam-setup-tuareg)
("ocp-indent" . opam-setup-ocp-indent)
("ocp-index" . opam-setup-ocp-index)
("merlin" . opam-setup-merlin)
("utop" . opam-setup-utop)))
(defun opam-detect-installed-tools ()
(let*
((command "opam list --installed --short --safe --color=never")
(names (mapcar 'car opam-tools))
(command-string (mapconcat 'identity (cons command names) " "))
(reply (opam-shell-command-to-string command-string)))
(when reply (split-string reply))))
(defvar opam-tools-installed (opam-detect-installed-tools))
(defun opam-auto-tools-setup ()
(interactive)
(dolist (tool opam-tools)
(when (member (car tool) opam-tools-installed)
(funcall (symbol-function (cdr tool))))))
(opam-auto-tools-setup)
;; ## end of OPAM user-setup addition for emacs / base ## keep this line
;; ## added by OPAM user-setup for emacs / tuareg ## 11220c2e9f3815dba1b048191055cfcd ## you can edit, but keep this line
;; Set to autoload tuareg from its original switch when not found in current
;; switch (don't load tuareg-site-file as it adds unwanted load-paths)
(defun opam-tuareg-autoload (fct file doc args)
(let ((load-path (cons "/home/vladan/.opam/default/share/emacs/site-lisp" load-path)))
(load file))
(apply fct args))
(when (not (member "tuareg" opam-tools-installed))
(defun tuareg-mode (&rest args)
(opam-tuareg-autoload 'tuareg-mode "tuareg" "Major mode for editing OCaml code" args))
(defun tuareg-run-ocaml (&rest args)
(opam-tuareg-autoload 'tuareg-run-ocaml "tuareg" "Run an OCaml toplevel process" args))
(defun ocamldebug (&rest args)
(opam-tuareg-autoload 'ocamldebug "ocamldebug" "Run the OCaml debugger" args))
(defalias 'run-ocaml 'tuareg-run-ocaml)
(defalias 'camldebug 'ocamldebug)
(add-to-list 'auto-mode-alist '("\\.ml[iylp]?\\'" . tuareg-mode))
(add-to-list 'auto-mode-alist '("\\.eliomi?\\'" . tuareg-mode))
(add-to-list 'interpreter-mode-alist '("ocamlrun" . tuareg-mode))
(add-to-list 'interpreter-mode-alist '("ocaml" . tuareg-mode))
(dolist (ext '(".cmo" ".cmx" ".cma" ".cmxa" ".cmxs" ".cmt" ".cmti" ".cmi" ".annot"))
(add-to-list 'completion-ignored-extensions ext)))
;; ## end of OPAM user-setup addition for emacs / tuareg ## keep this line