Commit 5ab6d3a9 authored by Bobby Burden III's avatar Bobby Burden III

Initial commit

parents
;;; kit-mode.el --- Major mode for editing Kit Lang files. -*- coding: utf-8; lexical-binding: t; -*-
;; Copyright © 2018, by Bobby Burden III
;; Author: Bobby Burden III <bobby@brb3.org>
;; Version: 1.0.0
;; Created: 20 September 2018
;; Keywords: languages
;; Homepage:
;; This file is not part of GNU Emacs.
;;; License:
;; You can redistribute this program and/or modify it under the terms of the GNU
;; General Public License version 2.
;;; Commentary:
;; Major mode for editing Kit Lang files
;; Currently, this mode only provides syntax highlighting for Kit Lang files.
;; This is based on the Major Mode example by Xah Lee from
;; http://ergoemacs.org/emacs/elisp_syntax_coloring.html
;;; Code:
;; create the list for font-lock.
;; each category of keyword is given a particular face
(setq kit-font-lock-keywords
(let* (
;; define several category of keywords
(x-keywords
'("abstract" "box" "defer" "enum" "for" "function" "if" "import"
"match" "public" "sizeof" "struct" "trait" "typdef" "union"
"using" "var" "while"))
(x-types '("Box" "CString" "Float" "Int" "Ptr"))
(x-constants '("Self" "this"))
(x-events '())
(x-functions '("main" "printf"))
;; generate regex string for each category of keywords
(x-keywords-regexp (regexp-opt x-keywords 'words))
(x-types-regexp (regexp-opt x-types 'words))
(x-constants-regexp (regexp-opt x-constants 'words))
(x-events-regexp (regexp-opt x-events 'words))
(x-functions-regexp (regexp-opt x-functions 'words)))
`(
(,x-types-regexp . font-lock-type-face)
(,x-constants-regexp . font-lock-constant-face)
(,x-events-regexp . font-lock-builtin-face)
(,x-functions-regexp . font-lock-function-name-face)
(,x-keywords-regexp . font-lock-keyword-face)
)))
;;;###autoload
(define-derived-mode kit-mode c-mode "kit mode"
"Major mode for editing Kit Lang files."
(setq font-lock-defaults '((kit-font-lock-keywords))))
(provide 'kit-mode)
;;; kit-mode.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment