Skip to content

Commit

Permalink
Merge branch 'stevearc:master' into php-method-scope
Browse files Browse the repository at this point in the history
  • Loading branch information
romankr-dv authored Jan 8, 2025
2 parents d26597c + b3ec25c commit 4802074
Show file tree
Hide file tree
Showing 8 changed files with 279 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ In addition, you will need to have either Treesitter or a working LSP client. Yo
- dart
- djot
- elixir
- fish
- go
- groovy
- help
Expand All @@ -158,6 +159,7 @@ In addition, you will need to have either Treesitter or a working LSP client. Yo
- make
- markdown
- norg
- nu
- objdump
- org
- php
Expand Down
3 changes: 3 additions & 0 deletions queries/fish/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
(function_definition
name: (word) @name
(#set! "kind" "Function")) @symbol
23 changes: 23 additions & 0 deletions queries/nu/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; Functions
(decl_def
(cmd_identifier) @name
(#set! "kind" "Function")
) @symbol

(decl_def
(val_string) @name
(#offset! @name 0 1 0 -1)
(#set! "kind" "Function")
) @symbol

; Modules
(decl_module
(cmd_identifier) @name
(#set! "kind" "Module")
) @symbol

; Constant
(stmt_const
(identifier) @name
(#set! "kind" "Constant")
) @symbol
2 changes: 2 additions & 0 deletions tests/minimal_init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ vim.filetype.add({
usda = "usd",
smk = "snakemake",
dj = "djot",
nu = "nu",
},
})

Expand All @@ -24,6 +25,7 @@ for lang, _ in vim.fs.dir("queries") do
end
local master_nvim_ts, configs = pcall(require, "nvim-treesitter.configs")
if master_nvim_ts then
---@diagnostic disable-next-line: missing-fields
configs.setup({
ensure_installed = langs,
sync_install = true,
Expand Down
81 changes: 81 additions & 0 deletions tests/symbols/fish_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[
{
"children": [
{
"children": [
{
"col": 8,
"end_col": 11,
"end_lnum": 6,
"kind": "Function",
"level": 2,
"lnum": 5,
"name": "baz",
"selection_range": {
"col": 17,
"end_col": 20,
"end_lnum": 5,
"lnum": 5
}
}
],
"col": 4,
"end_col": 7,
"end_lnum": 7,
"kind": "Function",
"level": 1,
"lnum": 4,
"name": "bar",
"selection_range": {
"col": 13,
"end_col": 16,
"end_lnum": 4,
"lnum": 4
}
}
],
"col": 0,
"end_col": 3,
"end_lnum": 8,
"kind": "Function",
"level": 0,
"lnum": 3,
"name": "foo",
"selection_range": {
"col": 9,
"end_col": 12,
"end_lnum": 3,
"lnum": 3
}
},
{
"col": 0,
"end_col": 3,
"end_lnum": 11,
"kind": "Function",
"level": 0,
"lnum": 10,
"name": "foo1",
"selection_range": {
"col": 9,
"end_col": 13,
"end_lnum": 10,
"lnum": 10
}
},
{
"col": 0,
"end_col": 3,
"end_lnum": 14,
"kind": "Function",
"level": 0,
"lnum": 13,
"name": "foo2",
"selection_range": {
"col": 9,
"end_col": 13,
"end_lnum": 13,
"lnum": 13
}
}
]
141 changes: 141 additions & 0 deletions tests/symbols/nushell_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
[
{
"children": [
{
"col": 2,
"end_col": 32,
"end_lnum": 2,
"kind": "Constant",
"level": 1,
"lnum": 2,
"name": "MY_CONSTANT",
"selection_range": {
"col": 15,
"end_col": 26,
"end_lnum": 2,
"lnum": 2
}
},
{
"col": 2,
"end_col": 24,
"end_lnum": 4,
"kind": "Function",
"level": 1,
"lnum": 4,
"name": "PRIVATE_DEF",
"selection_range": {
"col": 6,
"end_col": 17,
"end_lnum": 4,
"lnum": 4
}
},
{
"col": 2,
"end_col": 30,
"end_lnum": 5,
"kind": "Function",
"level": 1,
"lnum": 5,
"name": "PUBLIC_DEF",
"selection_range": {
"col": 13,
"end_col": 23,
"end_lnum": 5,
"lnum": 5
}
},
{
"col": 2,
"end_col": 37,
"end_lnum": 6,
"kind": "Function",
"level": 1,
"lnum": 6,
"name": "DEF WITH SPACES",
"selection_range": {
"col": 13,
"end_col": 30,
"end_lnum": 6,
"lnum": 6
}
},
{
"children": [
{
"col": 4,
"end_col": 39,
"end_lnum": 9,
"kind": "Constant",
"level": 2,
"lnum": 9,
"name": "MY_SUB_CONSTANT",
"selection_range": {
"col": 17,
"end_col": 32,
"end_lnum": 9,
"lnum": 9
}
},
{
"col": 4,
"end_col": 30,
"end_lnum": 10,
"kind": "Function",
"level": 2,
"lnum": 10,
"name": "SUB_PRIVATE_DEF",
"selection_range": {
"col": 8,
"end_col": 23,
"end_lnum": 10,
"lnum": 10
}
},
{
"col": 4,
"end_col": 36,
"end_lnum": 11,
"kind": "Function",
"level": 2,
"lnum": 11,
"name": "SUB_PUBLIC_DEF",
"selection_range": {
"col": 15,
"end_col": 29,
"end_lnum": 11,
"lnum": 11
}
}
],
"col": 2,
"end_col": 3,
"end_lnum": 12,
"kind": "Module",
"level": 1,
"lnum": 8,
"name": "MY_SUB_MODULE",
"selection_range": {
"col": 9,
"end_col": 22,
"end_lnum": 8,
"lnum": 8
}
}
],
"col": 0,
"end_col": 1,
"end_lnum": 13,
"kind": "Module",
"level": 0,
"lnum": 1,
"name": "MY_MODULE",
"selection_range": {
"col": 7,
"end_col": 16,
"end_lnum": 1,
"lnum": 1
}
}
]
14 changes: 14 additions & 0 deletions tests/treesitter/fish_test.fish
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/fish

function foo
function bar
function baz
end
end
end

function foo1
end

function foo2
end
13 changes: 13 additions & 0 deletions tests/treesitter/nushell_test.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module MY_MODULE {
export const MY_CONSTANT = "X"

def PRIVATE_DEF [] { }
export def PUBLIC_DEF [] { }
export def "DEF WITH SPACES" [] { }

module MY_SUB_MODULE {
export const MY_SUB_CONSTANT = "XX"
def SUB_PRIVATE_DEF [] { }
export def SUB_PUBLIC_DEF [] { }
}
}

0 comments on commit 4802074

Please sign in to comment.