python: Add SQL syntax highlighting (#43756)
Release Notes: - Added support for SQL syntax highlighting in Python files ## Summary I am a data engineer who spends a lot of time writing SQL in Python files using Zed. This PR adds support for SQL syntax highlighting with common libraries (like pyspark, polars, pandas) and string variables (prefixed with a `# sql` comment). I referenced [#37605](https://github.com/zed-industries/zed/pull/37605) for this implementation to keep the comment prefix consistent. ## Examples <img width="738" height="990" alt="image" src="https://github.com/user-attachments/assets/48a859da-c477-490d-be73-ca70d8e47cc9" /> --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
This commit is contained in:
1 parent
f2f3d9faf6
commit
c20cbba0eb
2 files changed
+50
No files matched your search
@@ -1,3 +1,34 @@
|
||||
((comment) @injection.content
|
||||
(#set! injection.language "comment")
|
||||
)
|
||||
|
||||
; SQL -----------------------------------------------------------------------------
|
||||
(
|
||||
[
|
||||
; function calls
|
||||
(call
|
||||
[
|
||||
(attribute attribute: (identifier) @function_name)
|
||||
(identifier) @function_name
|
||||
]
|
||||
arguments: (argument_list
|
||||
(comment) @comment
|
||||
(string
|
||||
(string_content) @injection.content
|
||||
)
|
||||
))
|
||||
|
||||
; string variables
|
||||
((comment) @comment
|
||||
.
|
||||
(expression_statement
|
||||
(assignment
|
||||
right: (string
|
||||
(string_content) @injection.content
|
||||
)
|
||||
)
|
||||
))
|
||||
]
|
||||
(#match? @comment "^(#|#\\s+)(?i:sql)\\s*$")
|
||||
(#set! injection.language "sql")
|
||||
)
|
||||
Reference in new issue
Block a user