Add Layer for the Factor Programming Language
This commit is contained in:
parent
670a483735
commit
2c4ac9b2f4
75
layers/+lang/factor/README.org
Normal file
75
layers/+lang/factor/README.org
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#+TITLE: Factor Layer
|
||||||
|
[[file:img/logo.png]]
|
||||||
|
|
||||||
|
* Table of Contents :TOC_4_gh:noexport:
|
||||||
|
- [[#description][Description]]
|
||||||
|
- [[#install][Install]]
|
||||||
|
- [[#key-bindings][Key Bindings]]
|
||||||
|
- [[#factor-mode-editing-source-files][factor-mode (editing source files)]]
|
||||||
|
- [[#fuel-listener-mode][fuel-listener-mode]]
|
||||||
|
- [[#snippets][Snippets]]
|
||||||
|
|
||||||
|
* Description
|
||||||
|
A spacemacs layer for Factor language support.
|
||||||
|
|
||||||
|
* Install
|
||||||
|
This layer depends on the elisp files that are bundled with factor. To use this
|
||||||
|
layer, make sure that factor is installed and the bundled elisp files are picked
|
||||||
|
up by emacs (usually somewhere in site-lisp).
|
||||||
|
|
||||||
|
To use this layer, add it to your =./spacemacs= file. Add =factor= to the
|
||||||
|
=dotspacemacs-configuration-layers= list there.
|
||||||
|
|
||||||
|
* Key Bindings
|
||||||
|
** factor-mode (editing source files)
|
||||||
|
|
||||||
|
| Key Binding | Description |
|
||||||
|
|-------------+--------------------------------------------------------|
|
||||||
|
| ~SPC m '~ | Jump to the factor listener, start if required |
|
||||||
|
| ~SPC m c c~ | Compile and run the current file |
|
||||||
|
| | |
|
||||||
|
| ~SPC m e f~ | Evaluate definition at point |
|
||||||
|
| ~SPC m e r~ | Evaluate region |
|
||||||
|
| ~SPC m e R~ | Evaluate region extended to nearest definition |
|
||||||
|
| | |
|
||||||
|
| ~SPC m g g~ | Jump to definition of word under point |
|
||||||
|
| ~SPC m g G~ | Jump to definition of word under point in other window |
|
||||||
|
| ~SPC m g a~ | Cycle between source, test, and documentation |
|
||||||
|
| | |
|
||||||
|
| ~SPC m t a~ | Run tests for current vocab |
|
||||||
|
| | |
|
||||||
|
| ~SPC m r s~ | Extract innermost sexp as separate word |
|
||||||
|
| ~SPC m r r~ | Extract region as separate word |
|
||||||
|
| ~SPC m r v~ | Create new Vocab with words in region |
|
||||||
|
| ~SPC m r i~ | Inline word |
|
||||||
|
| ~SPC m r w~ | Rename all occurences of word |
|
||||||
|
| ~SPC m r a~ | Extract region as new ARTICLE form |
|
||||||
|
| ~SPC m r g~ | Turn current definition into generic word |
|
||||||
|
| | |
|
||||||
|
| ~SPC m s s~ | Switch to factor listener |
|
||||||
|
| | |
|
||||||
|
| ~SPC m h h~ | Help for thing at point |
|
||||||
|
| ~SPC m h e~ | Infer stack effect for sexp/region |
|
||||||
|
| ~SPC m h p~ | Apropos |
|
||||||
|
| ~SPC m h v~ | List all words in current file/vocab |
|
||||||
|
| ~SPC m h <~ | Show calling words of current word |
|
||||||
|
| ~SPC m h >~ | Show words called by current word |
|
||||||
|
| | |
|
||||||
|
| ~SPC m S v~ | Scaffold vocab |
|
||||||
|
| ~SPC m S h~ | Scaffold help for current vocab |
|
||||||
|
|
||||||
|
** fuel-listener-mode
|
||||||
|
|
||||||
|
| Key Binding | Description |
|
||||||
|
|-------------+---------------------------|
|
||||||
|
| ~SPC m r~ | Refresh all loaded vocabs |
|
||||||
|
| ~SPC m T s~ | Toggle stack mode |
|
||||||
|
| ~SPC m h~ | Help for word at point |
|
||||||
|
| ~SPC m v~ | Edit vocab |
|
||||||
|
| ~SPC m S v~ | Scaffold vocab |
|
||||||
|
|
||||||
|
* Snippets
|
||||||
|
This layer provides a yasnippet for colon definitions. Note that you might have
|
||||||
|
to set =yas-triggers-in-field= to nil if you use =x= for stack effect
|
||||||
|
declaration elements a lot, as this will trigger a builtin snippet from
|
||||||
|
prog-mode instead of advancing to the next field when pressing =<TAB>=.
|
9
layers/+lang/factor/config.el
Normal file
9
layers/+lang/factor/config.el
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
;;; config.el --- Factor Layer Configuration File for Spacemacs
|
||||||
|
;;
|
||||||
|
;; URL: https://github.com/syl20bnr/spacemacs
|
||||||
|
;;
|
||||||
|
;; This file is not part of GNU Emacs.
|
||||||
|
;;
|
||||||
|
;;; License: GPLv3
|
||||||
|
|
||||||
|
(spacemacs|define-jump-handlers factor-mode 'fuel-edit-word)
|
7
layers/+lang/factor/funcs.el
Normal file
7
layers/+lang/factor/funcs.el
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(defun factor//fuel-stack-effect ()
|
||||||
|
"Small wrapper around factors stack effect help. If region is
|
||||||
|
active, use that, otherwise use sexp under point."
|
||||||
|
(interactive)
|
||||||
|
(if (region-active-p)
|
||||||
|
(call-interactively 'fuel-stack-effect-region)
|
||||||
|
(call-interactively 'fuel-stack-effect-sexp)))
|
BIN
layers/+lang/factor/img/logo.png
Normal file
BIN
layers/+lang/factor/img/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 161 KiB |
6
layers/+lang/factor/local/snippets/factor-mode/:
Normal file
6
layers/+lang/factor/local/snippets/factor-mode/:
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# key: :
|
||||||
|
# name: :
|
||||||
|
# condition: (looking-back "^:")
|
||||||
|
# --
|
||||||
|
: $1 ( $2 -- $3 )
|
||||||
|
$0;
|
86
layers/+lang/factor/packages.el
Normal file
86
layers/+lang/factor/packages.el
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
;;; packages.el --- Factor packages File for Spacemacs
|
||||||
|
;;
|
||||||
|
;; This file is not part of GNU Emacs.
|
||||||
|
|
||||||
|
|
||||||
|
(defconst factor-packages
|
||||||
|
'(
|
||||||
|
;; Assume that factor is installed, and emacs lisp files are correctly
|
||||||
|
;; located in site-lisp
|
||||||
|
(factor-mode :location site)
|
||||||
|
yasnippet
|
||||||
|
))
|
||||||
|
|
||||||
|
;; for some reason, the following does not work
|
||||||
|
(defun factor/post-init-yasnippet ()
|
||||||
|
(add-to-list 'yas-snippet-dirs (expand-file-name
|
||||||
|
"snippets"
|
||||||
|
(configuration-layer/get-layer-local-dir
|
||||||
|
'factor))
|
||||||
|
t)
|
||||||
|
(spacemacs/add-to-hooks 'spacemacs/load-yasnippet '(factor-mode-hook fuel-mode-hook)))
|
||||||
|
|
||||||
|
(defun factor/init-factor-mode()
|
||||||
|
(use-package factor-mode
|
||||||
|
:commands factor-mode run-factor fuel-mode
|
||||||
|
:mode ("factor\\'" . factor-mode)
|
||||||
|
:init
|
||||||
|
(progn
|
||||||
|
(spacemacs/register-repl 'fuel-mode 'run-factor))
|
||||||
|
:config
|
||||||
|
(progn
|
||||||
|
(require 'fuel-mode)
|
||||||
|
(mapc (lambda (x)
|
||||||
|
(spacemacs/declare-prefix-for-mode 'factor-mode (car x) (cdr x)))
|
||||||
|
'(("mh" . "help")
|
||||||
|
("me" . "eval")
|
||||||
|
("mc" . "compile")
|
||||||
|
("mg" . "nav")
|
||||||
|
("ms" . "repl")
|
||||||
|
("mS" . "scaffold")))
|
||||||
|
(spacemacs/set-leader-keys-for-major-mode 'factor-mode
|
||||||
|
"'" 'run-factor
|
||||||
|
|
||||||
|
"cc" 'fuel-run-file
|
||||||
|
|
||||||
|
"ef" 'fuel-eval-definition
|
||||||
|
"er" 'fuel-eval-region
|
||||||
|
"eR" 'fuel-eval-extended-region
|
||||||
|
|
||||||
|
"gg" 'fuel-edit-word
|
||||||
|
"gG" 'fuel-edit-word-at-point
|
||||||
|
"ga" 'factor-visit-other-file
|
||||||
|
|
||||||
|
"ta" 'fuel-test-vocab
|
||||||
|
|
||||||
|
"rs" 'fuel-refactor-extract-sexp
|
||||||
|
"rr" 'fuel-refactor-extract-region
|
||||||
|
"rv" 'fuel-refactor-extract-vocab
|
||||||
|
"ri" 'fuel-refactor-inline-word
|
||||||
|
"rw" 'fuel-refactor-rename-word
|
||||||
|
"ra" 'fuel-refactor-extract-article
|
||||||
|
"rg" 'fuel-refactor-make-generic
|
||||||
|
|
||||||
|
"ss" 'run-factor
|
||||||
|
|
||||||
|
"hh" 'fuel-help
|
||||||
|
"he" 'factor//fuel-stack-effect
|
||||||
|
"hp" 'fuel-apropos
|
||||||
|
"hv" 'fuel-show-file-words
|
||||||
|
"h<" 'fuel-show-callers
|
||||||
|
"h>" 'fuel-show-callees
|
||||||
|
|
||||||
|
"Sv" 'fuel-scaffold-vocab
|
||||||
|
"Sh" 'fuel-scaffold-help
|
||||||
|
)
|
||||||
|
|
||||||
|
(spacemacs/set-leader-keys-for-major-mode 'fuel-listener-mode
|
||||||
|
"v" 'fuel-edit-vocabulary
|
||||||
|
"r" 'fuel-refresh-all
|
||||||
|
"Ts" 'fuel-stack-mode
|
||||||
|
"w" 'fuel-help
|
||||||
|
"Sv" 'fuel-scaffold-vocab
|
||||||
|
)
|
||||||
|
|
||||||
|
(evilified-state-evilify fuel-help-mode fuel-help-mode-map)))
|
||||||
|
)
|
Loading…
Reference in a new issue