Skip to content
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
1 change: 1 addition & 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
- c_sharp
- cpp
- css
- cuda
- dart
- djot
- editorconfig
Expand Down
13 changes: 10 additions & 3 deletions lua/aerial/backends/treesitter/extensions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ end
M.c = {
postprocess = c_postprocess,
}
M.cpp = {
postprocess = function(bufnr, item, match)

local function cpp_postprocess(bufnr, item, match)
if item.kind ~= "Function" then
return
end
Expand All @@ -331,7 +331,14 @@ M.cpp = {
item[k] = v
end
end
end,
end

M.cpp = {
postprocess = cpp_postprocess,
}

M.cuda = {
postprocess = cpp_postprocess,
}

M.rst = {
Expand Down
22 changes: 22 additions & 0 deletions queries/cuda/aerial.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(struct_specifier
name: (type_identifier) @name
body: (field_declaration_list)
(#set! "kind" "Struct")) @symbol

(declaration
(struct_specifier
body: (field_declaration_list)) @symbol
declarator: (identifier) @name
(#set! "kind" "Struct"))

(function_declarator
declarator: (_) @name
(#set! "kind" "Function")) @symbol

(enum_specifier
name: (type_identifier) @name
(#set! "kind" "Enum")) @symbol

(class_specifier
name: (type_identifier) @name
(#set! "kind" "Class")) @symbol
231 changes: 231 additions & 0 deletions tests/symbols/cuda_test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
[
{
"col": 0,
"end_col": 14,
"end_lnum": 1,
"kind": "Function",
"level": 0,
"lnum": 1,
"name": "fn_1",
"selection_range": {
"col": 5,
"end_col": 9,
"end_lnum": 1,
"lnum": 1
}
},
{
"col": 0,
"end_col": 14,
"end_lnum": 3,
"kind": "Struct",
"level": 0,
"lnum": 3,
"name": "st_1",
"selection_range": {
"col": 7,
"end_col": 11,
"end_lnum": 3,
"lnum": 3
}
},
{
"col": 0,
"end_col": 1,
"end_lnum": 6,
"kind": "Struct",
"level": 0,
"lnum": 5,
"name": "st_2",
"selection_range": {
"col": 2,
"end_col": 6,
"end_lnum": 6,
"lnum": 6
}
},
{
"col": 0,
"end_col": 12,
"end_lnum": 8,
"kind": "Enum",
"level": 0,
"lnum": 8,
"name": "en_1",
"selection_range": {
"col": 5,
"end_col": 9,
"end_lnum": 8,
"lnum": 8
}
},
{
"children": [
{
"col": 2,
"end_col": 12,
"end_lnum": 11,
"kind": "Function",
"level": 1,
"lnum": 11,
"name": "~cl_1",
"selection_range": {
"col": 2,
"end_col": 7,
"end_lnum": 11,
"lnum": 11
}
},
{
"col": 2,
"end_col": 29,
"end_lnum": 14,
"kind": "Function",
"level": 1,
"lnum": 14,
"name": "meth_1",
"selection_range": {
"col": 18,
"end_col": 24,
"end_lnum": 14,
"lnum": 14
}
}
],
"col": 0,
"end_col": 1,
"end_lnum": 15,
"kind": "Class",
"level": 0,
"lnum": 10,
"name": "cl_1",
"selection_range": {
"col": 6,
"end_col": 10,
"end_lnum": 10,
"lnum": 10
}
},
{
"col": 0,
"end_col": 16,
"end_lnum": 18,
"kind": "Function",
"level": 0,
"lnum": 17,
"name": "A::bar",
"selection_range": {
"col": 5,
"end_col": 11,
"end_lnum": 18,
"lnum": 18
}
},
{
"col": 0,
"end_col": 14,
"end_lnum": 19,
"kind": "Function",
"level": 0,
"lnum": 19,
"name": "fn_2",
"selection_range": {
"col": 5,
"end_col": 9,
"end_lnum": 19,
"lnum": 19
}
},
{
"col": 0,
"end_col": 15,
"end_lnum": 22,
"kind": "Function",
"level": 0,
"lnum": 21,
"name": "fn_3",
"selection_range": {
"col": 6,
"end_col": 10,
"end_lnum": 22,
"lnum": 21
}
},
{
"col": 0,
"end_col": 27,
"end_lnum": 23,
"kind": "Function",
"level": 0,
"lnum": 23,
"name": "operator<",
"selection_range": {
"col": 5,
"end_col": 14,
"end_lnum": 23,
"lnum": 23
}
},
{
"col": 0,
"end_col": 1,
"end_lnum": 28,
"kind": "Function",
"level": 0,
"lnum": 25,
"name": "fn_4",
"selection_range": {
"col": 5,
"end_col": 9,
"end_lnum": 25,
"lnum": 25
}
},
{
"col": 0,
"end_col": 23,
"end_lnum": 30,
"kind": "Function",
"level": 0,
"lnum": 30,
"name": "declaredFunction",
"selection_range": {
"col": 4,
"end_col": 20,
"end_lnum": 30,
"lnum": 30
}
},
{
"children": [
{
"col": 2,
"end_col": 28,
"end_lnum": 33,
"kind": "Function",
"level": 1,
"lnum": 33,
"name": "clsDeclaredFunction",
"selection_range": {
"col": 6,
"end_col": 25,
"end_lnum": 33,
"lnum": 33
}
}
],
"col": 0,
"end_col": 1,
"end_lnum": 34,
"kind": "Class",
"level": 0,
"lnum": 32,
"name": "A",
"selection_range": {
"col": 6,
"end_col": 7,
"end_lnum": 32,
"lnum": 32
}
}
]
34 changes: 34 additions & 0 deletions tests/treesitter/cuda_test.cu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
__global__ void fn_1() {}

struct st_1 {};

struct {
} st_2;

enum en_1 {};

class cl_1 {
~cl_1() {}

public:
__device__ void meth_1() {}
};

__host__
void A::bar() {}
__host__ __device__ int *fn_2() {}

__device__ __host__
int **fn_3() {}
bool operator<(int, int) {}

void fn_4() {
struct Point p1; // This should not show up as a symbol
struct Point *p2 = new struct Point; // This should not show up as a symbol
__shared__ struct Point *p3 = new struct Point; // This should not show up as a symbol
}
int declaredFunction();

class A {
int clsDeclaredFunction();
};