Repository navigation
Expand file tree
/
Copy pathtest.lua
More file actions
144 lines (116 loc) · 2.65 KB
/
Copy pathtest.lua
File metadata and controls
144 lines (116 loc) · 2.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- AI HINTS: Test Lua file for xmap.nvim
-- AI HINTS: This file contains various code structures to test Tree-sitter integration
local M = {}
-- AI HINTS: TODO: Add error handling
-- AI HINTS: FIXME: Improve performance
-- AI HINTS: NOTE: This is a test file
-- AI HINTS: A simple variable
local test_variable = "Hello, World!"
local another_var = 42
-- AI HINTS: Global function
function setup_global()
print("Global setup")
end
-- AI HINTS: A function definition
function M.setup(opts)
local config = opts or {}
-- AI HINTS: Nested function
local function validate_config(cfg)
if not cfg then
return false
end
return true
end
if validate_config(config) then
print("Config is valid")
end
return M
end
-- AI HINTS: Another function
function M.render_line(line, line_nr)
local trimmed = vim.trim(line)
if #trimmed == 0 then
return ""
end
return trimmed
end
-- AI HINTS: Class-like table
M.state = {
bufnr = nil,
winid = nil,
is_open = false,
}
-- AI HINTS: Method-like function
function M.open()
if M.state.is_open then
return
end
M.state.is_open = true
print("Opening...")
end
function M.close()
if not M.state.is_open then
return
end
M.state.is_open = false
print("Closing...")
end
-- AI HINTS: Toggle function
function M.toggle()
if M.state.is_open then
M.close()
else
M.open()
end
end
-- AI HINTS: Complex function with multiple lines
function M.process_buffer(bufnr, opts)
if not vim.api.nvim_buf_is_valid(bufnr) then
return nil
end
local lines = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
local processed = {}
for i, line in ipairs(lines) do
local rendered = M.render_line(line, i)
table.insert(processed, rendered)
end
return processed
end
-- AI HINTS: Arrow function style (module method)
M.validate = function(input)
return input ~= nil
end
-- AI HINTS: Another module method
M.transform = function(data)
local result = {}
for k, v in pairs(data) do
result[k] = tostring(v)
end
return result
end
-- AI HINTS: Local function
local function helper_function(arg)
-- AI HINTS: HACK: Quick workaround for testing
return arg * 2
end
-- AI HINTS: Function with return statement
function M.calculate(a, b)
if a > b then
return a - b
end
return b - a
end
-- AI HINTS: WARNING: Deprecated function
function M.old_method()
-- AI HINTS: BUG: This doesn't work correctly
return nil
end
-- AI HINTS: - Documentation comment
-- AI HINTS: - This is a documented function
-- AI HINTS: - @param value any
-- AI HINTS: - @return boolean
function M.is_valid(value)
return value ~= nil and value ~= ""
end
-- AI HINTS: Final return
return M