aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-11-19 04:10:52 -0500
committerGitHub <noreply@github.com>2023-11-19 18:10:52 +0900
commitd87629647614b779fb2aad8f0042fe2864253ea6 (patch)
tree46b35ae0134c3bc5446df7c5bdd2735b7b640f1a
parentfeat(lua): folds for parameter, argument lists (diff)
downloadnvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar.gz
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar.bz2
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar.lz
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar.xz
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.tar.zst
nvim-treesitter-d87629647614b779fb2aad8f0042fe2864253ea6.zip
feat: add Linkerscript (#5693)
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/linkerscript/folds.scm6
-rw-r--r--queries/linkerscript/highlights.scm146
-rw-r--r--queries/linkerscript/indents.scm11
-rw-r--r--queries/linkerscript/injections.scm2
-rw-r--r--queries/linkerscript/locals.scm15
8 files changed, 193 insertions, 0 deletions
diff --git a/README.md b/README.md
index 803db1a1a..559ae50da 100644
--- a/README.md
+++ b/README.md
@@ -284,6 +284,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [latex](https://github.com/latex-lsp/tree-sitter-latex) (maintained by @theHamsta, @clason)
- [x] [ledger](https://github.com/cbarrete/tree-sitter-ledger) (maintained by @cbarrete)
- [x] [leo](https://github.com/r001/tree-sitter-leo) (maintained by @r001)
+- [x] [linkerscript](https://github.com/amaanq/tree-sitter-linkerscript) (maintained by @amaanq)
- [x] [liquidsoap](https://github.com/savonet/tree-sitter-liquidsoap) (maintained by @toots)
- [x] [llvm](https://github.com/benwilliamgraham/tree-sitter-llvm) (maintained by @benwilliamgraham)
- [x] [lua](https://github.com/MunifTanjim/tree-sitter-lua) (maintained by @muniftanjim)
diff --git a/lockfile.json b/lockfile.json
index 4f23fa692..4f268d678 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -332,6 +332,9 @@
"leo": {
"revision": "23a9534d09d523d0dcee7dbf89e7c819e6835f6f"
},
+ "linkerscript": {
+ "revision": "f99011a3554213b654985a4b0a65b3b032ec4621"
+ },
"liquidsoap": {
"revision": "91d2708e12a5869154a85190b13ac89cb1414189"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index 9077bc8d4..dc9135698 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1017,6 +1017,15 @@ list.llvm = {
maintainers = { "@benwilliamgraham" },
}
+list.linkerscript = {
+ install_info = {
+ url = "https://github.com/amaanq/tree-sitter-linkerscript",
+ files = { "src/parser.c" },
+ },
+ filetype = "ld",
+ maintainers = { "@amaanq" },
+}
+
list.liquidsoap = {
install_info = {
url = "https://github.com/savonet/tree-sitter-liquidsoap",
diff --git a/queries/linkerscript/folds.scm b/queries/linkerscript/folds.scm
new file mode 100644
index 000000000..0fc77b1a7
--- /dev/null
+++ b/queries/linkerscript/folds.scm
@@ -0,0 +1,6 @@
+[
+ (sections_command)
+ (output_section)
+ (memory_command)
+ (phdrs_command)
+] @fold
diff --git a/queries/linkerscript/highlights.scm b/queries/linkerscript/highlights.scm
new file mode 100644
index 000000000..f933f31ca
--- /dev/null
+++ b/queries/linkerscript/highlights.scm
@@ -0,0 +1,146 @@
+; Keywords
+
+[
+ "ENTRY"
+ "SECTIONS"
+ "AT"
+ "OVERLAY"
+ "NOCROSSREFS"
+ "MEMORY"
+ "PHDRS"
+ "FILEHDR"
+] @keyword
+
+; Conditionals
+
+(conditional_expression [ "?" ":" ] @conditional.ternary)
+
+; Variables
+
+(symbol) @variable
+
+(filename) @string.special @text.underline
+
+; Functions
+
+(call_expression
+ function: (symbol) @function.call)
+
+((call_expression
+ function: (symbol) @preproc)
+ (#eq? @preproc "DEFINED"))
+
+((call_expression
+ function: (symbol) @function.builtin)
+ (#any-of? @function.builtin
+ "ABSOLUTE" "ALIAS" "ADDR" "ALIGN" "ALIGNOF" "BASE" "BLOCK" "CHIP" "DATA_SEGMENT_ALIGN"
+ "DATA_SEGMENT_END" "DATA_SEGMENT_RELRO_END" "END" "LENGTH" "LOADADDR" "LOG2CEIL" "MAX" "MIN"
+ "NEXT" "ORIGIN" "SEGMENT_START" "SIZEOF" "BYTE" "FILL" "LONG" "SHORT" "QUAD" "SQUAD" "WORD"))
+
+[
+ "KEEP"
+ "PROVIDE"
+ "PROVIDE_HIDDEN"
+] @function.builtin
+
+; Types
+
+(section_type "(" [ "NOLOAD" "DSECT" "COPY" "INFO" "OVERLAY" ] @type.builtin ")")
+
+; Fields
+
+[
+ "ORIGIN" "org" "o"
+ "LENGTH" "len" "l"
+] @field.builtin
+
+; Constants
+
+((symbol) @constant
+ (#lua-match? @constant "^[%u_][%u%d_]+$"))
+
+; Labels
+
+(entry_command name: (symbol) @label)
+
+(output_section name: (symbol) @label)
+
+(memory_command name: (symbol) @label)
+
+(phdrs_command name: (symbol) @label)
+
+(region ">" (symbol) @label)
+
+(lma_region ">" (symbol) @label)
+
+(phdr ":" (symbol) @label)
+
+([(symbol) (filename)] @label
+ (#lua-match? @label "^%."))
+
+; Exceptions
+
+"ASSERT" @exception
+
+[
+ "/DISCARD/"
+ "."
+] @variable.builtin
+
+; Operators
+
+[
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+ "||"
+ "&&"
+ "|"
+ "&"
+ "=="
+ "!="
+ ">"
+ ">="
+ "<="
+ "<"
+ "<<"
+ ">>"
+ "!"
+ "~"
+ "="
+ "+="
+ "-="
+ "*="
+ "/="
+ "<<="
+ ">>="
+ "&="
+ "|="
+] @operator
+
+; Literals
+
+(number) @number
+
+(quoted_symbol) @string
+
+(wildcard_pattern [ "*" "[" "]" ] @character.special)
+
+(attributes) @character.special
+
+; Punctuation
+
+[ "{" "}" "(" ")" ] @punctuation.bracket
+
+[
+ ":"
+ ";"
+] @punctuation.delimiter
+
+">" @punctuation.special
+
+; Comments
+
+(comment) @comment @spell
diff --git a/queries/linkerscript/indents.scm b/queries/linkerscript/indents.scm
new file mode 100644
index 000000000..a636ba109
--- /dev/null
+++ b/queries/linkerscript/indents.scm
@@ -0,0 +1,11 @@
+[
+ (sections_command)
+ (output_section)
+ (memory_command)
+ (phdrs_command)
+] @indent.begin
+
+[
+ "}"
+ ")"
+] @indent.branch @indent.end
diff --git a/queries/linkerscript/injections.scm b/queries/linkerscript/injections.scm
new file mode 100644
index 000000000..51e6d1f6b
--- /dev/null
+++ b/queries/linkerscript/injections.scm
@@ -0,0 +1,2 @@
+((comment)
+ (#set! injection.language "comment"))
diff --git a/queries/linkerscript/locals.scm b/queries/linkerscript/locals.scm
new file mode 100644
index 000000000..93ddb4357
--- /dev/null
+++ b/queries/linkerscript/locals.scm
@@ -0,0 +1,15 @@
+; References
+
+[
+ (symbol)
+ (filename)
+ (quoted_symbol)
+] @reference
+
+; Definitions
+
+(output_section name: (symbol) @definition.var)
+
+(memory_command name: (symbol) @definition.var)
+
+(phdrs_command name: (symbol) @definition.var)