Compare commits

...

6 Commits

7 changed files with 144 additions and 20 deletions

View File

@@ -69,4 +69,6 @@
syd/lsp syd/lsp
syd/custom syd/custom
syd/transient syd/transient
syd/bookmark)) syd/bookmark
syd/haskell
syd/qbe))

View File

@@ -21,21 +21,38 @@
(use-package cider (use-package cider
:after clojure-mode :after clojure-mode
:config :config
(defun syd-clojure-doc (arg) (defun syd-clojure-doc (arg)
(interactive "P") (interactive "P")
(cider-doc arg) (cider-doc arg)
cider-doc-buffer) cider-doc-buffer)
(defun syd-clojure-eval-region (beg end) (defun syd-clojure-eval-region (beg end)
(cider-eval-region beg end)) (cider-eval-region beg end))
(syd-handle '(clojure-mode clojurescript-mode cider-repl-mode) (syd-handle '(clojure-mode clojurescript-mode cider-repl-mode)
:docs #'cider-doc :docs #'cider-doc
:eval-region #'syd-clojure-eval-region :eval-region #'syd-clojure-eval-region
:load-buffer #'cider-load-buffer) :load-buffer #'cider-load-buffer)
(add-hook 'cider-repl-mode-hook #'syd-lisp-mode) (add-hook 'cider-repl-mode-hook #'syd-lisp-mode)
(syd-push shackle-rules (syd-push shackle-rules
`("*cider-doc*" ,@syd-help-popup-options) `("*cider-doc*" ,@syd-help-popup-options)
'("*cider-test-report*") '("*cider-test-report*")
'("*cider-error*"))) '("*cider-error*"))
(defun syd-clojure-classpath-relative-file-name (file-name)
(when (and cider-mode (cider-nrepl-eval-session))
(let ((prefixes (-filter #'file-directory-p
(cider-classpath-entries))))
(cl-loop for classpath-entry in prefixes
for prefix = (file-name-as-directory classpath-entry)
when (string-prefix-p prefix file-name)
return (string-remove-prefix prefix file-name)))))
(add-to-list 'syd-insert-file-name-alist
`(,#'syd-clojure-classpath-relative-file-name
. "Classpath-relative")))
(use-package cider-mode (use-package cider-mode
:straight nil ; Part of `cider'. :straight nil ; Part of `cider'.

View File

@@ -0,0 +1,65 @@
;; -*- lexical-binding: t; -*-
(require 'syd/base)
(require 'syd/handle)
(defun syd-haskell-open-repl ()
"Open a Haskell REPL."
(interactive)
(require 'inf-haskell)
(run-haskell))
(defun syd-haskell-evil-open-above ()
"Opens a line above the current, following Haskell-mode's indentation"
(interactive)
(evil-beginning-of-line)
(haskell-indentation-newline-and-indent)
(evil-previous-line)
(haskell-indentation-indent-line)
(evil-append-line nil))
(defun syd-haskell-evil-open-below ()
"Opens a line below the current, following Haskell-mode's indentation"
(interactive)
(evil-append-line nil)
(haskell-indentation-newline-and-indent))
(defun syd-haskell-hoogle-start-server ()
(interactive)
(haskell-hoogle-start-server)
(message "Hoogle started on localhost:%d" haskell-hoogle-port-number))
(use-package haskell-mode
:mode (("\\.l?hs'" . haskell-literate-mode)
("\\.hs'" . haskell-mode))
:custom (; Show errors in REPL, not popup buffers.
(haskell-interactive-popup-errors nil)
(haskell-process-suggest-remove-import-line t)
(haskell-process-auto-import-loaded-modules t))
:general
(:keymaps 'haskell-mode-map
:states '(normal visual motion emacs insert)
:major-modes t
:prefix syd-localleader-key
:non-normal-prefix syd-alt-localleader-key
"c" #'haskell-cabal-visit-file
"h s" #'syd-haskell-hoogle-start-server
"h q" #'haskell-hoogle-kill-server)
(:keymaps 'interactive-haskell-mode-map
:states '(normal insert)
"C-j" #'haskell-interactive-mode-history-next
"C-k" #'haskell-interactive-mode-history-previous)
(:keymaps 'haskell-mode-map
:states 'normal
[remap evil-open-above] #'syd-haskell-evil-open-above
[remap evil-open-below] #'syd-haskell-evil-open-below)
:config
(add-to-list 'completion-ignored-extensions ".hi"))
(use-package lsp-haskell
:defer t
:custom ((lsp-haskell-server-path "haskell-language-server"))
:init
(add-hook 'haskell-mode-hook #'lsp-deferred 'append)
(add-hook 'haskell-literate-mode-hook #'lsp-deferred 'append))
(provide 'syd/haskell)

View File

@@ -2,6 +2,7 @@
(require 'syd/base) (require 'syd/base)
(require 'syd/popups) (require 'syd/popups)
(require 'syd/handle)
(use-package lsp-mode (use-package lsp-mode
:init :init
@@ -35,6 +36,12 @@
(syd-push (syd-push
shackle-rules shackle-rules
`(("*lsp-help*" "*lsp-install*") `(("*lsp-help*" "*lsp-install*")
,@syd-help-popup-options))) :select nil :size 0.42 :popup t :align bottom))
(defun syd-lsp-handle-docs ()
(interactive)
(lsp-describe-thing-at-point)
(get-buffer "*lsp-help*"))
(syd-handle 'lsp-mode
:docs #'syd-lsp-handle-docs)))
(provide 'syd/lsp) (provide 'syd/lsp)

View File

@@ -193,21 +193,37 @@ form."
(cons mode (intern (concat (match-string 1 s) "-ts-mode")))) (cons mode (intern (concat (match-string 1 s) "-ts-mode"))))
(error "Symbol `%c' is not a mode." mode)))) (error "Symbol `%c' is not a mode." mode))))
(defun syd--insert-file-name-annotation (x) (defun syd--insert-file-name-annotation (descs)
(concat (when descs
" " (let ((s (string-join descs ", ")))
(propertize " " 'display `(space :align-to (- right ,(+ 1 (length x))))) (concat
x)) " "
(propertize " " 'display `(space :align-to (- right ,(+ 1 (length s)))))
s))))
(defun syd-project-relative-file-name (file-name)
(file-relative-name file-name (project-root (project-current))))
(defvar syd-insert-file-name-alist
`((,#'syd-project-relative-file-name . "Project-relative")
(,#'file-relative-name . "File-relative")
(,#'identity . "Absolute"))
"List of pairs where each cons is a function mapping paths to paths
or nil, and each cons is a string description.")
(defun syd--evaluate-syd-insert-file-name-alist (path)
(cl-loop for (fn . lbl) in syd-insert-file-name-alist
for r = (funcall fn path)
when r
collect (cons r lbl)))
(defun syd-insert-file-name () (defun syd-insert-file-name ()
(interactive) (interactive)
(let* ((path (read-file-name "Path: " nil nil 'confirm)) (let* ((path (expand-file-name
(proj-root (project-root (project-current))) (read-file-name "Path: " nil nil 'confirm)))
(alts (choose-a-dir "... (choose a dir)")
`((,(file-relative-name path proj-root) . "Project-relative") (alts (cons `(,choose-a-dir)
(,(file-relative-name path default-directory) . "File-relative") (syd--evaluate-syd-insert-file-name-alist path)))
(,path . "Absolute")
("... (choose a dir)")))
(choice (choice
(completing-read (completing-read
"Variant: " "Variant: "
@@ -217,11 +233,14 @@ form."
`(metadata `(metadata
(annotation-function (annotation-function
. ,(lambda (s) . ,(lambda (s)
(when-let* ((desc (cdr (assoc s alts)))) (let ((descs
(cl-loop for (p . lbl) in alts
when (equal p s)
collect lbl)))
(syd--insert-file-name-annotation (syd--insert-file-name-annotation
desc)))))) descs))))))
(_ (all-completions s (mapcar #'car alts) p))))))) (_ (all-completions s (mapcar #'car alts) p)))))))
(if (equal choice "... (choose a root)") (if (equal choice choose-a-dir)
(insert (file-relative-name (insert (file-relative-name
path (read-file-name "Relative to: " nil nil path (read-file-name "Relative to: " nil nil
'confirm))) 'confirm)))

View File

@@ -0,0 +1,12 @@
;; -*- lexical-binding: t; -*-
(require 'syd/base)
(use-package qbe-mode
:mode "\\.qbe\\'"
:straight (:type git
:host github
:repo "mbknust/qbe-mode")
:config
(add-hook 'qbe-mode-hook #'indent-tabs-mode))
(provide 'syd/qbe)

View File

@@ -22,11 +22,13 @@ in {
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://cache.nixos.org" "https://cache.nixos.org"
"https://cache.iog.io" "https://cache.iog.io"
"https://cache.zw3rk.com"
]; ];
trusted-public-keys = [ trusted-public-keys = [
(builtins.readFile ../../public-keys/deertopia-cache.pub.pem) (builtins.readFile ../../public-keys/deertopia-cache.pub.pem)
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ="
"loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk="
]; ];
}; };
}; };