fix(emacs): roll back to generic mode
This commit is contained in:
parent
359c72b02f
commit
09b6fb4f7c
2 changed files with 100 additions and 43 deletions
|
@ -60,47 +60,104 @@
|
||||||
("def" "definition")
|
("def" "definition")
|
||||||
("th" "theorem")))
|
("th" "theorem")))
|
||||||
|
|
||||||
;; Automode List
|
;; Roll back to generic-mode
|
||||||
;;;###autoload
|
(define-generic-mode
|
||||||
(define-derived-mode lean-mode prog-mode "Lean"
|
'lean-mode ;; name of the mode to create
|
||||||
"Major mode for Lean"
|
'("--") ;; comments start with
|
||||||
:syntax-table lean-syntax-table
|
'("import" "abbreviation" "opaque_hint" "tactic_hint" "definition" "renaming" "inline" "hiding" "exposing" "parameter" "parameters" "proof" "qed" "conjecture" "hypothesis" "lemma" "corollary" "variable" "variables" "print" "theorem" "axiom" "inductive" "with" "structure" "universe" "alias" "help" "environment" "options" "precedence" "postfix" "prefix" "calc_trans" "calc_subst" "calc_refl" "infix" "infixl" "infixr" "notation" "eval" "check" "exit" "coercion" "end" "private" "using" "namespace" "builtin" "including" "instance" "section" "set_option" "add_rewrite" "extends") ;; some keywords
|
||||||
:abbrev-table lean-abbrev-table
|
'(("\\_<\\(bool\\|int\\|nat\\|real\\|Prop\\|Type\\|ℕ\\|ℤ\\)\\_>" . 'font-lock-type-face)
|
||||||
:group 'lean
|
("\\_<\\(calc\\|have\\|obtains\\|show\\|by\\|in\\|let\\|forall\\|fun\\|exists\\|if\\|then\\|else\\|assume\\|take\\|obtain\\|from\\)\\_>" . font-lock-keyword-face)
|
||||||
(set (make-local-variable 'comment-start) "--")
|
("\"[^\"]*\"" . 'font-lock-string-face)
|
||||||
(set (make-local-variable 'comment-end) "")
|
("\\(->\\|↔\\|/\\\\\\|==\\|\\\\/\\|[*+/<=>¬∧∨≠≤≥-]\\)" . 'font-lock-constant-face)
|
||||||
(set (make-local-variable 'comment-padding) 1)
|
("\\(λ\\|→\\|∃\\|∀\\|:\\|:=\\)" . font-lock-constant-face)
|
||||||
(set (make-local-variable 'comment-use-syntax) t)
|
("\\_<\\(\\b.*_tac\\|Cond\\|or_else\\|t\\(?:hen\\|ry\\)\\|when\\|assumption\\|apply\\|b\\(?:ack\\|eta\\)\\|done\\|exact\\)\\_>" . 'font-lock-constant-face)
|
||||||
(set (make-local-variable 'font-lock-defaults) lean-font-lock-defaults)
|
("\\_<\\(universe\\|inductive\\|theorem\\|axiom\\|lemma\\|hypothesis\\|abbreviation\\|definition\\|variable\\|parameter\\)\\_>[ \t\{\[]*\\([^ \t\n]*\\)" (2 'font-lock-function-name-face))
|
||||||
(set (make-local-variable 'indent-tabs-mode) nil)
|
("\\_<\\(variables\\|parameters\\)\\_>[ \t\(\{\[]*\\([^:]*\\)" (2 'font-lock-function-name-face))
|
||||||
(set-input-method "Lean")
|
("\\(set_opaque\\|set_option\\)[ \t]*\\([^ \t\n]*\\)" (2 'font-lock-constant-face))
|
||||||
(set (make-local-variable 'lisp-indent-function)
|
("\\_<_\\_>" . 'font-lock-preprocessor-face)
|
||||||
'common-lisp-indent-function)
|
("\\_<sorry\\_>" . 'font-lock-warning-face)
|
||||||
(lean-set-keys)
|
;;
|
||||||
(abbrev-mode 1)
|
)
|
||||||
(add-hook 'before-change-functions 'lean-before-change-function nil t)
|
'("\\.lean$") ;; files for which to activate this mode
|
||||||
(add-hook 'after-change-functions 'lean-after-change-function nil t)
|
'((lambda()
|
||||||
;; Draw a vertical line for rule-column
|
(set-input-method "Lean")
|
||||||
(when (and lean-rule-column
|
(set (make-local-variable 'lisp-indent-function)
|
||||||
lean-show-rule-column-method)
|
'common-lisp-indent-function)
|
||||||
(cl-case lean-show-rule-column-method
|
(lean-set-keys)
|
||||||
('vline (require 'fill-column-indicator)
|
(setq local-abbrev-table lean-abbrev-table)
|
||||||
(setq fci-rule-column lean-rule-column)
|
(abbrev-mode 1)
|
||||||
(setq fci-rule-color lean-rule-color)
|
(add-hook 'before-change-functions '
|
||||||
(add-hook 'lean-mode-hook 'fci-mode nil t))))
|
lean-before-change-function nil t)
|
||||||
;; Delete Trailing Whitespace
|
(add-hook 'after-change-functions '
|
||||||
(if lean-delete-trailing-whitespace
|
lean-after-change-function nil t)
|
||||||
(progn (require 'whitespace-cleanup-mode)
|
;; Draw a vertical line for rule-column
|
||||||
(add-hook 'lean-mode-hook 'whitespace-cleanup-mode nil t))
|
(when (and lean-rule-column
|
||||||
(remove-hook 'lean-mode-hook 'whitespace-cleanup-mode))
|
lean-show-rule-column-method)
|
||||||
;; eldoc
|
(cl-case lean-show-rule-column-method
|
||||||
(set (make-local-variable 'eldoc-documentation-function)
|
('vline (require 'fill-column-indicator)
|
||||||
'lean-eldoc-documentation-function)
|
(setq fci-rule-column lean-rule-column)
|
||||||
;; company-mode
|
(setq fci-rule-color lean-rule-color)
|
||||||
(when lean-company-use
|
(add-hook 'lean-mode-hook 'fci-mode nil t))))
|
||||||
(require 'company)
|
;; Delete Trailing Whitespace
|
||||||
(company-mode t)
|
(if lean-delete-trailing-whitespace
|
||||||
(set (make-local-variable 'company-backends) '(company-etags))))
|
(progn (require 'whitespace-cleanup-mode)
|
||||||
|
(add-hook 'lean-mode-hook 'whitespace-cleanup-mode nil t))
|
||||||
|
(remove-hook 'lean-mode-hook 'whitespace-cleanup-mode))
|
||||||
|
;; eldoc
|
||||||
|
(set (make-local-variable 'eldoc-documentation-function)
|
||||||
|
'lean-eldoc-documentation-function)
|
||||||
|
(eldoc-mode +1)
|
||||||
|
(when lean-company-use
|
||||||
|
(require 'company)
|
||||||
|
(set (make-local-variable 'company-backends) '(company-etags))
|
||||||
|
(company-mode t))))
|
||||||
|
"A mode for Lean files" ;; doc string for this mode
|
||||||
|
)
|
||||||
|
|
||||||
|
;; TODO(soonhok): the following lines are commented out due to a bug
|
||||||
|
;; reported by Leo. We roll back to the generic-mode for now.
|
||||||
|
|
||||||
|
;; ;; Automode List
|
||||||
|
;; ;;;###autoload
|
||||||
|
;; (define-derived-mode lean-mode prog-mode "Lean"
|
||||||
|
;; "Major mode for Lean"
|
||||||
|
;; :syntax-table lean-syntax-table
|
||||||
|
;; :abbrev-table lean-abbrev-table
|
||||||
|
;; :group 'lean
|
||||||
|
;; (set (make-local-variable 'comment-start) "--")
|
||||||
|
;; (set (make-local-variable 'comment-end) "")
|
||||||
|
;; (set (make-local-variable 'comment-padding) 1)
|
||||||
|
;; (set (make-local-variable 'comment-use-syntax) t)
|
||||||
|
;; (set (make-local-variable 'font-lock-defaults) lean-font-lock-defaults)
|
||||||
|
;; (set (make-local-variable 'indent-tabs-mode) nil)
|
||||||
|
;; (set-input-method "Lean")
|
||||||
|
;; (set (make-local-variable 'lisp-indent-function)
|
||||||
|
;; 'common-lisp-indent-function)
|
||||||
|
;; (lean-set-keys)
|
||||||
|
;; (abbrev-mode 1)
|
||||||
|
;; (add-hook 'before-change-functions 'lean-before-change-function nil t)
|
||||||
|
;; (add-hook 'after-change-functions 'lean-after-change-function nil t)
|
||||||
|
;; ;; Draw a vertical line for rule-column
|
||||||
|
;; (when (and lean-rule-column
|
||||||
|
;; lean-show-rule-column-method)
|
||||||
|
;; (cl-case lean-show-rule-column-method
|
||||||
|
;; ('vline (require 'fill-column-indicator)
|
||||||
|
;; (setq fci-rule-column lean-rule-column)
|
||||||
|
;; (setq fci-rule-color lean-rule-color)
|
||||||
|
;; (add-hook 'lean-mode-hook 'fci-mode nil t))))
|
||||||
|
;; ;; Delete Trailing Whitespace
|
||||||
|
;; (if lean-delete-trailing-whitespace
|
||||||
|
;; (progn (require 'whitespace-cleanup-mode)
|
||||||
|
;; (add-hook 'lean-mode-hook 'whitespace-cleanup-mode nil t))
|
||||||
|
;; (remove-hook 'lean-mode-hook 'whitespace-cleanup-mode))
|
||||||
|
;; ;; eldoc
|
||||||
|
;; (set (make-local-variable 'eldoc-documentation-function)
|
||||||
|
;; 'lean-eldoc-documentation-function)
|
||||||
|
;; ;; company-mode
|
||||||
|
;; (when lean-company-use
|
||||||
|
;; (require 'company)
|
||||||
|
;; (company-mode t)
|
||||||
|
;; (set (make-local-variable 'company-backends) '(company-etags))))
|
||||||
|
|
||||||
;; Automatically use lean-mode for .lean files.
|
;; Automatically use lean-mode for .lean files.
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
|
@ -80,8 +80,8 @@
|
||||||
;; ==============================
|
;; ==============================
|
||||||
(defun lean-server-create-process ()
|
(defun lean-server-create-process ()
|
||||||
"Create lean-server process."
|
"Create lean-server process."
|
||||||
(when (buffer-modified-p)
|
;; (when (buffer-modified-p)
|
||||||
(error "Please save the buffer before start lean-server."))
|
;; (error "Please save the buffer before start lean-server."))
|
||||||
(let ((process-connection-type nil)
|
(let ((process-connection-type nil)
|
||||||
(lean-server-process
|
(lean-server-process
|
||||||
(start-process lean-server-process-name
|
(start-process lean-server-process-name
|
||||||
|
|
Loading…
Reference in a new issue