Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ All notable changes to the "pustota" extension will be documented in this file.

Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.

## 0.36.0
## 0.36.0 aka The First Public Release

- Added Lua support
- Added SQL support

## 0.35.0 aka The First Public Release
## 0.35.0

- In Python fixed that some regex patterns where highlighted as keywords
- In TypeScript fixed `null` and `undefined` highlight in type annitations
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@
"path": "./syntaxes/lua-constants.injection.json",
"injectTo": ["source.lua"]
},
{
"scopeName": "pustota.injection.sql.definitions",
"path": "./syntaxes/sql-definitions.injection.json",
"injectTo": ["source.sql"]
},
{
"scopeName": "pustota.injection.sql.constants",
"path": "./syntaxes/sql-constants.injection.json",
"injectTo": ["source.sql"]
},
{
"scopeName": "pustota.injection.typescript.types",
"path": "./syntaxes/typescript-types.injection.json",
Expand Down
2 changes: 2 additions & 0 deletions src/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,8 @@ function tokenColors(c) {
'entity.name.function.lisp',
// Lua: not `local f = function() end`, same as `const` in JS
'meta.function.lua entity.name.function.lua',
// SQL:
'meta.function.sql entity.name.function.sql', // from `syntaxes/sql-definitions.injection.json`
// Objective-C:
'meta.function entity.name.function.objc', // function def with params
'meta.function entity.name.function.name-of-parameter.objc',
Expand Down
23 changes: 23 additions & 0 deletions syntaxes/sql-constants.injection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"comment": "SQL `true`, `false`, `null` and float numbers, like `3.14`, `.5` or `1.5e3`. The builtin SQL grammar does not scope `true` and `false` at all, scopes `null` as a keyword, and only knows integers, so `3.14` is split into two numbers and `1.5e3` stays uncolored.",
"scopeName": "pustota.injection.sql.constants",
"injectionSelector": "L:source.sql -comment -string",
"patterns": [
{
"comment": "`is null`, `is not null` and `not null` are matched as one keyword by the builtin grammar",
"match": "(?i)\\b(?:((?:is\\s+)?not|is)\\s+)?(null)\\b",
"captures": {
"1": { "name": "keyword.other.DDL.create.II.sql" },
"2": { "name": "constant.language.null.sql" }
}
},
{
"match": "(?i)\\b(?:true|false)\\b",
"name": "constant.language.boolean.sql"
},
{
"match": "(?<![\\w.])(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[eE][-+]?\\d+)?(?![\\w.])",
"name": "constant.numeric.sql"
}
]
}
16 changes: 16 additions & 0 deletions syntaxes/sql-definitions.injection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"comment": "SQL function and stored procedure definitions, like `create or replace function f` or `create procedure schema.p`. The builtin SQL grammar scopes every created name as `entity.name.function.sql`, including tables and indexes, and does not support `procedure` at all. This rule marks function and procedure definitions with `meta.function.sql`.",
"scopeName": "pustota.injection.sql.definitions",
"injectionSelector": "L:source.sql -comment -string",
"patterns": [
{
"match": "(?i)^\\s*(create(?:\\s+or\\s+(?:replace|alter))?)\\s+(function|procedure|proc)\\s+(?:[\"`\\[]?\\w+[\"`\\]]?\\.)?([\"`\\[]?)(\\w+)[\"`\\]]?",
"name": "meta.function.sql",
"captures": {
"1": { "name": "keyword.other.create.sql" },
"2": { "name": "keyword.other.sql" },
"4": { "name": "entity.name.function.sql" }
}
}
]
}
56 changes: 56 additions & 0 deletions test/Batch.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
@echo off
rem Batch file example
:: Comment with double colon
setlocal enabledelayedexpansion

rem Variables
set NAME=World
set /a COUNT=1 + 2 * 3
set /p INPUT=Enter value:
set "QUOTED=value with spaces"
echo Hello, %NAME%!
echo Count is !COUNT!
echo Script dir: %~dp0
echo First arg: %1, all args: %*

rem Conditionals
if "%NAME%"=="World" (
echo Matched
) else (
echo Not matched
)

if not exist "output" mkdir output
if defined NAME echo NAME is set
if %COUNT% GEQ 5 echo Big
if /i "%INPUT%" EQU "yes" goto :confirmed
if errorlevel 1 echo Failed

rem Loops
for %%i in (1 2 3) do echo %%i
for /l %%n in (1, 1, 5) do (
echo Number %%n
)
for /f "tokens=1,2 delims=," %%a in (data.csv) do echo %%a - %%b
for /d %%d in (*) do echo Folder %%d
for /r %%f in (*.txt) do echo File %%f

