mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 01:16:31 +00:00
docs: vim.fs., diagnostics, lsp #34488
backport of #34402
(cherry picked from commit 8001276bd0
)
This commit is contained in:
@@ -303,7 +303,7 @@ void ui_refresh(void)
|
||||
}
|
||||
}]]
|
||||
|
||||
it('allows to iterate over nodes children', function()
|
||||
it('can iterate over nodes children', function()
|
||||
insert(test_text)
|
||||
|
||||
local res = exec_lua(function()
|
||||
@@ -337,7 +337,7 @@ void ui_refresh(void)
|
||||
exec_lua("vim.treesitter.get_parser(0, 'c')")
|
||||
end)
|
||||
|
||||
it('allows to get a child by field', function()
|
||||
it('can get a child by field', function()
|
||||
insert(test_text)
|
||||
|
||||
local res = exec_lua(function()
|
||||
@@ -363,7 +363,7 @@ void ui_refresh(void)
|
||||
assert(res_fail)
|
||||
end)
|
||||
|
||||
it('supports getting text of multiline node', function()
|
||||
it('can get text of multiline node', function()
|
||||
insert(test_text)
|
||||
local res = exec_lua(function()
|
||||
local parser = vim.treesitter.get_parser(0, 'c')
|
||||
@@ -380,7 +380,7 @@ void ui_refresh(void)
|
||||
eq('void', res2)
|
||||
end)
|
||||
|
||||
it('supports getting text where start of node is one past EOF', function()
|
||||
it('can get text where start of node is one past EOF', function()
|
||||
local text = [[
|
||||
def run
|
||||
a = <<~E
|
||||
@@ -407,7 +407,7 @@ end]]
|
||||
)
|
||||
end)
|
||||
|
||||
it('supports getting empty text if node range is zero width', function()
|
||||
it('can get empty text if node range is zero-width', function()
|
||||
local text = [[
|
||||
```lua
|
||||
{}
|
||||
@@ -429,7 +429,7 @@ end]]
|
||||
eq(true, result)
|
||||
end)
|
||||
|
||||
it('allows to set simple ranges', function()
|
||||
it('can set simple ranges', function()
|
||||
insert(test_text)
|
||||
|
||||
local res = exec_lua(function()
|
||||
@@ -461,7 +461,7 @@ end]]
|
||||
eq({ { { 0, 0, 0, 17, 1, 508 } } }, range_tbl)
|
||||
end)
|
||||
|
||||
it('allows to set complex ranges', function()
|
||||
it('can set complex ranges', function()
|
||||
insert(test_text)
|
||||
|
||||
local res = exec_lua(function()
|
||||
@@ -495,7 +495,7 @@ end]]
|
||||
}, res)
|
||||
end)
|
||||
|
||||
it('allows to create string parsers', function()
|
||||
it('can create string parsers', function()
|
||||
local ret = exec_lua(function()
|
||||
local parser = vim.treesitter.get_string_parser('int foo = 42;', 'c')
|
||||
return { parser:parse()[1]:root():range() }
|
||||
@@ -513,7 +513,7 @@ end]]
|
||||
eq({ 0, 0, 0, 13 }, ret)
|
||||
end)
|
||||
|
||||
it('allows to run queries with string parsers', function()
|
||||
it('can run queries with string parsers', function()
|
||||
local txt = [[
|
||||
int foo = 42;
|
||||
int bar = 13;
|
||||
@@ -535,7 +535,7 @@ end]]
|
||||
eq({ { 0, 10, 0, 13 } }, ret)
|
||||
end)
|
||||
|
||||
describe('when creating a language tree', function()
|
||||
describe('creating a language tree', function()
|
||||
local function get_ranges()
|
||||
return exec_lua(function()
|
||||
local result = {}
|
||||
@@ -557,8 +557,8 @@ int x = INT_MAX;
|
||||
]])
|
||||
end)
|
||||
|
||||
describe('when parsing regions independently', function()
|
||||
it('should inject a language', function()
|
||||
describe('parsing regions independently', function()
|
||||
it('injects a language', function()
|
||||
exec_lua(function()
|
||||
_G.parser = vim.treesitter.get_parser(0, 'c', {
|
||||
injections = {
|
||||
@@ -596,7 +596,7 @@ int x = INT_MAX;
|
||||
end)
|
||||
|
||||
describe('when parsing regions combined', function()
|
||||
it('should inject a language', function()
|
||||
it('injects a language', function()
|
||||
exec_lua(function()
|
||||
_G.parser = vim.treesitter.get_parser(0, 'c', {
|
||||
injections = {
|
||||
@@ -777,7 +777,7 @@ int x = INT_MAX;
|
||||
end)
|
||||
|
||||
describe('when using injection.self', function()
|
||||
it('should inject the source language', function()
|
||||
it('injects the source language', function()
|
||||
exec_lua(function()
|
||||
_G.parser = vim.treesitter.get_parser(0, 'c', {
|
||||
injections = {
|
||||
@@ -815,7 +815,7 @@ int x = INT_MAX;
|
||||
end)
|
||||
|
||||
describe('when using the offset directive', function()
|
||||
it('should shift the range by the directive amount', function()
|
||||
it('shifts the range by the directive amount', function()
|
||||
exec_lua(function()
|
||||
_G.parser = vim.treesitter.get_parser(0, 'c', {
|
||||
injections = {
|
||||
@@ -838,7 +838,7 @@ int x = INT_MAX;
|
||||
{ 2, 29, 2, 66 }, -- READ_STRING_OK(x, y) (char *)read_string((x), (size_t)(y))
|
||||
}, get_ranges())
|
||||
end)
|
||||
it('should list all directives', function()
|
||||
it('lists all directives', function()
|
||||
local res_list = exec_lua(function()
|
||||
local query = vim.treesitter.query
|
||||
|
||||
@@ -862,7 +862,7 @@ int x = INT_MAX;
|
||||
]])
|
||||
end)
|
||||
|
||||
it('should return the correct language tree', function()
|
||||
it('returns the correct language tree', function()
|
||||
local result = exec_lua(function()
|
||||
local parser = vim.treesitter.get_parser(0, 'c', {
|
||||
injections = {
|
||||
@@ -912,7 +912,7 @@ print()
|
||||
|
||||
describe('when getting/setting match data', function()
|
||||
describe('when setting for the whole match', function()
|
||||
it('should set/get the data correctly', function()
|
||||
it('sets/gets the data correctly', function()
|
||||
insert([[
|
||||
int x = 3;
|
||||
]])
|
||||
@@ -930,7 +930,7 @@ print()
|
||||
end)
|
||||
|
||||
describe('when setting a key on a capture', function()
|
||||
it('it should create the nested table', function()
|
||||
it('creates the nested table', function()
|
||||
insert([[
|
||||
int x = 3;
|
||||
]])
|
||||
@@ -950,7 +950,7 @@ print()
|
||||
eq('value', result)
|
||||
end)
|
||||
|
||||
it('it should not overwrite the nested table', function()
|
||||
it('does not overwrite the nested table', function()
|
||||
insert([[
|
||||
int x = 3;
|
||||
]])
|
||||
@@ -1206,7 +1206,7 @@ print()
|
||||
eq({ { { 1, 0, 21, 2, 0, 42 } } }, exec_lua('return parser2:children().lua:included_regions()'))
|
||||
end)
|
||||
|
||||
it('parsers injections incrementally', function()
|
||||
it('parses injections incrementally', function()
|
||||
insert(dedent [[
|
||||
>lua
|
||||
local a = {}
|
||||
@@ -1349,7 +1349,7 @@ print()
|
||||
end)
|
||||
|
||||
it(
|
||||
'is valid excluding, invalid including children after a range parse that does not lead to parsing not parsed injections',
|
||||
'is valid excluding, invalid including children after a range parse that does not lead to parsing non-parsed injections',
|
||||
function()
|
||||
exec_lua('vim.treesitter.get_parser():parse({2, 4})')
|
||||
eq(true, exec_lua('return vim.treesitter.get_parser():is_valid(true)'))
|
||||
|
Reference in New Issue
Block a user