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 @@
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