Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prolog tree-sitter grammar #11611

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion book/src/generated/lang-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
| ponylang | ✓ | ✓ | ✓ | |
| powershell | ✓ | | | |
| prisma | ✓ | ✓ | | `prisma-language-server` |
| prolog | | | | `swipl` |
| prolog | | | | `swipl` |
| protobuf | ✓ | ✓ | ✓ | `bufls`, `pb` |
| prql | ✓ | | | |
| purescript | ✓ | ✓ | | `purescript-language-server` |
Expand Down
6 changes: 5 additions & 1 deletion languages.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,10 @@ comment-token = "%"
block-comment-tokens = { start = "/*", end = "*/" }
language-servers = [ "swipl" ]

[[grammar]]
name = "prolog"
source = { git = "https://codeberg.org/foxy/tree-sitter-prolog", subpath = "grammars/prolog", rev = "93c69d2f84d8a167c0a3f4a8d51ccefe365a4dc8" }

[[language]]
name = "tsq"
scope = "source.tsq"
Expand Down Expand Up @@ -3785,4 +3789,4 @@ indent = { tab-width = 2, unit = " " }

[[grammar]]
name = "thrift"
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-thrift" , rev = "68fd0d80943a828d9e6f49c58a74be1e9ca142cf" }
source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-thrift" , rev = "68fd0d80943a828d9e6f49c58a74be1e9ca142cf" }
6 changes: 6 additions & 0 deletions runtime/queries/prolog/folds.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
(directive_term)
(clause_term)
(arg_list)
(list_notation)
] @fold
46 changes: 46 additions & 0 deletions runtime/queries/prolog/highlights.scm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The captures need some tweaks to match the scopes we use: https://docs.helix-editor.com/master/themes.html#syntax-highlighting

For example boolean should be constant.builtin.boolean, number should be constant.numeric.integer or constant.numeric.float

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
(comment) @comment @spell

(atom) @constant

((atom) @boolean
(#eq? @boolean "true"))

((atom) @boolean
(#eq? @boolean "false"))

(functional_notation
function: (atom) @function.call)

(integer) @number

(float_number) @number.float

(directive_head) @operator

(operator_notation
operator: _ @operator)

[
(open)
(open_ct)
(close)
(open_list)
"|"
(close_list)
(open_curly)
(close_curly)
] @punctuation.bracket

[
(arg_list_separator)
(comma)
(end)
(list_notation_separator)
] @punctuation.delimiter

(operator_notation
operator: (semicolon) @punctuation.delimiter)

(double_quoted_list_notation) @string

(variable_term) @variable
16 changes: 16 additions & 0 deletions runtime/queries/prolog/indents.scm
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are written for neovim's indentation system. Ours has different captures: https://docs.helix-editor.com/master/guides/indent.html

We could remove this file to use the default indentation and indents queries could be contributed as a follow-up

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(directive_term) @indent.zero

(clause_term) @indent.zero

(functional_notation
(atom)
(open_ct) @indent.begin
(close) @indent.end)

(list_notation
(open_list) @indent.begin
(close_list) @indent.end)

(curly_bracketed_notation
(open_curly) @indent.begin
(close_curly) @indent.end)
2 changes: 2 additions & 0 deletions runtime/queries/prolog/injections.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
((comment) @injection.content
(#set! injection.language "comment"))