rem Labels and calls
call :greet "Ann"
goto :eof

:greet
echo Hello, %~1
exit /b 0

:confirmed
echo Confirmed

rem Redirection and pipes
dir /b > files.txt 2>&1
type files.txt | find "txt" >> found.txt
echo ok && echo success || echo failure
copy nul empty.txt >nul

endlocal
exit /b %ERRORLEVEL%
118 changes: 118 additions & 0 deletions test/Clojure.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
(ns example.core
"Namespace docstring."
(:require [clojure.string :as str]
[clojure.set :refer [union]])
(:import (java.util Date UUID)))

;; Single line comment
; Another comment
#_(ignored form)
(comment
(this is a rich comment))

;; Constants and literals
(def int-num 42)
(def float-num 3.14)
(def ratio 1/3)
(def big 123N)
(def hex 0xFF)
(def chars [\a \newline \space A])
(def flags [true false nil])
(def kw :keyword)
(def ns-kw ::namespaced)
(def sym 'symbol)
(def text "string with \"escapes\" \n")
(def pattern #"\d+[a-z]*")
(def ^:private ^:dynamic *config* {:debug false})

;; Collections
(def a-list '(1 2 3))
(def a-vector [1 2 3])
(def a-map {:name "Ann" :age 30})
(def a-set #{1 2 3})

;; Functions
(defn greet
"Greets someone."
([] (greet "world"))
([name]
(str "Hello, " name "!")))

(defn- private-helper [x] (* x 2))

(defn destructure [{:keys [name age] :or {age 0}} & rest]
[name age rest])

(def anonymous (fn [x] (inc x)))
(def short-fn #(+ % %2))

;; Macros
(defmacro unless [test & body]
`(if (not ~test) (do ~@body)))

;; Protocols, records, and types
(defprotocol Shape
(area [this]))

(defrecord Circle [radius]
Shape
(area [_] (* Math/PI radius radius)))

(deftype Point [x y])

(defmulti speak :kind)
(defmethod speak :dog [_] "Woof")

;; Control flow
(defn classify [n]
(cond
(neg? n) :negative
(zero? n) :zero
:else :positive))

(let [x 1
y (if (> x 0) "pos" "neg")]
(when-let [z (seq [x])]
(case y
"pos" (println "positive" z)
(println "other"))))

(loop [i 0]
(when (< i 10)
(recur (inc i))))

(doseq [n (range 3)]
(println n))

(for [x (range 5) :when (odd? x)] (* x x))

;; Threading
(->> (range 10)
(filter even?)
(map inc)
(reduce +))

(-> {:a 1}
(assoc :b 2)
(update :a inc))

;; Java interop
(.toUpperCase "text")
(Date.)
(new UUID 0 0)
(System/currentTimeMillis)

;; Exceptions
(try
(throw (ex-info "Boom" {:code 1}))
(catch Exception e
(println (ex-message e)))
(finally
(println "done")))

;; Atoms and reader macros
(def counter (atom 0))
(swap! counter inc)
@counter
#inst "2024-01-01T00:00:00.000-00:00"
#uuid "00000000-0000-0000-0000-000000000000"
101 changes: 101 additions & 0 deletions test/RST.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
==========
Main title
==========

Section
=======

Subsection
----------

Paragraph with *emphasis*, **strong emphasis**, ``inline literal``,
`interpreted text`, :code:`role text`, and a link_ to somewhere.
Also an `inline link <https://example.com>`_ and an anonymous one__.

.. _link: https://example.com
__ https://example.org

Footnote reference [1]_ and a citation [CIT2002]_.

.. [1] The footnote.
.. [CIT2002] The citation.

.. This is a comment
that spans multiple lines.

Lists
-----

- Bullet item
- Another item

* Nested item

1. Numbered item
2. Second item

#. Auto-numbered item

term
Definition of the term.

:field: Field list value
:another field: Another value

Code
----

A literal block follows::

def hello():
return "world"

.. code-block:: python

def add(a, b):
return a + b

>>> print("doctest")
doctest

Directives
----------

.. note::

This is a note.

.. image:: /assets/icon.png
:alt: Icon
:width: 100px

.. |name| replace:: substitution text

Text with a |name| substitution.

Tables
------

===== ===== ======
A B A or B
===== ===== ======
False False False
True False True
===== ===== ======

+------------+------------+
| Header 1 | Header 2 |
+============+============+
| Cell 1 | Cell 2 |
+------------+------------+

| Line block
| keeps line breaks

Block quote text.

-- Attribution

----

Transition above.
Loading
Loading