[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode ae17e75812 120/500: First try at smie from damien
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode ae17e75812 120/500: First try at smie from damiencassou/nix-mode |
Date: |
Sat, 29 Jan 2022 08:26:46 -0500 (EST) |
branch: elpa/nix-mode
commit ae17e75812150419acdefbeb549f4382c78d8047
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
First try at smie from damiencassou/nix-mode
---
nix-smie.el | 121 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 121 insertions(+)
diff --git a/nix-smie.el b/nix-smie.el
new file mode 100644
index 0000000000..cad6eb7077
--- /dev/null
+++ b/nix-smie.el
@@ -0,0 +1,121 @@
+;;; nix-mode+.el --- Major mode to edit Nix files
+
+;; Copyright (C) 2014 Jenny Cassou
+
+;; Author: Jenny Cassou <damien.cassou@gmail.com>
+;; Version: 0.1
+
+;; This file is not part of GNU Emacs.
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Major mode to edit Nix files
+
+;;; Code:
+(require 'smie)
+
+(defvar nix+-smie-grammar
+ (smie-prec2->grammar
+ (smie-bnf->prec2
+ '((id)
+ (expr (exprfunction))
+ (exprfunction ("{" formals "}" ":" exprfunction)
+ (exprassert))
+ (exprassert ("assert" expr ";" exprassert)
+ (exprif))
+ (exprif ("if" expr "then" expr "else" expr)
+ (exprop))
+ (exprop ("!" exprop)
+ (exprop "==" exprop)
+ (exprop "!=" exprop)
+ (exprop "&&" exprop)
+ (exprop "||" exprop)
+ (exprop "->" exprop)
+ (exprop "//" exprop)
+ (exprop "~" exprop)
+ (exprop "?" id)
+ (exprapp))
+ (exprapp (exprapp "." exprselect)
+ (exprselect))
+ (exprselect (exprsimple))
+ (exprsimple (id)
+ ("true")
+ ("false")
+ ("null")
+ ("(" expr ")")
+ ("{" binds "}")
+ ("let" "{" binds "}")
+ ("rec" "{" binds "}")
+ ("[" exprselects "]"))
+ (binds (binds ";" binds)
+ (bind))
+ (exprselects (expreselect))
+ (bind (id "=" expr)
+ ("inherit" exprp))
+ (exprp ("(" expr ")"))
+ (formals (formals "," formals)
+ (formal))
+ (formal (id)
+ (id "?" expr)))
+ '((assoc ";"))
+ '((assoc ","))
+ '((assoc "==")
+ (assoc "!=")
+ (assoc "&&")
+ (assoc "||")
+ (assoc "->")
+ (assoc "//")
+ (assoc "~")
+ (assoc "?")
+ (assoc "!")))))
+
+(defvar nix+-syntax-table
+ (let ((table (make-syntax-table)))
+ (modify-syntax-entry ?/ ". 14" table)
+ (modify-syntax-entry ?* ". 23" table)
+ (modify-syntax-entry ?# "< b" table)
+ (modify-syntax-entry ?\n "> b" table)
+ table)
+ "Syntax table for Nix mode.")
+
+;;;###autoload
+(define-derived-mode nix-mode+ prog-mode "Nix"
+ "Major mode for editing Nix expressions.
+
+The following commands may be useful:
+
+ '\\[newline-and-indent]'
+ Insert a newline and move the cursor to align with the previous
+ non-empty line.
+
+ '\\[fill-paragraph]'
+ Refill a paragraph so that all lines are at most `fill-column'
+ lines long. This should do the right thing for comments beginning
+ with `#'. However, this command doesn't work properly yet if the
+ comment is adjacent to code (i.e., no intervening empty lines).
+ In that case, select the text to be refilled and use
+ `\\[fill-region]' instead.
+
+The hook `nix-mode-hook' is run when Nix mode is started.
+
+\\{nix-mode-map}
+"
+ (set-syntax-table nix+-syntax-table)
+ (smie-setup nix+-smie-grammar #'ignore))
+
+(provide 'nix-mode+)
+
+;;; nix-mode+.el ends here
- [nongnu] elpa/nix-mode 0d65c482b2 477/500: nix-flake: Avoid use of flatten-list to support older Emacs versions, (continued)
- [nongnu] elpa/nix-mode 0d65c482b2 477/500: nix-flake: Avoid use of flatten-list to support older Emacs versions, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 07b6069c78 491/500: nix-flake: Fix an unexpected error in assert, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 14f1bb20b9 487/500: chore: Bump install-nix-action to v14.1, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 00b2b8da57 500/500: Merge pull request #145 from NixOS/dependabot/github_actions/cachix/install-nix-action-16, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1e0709acde 028/500: Fixup indentation, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode aee3dea8ec 031/500: Refactor font lock, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 8cb5ba0bc8 048/500: Change nix keymaps, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 76df9f3e6b 044/500: Add let indent level counter., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 7fbc65ae68 101/500: Merge pull request #16 from ljli/fontification-improvs, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 070891aae4 105/500: Fix lexical bindings., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ae17e75812 120/500: First try at smie from damiencassou/nix-mode,
ELPA Syncer <=
- [nongnu] elpa/nix-mode c758b179e9 184/500: Add nix-shebang, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b8b6f5eac 339/500: Add failing test that checks indentation of let expressions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2bb0a0c1f4 340/500: Improve indentation of let expressions., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 1b2f22f235 343/500: Add issue 84 test, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode aaef8580c5 351/500: Merge pull request #86 from j-piecuch/smie-tweaks, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 4ffab960ef 345/500: Add AUTHORS.md to gitignore, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ecf005009e 361/500: Remove org-man.el from .texi makefile rule, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 32b013cd62 363/500: Merge pull request #97 from NixOS/fix-94, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 2c19243e2a 364/500: Revert fix for #94, but leave the test., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 55985b326b 366/500: Be smarter about tokenizing symbols., ELPA Syncer, 2022/01/29