1

Update generated neovim config

This commit is contained in:
2024-08-15 14:28:54 +02:00
parent 07409c223d
commit 25cfcf2941
3809 changed files with 351157 additions and 0 deletions

View File

@ -0,0 +1,13 @@
local M = {}
function M.a(x, y)
return function() print(x .. y) end
end
M.b = function()
local x = 1 + 1
print('1 + 1 = ' .. x)
return true
end
return M

View File

@ -0,0 +1,39 @@
local new_match = function(range)
return {
node = {
-- `node:range()` should return 0-based numbers (row1, col1, row2, col2)
-- for end-exclusive region
range = function() return unpack(range) end,
},
}
end
-- Imitate matches from reference file 'tests/dir-ai/lua-file.lua'
-- The 'function.outer' and 'function.inner' matches are "real"
--stylua: ignore
local matches = {
['@function.outer'] = {
new_match({ 2, 0, 4, 3 }) ,
new_match({ 3, 9, 3, 37 }) ,
new_match({ 6, 6, 10, 3 }) ,
},
['@function.inner'] = {
new_match({ 3, 2, 3, 37 }) ,
new_match({ 3, 20, 3, 33 }) ,
new_match({ 7, 2, 9, 13 }) ,
},
['@plugin_other'] = {
new_match({ 0, 0, 0, 12 }) ,
new_match({ 12, 0, 12, 8 }) ,
},
}
local get_capture_matches_recursively = function(_, captures, _)
local res = {}
for _, cap in ipairs(captures) do
vim.list_extend(res, matches[cap])
end
return res
end
return { get_capture_matches_recursively = get_capture_matches_recursively }

View File

@ -0,0 +1,61 @@
-- Mock treesitter for 'lua'
vim.treesitter.get_parser = function(_, lang, _)
if lang ~= 'lua' then error([[There is parser only for 'lua' language.]]) end
return {
trees = function(_)
return { { root = function(_) return {} end } }
end,
lang = function(_) return lang end,
}
end
local new_node = function(range)
-- `node:range()` should return 0-based numbers (row1, col1, row2, col2) for
-- end-exclusive region
return { range = function(_) return unpack(range) end }
end
local get_query = function(lang, _)
if lang ~= 'lua' then error([[There is query only for 'lua' language.]]) end
local query = {}
query.captures = { 'function.outer', 'function.inner', 'other' }
-- Imitate matches from reference file 'tests/dir-ai/lua-file.lua'
-- The 'function.outer' and 'function.inner' matches are "real"
--stylua: ignore
local matches = {
{ 3, new_node({ 0, 0, 0, 12 }), {} },
{ 1, new_node({ 2, 0, 4, 3 }), {} },
{ 2, new_node({ 3, 2, 3, 37 }), {} },
{ 1, new_node({ 3, 9, 3, 37 }), {} },
{ 2, new_node({ 3, 20, 3, 33 }), {} },
{ 1, new_node({ 6, 6, 10, 3 }), {} },
{ 2, new_node({ 7, 2, 9, 13 }), {} },
{ 3, new_node({ 12, 0, 12, 8 }), {} },
}
query.iter_captures = function(_, _, _, _, _)
local iterator = function(s, _)
s.i = s.i + 1
local res = matches[s.i]
if res == nil then return nil end
return unpack(res)
end
return iterator, { i = 0 }
end
return query
end
vim.treesitter.get_query = function(...)
if vim.fn.has('nvim-0.9') == 1 then error('Use `vim.treesitter.query.get`.') end
return get_query(...)
end
vim.treesitter.query = vim.treesitter.query or {}
vim.treesitter.query.get = function(...)
if vim.fn.has('nvim-0.9') == 0 then error('This does not yet exist in Neovim<0.9.') end
return get_query(...)
end

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1 @@
Placeholder to test file-related functions of 'mini.bracketed'

View File

@ -0,0 +1,47 @@
local lines = {
'Error Warning Info Hint',
' Error ',
' Warning ',
' Info ',
' Hint ',
'Hint Info Warning Error',
}
local severity = vim.diagnostic.severity
--stylua: ignore
local diagnostic_arr = {
{ lnum = 0, end_lnum = 0, col = 0, end_col = 5, message = 'Error 1', severity = severity.ERROR },
{ lnum = 0, end_lnum = 0, col = 6, end_col = 13, message = 'Warning 1', severity = severity.WARN },
{ lnum = 0, end_lnum = 0, col = 14, end_col = 18, message = 'Info 1', severity = severity.INFO },
{ lnum = 0, end_lnum = 0, col = 19, end_col = 23, message = 'Hint 1', severity = severity.HINT },
{ lnum = 1, end_lnum = 1, col = 2, end_col = 7, message = 'Error 2', severity = severity.ERROR },
{ lnum = 2, end_lnum = 2, col = 2, end_col = 9, message = 'Warning 2', severity = severity.WARN },
{ lnum = 3, end_lnum = 3, col = 2, end_col = 6, message = 'Info 2', severity = severity.INFO },
{ lnum = 4, end_lnum = 4, col = 2, end_col = 6, message = 'Hint 2', severity = severity.HINT },
{ lnum = 5, end_lnum = 5, col = 0, end_col = 4, message = 'Hint 3', severity = severity.HINT },
{ lnum = 5, end_lnum = 5, col = 5, end_col = 9, message = 'Info 3', severity = severity.INFO },
{ lnum = 5, end_lnum = 5, col = 10, end_col = 17, message = 'Warning 3', severity = severity.WARN },
{ lnum = 5, end_lnum = 5, col = 18, end_col = 23, message = 'Error 3', severity = severity.ERROR },
}
local filter = function(severity_level)
return vim.tbl_filter(function(x) return x.severity == severity[severity_level] end, diagnostic_arr)
end
local convert_to_cursor_positions = function(arr)
return vim.tbl_map(function(x) return { x.lnum + 1, x.col } end, arr)
end
local cursor_positions = {
all = convert_to_cursor_positions(diagnostic_arr),
error = convert_to_cursor_positions(filter('ERROR')),
warning = convert_to_cursor_positions(filter('WARN')),
info = convert_to_cursor_positions(filter('INFO')),
hint = convert_to_cursor_positions(filter('HINT')),
error_warning = convert_to_cursor_positions(
vim.tbl_filter(function(x) return x.severity == severity.ERROR or x.severity == severity.WARN end, diagnostic_arr)
),
}
return { diagnostic_arr = diagnostic_arr, lines = lines, cursor_positions = cursor_positions }

View File

