-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ns docstring highlighting regression
This also begins the process of making our symbol matching regular expressions user extensible (see issue #15). There are more to convert from regexps to normal lists, but I want to take my time and make sure I get the names down correctly. It is important to get maximum reuse so users don't have to add their fancy def-whatever to 4 different lists.
- Loading branch information
1 parent
6ea4196
commit ec48877
Showing
2 changed files
with
112 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
(ns clojure-ts-mode.docstrings | ||
"This is a namespace | ||
See my famous `fix-bug` macro if you need help." | ||
(:require [clojure.test :refer [deftest]]) | ||
(:import (java.util UUID))) | ||
|
||
(def foo ;;asdf | ||
"I'm a value") | ||
(def bar "I'm a docstring" "and I'm a value") | ||
|
||
(defonce ^{:doc "gotta document in metadata."} baz | ||
"Did you know defonce doesn't have a docstring arity like def?") | ||
|
||
(def foobar | ||
;; Comments shouldn't disrupt docstring highlighting | ||
"I'm a docstring" | ||
123) | ||
|
||
(defn ;;asdf | ||
foobarbaz ;;asdf | ||
"I'm the docstring!" ;;asdf | ||
[x] | ||
(inc x)) | ||
|
||
(;; starting comments break docstrings | ||
defn busted! | ||
"We really need to anchor symbols like defn to the front of the list. | ||
I don't want every query to have to check for comments. | ||
Don't format code this way." | ||
[] | ||
nil) | ||
|
||
(defn buzz "Looking for `fizz`" | ||
[x] | ||
(when (zero? (% x 5)) | ||
"buzz")) | ||
|
||
(defn- fizz | ||
"Pairs well with `buzz`" | ||
[x] | ||
(when (zero? (% x 3)) | ||
"fizz")) | ||
|
||
(defmacro fix-bug | ||
"Fixes most known bugs." | ||
[& body] | ||
`(try | ||
~@body | ||
(catch Throwable _ | ||
nil))) | ||
|
||
(definline never-used-this ":)" [x] x) | ||
|
||
(deftype ^{:doc "asdf" :something-else "asdf"} T | ||
java.lang.Closeable | ||
(close [this] | ||
(print "done"))) | ||
|
||
(defprotocol Fooable | ||
(foo [this] | ||
"Does foo")) | ||
|
||
(definterface Barable | ||
(^String bar [] "Does bar")) | ||
|
||
(deftest ^{:doc "doctest"} some-test | ||
(is (= 1 2))) |