|
|
@@ -1,42 +1,120 @@ |
|
|
(require 'cl-lib) |
|
|
(require 'cl-lib) |
|
|
(require 'company) |
|
|
(require 'company) |
|
|
|
|
|
|
|
|
|
|
|
;; "= . args" |
|
|
|
|
|
;; "> . args" |
|
|
|
|
|
;; ">= . args" |
|
|
|
|
|
;; "< . args" |
|
|
|
|
|
;; "<= . args" |
|
|
|
|
|
;; "+ . args" |
|
|
|
|
|
;; "- . args" |
|
|
|
|
|
;; "* . args" |
|
|
|
|
|
;; "/ . args" |
|
|
|
|
|
;; "** a b" |
|
|
|
|
|
;; "% a b" |
|
|
|
|
|
;; "get-random-between a b" |
|
|
|
|
|
;; "assert test" |
|
|
|
|
|
;; "define-syntax form (:doc \"\") . body" |
|
|
|
|
|
;; "define definee (:doc \"\") . body" |
|
|
|
|
|
;; "mutate target source" |
|
|
|
|
|
;; "vector-length v" |
|
|
|
|
|
;; "vector-ref vec idx" |
|
|
|
|
|
;; "vector-set! vec idx val" |
|
|
|
|
|
;; "set! sym val" |
|
|
|
|
|
;; "set-car! target source" |
|
|
|
|
|
;; "set-cdr! target source" |
|
|
|
|
|
;; "if test then_part else_part" |
|
|
|
|
|
;; "quote datum" |
|
|
|
|
|
;; "quasiquote expr" |
|
|
|
|
|
;; "and . args" |
|
|
|
|
|
;; "or . args" |
|
|
|
|
|
;; "not test" |
|
|
|
|
|
;; "lambda args . body" |
|
|
|
|
|
;; "apply fun args" |
|
|
|
|
|
;; "eval expr" |
|
|
|
|
|
;; "begin . args" |
|
|
|
|
|
;; "list . args" |
|
|
|
|
|
;; "pair car cdr" |
|
|
|
|
|
;; "first seq" |
|
|
|
|
|
;; "rest seq" |
|
|
|
|
|
;; "set-type! node new_type" |
|
|
|
|
|
;; "delete-type! n" |
|
|
|
|
|
;; "type n" |
|
|
|
|
|
;; "mem-reset" |
|
|
|
|
|
;; "info n" |
|
|
|
|
|
;; "show n" |
|
|
|
|
|
;; "addr-of var" |
|
|
|
|
|
;; "generate-docs file_name" |
|
|
|
|
|
;; "print (:sep \" \") (:end \"\\n\") . things" |
|
|
|
|
|
;; "read (:prompt \">\"" |
|
|
|
|
|
;; "exit (:code 0)" |
|
|
|
|
|
;; "break" |
|
|
|
|
|
;; "memstat" |
|
|
|
|
|
;; "mytry try_part catch_part" |
|
|
|
|
|
;; "load file" |
|
|
|
|
|
;; "import f" |
|
|
|
|
|
;; "copy obj" |
|
|
|
|
|
;; "error type message" |
|
|
|
|
|
;; "symbol->keyword sym" |
|
|
|
|
|
;; "string->symbol str" |
|
|
|
|
|
;; "symbol->string sym" |
|
|
|
|
|
;; "concat-strings . strings" |
|
|
|
|
|
|
|
|
(defconst slime-built-ins |
|
|
(defconst slime-built-ins |
|
|
'("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%" |
|
|
|
|
|
"assert" "define" "define-syntax" "mutate" "if" |
|
|
|
|
|
"quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "while" "let" |
|
|
|
|
|
"lambda" "special-lambda" "eval" "begin" "list" "pair" |
|
|
|
|
|
"first" "rest" "set-type" "delete-type" "type" "info" |
|
|
|
|
|
"show" "addr-of" "generate-docs" "print" "read" "exit" "break" "memstat" "try" |
|
|
|
|
|
"load" "import" "copy" "error" "symbol->keyword" "string->symbol" |
|
|
|
|
|
|
|
|
'("=" ">" ">=" "<" "<=" "+" "-" "*" "/" "**" "%" "get-random-between" |
|
|
|
|
|
"assert" "define" "define-syntax" "mutate" "if" "vector-length" |
|
|
|
|
|
"vector-ref" "vector-set!" "set!" "set-car!" "set-cdr!" |
|
|
|
|
|
"quote" "quasiquote" "unquote" "unquote-splicing" "and" "or" "not" "let" |
|
|
|
|
|
"lambda" "apply" "eval" "begin" "list" "pair" "create-hash-map" |
|
|
|
|
|
"hash-map-get" "hash-map-set!" "hash-map-delete!" "vector" |
|
|
|
|
|
"first" "rest" "set-type!" "delete-type!" "type" "info" "mem-reset" |
|
|
|
|
|
"show" "addr-of" "generate-docs" "print" "read" "exit" "break" "memstat" |
|
|
|
|
|
"mytry" "load" "import" "copy" "error" "symbol->keyword" "string->symbol" |
|
|
"symbol->string" "concat-strings")) |
|
|
"symbol->string" "concat-strings")) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun my-slime-eldoc-function () |
|
|
|
|
|
(let ((symbol (symbol-name (car (read (thing-at-point 'sexp)))))) |
|
|
|
|
|
(if (member symbol slime-built-ins) |
|
|
|
|
|
(sample-meta symbol) |
|
|
|
|
|
(concat symbol " ?")))) |
|
|
|
|
|
|
|
|
|
|
|
(defun sample-meta (s) |
|
|
|
|
|
|
|
|
(defun get-args (s) |
|
|
(cond |
|
|
(cond |
|
|
((string= s "=") "(= :rest <objects>)") |
|
|
|
|
|
((string= s ">") "(> :rest <numbers>)") |
|
|
|
|
|
((string= s ">=") "(>= :rest <numbers>)") |
|
|
|
|
|
((string= s "<") "(< :rest <numbers>)") |
|
|
|
|
|
((string= s "<=") "(<= :rest <numbers>)") |
|
|
|
|
|
((string= s "+") "(+ :rest <numbers>)") |
|
|
|
|
|
((string= s "-") "(- :rest <numbers>)") |
|
|
|
|
|
((string= s "*") "(* :rest <numbers>)") |
|
|
|
|
|
((string= s "/") "(/ :rest <numbers>)") |
|
|
|
|
|
((string= s "**") "(** <number> <exponent>)") |
|
|
|
|
|
((string= s "assert") "(assert <condition>)") |
|
|
|
|
|
((string= s "define") "(define <name-or-lambda-list> [doc-string] <expression-or-bodx>)") |
|
|
|
|
|
((string= s "define-syntax") "(define-syntax <name-and-lambda-list> [doc-string] <bodx>)") |
|
|
|
|
|
|
|
|
((string= s "=") ". objects") |
|
|
|
|
|
((string= s ">") ". objects") |
|
|
|
|
|
((string= s ">=") ". objects") |
|
|
|
|
|
((string= s "<") ". objects") |
|
|
|
|
|
((string= s "<=") ". objects") |
|
|
|
|
|
((string= s "+") ". objects") |
|
|
|
|
|
((string= s "-") ". objects") |
|
|
|
|
|
((string= s "*") ". objects") |
|
|
|
|
|
((string= s "/") ". objects") |
|
|
|
|
|
((string= s "**") "a b") |
|
|
|
|
|
((string= s "%") "a b") |
|
|
|
|
|
((string= s "get-random-between") "a b") |
|
|
|
|
|
((string= s "assert") "test") |
|
|
|
|
|
((string= s "define") "definee (:doc \"\") . body") |
|
|
|
|
|
((string= s "define-syntax") "form (:doc \"\") . body") |
|
|
((string= s "mutate") "(mutate <expression> <expression>)") |
|
|
((string= s "mutate") "(mutate <expression> <expression>)") |
|
|
((string= s "if") "(if <test> <consequence> <alternative>)") |
|
|
((string= s "if") "(if <test> <consequence> <alternative>)") |
|
|
(t ""))) |
|
|
|
|
|
|
|
|
(t '()))) |
|
|
|
|
|
|
|
|
|
|
|
(defun sample-meta (s) |
|
|
|
|
|
(message "%s%s%s%s" |
|
|
|
|
|
(propertize "(" 'face '(:foreground "orange")) |
|
|
|
|
|
(propertize s 'face '(:foreground "#859900")) |
|
|
|
|
|
(let ((args (get-args s))) |
|
|
|
|
|
(if args |
|
|
|
|
|
(concat " " args) |
|
|
|
|
|
"")) |
|
|
|
|
|
(propertize ")" 'face '(:foreground "orange")) |
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(defun my-slime-eldoc-function () |
|
|
|
|
|
(let ((sexp-text (thing-at-point 'sexp))) |
|
|
|
|
|
(when sexp-text |
|
|
|
|
|
(let* ((sexp (read sexp-text)) |
|
|
|
|
|
(symbol (if (listp sexp) |
|
|
|
|
|
(symbol-name (car sexp)) |
|
|
|
|
|
(symbol-name sexp)))) |
|
|
|
|
|
(when (member symbol slime-built-ins) |
|
|
|
|
|
(sample-meta symbol)))))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(add-to-list 'auto-mode-alist '("\\.slime\\'" . slime-mode)) |
|
|
(add-to-list 'auto-mode-alist '("\\.slime\\'" . slime-mode)) |
|
|
@@ -124,7 +202,7 @@ |
|
|
(setq-local electric-quote-string t)) |
|
|
(setq-local electric-quote-string t)) |
|
|
(setq imenu-case-fold-search nil) |
|
|
(setq imenu-case-fold-search nil) |
|
|
(add-function :before-until (local 'eldoc-documentation-function) |
|
|
(add-function :before-until (local 'eldoc-documentation-function) |
|
|
#'elisp-eldoc-documentation-function) |
|
|
|
|
|
|
|
|
#'my-slime-eldoc-function) |
|
|
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t) |
|
|
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t) |
|
|
(setq-local project-vc-external-roots-function #'elisp-load-path-roots) |
|
|
(setq-local project-vc-external-roots-function #'elisp-load-path-roots) |
|
|
(add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local) |
|
|
(add-hook 'completion-at-point-functions #'elisp-completion-at-point nil 'local) |
|
|
@@ -160,7 +238,7 @@ |
|
|
|
|
|
|
|
|
(add-hook 'slime-mode-hook |
|
|
(add-hook 'slime-mode-hook |
|
|
(lambda () |
|
|
(lambda () |
|
|
;; (set (make-local-variable 'eldoc-documentation-function) 'my-slime-eldoc-function) |
|
|
|
|
|
|
|
|
(set (make-local-variable 'eldoc-documentation-function) 'my-slime-eldoc-function) |
|
|
(set (make-local-variable 'company-backends) '(company-sample-backend)))) |
|
|
(set (make-local-variable 'company-backends) '(company-sample-backend)))) |
|
|
|
|
|
|
|
|
(provide 'slime-mode) |
|
|
(provide 'slime-mode) |