@ -0,0 +1,63 @@
-- Mock tree-sitter as if node is a region inside balanced `{}`
-- Find enclosing balanced `{}`. If `accept_at_cursor`, return balanced `{}`
-- when on it.
local find_enclosing_brackets = function(row, col, accept_at_cursor)
local searchpairpos = function(flags)
flags = flags or ''
local cache_cursor = vim.api.nvim_win_get_cursor(0)
vim.api.nvim_win_set_cursor(0, { row, col - 1 })
local res = vim.fn.searchpairpos('{', '', '}', 'nWz' .. flags)
vim.api.nvim_win_set_cursor(0, cache_cursor)
return res
end
if accept_at_cursor == nil then accept_at_cursor = true end
local char_at_cursor = vim.fn.getline(row):sub(col, col)
if char_at_cursor == '{' and accept_at_cursor then return { row, col }, searchpairpos() end
if char_at_cursor == '{' and not accept_at_cursor then return searchpairpos('b'), searchpairpos('c') end
if char_at_cursor == '}' and accept_at_cursor then return searchpairpos('b'), { row, col } end
if char_at_cursor == '}' and not accept_at_cursor then return searchpairpos('bc'), searchpairpos() end
return searchpairpos('b'), searchpairpos()
end
--@param row number Row number starting from 1.
--@param col number Column number starting from 1.
local new_node
new_node = function(row, col, accept_at_cursor)
if row == nil or col == nil then return nil end
-- Start and end of this node
local node_start, node_end = find_enclosing_brackets(row, col, accept_at_cursor)
-- - No node under cursor if no `{}` found
local no_node_found = (node_start[1] == 0 and node_start[2] == 0) or (node_end[1] == 0 and node_end[2] == 0)
if no_node_found then return nil end
-- Row and column for parent node
local node = {}
-- Start - inclusive, end - row-inclusive, col-exclusive. All zero-indexed.
node.start = function(_) return node_start[1] - 1, node_start[2] - 1 end
node.end_ = function(_) return node_end[1] - 1, node_end[2] end
node.range = function(_) return node_start[1] - 1, node_start[2] - 1, node_end[1] - 1, node_end[2] - 1 end
-- NOTE: this recursively searches for all parents for initial node
local parent_node = new_node(node_start[1], node_start[2], false)
node.parent = function(_) return parent_node end
return node
end
-- `row` and `col` are both zero-indexed here
if vim.fn.has('nvim-0.9') == 1 then
vim.treesitter.get_node = function(opts) return new_node(opts.pos[1] + 1, opts.pos[2] + 1) end
else
vim.treesitter.get_node_at_pos = function(_, row, col, _) return new_node(row + 1, col + 1) end
end

View File

@ -0,0 +1,13 @@
vim.cmd('highlight clear')
vim.g.colors_name = 'mock_cs'
--stylua: ignore start
vim.api.nvim_set_hl(0, 'Normal', { fg = '#5f87af', bg = '#080808' })
vim.api.nvim_set_hl(0, 'TestNormalCterm', { ctermfg = 67, ctermbg = 232 })
vim.api.nvim_set_hl(0, 'TestComment', { fg = '#5f87af', bg = '#080808' })
vim.api.nvim_set_hl(0, 'TestSpecial', { sp = '#00ff00', underline = true })
vim.api.nvim_set_hl(0, 'TestBlend', { bg = '#121212', blend = 0 })
--stylua: ignore end
vim.g.terminal_color_0 = '#010101'
vim.g.terminal_color_7 = '#fefefe'

View File

@ -0,0 +1,163 @@
_G.Months = {}
--stylua: ignore start
Months.items = {
{ name = 'January', kind = 1},
{ name = 'February', kind = 1 },
{ name = 'March', kind = 2 },
{ name = 'April', kind = 2 },
{ name = 'May', kind = 2 },
{ name = 'June', kind = 3 },
{ name = 'July', kind = 3 },
{ name = 'August', kind = 3 },
{ name = 'September', kind = 4 },
{ name = 'October', kind = 4 },
{ name = 'November', kind = 4 },
{ name = 'December', kind = 1 },
}
Months.data = {
January = { documentation = 'Month #01' },
February = { documentation = 'Month #02' },
March = { documentation = 'Month #03' },
April = { documentation = 'Month #04' },
May = { documentation = 'Month #05' },
June = { documentation = 'Month #06' },
July = { documentation = 'Month #07' },
August = { documentation = 'Month #08' },
September = { documentation = 'Month #09' },
October = { documentation = 'Month #10' },
November = { documentation = 'Month #11' },
December = { documentation = string.rep('a ', 1000) },
}
--stylua: ignore end
local construct_additionTextEdits = function(id, name)
return {
{
newText = ('from months.%s import %s\n'):format(id, name),
range = {
start = { line = 0, character = 0 },
['end'] = { line = 0, character = 0 },
},
},
}
end
local construct_textEdit = function(name, kind)
if _G.mock_textEdit == nil then return end
local new_text, pos = _G.mock_textEdit.new_text, _G.mock_textEdit.pos
local is_insertreplaceedit = kind == 'InsertReplaceEdit'
local range = {
start = { line = pos[1] - 1, character = pos[2] - 1 },
['end'] = { line = pos[1] - 1, character = pos[2] },
}
return {
newText = new_text(name),
[is_insertreplaceedit and 'insert' or 'range'] = range,
replace = is_insertreplaceedit and range or nil,
}
end
local construct_filterText = function(name)
if _G.mock_filterText == nil then return end
return _G.mock_filterText(name)
end
Months.requests = {
['textDocument/completion'] = function(params)
-- Imitate returning nothing in comments
local line = vim.fn.getline(params.position.line + 1)
if line:find('^%s*#') ~= nil then return { { result = { items = {} } } } end
local items = {}
for i, item in ipairs(Months.items) do
local res = { label = item.name, kind = item.kind, sortText = ('%03d'):format(i) }
-- Mock `additionalTextEdits` as in `pyright`
if vim.tbl_contains({ 'September', 'November' }, item.name) then
res.additionalTextEdits = construct_additionTextEdits('completion', item.name)
end
if item.name == 'April' then
res.textEdit = construct_textEdit(item.name, 'InsertReplaceEdit')
res.filterText = construct_filterText(item.name)
end
if item.name == 'August' then
res.textEdit = construct_textEdit(item.name, 'textEdit')
res.filterText = construct_filterText(item.name)
end
table.insert(items, res)
end
return { { result = { items = items } } }
end,
['completionItem/resolve'] = function(params)
params.documentation = { kind = 'markdown', value = Months.data[params.label].documentation }
-- Mock additionalTextEdits as in `typescript-language-server`
if vim.tbl_contains({ 'October', 'November' }, params.label) then
params.additionalTextEdits = construct_additionTextEdits('resolve', params.label)
end
return { { result = params } }
end,
['textDocument/signatureHelp'] = function(params)
local n_line, n_col = params.position.line, params.position.character
local line = vim.api.nvim_buf_get_lines(0, n_line, n_line + 1, false)[1]
line = line:sub(1, n_col)
local after_open_paren = line:match('%(.*$') or line
local after_close_paren = line:match('%).*$') or line
-- Stop showing signature help after closing bracket
if after_close_paren:len() < after_open_paren:len() then return { {} } end
-- Compute active parameter id by counting number of ',' from latest '('
local _, active_param_id = after_open_paren:gsub('%,', '%,')
-- Compute what is displayed in signature help: text and parameter info
-- (for highlighting) based on latest word
local word = line:match('%S+$')
local label, parameters
if word == 'long(' then
label = string.rep('a ', 1000)
else
label = 'abc(param1, param2)'
parameters = { { label = { 4, 10 } }, { label = { 12, 18 } } }
end
-- Construct output
local signature = {
activeParameter = active_param_id,
label = label,
parameters = parameters,
}
return { { result = { signatures = { signature } } } }
end,
}
-- Replace builtin functions with custom testable ones ========================
vim.lsp.buf_request_all = function(bufnr, method, params, callback)
local requests = Months.requests[method]
if requests == nil then return end
callback(requests(params))
end
local get_lsp_clients = function()
return {
{
name = 'months-lsp',
offset_encoding = 'utf-16',
server_capabilities = {
completionProvider = { resolveProvider = true, triggerCharacters = { '.' } },
signatureHelpProvider = { triggerCharacters = { '(', ',' } },
},
},
}
end
if vim.fn.has('nvim-0.10') == 0 then vim.lsp.buf_get_clients = get_lsp_clients end
if vim.fn.has('nvim-0.10') == 1 then vim.lsp.get_clients = get_lsp_clients end
vim.lsp.get_client_by_id = function(client_id) return get_lsp_clients()[client_id] end

