[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/nix-mode 6534f146eb 065/500: Formatting
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/nix-mode 6534f146eb 065/500: Formatting |
Date: |
Sat, 29 Jan 2022 08:26:36 -0500 (EST) |
branch: elpa/nix-mode
commit 6534f146eb56568cbccd39f0d317910766c4eb3d
Author: Matthew Bauer <mjbauer95@gmail.com>
Commit: Matthew Bauer <mjbauer95@gmail.com>
Formatting
---
nix-mode.el | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/nix-mode.el b/nix-mode.el
index bc253f7185..bb19472a2e 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -21,6 +21,8 @@
"Set variable VAR to value VAL in current buffer."
`(set (make-local-variable ',var) ,val)))
+;; Syntax coloring
+
(defun nix-syntax-match-antiquote (limit)
"Find antiquote within a Nix expression up to LIMIT."
(let ((pos (next-single-char-property-change (point) 'nix-syntax-antiquote
@@ -95,11 +97,13 @@
(context (save-excursion (save-match-data (syntax-ppss start))))
(string-type (nth 3 context)))
(pcase string-type
+
(`t
;; inside a multiline string
;; ending multi-line string delimiter
(put-text-property (1- end) end
'syntax-table (string-to-syntax "|")))
+
(`nil
;; beginning multi-line string delimiter
(put-text-property start (1+ start)
@@ -111,8 +115,7 @@
(context (save-excursion (save-match-data (syntax-ppss start))))
(string-type (nth 3 context)))
- ;; only add antiquote when we're already in a string
- (when string-type
+ (when string-type ;; only add antiquote when we're already in a string
(put-text-property start (1+ start)
'syntax-table (string-to-syntax "|"))
(put-text-property start (+ start 2)
@@ -125,6 +128,7 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(end (match-end 0))
(context (save-excursion (save-match-data (syntax-ppss start))))
(open (nth 1 context)))
+
(when open ;; a corresponding open-brace was found
(let* ((antiquote (get-text-property open 'nix-syntax-antiquote)))
(when antiquote
@@ -150,6 +154,8 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(0 (ignore (nix-syntax-propertize-close-brace)))))
start end))
+;; Indentation
+
(defun nix-indent-level-parens ()
"Find indent level based on parens."
(setq n 0)
@@ -179,6 +185,7 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(setq lets 0)
(setq ins 0)
(beginning-of-line)
+
(while (not (eq (point) (point-min)))
(forward-line -1)
(cond
@@ -268,6 +275,8 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(t
(indent-line-to (nix-indent-level)))))
+;; Visit file
+
(defun nix-visit-file ()
"Go to file under cursor."
(interactive)
@@ -277,6 +286,8 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(if (looking-at nix-re-file-path)
(find-file (match-string-no-properties 0)))))
+;; Formatting
+
(defcustom nix-nixfmt-bin "nixfmt"
"Path to nixfmt executable."
:group 'nix
@@ -302,6 +313,8 @@ If a close brace `}' ends an antiquote, the next character
begins a string."
(nix--format-call (current-buffer))
(message "Formatted buffer with rustfmt."))
+;; Key maps
+
(defvar nix-mode-menu (make-sparse-keymap "Nix")
"Menu for Nix mode.")
- [nongnu] elpa/nix-mode ff550f9bbd 036/500: Add comments., (continued)
- [nongnu] elpa/nix-mode ff550f9bbd 036/500: Add comments., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ea95e3c9c6 068/500: Add nix-prettify-mode.el., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6eaf2a97d2 069/500: Fixup hanging indent., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode e53d99d840 064/500: Ignore '* chars in syntax propertize., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 9b705381c4 063/500: Fix antiquote highlighting., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0624820fd3 067/500: Fix org-mode fontification error., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 3338f5997e 056/500: Fix beginning of buffer issue, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 0f01eecdaa 050/500: Make sure everything starts at beginning of line., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 03f462ef34 062/500: Add "+" to hanging indent list., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ad09b3be7f 066/500: Fix flycheck errors., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6534f146eb 065/500: Formatting,
ELPA Syncer <=
- [nongnu] elpa/nix-mode 5a29112764 073/500: Add function for escaped antiquote., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 460cc23161 075/500: Make " be treated as generic | syntax class., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ff8409c617 079/500: Declare lexical-binding, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 6a9cb7e682 081/500: Add basic REPL via nix-repl, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 836e14fdd4 093/500: Merge pull request #12 from matthewbauer/case-sensitive-searching, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode ea23a301d7 086/500: Fontification.., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f309e106ef 090/500: Revert "Make " be treated as generic | syntax class.", ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode 64d615d628 096/500: Add nix-mode-mmm, ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode f968cb98ef 097/500: Add nix-buffer., ELPA Syncer, 2022/01/29
- [nongnu] elpa/nix-mode c0502994b5 100/500: Remove nix-mode-reload., ELPA Syncer, 2022/01/29