diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/lintcommit.lua | 31 | ||||
-rw-r--r-- | scripts/lua2dox.lua | 27 |
2 files changed, 45 insertions, 13 deletions
diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 87a8e62503..977f7e7e46 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -78,10 +78,12 @@ local function validate_commit(commit_message) -- Check if type is correct local type = vim.split(before_colon, "%(")[1] - local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'dist', 'vim-patch'} + local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch'} if not vim.tbl_contains(allowed_types, type) then return string.format( - 'Invalid commit type "%s". Allowed types are:\n %s', + [[Invalid commit type "%s". Allowed types are: + %s. + If none of these seem appropriate then use "fix"]], type, vim.inspect(allowed_types)) end @@ -126,10 +128,10 @@ local function validate_commit(commit_message) return [[There should only be one whitespace after the colon.]] end - -- Check that first character after space isn't uppercase. - if string.match(after_colon:sub(2,2), '%u') then - return [[First character should not be uppercase.]] - end + -- Allow lowercase or ALL_UPPER but not Titlecase. + if after_colon:match(' *%u%l') then + return [[Description should not be Capitalized.]] + end -- Check that description isn't just whitespaces if vim.trim(after_colon) == "" then @@ -164,13 +166,16 @@ function M.main(opt) local invalid_msg = validate_commit(msg) if invalid_msg then failed = failed + 1 + + -- Some breathing room + if failed == 1 then + p('\n') + end + p(string.format([[ Invalid commit message: "%s" Commit: %s %s - See also: - https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md#commit-messages - https://www.conventionalcommits.org/en/v1.0.0/ ]], msg, commit_id, @@ -180,6 +185,10 @@ Invalid commit message: "%s" end if failed > 0 then + p([[ +See also: + https://github.com/neovim/neovim/blob/master/CONTRIBUTING.md#commit-messages +]]) die() -- Exit with error. else p('') @@ -198,7 +207,6 @@ function M._test() ['refactor: normal message'] = true, ['revert: normal message'] = true, ['test: normal message'] = true, - ['dist: normal message'] = true, ['ci(window): message with scope'] = true, ['ci!: message with breaking change'] = true, ['ci(tui)!: message with scope and breaking change'] = true, @@ -223,7 +231,8 @@ function M._test() ['refactor(): empty scope'] = false, ['ci( ): whitespace as scope'] = false, ['ci: period at end of sentence.'] = false, - ['ci: Starting sentence capitalized'] = false, + ['ci: Capitalized first word'] = false, + ['ci: UPPER_CASE first word'] = true, ['unknown: using unknown type'] = false, ['ci: you\'re saying this commit message just goes on and on and on and on and on and on for way too long?'] = false, } diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 19f8f8141d..fc0e915307 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -286,7 +286,12 @@ local function checkComment4fn(Fn_magic, MagicLines) return fn_magic end -local types = { 'number', 'string', 'table', 'list', 'boolean', 'function' } +local types = { 'integer', 'number', 'string', 'table', 'list', 'boolean', 'function' } + +local tagged_types = { 'TSNode', 'LanguageTree' } + +-- Document these as 'table' +local alias_types = { 'Range' } --! \brief run the filter function TLua2DoX_filter.readfile(this, AppStamp, Filename) @@ -320,7 +325,12 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename) offset = 1 end - if string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment + if vim.startswith(line, '---@cast') + or vim.startswith(line, '---@diagnostic') + or vim.startswith(line, '---@type') then + -- Ignore LSP directives + outStream:writeln('// gg:"' .. line .. '"') + elseif string.sub(line, 3, 3) == '@' or string.sub(line, 1, 4) == '---@' then -- it's a magic comment state = 'in_magic_comment' local magic = string.sub(line, 4 + offset) @@ -366,6 +376,17 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename) magic_split[type_index] = magic_split[type_index]:gsub(k, v) end end + + for _, type in ipairs(tagged_types) do + magic_split[type_index] = + magic_split[type_index]:gsub(type, '|%1|') + end + + for _, type in ipairs(alias_types) do + magic_split[type_index] = + magic_split[type_index]:gsub('^'..type..'$', 'table') + end + -- surround some types by () for _, type in ipairs(types) do magic_split[type_index] = @@ -373,6 +394,8 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename) magic_split[type_index] = magic_split[type_index]:gsub('^(' .. type .. '):?$', '(%1)') end + + end magic = table.concat(magic_split, ' ') |