View File

@ -0,0 +1,75 @@
_G.process_log = {}
local process_id = 1
local new_process = function(pid)
local is_active, is_closing = true, false
return {
pid = pid,
close = function(_)
table.insert(_G.process_log, 'Process ' .. pid .. ' was closed.')
is_active, is_closing = false, true
end,
is_closing = function(_) return is_closing end,
is_active = function(_) return is_active end,
}
end
-- Define object containing the queue with mocking stdio data.
-- Each element is a table with `out` and `err` fields, both can be `nil`,
-- `string`, or `string[]`. **Heavy** assumptions about how `new_pipe` is used:
-- - It is called twice before each `vim.loop.spawn`.
-- - It is first called for `stdout`, then for `stderr`.
_G.stdio_queue = {}
local io_field = 'out'
vim.loop.new_pipe = function()
local cur_process_id, cur_io_field = process_id, io_field
local cur_feed = (_G.stdio_queue[cur_process_id] or {})[cur_io_field]
if type(cur_feed) ~= 'table' then cur_feed = { cur_feed } end
io_field = io_field == 'out' and 'err' or 'out'
return {
read_start = function(_, callback)
for _, x in ipairs(cur_feed) do
if type(x) == 'table' then callback(x.err, nil) end
if type(x) == 'string' then callback(nil, x) end
end
callback(nil, nil)
end,
close = function()
table.insert(_G.process_log, string.format('Stream %s for process %s was closed.', cur_io_field, cur_process_id))
end,
}
end
-- Array of data to mock the process. Each element can be either `nil` or
-- a table with the following fields:
-- - <action> `(function|nil)` - callable to simulate job's side-effects.
-- - <duration> `(number|nil)` - how long a process should take. Default: 0.
-- - <exit_code> `(number|nil)` - exit code. Default: 0.
_G.process_mock_data = {}
_G.spawn_log = {}
vim.loop.spawn = function(path, options, on_exit)
local options_without_callables = vim.deepcopy(options) or {}
options_without_callables.stdio = nil
table.insert(_G.spawn_log, { executable = path, options = options_without_callables })
local pid = process_id
process_id = process_id + 1
local mock_data = _G.process_mock_data[pid] or {}
if vim.is_callable(mock_data.action) then mock_data.action() end
vim.defer_fn(function() on_exit(mock_data.exit_code or 0) end, mock_data.duration or 0)
return new_process(pid), pid
end
vim.loop.process_kill = function(process) table.insert(_G.process_log, 'Process ' .. process.pid .. ' was killed.') end
_G.n_cpu_info = 4
vim.loop.cpu_info = function()
local res = {}
for i = 1, _G.n_cpu_info do
res[i] = { model = 'A Very High End CPU' }
end
return res
end

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'after/plugin/plug_1.lua')

View File

@ -0,0 +1,5 @@
lua <<EOF
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'after/plugin/plug_1.vim')
EOF

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'after/plugin/subdir/plug_1_sub.lua')

View File

@ -0,0 +1,2 @@
*depstest_plugin_1_tag*
This is help for plugin_1.

View File

@ -0,0 +1 @@
return { 'plugin_1/lua/plug_1.lua' }

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'plugin/plug_1.lua')

View File

@ -0,0 +1,5 @@
lua <<EOF
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'plugin/plug_1.vim')
EOF

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'plugin/subdir/plug_1_sub.lua')

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'after/plugin/plug_2.lua')

View File

@ -0,0 +1,2 @@
*depstest_plugin_2_tag*
This is help for plugin_2.

View File

@ -0,0 +1 @@
return { 'plugin_2/lua/plug_2.lua' }

View File

@ -0,0 +1,2 @@
_G.plugin_log = _G.plugin_log or {}
table.insert(_G.plugin_log, 'plugin/plug_2.lua')

View File

@ -0,0 +1 @@
return { 'plugin_3/lua/plug_3.lua' }

View File

@ -0,0 +1 @@
Not proper Lua

View File

@ -0,0 +1 @@
return "Proper Lua but not proper return"

View File

@ -0,0 +1,4 @@
return {
plugin_1 = 'sha1head',
plugin_2 = 'sha2head'
}

View File

@ -0,0 +1,11 @@
========== Update 2024-01-02 03:04:05 ==========
+++ plugin_1 +++
Path: MOCKDIR/pack/deps/opt/plugin_1
Source: https://github.com/user/plugin_1
State before: sha1head
State after: new1head (main)
Pending updates from `main`:
> new1head | 2024-01-02 01:01:01 +0200 | Neo McVim
Added commit in checkout.

View File

@ -0,0 +1,2 @@
aaa
uuu

View File

@ -0,0 +1,5 @@
Line 1
Line 2
Line 3
Line 4
Line 5

View File

@ -0,0 +1,67 @@
_G.process_log = {}
local process_id = 1
local new_process = function(pid)
local close = function(_) table.insert(_G.process_log, 'Process ' .. pid .. ' was closed.') end
return { pid = pid, close = close }
end
-- Define object containing the queue with mocking stdio data.
-- Each element is an array of tables with the format:
-- - Element 1 is stdio type. One of "in", "out", "err".
-- - Element 2 is the feed of the pipe. Can be `nil`, `string`, `string[]`.
_G.stdio_queue = {}
local process_pipe_indexes = {}
vim.loop.new_pipe = function()
local cur_process_id = process_id
local process_pipe_data = _G.stdio_queue[cur_process_id] or {}
process_pipe_indexes[cur_process_id] = (process_pipe_indexes[cur_process_id] or 0) + 1
local cur_pipe_data = process_pipe_data[process_pipe_indexes[cur_process_id]] or {}
local cur_io_field, cur_feed = cur_pipe_data[1], cur_pipe_data[2]
if type(cur_feed) ~= 'table' then cur_feed = { cur_feed } end
return {
read_start = function(_, callback)
for _, x in ipairs(cur_feed) do
if type(x) == 'table' then callback(x.err, nil) end
if type(x) == 'string' then callback(nil, x) end
end
callback(nil, nil)
end,
write = function(_, chars)
local msg = string.format('Stream %s for process %s wrote: %s', cur_io_field, cur_process_id, chars)
table.insert(_G.process_log, msg)
end,
shutdown = function()
local msg = string.format('Stream %s for process %s was shut down.', cur_io_field, cur_process_id)
table.insert(_G.process_log, msg)
end,
close = function()
table.insert(_G.process_log, string.format('Stream %s for process %s was closed.', cur_io_field, cur_process_id))
end,
}
end
-- Array of data to mock the process. Each element can be either `nil` or
-- a table with the following fields:
-- - <action> `(function|nil)` - callable to simulate job's side-effects.
-- - <duration> `(number|nil)` - how long a process should take. Default: 0.
-- - <exit_code> `(number|nil)` - exit code. Default: 0.
_G.process_mock_data = {}
_G.spawn_log = {}
vim.loop.spawn = function(path, options, on_exit)
local options_without_callables = vim.deepcopy(options) or {}
options_without_callables.stdio = nil
table.insert(_G.spawn_log, { executable = path, options = options_without_callables })
local pid = process_id
process_id = process_id + 1
local mock_data = _G.process_mock_data[pid] or {}
if vim.is_callable(mock_data.action) then mock_data.action() end
vim.defer_fn(function() on_exit(mock_data.exit_code or 0) end, mock_data.duration or 0)
return new_process(pid), pid
end

View File

@ -0,0 +1,2 @@
*-output.txt
doc/

View File

@ -0,0 +1,3 @@
-- This file should be used to generate output help file.
-- It also should respect `--` as annotation prefix (as test for respecting
-- `config` argument).

View File

@ -0,0 +1 @@
-- This file should be ignored

View File

@ -0,0 +1,9 @@
==============================================================================
------------------------------------------------------------------------------
This file should be used to generate output help file.
It also should respect `--` as annotation prefix (as test for respecting
`config` argument).
This line should be added in `section_post` hook.
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,4 @@
_G.is_inside_buffer_local_script = true
-- Buffer variable should be later restored
vim.b.minidoc_config = { script_path = 'aaa' }

View File

@ -0,0 +1,4 @@
-- Global config should be later restored
MiniDoc.config.aaa = true
return require('mini.doc').generate(nil, 'output.txt', {})

View File

@ -0,0 +1 @@
--- File inside test for usage of custom script

View File

@ -0,0 +1,6 @@
==============================================================================
------------------------------------------------------------------------------
File inside test for usage of custom script
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1 @@
--- File 'default-collation/after/file01.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/after/file02.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/after/init.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/colors/file01.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/colors/file02.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/colors/init.lua'

View File

@ -0,0 +1,66 @@
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/init.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/file01.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/file02.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/lua/init.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/lua/file01.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/lua/file02.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/lua/aaa/init.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/after/init.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/after/file01.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/after/file02.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/colors/init.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/colors/file01.lua'
==============================================================================
------------------------------------------------------------------------------
File 'default-collation/colors/file02.lua'
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1 @@
--- File 'default-collation/file01.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/file02.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/init.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/lua/aaa/init.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/lua/file01.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/lua/file02.lua'

View File

@ -0,0 +1 @@
--- File 'default-collation/lua/init.lua'

View File

