- constrain ignore_parse_error()
This commit is contained in:
Justin M. Keyes 2024-02-21 17:36:28 -05:00
parent f9db95e5f9
commit c592617dd5
5 changed files with 19 additions and 17 deletions

View File

@ -926,13 +926,13 @@ a `return` statement, then the function returns with no results.
*lua-colonsyntax*
The colon syntax is used for defining methods, that is, functions that have an
implicit extra parameter `self`. Thus, the statement
implicit extra parameter `self`. Thus, the statement >
`function t.a.b.c:f (` `params` `)` `body` `end`
function t.a.b.c:f ( params ) body end
is syntactic sugar for
is syntactic sugar for >
`t.a.b.c:f = function (` `self`, `params` `)` `body` `end`
t.a.b.c:f = function ( self, params ) body end
==============================================================================
2.6 Visibility Rules *lua-visibility*

View File

@ -72,12 +72,12 @@ local function valid_lang(lang)
return lang and lang ~= ''
end
--- Returns the parser for a specific buffer and attaches it to the buffer
--- Gets the parser for a buffer and attaches it to the buffer.
---
--- If needed, this will create the parser.
--- Creates the parser, if needed.
---
---@param bufnr (integer|nil) Buffer the parser should be tied to (default: current buffer)
---@param lang (string|nil) Language of this parser (default: from buffer filetype)
---@param bufnr (integer|nil) Buffer to parse (default: current buffer)
---@param lang (string|nil) Language of this parser (default: buffer 'filetype')
---@param opts (table|nil) Options to pass to the created language tree
---
---@return vim.treesitter.LanguageTree object to use for parsing
@ -96,15 +96,13 @@ function M.get_parser(bufnr, lang, opts)
if not parsers[bufnr] then
error(
string.format(
'There is no parser available for buffer %d and one could not be'
.. ' created because lang could not be determined. Either pass lang'
.. ' or set the buffer filetype',
"No parser for buffer %d with unknown lang. Either pass lang or set 'filetype'.",
bufnr
)
)
end
elseif parsers[bufnr] == nil or parsers[bufnr]:lang() ~= lang then
assert(lang, 'lang should be valid')
assert(lang, 'invalid lang')
parsers[bufnr] = M._create_parser(bufnr, lang, opts)
end

View File

@ -10,13 +10,13 @@
--
-- USAGE (GENERATE HTML):
-- 1. `:helptags ALL` first; this script depends on vim.fn.taglist().
-- 2. nvim -V1 -es --clean +"lua require('scripts.gen_help_html').gen('./runtime/doc', 'target/dir/')" +q
-- 2. rm -rf build/runtime/doc/ && make && nvim -V1 -es --clean +"lua require('scripts.gen_help_html').gen('./runtime/doc', 'target/dir/')" +q
-- - Read the docstring at gen().
-- 3. cd target/dir/ && jekyll serve --host 0.0.0.0
-- 4. Visit http://localhost:4000/…/help.txt.html
--
-- USAGE (VALIDATE):
-- 1. nvim -V1 -es +"lua require('scripts.gen_help_html').validate('./runtime/doc')" +q
-- 1. rm -rf build/runtime/doc/ && make && nvim -V1 -es +"lua require('scripts.gen_help_html').validate('./runtime/doc')" +q
-- - validate() is 10x faster than gen(), so it is used in CI.
--
-- SELF-TEST MODE:
@ -28,6 +28,7 @@
-- * visit_node() is the core function used by gen() to traverse the document tree and produce HTML.
-- * visit_validate() is the core function used by validate().
-- * Files in `new_layout` will be generated with a "flow" layout instead of preformatted/fixed-width layout.
-- All Nvim-owned files should migrate to "flow" layout.
local tagmap = nil ---@type table<string, string>
local helpfiles = nil ---@type string[]
@ -57,6 +58,7 @@ local M = {}
-- These files are generated with "flow" layout (non fixed-width, wrapped text paragraphs).
-- All other files are "legacy" files which require fixed-width layout.
-- All Nvim-owned files should migrate to "flow" layout.
local new_layout = {
['api.txt'] = true,
['lsp.txt'] = true,
@ -328,7 +330,7 @@ local function ignore_parse_error(fname, s)
end
-- Ignore parse errors for unclosed tag.
-- This is common in vimdocs and is treated as plaintext by :help.
return s:find("^[`'|*]")
return s:find('^``') or s:find("^['|]")
end
---@param node TSNode

View File

@ -953,6 +953,8 @@ add_dependencies(doc doc-vim doc-eval)
add_target(lintdoc
COMMAND $<TARGET_FILE:nvim_bin> -u NONE -l scripts/lintdoc.lua
DEPENDS ${DOCFILES}
DEPENDS
${DOCFILES}
${PROJECT_SOURCE_DIR}/scripts/gen_help_html.lua
CUSTOM_COMMAND_ARGS USES_TERMINAL)
add_dependencies(lintdoc nvim)

View File

@ -91,7 +91,7 @@ static TSLanguage *load_language(lua_State *L, const char *path, const char *lan
return lang;
}
// Creates the language into the internal language map.
// Creates and adds a language to the internal language map.
//
// Returns true if the language is correctly loaded in the language map
int tslua_add_language(lua_State *L)