Skip to content

Instantly share code, notes, and snippets.

@ivg
Created September 26, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivg/25a48b9452fe2ea42ae5965f45c26a3e to your computer and use it in GitHub Desktop.
Save ivg/25a48b9452fe2ea42ae5965f45c26a3e to your computer and use it in GitHub Desktop.
BAP Vagrant file with the emacs development environment
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.provider "virtualbox" do |vb|
vb.memory = "4096"
end
config.vm.provision "shell", privileged: false, inline: <<-SHELL
sudo add-apt-repository --yes ppa:avsm/ppa
sudo apt-get update
sudo apt-get --yes install opam
opam init --auto-setup --comp=4.02.3 --yes
eval `opam config env`
opam depext bap --install --yes
sudo apt-get install emacs24 --yes
opam install tuareg merlin ocp-indent --yes
sudo apt-get install python-pip --yes
sudo pip install bap
cat > .emacs << EOF
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.milkbox.net/packages/")))
(package-initialize)
(defun opam-path (path)
(let ((opam-share-dir
(shell-command-to-string
"echo -n `opam config var share`")))
(concat opam-share-dir "/" path)))
(add-to-list 'load-path (opam-path "emacs/site-lisp"))
(add-to-list 'load-path (opam-path "tuareg"))
(load "tuareg-site-file")
(unless (package-installed-p 'company)
(package-install 'company))
(require 'ocp-indent)
(require 'merlin)
(require 'company)
(add-to-list 'company-backends 'merlin-company-backend)
(add-hook 'merlin-mode-hook 'company-mode)
(define-key merlin-mode-map (kbd "C-c TAB") 'company-complete)
(define-key merlin-mode-map (kbd "C-c C-d") 'merlin-document)
(define-key merlin-mode-map (kbd "C-c d") 'merlin-destruct)
(setq merlin-completion-with-doc t)
(setq merlin-use-auto-complete-mode nil)
(setq merlin-command 'opam)
(setq merlin-locate-preference 'mli)
(defun ocp-indent-buffer ()
(interactive)
(save-excursion
(mark-whole-buffer)
(ocp-indent-region (region-beginning)
(region-end))))
(add-hook 'tuareg-mode-hook
(lambda ()
(merlin-mode)
(local-set-key (kbd "C-c c") 'recompile)
(local-set-key (kbd "C-c C-c") 'recompile)
(auto-fill-mode)
(tuareg-make-indentation-regexps)
(add-hook 'before-save-hook 'ocp-indent-buffer nil t)))
(defun opam-env ()
(interactive nil)
(dolist (var
(car (read-from-string
(shell-command-to-string "opam config env --sexp"))))
(setenv (car var) (cadr var))))
EOF
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment