Regenerate nvim config
This commit is contained in:
@ -0,0 +1,6 @@
|
||||
.. default-role:: code
|
||||
|
||||
|
||||
This directory exists so that we can point Neovim to its sub-directories
|
||||
instead of the default XDG base directories. This isolates the Neovim instance
|
||||
used during testing from the user's own configuration and data.
|
||||
@ -0,0 +1,11 @@
|
||||
-- Tree-sitter highlighting needs to be running, otherwise rainbow highlighting
|
||||
-- won't get updated on tree changes. The following autocommand enables it on
|
||||
-- every file type change.
|
||||
|
||||
|
||||
local function on_file_type(_args)
|
||||
vim.treesitter.start()
|
||||
end
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd('FileType', {pattern = '*', callback = on_file_type})
|
||||
@ -0,0 +1,35 @@
|
||||
-- Custom configuration for Busted
|
||||
|
||||
local say = require 'say'
|
||||
local assert = require 'luassert'
|
||||
local filter = vim.fn.filter
|
||||
|
||||
|
||||
local NVIM_STATE_KEY = {}
|
||||
|
||||
local function nvim(state, args, level)
|
||||
assert(args.n > 0, "No Neovim channel provided to the modifier")
|
||||
assert(rawget(state, NVIM_STATE_KEY) == nil, "Neovim already set")
|
||||
rawset(state, NVIM_STATE_KEY, args[1])
|
||||
return state
|
||||
end
|
||||
|
||||
---Asserts that there are Rainbow Delimiters extmarks at the given position
|
||||
---@param arguments integer[] Row and column, both zero-based
|
||||
local function has_extmarks_at(_state, arguments, lang)
|
||||
local nvim = rawget(_state, NVIM_STATE_KEY)
|
||||
assert(nvim ~= nil, 'No Neovim channel set, use the nvim modifier to set the channel')
|
||||
local row, column = arguments[1], arguments[2]
|
||||
local nsid = nvim:exec_lua('return require("rainbow-delimiters.lib").nsids[...]', {lang})
|
||||
local extmarks = nvim:exec_lua('return vim.inspect_pos(...).extmarks', {0, row, column})
|
||||
filter(extmarks, function(_, v) return v.ns_id == nsid end)
|
||||
return #extmarks > 0
|
||||
end
|
||||
|
||||
say:set('assertion.extmarks_at.positive', 'Expected extmarks at (%s, %s)')
|
||||
say:set('assertion.extmarks_at.negative', 'Expected no extmarks at (%s, %s)')
|
||||
|
||||
assert:register(
|
||||
'assertion', 'has_extmarks_at', has_extmarks_at,
|
||||
'assertion.has_extmarks_at.positive', 'assertion.has_extmarks_at.negative')
|
||||
assert:register('modifier', 'nvim', nvim)
|
||||
@ -0,0 +1,14 @@
|
||||
local get_runtime_file = vim.api.nvim_get_runtime_file
|
||||
local parser_pattern = 'parser/%s.*'
|
||||
|
||||
---Wrapper around the `:TSinstall` command which will only install a parser if
|
||||
---it is not installed yet
|
||||
---@param lang string Language to install
|
||||
function TSEnsure(lang, ...)
|
||||
for _, l in ipairs({lang, ...}) do
|
||||
local parsers = get_runtime_file(parser_pattern:format(l), true)
|
||||
if #parsers == 0 then
|
||||
vim.cmd {cmd = 'TSInstallSync', args = {l}}
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user