@ -0,0 +1,89 @@
H = {}
--- Remove (possibly not empty) directory
_G.remove_dir = function(path)
local fs = vim.loop.fs_scandir(path)
if not fs then
vim.notify([[Couldn't open directory ]] .. path)
return
end
local path_sep = package.config:sub(1, 1)
while true do
local f_name, _ = vim.loop.fs_scandir_next(fs)
if f_name == nil then break end
local p = ('%s%s%s'):format(path, path_sep, f_name)
vim.loop.fs_unlink(p)
end
vim.loop.fs_rmdir(path)
end
_G.validate_doc_structure = function(x)
H.validate_structure(x, 'doc', nil)
for _, file in ipairs(x) do
H.validate_structure(file, 'file', x)
for _, block in ipairs(file) do
H.validate_structure(block, 'block', file)
for _, section in ipairs(block) do
H.validate_structure(section, 'section', block)
for _, line in ipairs(section) do
if type(line) ~= 'string' then error('Section element is not a line.') end
end
end
end
end
end
-- Helper methods =============================================================
H.validate_structure = function(x, struct_type, parent)
local type_string = vim.inspect(struct_type)
if not H.is_structure(x, struct_type) then error(('Element is not %s structure.'):format(type_string)) end
if parent == nil then return end
if tostring(x.parent) ~= tostring(parent) then
error(('%s structure has not correct `info.parent`.'):format(type_string))
end
if tostring(parent[x.parent_index]) ~= tostring(x) then
error(('%s structure has not correct `info.parent_index`.'):format(type_string))
end
end
H.info_fields = {
section = { id = 'string', line_begin = 'number', line_end = 'number' },
block = { afterlines = 'table', line_begin = 'number', line_end = 'number' },
file = { path = 'string' },
doc = { input = 'table', output = 'string', config = 'table' },
}
H.is_structure = function(x, struct_type)
if not H.struct_has_elements(x) then return false end
if not x.type == struct_type then return false end
for info_name, info_type in pairs(H.info_fields[struct_type]) do
if type(x.info[info_name]) ~= info_type then return false end
end
return true
end
H.struct_has_elements = function(x)
-- Fields
if not (type(x.info) == 'table' and type(x.type) == 'string') then return false end
if x.parent ~= nil and not (type(x.parent) == 'table' and type(x.parent_index) == 'number') then return false end
-- Methods
for _, name in ipairs({ 'insert', 'remove', 'has_descendant', 'has_lines', 'clear_lines' }) do
if type(x[name]) ~= 'function' then return false end
end
return true
end

View File

@ -0,0 +1,74 @@
==============================================================================
------------------------------------------------------------------------------
Tests for inferring from afterline
------------------------------------------------------------------------------
*M.a()*
`M.a`({x}, {y})
This function definition should be inferred
------------------------------------------------------------------------------
This function definition should not be inferred (not from first column)
------------------------------------------------------------------------------
*b()*
`b`({x}, {y})
This function definition should be inferred
------------------------------------------------------------------------------
This function definition should not be inferred (not from first column)
------------------------------------------------------------------------------
*M.c()*
`M.c`({x}, {y})
This function definition should be inferred
------------------------------------------------------------------------------
*M.c_1()*
`M.c_1`()
This function definition should be inferred
------------------------------------------------------------------------------
This function definition should not be inferred (not from first column)
------------------------------------------------------------------------------
*d()*
`d`({x}, {y})
This function definition should be inferred
------------------------------------------------------------------------------
*d_1()*
`d_1`()
This function definition should be inferred
------------------------------------------------------------------------------
This function definition should not be inferred (not from first column)
------------------------------------------------------------------------------
*M.A*
`M.A`
This assignment should be inferred
------------------------------------------------------------------------------
*M.A_1*
`M.A_1`
This assignment should be inferred
------------------------------------------------------------------------------
This assignment should not be inferred (not from first column)
------------------------------------------------------------------------------
*B*
`B`
This assignment should be inferred
------------------------------------------------------------------------------
*B_1*
`B_1`
This assignment should be inferred
------------------------------------------------------------------------------
This assignment should not be inferred (not from first column)
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,68 @@
--stylua: ignore start
--- Tests for inferring from afterline
local M = {}
-- Functions
--- This function definition should be inferred
M.a = function(x, y)
print('M.a')
end
--- This function definition should not be inferred (not from first column)
M.a_no = function() end
--- This function definition should be inferred
local function b(x, y)
print('b')
end
--- This function definition should not be inferred (not from first column)
local function b_no() end
--- This function definition should be inferred
M.c = function(x, y)
print('M.c')
end
--- This function definition should be inferred
M.c_1=function() end
--- This function definition should not be inferred (not from first column)
M.c_no = function() end
--- This function definition should be inferred
local d = function(x, y)
print('d')
end
--- This function definition should be inferred
local d_1=function() end
--- This function definition should not be inferred (not from first column)
local d_no = function() end
-- Assignments
--- This assignment should be inferred
M.A = 1
--- This assignment should be inferred
M.A_1=1
--- This assignment should not be inferred (not from first column)
M.A_no = 1
--- This assignment should be inferred
local B = 1
--- This assignment should be inferred
local B_1=1
--- This assignment should not be inferred (not from first column)
local B_no = 1
return M
--stylua: ignore end

View File

@ -0,0 +1,17 @@
--- Test `@alias` section
---@alias var_one fun(type: string, data: any)
---@alias var_two Another data structure.
--- Its description spans over multiple lines.
---@alias %bad_name* This alias has bad name and should still work.
---@param x var_one
---@param y var_two
---@param z var_three
---@alias var_three This alias shouldn't be applied to previous line as it is defined after it.
--- Aliases also expand inside text: var_one
--- Test of `MiniDoc.current.aliases`
---
---@eval return vim.inspect(MiniDoc.current.aliases)

View File

@ -0,0 +1,30 @@
local M = {}
--- Tests of `@eval` section
---
--- Generic case
---
---@eval local i = 1
--- return ('This string is ' .. 'evaluated using local variable. '
--- .. i .. ' + ' .. i .. ' = ' .. (i + i))
--- Usage of `MiniDoc.afterlines_to_code()` and `MiniDoc.current.eval_section`
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
M.tab = {
-- Some functional setting
--minidoc_replace_start a = <function; should be padded>,
a = function() return 1 + 1 end,
--minidoc_replace_end
-- A very important setting
b = 2,
c = {
d = 3,
e = 4,
},
--minidoc_replace_start
f = 'This line should be completely removed',
--minidoc_replace_end
}
--minidoc_afterlines_end
M.entry = [[Shouldn't be included in afterlines]]

View File

@ -0,0 +1,64 @@
local M = {}
--- Test for `@class`, `@field`, and `@type`
---
---@class User
---
---@field login string User login.
---@field password string User password.
---@field address? string User address (should expand to optional).
---
---@type table
M.User = {}
--- Test `@diagnostic` (should be ignored in output) and `@overload`
---
---@param x string Variable.
---
---@overload fun(x: string)
---@diagnostic disable
local f = function(x, y) return x + 1 end
---@diagnostic enable
--- Test for `@private`
---
--- Private method that shouldn't be present in output
---@private
M._private_user = {}
--- Test for `@seealso` and `@usage`
---
---@usage `M.fun(1, 2)`
---
---@seealso |test-f| |f-test-different-line|
M.fun = function(a, b) return true end
--- Test for `@signature` and `@tag`
---
--- `@signature` should override default title inference where it is placed.
--- `@tag` should enclose non-whitespace group separately.
---
---@signature fun(x, y)
---@tag test-f f-test
--- f-test-different-line
local f = function() end
--- Test for smart empty line append
--- Some text
---
--- Test for smart empty line before tag
--- >lua
--- -- This is code block
--- <
---@tag important-tag
--- Test for `@text`
---
---@param a string
---@text
--- This illustrates some code:
--- >
--- require('mini.doc').setup()
--- <

View File

@ -0,0 +1,31 @@
--- Tests for `@param` section
--- Test for general cases
---
---@param b number Number.
---@param a string Some string. Multiline description:
--- - Item 1.
--- - Item 2.
---@param c table
---@param d
---@param x %%%bad_name!!
--- Test for expanding `?` to `(optional)`
---
---@param x? string This should add `(optional)`
---@param y string? This should not add `(optional)` as `?` is not after first word.
---@param abc string Having ? inside comment shouldn't trigger `(optional)`.
--- Test for enclosing type
---
---@param a number Should work.
---@param b number[] Should work.
---@param c number|nil Should work.
---@param d table<string, number> Should work.
---@param e fun(a: string, b:number) Should work.
---@param f fun(a: string, b:number): table Should work.
---@param g NUMBER Shouldn't work.
---@param a_function function Should enclose second `function`.
---@param function_a function Should enclose second `function`.
---@param a_function_a function Should enclose second `function`.
---@param afunction function Should enclose second `function`.

View File

@ -0,0 +1,22 @@
--- Tests for `@return` section
--- Test for general cases
---
---@return number Some number.
--- Test for expanding `?` to `(optional)`
---
---@return number?
---@return boolean? Second ? shouldn't trigger anything.
--- Test for enclosing type
---
---@return number Should work.
---@return number[] Should work.
---@return number|nil Should work.
---@return table<string, number> Should work.
---@return fun(a: string, b:number) Should work.
---@return fun(a: string, b:number): table Should work.
---@return NUMBER Shouldn't work.
---@return function Should not enclose second time: function .
---@return ... Should work.

View File

@ -0,0 +1,254 @@
==============================================================================
------------------------------------------------------------------------------
*M.User*
`M.User`
Test for `@class`, `@field`, and `@type`
Class ~
{User}
Fields ~
{login} `(string)` User login.
{password} `(string)` User password.
{address} `(optional)` `(string)` User address (should expand to optional).
Type ~
`(table)`
------------------------------------------------------------------------------
*f()*
`f`({x}, {y})
Test `@diagnostic` (should be ignored in output) and `@overload`
Parameters ~
{x} `(string)` Variable.
Overload ~
`fun(x: string)`
------------------------------------------------------------------------------
*M.fun()*
`M.fun`({a}, {b})
Test for `@seealso` and `@usage`
Usage ~
`M.fun(1, 2)`
See also ~
|test-f| |f-test-different-line|
------------------------------------------------------------------------------
*test-f* *f-test*
*f-test-different-line*
Test for `@signature` and `@tag`
`@signature` should override default title inference where it is placed.
`@tag` should enclose non-whitespace group separately.
`fun`({x}, {y})
------------------------------------------------------------------------------
Test for smart empty line append
Some text
------------------------------------------------------------------------------
*important-tag*
Test for smart empty line before tag
>lua
-- This is code block
<
------------------------------------------------------------------------------
Test for `@text`
Parameters ~
{a} `(string)`
This illustrates some code:
>
require('mini.doc').setup()
<
==============================================================================
------------------------------------------------------------------------------
Test `@alias` section
------------------------------------------------------------------------------
Parameters ~
{x} `(fun(type: string, data: any))`
{y} Another data structure.
Its description spans over multiple lines.
{z} var_three
------------------------------------------------------------------------------
Aliases also expand inside text: fun(type: string, data: any)
------------------------------------------------------------------------------
Test of `MiniDoc.current.aliases`
{
["%bad_name*"] = "This alias has bad name and should still work.",
var_one = " fun(type: string, data: any)",
var_three = "This alias shouldn't be applied to previous line as it is defined after it.",
var_two = "Another data structure.\n Its description spans over multiple lines."
}
==============================================================================
------------------------------------------------------------------------------
Tests of `@eval` section
Generic case
This string is evaluated using local variable. 1 + 1 = 2
------------------------------------------------------------------------------
*M.tab*
`M.tab`
Usage of `MiniDoc.afterlines_to_code()` and `MiniDoc.current.eval_section`
>lua
M.tab = {
-- Some functional setting
a = <function; should be padded>,
-- A very important setting
b = 2,
c = {
d = 3,
e = 4,
},
}
<
==============================================================================
------------------------------------------------------------------------------
Tests for `@param` section
------------------------------------------------------------------------------
Test for general cases
Parameters ~
{b} `(number)` Number.
{a} `(string)` Some string. Multiline description:
- Item 1.
- Item 2.
{c} `(table)`
{d}
{x} %%%bad_name!!
------------------------------------------------------------------------------
Test for expanding `?` to `(optional)`
Parameters ~
{x} `(optional)` `(string)` This should add `(optional)`
{y} `(string?)` This should not add `(optional)` as `?` is not after first word.
{abc} `(string)` Having ? inside comment shouldn't trigger `(optional)`.
------------------------------------------------------------------------------
Test for enclosing type
Parameters ~
{a} `(number)` Should work.
{b} `(number[])` Should work.
{c} `(number|nil)` Should work.
{d} `(table<string, number>)` Should work.
{e} `(fun(a: string, b:number))` Should work.
{f} `(fun(a: string, b:number): table)` Should work.
{g} NUMBER Shouldn't work.
{a_function} `(function)` Should enclose second `function`.
{function_a} `(function)` Should enclose second `function`.
{a_function_a} `(function)` Should enclose second `function`.
{afunction} `(function)` Should enclose second `function`.
==============================================================================
------------------------------------------------------------------------------
Tests for `@return` section
------------------------------------------------------------------------------
Test for general cases
Return ~
`(number)` Some number.
------------------------------------------------------------------------------
Test for expanding `?` to `(optional)`
Return ~
`(number)` `(optional)`
Return ~
`(boolean)` `(optional)` Second ? shouldn't trigger anything.
------------------------------------------------------------------------------
Test for enclosing type
Return ~
`(number)` Should work.
Return ~
`(number[])` Should work.
Return ~
`(number|nil)` Should work.
Return ~
`(table<string, number>)` Should work.
Return ~
`(fun(a: string, b:number))` Should work.
Return ~
`(fun(a: string, b:number): table)` Should work.
Return ~
NUMBER Shouldn't work.
Return ~
`(function)` Should not enclose second time: function .
Return ~
`(...)` Should work.
==============================================================================
------------------------------------------------------------------------------
Test `@toc` and `@toc_entry` sections
Table of contents:
Entry #1..............................................................
Entry #2:.................................................................
This time it is
multiline
Entry #3....................................................|toc-entry-with|
|multiline-tag|
Entry #4:............................................|toc-second-entry-with|
Multiline with |multiline-tag-2|
three lines
.............................................|toc-entry-without-description|
Entry #6 (without tag)....................................................
Entry #7: A very-very-very-very-very-very-very-very-very-very long description...
------------------------------------------------------------------------------
TOC entry with leading spaces
------------------------------------------------------------------------------
Multiline TOC entry
------------------------------------------------------------------------------
*toc-entry-with*
*multiline-tag*
TOC entry with multiline tag
------------------------------------------------------------------------------
*toc-second-entry-with*
*multiline-tag-2*
TOC entry with multiline tag and entry
------------------------------------------------------------------------------
*toc-entry-without-description*
TOC entry without description
------------------------------------------------------------------------------
TOC entry without tag
------------------------------------------------------------------------------
TOC entry with very long description
------------------------------------------------------------------------------
Test of `MiniDoc.current.toc`
Number of current TOC entries: 7
vim:tw=78:ts=8:noet:ft=help:norl:

View File

@ -0,0 +1,39 @@
--- Test `@toc` and `@toc_entry` sections
---
--- Table of contents:
---@toc
--- TOC entry with leading spaces
---@toc_entry Entry #1
--- Multiline TOC entry
---@toc_entry Entry #2:
--- This time it is
--- multiline
--- TOC entry with multiline tag
---@tag toc-entry-with
--- multiline-tag
---@toc_entry Entry #3
--- TOC entry with multiline tag and entry
---@tag toc-second-entry-with
--- multiline-tag-2
---@toc_entry Entry #4:
--- Multiline with
--- three lines
--- TOC entry without description
---
---@tag toc-entry-without-description
---@toc_entry
--- TOC entry without tag
---@toc_entry Entry #6 (without tag)
--- TOC entry with very long description
---@toc_entry Entry #7: A very-very-very-very-very-very-very-very-very-very long description
--- Test of `MiniDoc.current.toc`
---
---@eval return 'Number of current TOC entries: ' .. #MiniDoc.current.toc

View File

@ -0,0 +1,5 @@
---@text This is `@text` section.
--- It has multiple lines.
---@text This is another section in the same block.
---@text This is another block with single `@text` section.

View File

@ -0,0 +1 @@
---@text This is another file.

View File

@ -0,0 +1,21 @@
Line 1-1
Line 1-2
Line 1-3
Line 1-4
Line 1-5
Line 1-6
Line 1-7
Line 1-8
Line 1-9
Line 1-10
Line 1-11
Line 1-12
Line 1-13
Line 1-14
Line 1-15
Line 1-16
Line 1-17
Line 1-18
Line 1-19
Line 1-20
Line 1-21

View File

@ -0,0 +1,21 @@
Line 2-1
Line 2-2
Line 2-3
Line 2-4
Line 2-5
Line 2-6
Line 2-7
Line 2-8
Line 2-9
Line 2-10
Line 2-11
Line 2-12
Line 2-13
Line 2-14
Line 2-15
Line 2-16
Line 2-17
Line 2-18
Line 2-19
Line 2-20
Line 2-21

View File

@ -0,0 +1,17 @@
vim.cmd('hi DevIconLicense guifg=#111111')
vim.cmd('hi DevIconMakefile guifg=#222222')
vim.cmd('hi DevIconGif guifg=#333333')
vim.cmd('hi DevIconLua guifg=#444444')
vim.cmd('hi DevIconTxt guifg=#555555')
vim.cmd('hi DevIconDefault guifg=#666666')
return {
get_icon = function(filename, _, options)
if filename == 'LICENSE' then return '', 'DevIconLicense' end
if filename == 'Makefile' then return '', 'DevIconMakefile' end
if vim.endswith(filename, 'gif') then return '', 'DevIconGif' end
if vim.endswith(filename, 'lua') then return '', 'DevIconLua' end
if vim.endswith(filename, 'txt') then return '', 'DevIconTxt' end
if (options or {}).default then return '', 'DevIconDefault' end
end,
}

View File

@ -0,0 +1,5 @@
Error Warning Info Hint
Error
Warning
Info
Hint

View File

@ -0,0 +1,4 @@
Error
Warning
Info
Hint

View File

@ -0,0 +1,34 @@
local severity = vim.diagnostic.severity
_G.diag_ns = vim.api.nvim_create_namespace('mock-diagnostics')
-- Open files
vim.cmd('edit tests/dir-extra/mocks/diagnostic-file-1')
_G.buf_id_1 = vim.api.nvim_get_current_buf()
vim.cmd('edit tests/dir-extra/mocks/diagnostic-file-2')
_G.buf_id_2 = vim.api.nvim_get_current_buf()
-- Define diagnostic
--stylua: ignore
_G.diagnostic_arr = {
-- Several entries on one line
{ bufnr = buf_id_1, lnum = 0, end_lnum = 0, col = 0, end_col = 5, message = 'Error 1', severity = severity.ERROR },
{ bufnr = buf_id_1, lnum = 0, end_lnum = 0, col = 6, end_col = 13, message = 'Warning 1', severity = severity.WARN },
{ bufnr = buf_id_1, lnum = 0, end_lnum = 0, col = 14, end_col = 18, message = 'Info 1', severity = severity.INFO },
{ bufnr = buf_id_1, lnum = 0, end_lnum = 0, col = 19, end_col = 23, message = 'Hint 1', severity = severity.HINT },
-- Entries on separate lines not at line start
{ bufnr = buf_id_1, lnum = 1, end_lnum = 1, col = 2, end_col = 7, message = 'Error 2', severity = severity.ERROR },
{ bufnr = buf_id_1, lnum = 2, end_lnum = 2, col = 2, end_col = 9, message = 'Warning 2', severity = severity.WARN },
{ bufnr = buf_id_1, lnum = 3, end_lnum = 3, col = 2, end_col = 6, message = 'Info 2', severity = severity.INFO },
{ bufnr = buf_id_1, lnum = 4, end_lnum = 4, col = 2, end_col = 6, message = 'Hint 2', severity = severity.HINT },
-- Another buffer
{ bufnr = buf_id_2, lnum = 0, end_lnum = 0, col = 0, end_col = 5, message = 'Error 3', severity = severity.ERROR },
{ bufnr = buf_id_2, lnum = 1, end_lnum = 1, col = 0, end_col = 7, message = 'Warning 3', severity = severity.WARN },
{ bufnr = buf_id_2, lnum = 2, end_lnum = 2, col = 0, end_col = 4, message = 'Info 3', severity = severity.INFO },
{ bufnr = buf_id_2, lnum = 3, end_lnum = 3, col = 0, end_col = 4, message = 'Hint 3', severity = severity.HINT },
}
-- Set diagnostic
vim.diagnostic.set(diag_ns, buf_id_1, vim.tbl_filter(function(x) return x.bufnr == buf_id_1 end, _G.diagnostic_arr), {})
vim.diagnostic.set(diag_ns, buf_id_2, vim.tbl_filter(function(x) return x.bufnr == buf_id_2 end, _G.diagnostic_arr), {})

View File

@ -0,0 +1,18 @@
commit 1111111111111111111111111111111111111111
Author: Mini Nvim <mini.nvim@emailaddress.com>
Date: Thu Jan 1 11:11:11 1970 +0300
Initial commit.
diff --git a/git-files/git-file-1 b/git-files/git-file-1
index 1111111..0123456 100644
--- a/git-files/git-file-1
+++ b/git-files/git-file-1
@@ -1,5 +1,5 @@
Line 1-1
-Line 1-2
Line 1-3
Line 1-4
Line 1-5
+Line 1-6

View File

@ -0,0 +1,47 @@
diff --git a/git-files/git-file-1 b/git-files/git-file-1
index c139d4e..234d24d 100644
--- a/git-files/git-file-1
+++ b/git-files/git-file-1
@@ -1,4 +1,3 @@
-Line 1-1
Line 1-2
Line 1-3
Line 1-4
@@ -9,6 +8,7 @@ Line 1-8
Line 1-9
Line 1-10
Line 1-11
+Line new
Line 1-12
Line 1-13
Line 1-14
@@ -18,4 +18,4 @@ Line 1-17
Line 1-18
Line 1-19
Line 1-20
-Line 1-21
+Line changed
diff --git a/git-files/git-file-2 b/git-files/git-file-2
index e45e3de..bd830d0 100644
--- a/git-files/git-file-2
+++ b/git-files/git-file-2
@@ -1,5 +1,4 @@
Line 2-1
-Line 2-2
Line 2-3
Line 2-4
Line 2-5
@@ -10,10 +9,11 @@ Line 2-9
Line 2-10
Line 2-11
Line 2-12
+Line new
Line 2-13
Line 2-14
Line 2-15
-Line 2-16
+Line changed
Line 2-17
Line 2-18
Line 2-19

View File

@ -0,0 +1,23 @@
diff --git a/git-files/git-file-1 b/git-files/git-file-1
index c139d4e..234d24d 100644
--- a/git-files/git-file-1
+++ b/git-files/git-file-1
@@ -1 +0,0 @@
-Line 1-1
@@ -11,0 +11 @@ Line 1-11
+Line new
@@ -21 +21 @@ Line 1-20
-Line 1-21
+Line changed
diff --git a/git-files/git-file-2 b/git-files/git-file-2
index e45e3de..bd830d0 100644
--- a/git-files/git-file-2
+++ b/git-files/git-file-2
@@ -2 +1,0 @@ Line 2-1
-Line 2-2
@@ -12,0 +12 @@ Line 2-12
+Line new
@@ -16 +16 @@ Line 2-15
-Line 2-16
+Line changed

View File

@ -0,0 +1,57 @@
diff --git a/git-files/git-file-1 b/git-files/git-file-1
index c139d4e..234d24d 100644
--- a/git-files/git-file-1
+++ b/git-files/git-file-1
@@ -1,21 +1,21 @@
-Line 1-1
Line 1-2
Line 1-3
Line 1-4
Line 1-5
Line 1-6
Line 1-7
Line 1-8
Line 1-9
Line 1-10
Line 1-11
+Line new
Line 1-12
Line 1-13
Line 1-14
Line 1-15
Line 1-16
Line 1-17
Line 1-18
Line 1-19
Line 1-20
-Line 1-21
+Line changed
diff --git a/git-files/git-file-2 b/git-files/git-file-2
index e45e3de..bd830d0 100644
--- a/git-files/git-file-2
+++ b/git-files/git-file-2
@@ -1,21 +1,21 @@
Line 2-1
-Line 2-2
Line 2-3
Line 2-4
Line 2-5
Line 2-6
Line 2-7
Line 2-8
Line 2-9
Line 2-10
Line 2-11
Line 2-12
+Line new
Line 2-13
Line 2-14
Line 2-15
-Line 2-16
+Line changed
Line 2-17
Line 2-18
Line 2-19
Line 2-20
Line 2-21

View File

@ -0,0 +1,12 @@
local tmp = 1
local keymap_rhs = function()
-- Comment
_G.been_here = true
end
--stylua: ignore
vim.api.nvim_set_keymap(
'n', 'ga', '',
{ callback = keymap_rhs, desc = 'Keymap with callback' }
)

View File

@ -0,0 +1,96 @@
local filename = vim.fn.fnamemodify('tests/dir-extra/real-files/a.lua', ':p')
_G.lsp_buf_calls = {}
local make_context = function(lsp_method)
return {
bufnr = vim.api.nvim_get_current_buf(),
method = lsp_method,
-- There are more fields, but none are relevant
}
end
vim.lsp.buf.declaration = function(opts)
table.insert(_G.lsp_buf_calls, 'declaration')
local data = {
context = make_context('textDocument/declaration'),
items = { { col = 16, filename = filename, lnum = 3, text = ' x = math.max(a, 2),' } },
title = 'Declaration',
}
opts.on_list(data)
end
vim.lsp.buf.definition = function(opts)
table.insert(_G.lsp_buf_calls, 'definition')
local data = {
context = make_context('textDocument/definition'),
items = { { col = 16, filename = filename, lnum = 3, text = ' x = math.max(a, 2),' } },
title = 'Definition',
}
opts.on_list(data)
end
vim.lsp.buf.document_symbol = function(opts)
table.insert(_G.lsp_buf_calls, 'document_symbol')
local data = {
context = make_context('textDocument/documentSymbol'),
items = {
{ col = 7, filename = filename, kind = 'Number', lnum = 1, text = '[Number] a' },
{ col = 7, filename = filename, kind = 'Object', lnum = 2, text = '[Object] t' },
{ col = 3, filename = filename, kind = 'Variable', lnum = 3, text = '[Variable] x' },
{ col = 3, filename = filename, kind = 'Variable', lnum = 4, text = '[Variable] y' },
},
title = 'Symbols in a.lua',
}
opts.on_list(data)
end
vim.lsp.buf.implementation = function(opts)
table.insert(_G.lsp_buf_calls, 'implementation')
local data = {
context = make_context('textDocument/implementation'),
items = { { col = 16, filename = filename, lnum = 3, text = ' x = math.max(a, 2),' } },
title = 'Implementation',
}
opts.on_list(data)
end
vim.lsp.buf.references = function(_, opts)
table.insert(_G.lsp_buf_calls, 'references')
local data = {
context = make_context('textDocument/references'),
items = {
{ col = 7, filename = filename, lnum = 1, text = 'local a = 1' },
{ col = 16, filename = filename, lnum = 3, text = ' x = math.max(a, 2),' },
{ col = 16, filename = filename, lnum = 4, text = ' y = math.min(a, 2),' },
},
title = 'References',
}
opts.on_list(data)
end
vim.lsp.buf.type_definition = function(opts)
table.insert(_G.lsp_buf_calls, 'type_definition')
local data = {
context = make_context('textDocument/typeDefinition'),
items = { { col = 16, filename = filename, lnum = 3, text = ' x = math.max(a, 2),' } },
title = 'Type definition',
}
opts.on_list(data)
end
vim.lsp.buf.workspace_symbol = function(query, opts)
table.insert(_G.lsp_buf_calls, 'workspace_symbol')
_G.workspace_symbol_query = query
local data = {
context = make_context('textDocument/workspaceSymbol'),
items = {
{ col = 7, filename = filename, kind = 'Number', lnum = 1, text = '[Number] a' },
{ col = 7, filename = filename, kind = 'Object', lnum = 2, text = '[Object] t' },
{ col = 3, filename = filename, kind = 'Variable', lnum = 3, text = '[Variable] x' },
{ col = 3, filename = filename, kind = 'Variable', lnum = 4, text = '[Variable] y' },
},
title = "Symbols matching ''",
}
opts.on_list(data)
end

View File

@ -0,0 +1,55 @@
_G.process_log = {}
local n_pid, n_stream = 0, 0
local new_process = function(pid)
return {
pid = pid,
close = function(_) table.insert(_G.process_log, 'Process ' .. pid .. ' was closed.') end,
}
end
-- Mock streams by using global `_G.stdout_data_feed` and `_G.stderr_data_feed`
-- arrays as source. Each feed's element should be either string (for usable
-- data) or a table with `err` field (for error).
local stream_counts = {}
vim.loop.new_pipe = function()
-- NOTE: Use `_G.stream_type_queue` to determine which stream type to create
-- (for log purposes). This is to account for `vim.loop.spawn` creating
-- different sets of streams. Assume 'stdout' by default.
if _G.stream_type_queue == nil or #_G.stream_type_queue == 0 then _G.stream_type_queue = { 'stdout' } end
local stream_type = _G.stream_type_queue[1]
table.remove(_G.stream_type_queue, 1)
local new_count = (stream_counts[stream_type] or 0) + 1
stream_counts[stream_type] = new_count
local cur_stream_id = stream_type .. '_' .. new_count
return {
read_start = function(_, callback)
-- It is not possible in Neovim<=0.9 to execute `vim.fn` functions during
-- `pipe:read_start()`
local data_feed = stream_type == 'stdout' and _G.stdout_data_feed or _G.stderr_data_feed
for _, x in ipairs(data_feed or {}) do
if type(x) == 'table' then callback(x.err, nil) end
if type(x) == 'string' then callback(nil, x) end
end
callback(nil, nil)
end,
close = function() table.insert(_G.process_log, string.format('%s was closed.', cur_stream_id)) end,
}
end
_G.spawn_log = {}
vim.loop.spawn = function(path, options, on_exit)
local options_without_callables = vim.deepcopy(options)
options_without_callables.stdio = nil
table.insert(_G.spawn_log, { executable = path, options = options_without_callables })
vim.schedule(function() on_exit() end)
n_pid = n_pid + 1
local pid = 'Pid_' .. n_pid
return new_process(pid), pid
end
vim.loop.process_kill = function(process) table.insert(_G.process_log, 'Process ' .. process.pid .. ' was killed.') end

View File

@ -0,0 +1,3 @@
VAR ?= 1
all: test

View File

@ -0,0 +1,5 @@
local a = 1
local t = {
x = math.max(a, 2),
y = math.min(a, 2),
}

View File

@ -0,0 +1,26 @@
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
Line 11
Line 12
Line 13
Line 14
Line 15
Line 16
Line 17
Line 18
Line 19
Line 20
Line 21
Line 22
Line 23
Line 24
Line 25
Line 26

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Some files were not shown because too many files have changed in this diff Show More