Move some stuff
This commit is contained in:
parent
253d185ca3
commit
bcaa83cfd5
57 changed files with 55 additions and 12 deletions
98
user-lisp/langs/icejam-lang-ocaml.el
Normal file
98
user-lisp/langs/icejam-lang-ocaml.el
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
;;; ocaml -- summary -*- lexical-binding: t; -*-
|
||||
;;; Commentary:
|
||||
;;; Code:
|
||||
(eval-when-compile
|
||||
(defvar icejam-ocaml-lang-menu 'icejam-lang-ocaml)
|
||||
(defvar icejam-language-transient-alist)
|
||||
(declare-function transient-define-prefix 'transient)
|
||||
(declare-function icejam-set-indent 'icejam-prog-mode)
|
||||
(declare-function icejam-set-eglot-capfs 'icejam-complete-at-point))
|
||||
|
||||
(use-package merlin :defer t :ensure t)
|
||||
(use-package opam-switch-mode :defer t :ensure t :commands (opam-switch-mode))
|
||||
(use-package dune :defer t :ensure t)
|
||||
(use-package tuareg :defer t :ensure t)
|
||||
|
||||
(with-eval-after-load 'tuareg
|
||||
(add-hook 'tuareg-mode-hook 'merlin-mode))
|
||||
|
||||
(transient-define-prefix icejam-ocaml-lang-menu ()
|
||||
"Ocaml Actions."
|
||||
["OCaml actions"
|
||||
[""
|
||||
("r" "Reload" icejam-revert-buffer-no-confirm)
|
||||
("i" "Indent" icejam-mark-and-indent-whole-buffer)]
|
||||
[""
|
||||
("f" "Format" lsp-format-buffer)
|
||||
("e" "Errors" flymake-show-buffer-diagnostics)
|
||||
("o" "Opam Env" opam-switch-set-switch)]]
|
||||
[""
|
||||
("q" "Quit" keyboard-quit)])
|
||||
|
||||
(add-to-list 'icejam-language-transient-alist '(tuareg-mode . icejam-ocaml-lang-menu))
|
||||
|
||||
(defun icejam-load-ocaml-site-packages ()
|
||||
"Generate ocaml config."
|
||||
(let ((opam-share (ignore-errors (car (process-lines "opam" "var" "share")))))
|
||||
(when (and opam-share (file-directory-p opam-share))
|
||||
;; Register Merlin
|
||||
(add-to-list 'load-path (expand-file-name "emacs/site-lisp" opam-share))
|
||||
(autoload 'merlin-mode "merlin" nil t nil)
|
||||
(autoload 'utop "utop" nil t nil)
|
||||
(autoload 'dune "dune" nil t nil)
|
||||
|
||||
;; Use opam switch to lookup ocamlmerlin binary
|
||||
(setq merlin-command 'opam))))
|
||||
|
||||
;; OCaml setup
|
||||
(defun icejam-activate-tuareg-mode ()
|
||||
"All thing OCaml."
|
||||
(icejam-set-indent 2)
|
||||
(opam-switch-mode t)
|
||||
(icejam-load-ocaml-site-packages)
|
||||
(eglot-ensure)
|
||||
(icejam-set-eglot-capfs))
|
||||
|
||||
(add-hook 'tuareg-mode-hook 'icejam-activate-tuareg-mode)
|
||||
|
||||
;; Disable merlin keys that are unused by me
|
||||
(add-hook 'merlin-mode-hook (lambda ()
|
||||
(unbind-key "C-c C-d" merlin-mode-map)
|
||||
(unbind-key "C-c C-l" merlin-mode-map)
|
||||
(unbind-key "C-c C-n" merlin-mode-map)
|
||||
(unbind-key "C-c C-p" merlin-mode-map)
|
||||
(unbind-key "C-c C-r" merlin-mode-map)
|
||||
(unbind-key "C-c C-t" merlin-mode-map)
|
||||
(unbind-key "C-c C-x" merlin-mode-map)
|
||||
(unbind-key "C-c &" merlin-mode-map)))
|
||||
|
||||
;; Use tuareg-opam with lock files
|
||||
(add-to-list 'auto-mode-alist '("\\.opam.locked\\'" . tuareg-opam-mode))
|
||||
|
||||
;; (transient-define-prefix icejam-lang-reasonml-context-menu ()
|
||||
;; "ReasonML Actions."
|
||||
;; ["ReasonML actions"
|
||||
;; [""
|
||||
;; ("r" "Reload" icejam-revert-buffer-no-confirm)
|
||||
;; ("i" "Indent" icejam-mark-and-indent-whole-buffer)]
|
||||
;; [""
|
||||
;; ("f" "Format" refmt)
|
||||
;; ("e" "Opam Env" opam-switch-set-switch)]]
|
||||
;; [""
|
||||
;; ("q" "Quit" keyboard-quit)])
|
||||
|
||||
|
||||
;; (defun icejam-lang-activate-reason-mode ()
|
||||
;; "Generate reason config."
|
||||
;; (define-key
|
||||
;; reason-mode-map (kbd "C-c l") 'icejam-lang-reasonml-context-menu))
|
||||
|
||||
;; ;; Reason setup
|
||||
;; (add-hook 'reason-mode-hook
|
||||
;; (lambda ()
|
||||
;; (add-hook 'before-save-hook #'refmt-before-save)))
|
||||
;; (add-hook 'reason-mode-hook 'icejam-lang-activate-reason-mode)
|
||||
;; (add-hook 'reason-mode-hook 'merlin-mode)
|
||||
|
||||
(provide 'icejam-lang-ocaml)
|
||||
;;; icejam-lang-ocaml.el ends here
|
||||
Loading…
Add table
Add a link
Reference in a new issue