From 3ac55fe0831b6af7277e6b26333ddb49ef423fcb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 30 Jan 2023 07:15:38 +0800 Subject: build(bump_deps.lua): run command -v in shell (#22030) When I run ./scripts/bump_deps.lua I get an error: Vim:E475: Invalid value for argument cmd: 'command' is not executable Running command -v in shell fixes this. --- scripts/bump_deps.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bump_deps.lua b/scripts/bump_deps.lua index 1873c3cd0d..f980e800cf 100755 --- a/scripts/bump_deps.lua +++ b/scripts/bump_deps.lua @@ -54,7 +54,7 @@ local function run_die(cmd, err_msg) end local function require_executable(cmd) - local cmd_path = run_die({ 'command', '-v', cmd }, cmd .. ' not found!') + local cmd_path = run_die({ 'sh', '-c', 'command -v ' .. cmd }, cmd .. ' not found!') run_die({ 'test', '-x', cmd_path }, cmd .. ' is not executable') end -- cgit From 9a5678463c96baf3b39cb3083ddf0da87d39aa23 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Sat, 4 Feb 2023 14:58:38 +0000 Subject: fix(treesitter): fix most diagnostics --- scripts/lua2dox.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'scripts') 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, ' ') -- cgit From e5d8220179f932ab9c9ef59996cab357a25eaaf8 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 10 Feb 2023 17:03:01 +0100 Subject: ci: simplify lintcommit output (#22204) - Suggest reading CONTRIBUTING.md once, not for each commit failure - Suggest using "fix" type if none of the provided types are appropriate - Remove "dist" type. It's rarely used and can be replaced by using the "build" type --- scripts/lintcommit.lua | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 87a8e62503..71796a5e02 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 @@ -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, -- cgit From 84cf6a0a7e58aace0e659f2c6bb61d7179164add Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 13 Feb 2023 12:26:27 -0500 Subject: ci(lintcommit): allow UPPER_CASE first word (#22245) --- scripts/lintcommit.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 71796a5e02..977f7e7e46 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -128,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 @@ -231,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, } -- cgit From 5420bf99988be798938f7ee45b2f993e3c4ff2ee Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 16 Feb 2023 09:43:05 -0500 Subject: fix(lintcommit): capitalized description #22282 Problem: The "Capitalized" check should only check the first word of a description. Solution: Specify "^". --- scripts/lintcommit.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 977f7e7e46..7e08ca4ea0 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -129,8 +129,8 @@ local function validate_commit(commit_message) end -- Allow lowercase or ALL_UPPER but not Titlecase. - if after_colon:match(' *%u%l') then - return [[Description should not be Capitalized.]] + if after_colon:match('^ *%u%l') then + return [[Description first word should not be Capitalized.]] end -- Check that description isn't just whitespaces @@ -232,7 +232,7 @@ function M._test() ['ci( ): whitespace as scope'] = false, ['ci: period at end of sentence.'] = false, ['ci: Capitalized first word'] = false, - ['ci: UPPER_CASE first word'] = true, + ['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, } -- cgit From 9301abdf748b54fa3d41375cc4659ca9f4b57dd8 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 18 Feb 2023 17:43:39 +0100 Subject: ci: enable CI_BUILD automatically if environment variable CI is true (#22312) Having to specify CI_BUILD for every CI job requires boilerplate. More importantly, it's easy to forget to enable CI_BUILD, as seen by 8a20f9f98a90a7a43aea08fcde2c40a5356b4f7b. It's simpler to remember to turn CI_BUILD off when a job errors instead of remembering that every new job should have CI_BUILD on. --- scripts/genappimage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/genappimage.sh b/scripts/genappimage.sh index 9944b5eb31..dc46f4ce17 100755 --- a/scripts/genappimage.sh +++ b/scripts/genappimage.sh @@ -26,7 +26,7 @@ APP_DIR="$APP.AppDir" ######################################################################## # Build and install nvim into the AppImage -make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=${APP_DIR}/usr -DCMAKE_INSTALL_MANDIR=man" +make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCI_BUILD=OFF -DCMAKE_INSTALL_PREFIX=${APP_DIR}/usr -DCMAKE_INSTALL_MANDIR=man" make install ######################################################################## -- cgit From 75e53341f37eeeda7d9be7f934249f7e5e4397e9 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 23 Feb 2023 15:19:52 +0000 Subject: perf(treesitter): smarter languagetree invalidation Problem: Treesitter injections are slow because all injected trees are invalidated on every change. Solution: Implement smarter invalidation to avoid reparsing injected regions. - In on_bytes, try and update self._regions as best we can. This PR just offsets any regions after the change. - Add valid flags for each region in self._regions. - Call on_bytes recursively for all children. - We still need to run the query every time for the top level tree. I don't know how to avoid this. However, if the new injection ranges don't change, then we re-use the old trees and avoid reparsing children. This should result in roughly a 2-3x reduction in tree parsing when the comment injections are enabled. --- scripts/lua2dox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index fc0e915307..17de0ea9b4 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -291,7 +291,7 @@ local types = { 'integer', 'number', 'string', 'table', 'list', 'boolean', 'func local tagged_types = { 'TSNode', 'LanguageTree' } -- Document these as 'table' -local alias_types = { 'Range' } +local alias_types = { 'Range4', 'Range6' } --! \brief run the filter function TLua2DoX_filter.readfile(this, AppStamp, Filename) -- cgit From 2708507e877f3255076bab2f5f074667dd25f8fc Mon Sep 17 00:00:00 2001 From: Mathias Fußenegger Date: Sat, 25 Feb 2023 16:35:45 +0100 Subject: docs: use build/bin/nvim instead of nvim in gen_vimdoc (#22398) Problem: `nvim` could point to stable release missing the `nvim -l` functionality. Solution: Require to build nvim first and use `build/bin/nvim` --- scripts/gen_vimdoc.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 8e1d6ef80a..b8c36dc35d 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -42,6 +42,7 @@ import subprocess import collections import msgpack import logging +from pathlib import Path from xml.dom import minidom @@ -55,19 +56,19 @@ if sys.version_info < MIN_PYTHON_VERSION: doxygen_version = tuple((int(i) for i in subprocess.check_output(["doxygen", "-v"], universal_newlines=True).split()[0].split('.'))) -# Until 0.9 is released, need this hacky way to check that "nvim -l foo.lua" works. -nvim_version = list(line for line in subprocess.check_output(['nvim', '-h'], universal_newlines=True).split('\n') - if '-l ' in line) - if doxygen_version < MIN_DOXYGEN_VERSION: print("\nRequires doxygen {}.{}.{}+".format(*MIN_DOXYGEN_VERSION)) print("Your doxygen version is {}.{}.{}\n".format(*doxygen_version)) sys.exit(1) -if len(nvim_version) == 0: - print("\nRequires 'nvim -l' feature, see https://github.com/neovim/neovim/pull/18706") + +# Need a `nvim` that supports `-l`, so use the local build +nvim = Path(__file__).parent / "../build/bin/nvim" +if not nvim.exists(): + print("\nYou need to build Neovim first to build the documentation.") sys.exit(1) + # DEBUG = ('DEBUG' in os.environ) INCLUDE_C_DECL = ('INCLUDE_C_DECL' in os.environ) INCLUDE_DEPRECATED = ('INCLUDE_DEPRECATED' in os.environ) @@ -1163,7 +1164,7 @@ def main(doxygen_config, args): def filter_source(filename): name, extension = os.path.splitext(filename) if extension == '.lua': - p = subprocess.run(['nvim', '-l', lua2dox, filename], stdout=subprocess.PIPE) + p = subprocess.run([str(nvim), '-l', lua2dox, filename], stdout=subprocess.PIPE) op = ('?' if 0 != p.returncode else p.stdout.decode('utf-8')) print(op) else: -- cgit From db32d312acd4bee96b3463ff85a6574b5180502d Mon Sep 17 00:00:00 2001 From: Mathias Fußenegger Date: Sat, 25 Feb 2023 17:24:43 +0100 Subject: ci(fix): repair regen-api-docs (#22403) https://github.com/neovim/neovim/pull/22398 broke the job because there is no `build/bin/nvim` This keeps the preference for `build/bin/nvim` but adds back `nvim` as fallback if it doesn't exist. --- scripts/gen_vimdoc.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index b8c36dc35d..dd593475e2 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -62,11 +62,21 @@ if doxygen_version < MIN_DOXYGEN_VERSION: sys.exit(1) -# Need a `nvim` that supports `-l`, so use the local build -nvim = Path(__file__).parent / "../build/bin/nvim" -if not nvim.exists(): - print("\nYou need to build Neovim first to build the documentation.") - sys.exit(1) +# Need a `nvim` that supports `-l`, try the local build +nvim_path = Path(__file__).parent / "../build/bin/nvim" +if nvim_path.exists(): + nvim = str(nvim_path) +else: + # Until 0.9 is released, use this hacky way to check that "nvim -l foo.lua" works. + nvim_out = subprocess.check_output(['nvim', '-h'], universal_newlines=True) + nvim_version = [line for line in nvim_out.split('\n') + if '-l ' in line] + if len(nvim_version) == 0: + print(( + "\nYou need to have a local Neovim build or a `nvim` version 0.9 for `-l` " + "support to build the documentation.")) + sys.exit(1) + nvim = 'nvim' # DEBUG = ('DEBUG' in os.environ) -- cgit From 8414cfe7f4d8888698343cb54a3f373a28b365db Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 2 Mar 2023 20:46:59 +0100 Subject: docs: fix vim.treesitter tags Problem: Help tags like vim.treesitter.language.add() are confusing because `vim.treesitter.language` is (thankfully) not a user-facing module. Solution: Ignore the "fstem" when generating "treesitter" tags. --- scripts/gen_vimdoc.py | 2 +- scripts/lua2dox.lua | 55 +++++++++++++++++++++++++++------------------------ 2 files changed, 30 insertions(+), 27 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index dd593475e2..a4d6c3e2af 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -286,7 +286,7 @@ CONFIG = { if fstem == 'treesitter' else f'*{name}()*' if name[0].isupper() - else f'*vim.treesitter.{fstem}.{name}()*'), + else f'*vim.treesitter.{name}()*'), 'module_override': {}, 'append_only': [], } diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index 17de0ea9b4..d5b693a1a7 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -27,7 +27,10 @@ http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm Running ------- -This script "lua2dox.lua" gets called by "gen_vimdoc.py". +This script "lua2dox.lua" gets called by "gen_vimdoc.py". To debug, run gen_vimdoc.py with +--keep-tmpfiles: + + python3 scripts/gen_vimdoc.py -t treesitter --keep-tmpfiles Doxygen must be on your system. You can experiment like so: @@ -71,14 +74,14 @@ local function class() return newClass end ---! \brief write to stdout +-- write to stdout local function TCore_IO_write(Str) if Str then io.write(Str) end end ---! \brief write to stdout +-- write to stdout local function TCore_IO_writeln(Str) if Str then io.write(Str) @@ -86,12 +89,12 @@ local function TCore_IO_writeln(Str) io.write('\n') end ---! \brief trims a string +-- trims a string local function string_trim(Str) return Str:match('^%s*(.-)%s*$') end ---! \brief split a string +-- split a string --! --! \param Str --! \param Pattern @@ -117,12 +120,12 @@ local function string_split(Str, Pattern) end ------------------------------- ---! \brief file buffer +-- file buffer --! --! an input file buffer local TStream_Read = class() ---! \brief get contents of file +-- get contents of file --! --! \param Filename name of file to read (or nil == stdin) function TStream_Read.getContents(this, Filename) @@ -143,12 +146,12 @@ function TStream_Read.getContents(this, Filename) return filecontents end ---! \brief get lineno +-- get lineno function TStream_Read.getLineNo(this) return this.currentLineNo end ---! \brief get a line +-- get a line function TStream_Read.getLine(this) local line if this.currentLine then @@ -166,12 +169,12 @@ function TStream_Read.getLine(this) return line end ---! \brief save line fragment +-- save line fragment function TStream_Read.ungetLine(this, LineFrag) this.currentLine = LineFrag end ---! \brief is it eof? +-- is it eof? function TStream_Read.eof(this) if this.currentLine or this.currentLineNo <= this.contentsLen then return false @@ -179,31 +182,31 @@ function TStream_Read.eof(this) return true end ---! \brief output stream +-- output stream local TStream_Write = class() ---! \brief constructor +-- constructor function TStream_Write.init(this) this.tailLine = {} end ---! \brief write immediately +-- write immediately function TStream_Write.write(_, Str) TCore_IO_write(Str) end ---! \brief write immediately +-- write immediately function TStream_Write.writeln(_, Str) TCore_IO_writeln(Str) end ---! \brief write immediately +-- write immediately function TStream_Write.writelnComment(_, Str) TCore_IO_write('// ZZ: ') TCore_IO_writeln(Str) end ---! \brief write to tail +-- write to tail function TStream_Write.writelnTail(this, Line) if not Line then Line = '' @@ -211,7 +214,7 @@ function TStream_Write.writelnTail(this, Line) table.insert(this.tailLine, Line) end ---! \brief output tail lines +-- output tail lines function TStream_Write.write_tailLines(this) for _, line in ipairs(this.tailLine) do TCore_IO_writeln(line) @@ -219,17 +222,17 @@ function TStream_Write.write_tailLines(this) TCore_IO_write('// Lua2DoX new eof') end ---! \brief input filter +-- input filter local TLua2DoX_filter = class() ---! \brief allow us to do errormessages +-- allow us to do errormessages function TLua2DoX_filter.warning(this, Line, LineNo, Legend) this.outStream:writelnTail( '//! \todo warning! ' .. Legend .. ' (@' .. LineNo .. ')"' .. Line .. '"' ) end ---! \brief trim comment off end of string +-- trim comment off end of string --! --! If the string has a comment on the end, this trims it off. --! @@ -243,7 +246,7 @@ local function TString_removeCommentFromLine(Line) return Line, tailComment end ---! \brief get directive from magic +-- get directive from magic local function getMagicDirective(Line) local macro, tail local macroStr = '[\\@]' @@ -264,7 +267,7 @@ local function getMagicDirective(Line) return macro, tail end ---! \brief check comment for fn +-- check comment for fn local function checkComment4fn(Fn_magic, MagicLines) local fn_magic = Fn_magic -- TCore_IO_writeln('// checkComment4fn "' .. MagicLines .. '"') @@ -293,7 +296,7 @@ local tagged_types = { 'TSNode', 'LanguageTree' } -- Document these as 'table' local alias_types = { 'Range4', 'Range6' } ---! \brief run the filter +-- run the filter function TLua2DoX_filter.readfile(this, AppStamp, Filename) local inStream = TStream_Read() local outStream = TStream_Write() @@ -524,10 +527,10 @@ function TLua2DoX_filter.readfile(this, AppStamp, Filename) end end ---! \brief this application +-- this application local TApp = class() ---! \brief constructor +-- constructor function TApp.init(this) this.timestamp = os.date('%c %Z', os.time()) this.name = 'Lua2DoX' -- cgit From 57f26e0903af0e4569a70d310ca18696e7680c74 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 3 Mar 2023 13:49:22 +0100 Subject: docs: lua2dox.lua debugging --- scripts/gen_vimdoc.py | 16 +++++++++++---- scripts/lua2dox.lua | 57 +++++++++++++++++++++++++++++++++++---------------- 2 files changed, 51 insertions(+), 22 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index a4d6c3e2af..9e9e966627 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -265,6 +265,7 @@ CONFIG = { 'query.lua', 'highlighter.lua', 'languagetree.lua', + 'playground.lua', ], 'files': [ 'runtime/lua/vim/treesitter.lua', @@ -1171,10 +1172,12 @@ def main(doxygen_config, args): msg_report() -def filter_source(filename): +def filter_source(filename, keep_tmpfiles): + output_dir = out_dir.format(target='lua2dox') name, extension = os.path.splitext(filename) if extension == '.lua': - p = subprocess.run([str(nvim), '-l', lua2dox, filename], stdout=subprocess.PIPE) + args = [str(nvim), '-l', lua2dox, filename] + (['--outdir', output_dir] if keep_tmpfiles else []) + p = subprocess.run(args, stdout=subprocess.PIPE) op = ('?' if 0 != p.returncode else p.stdout.decode('utf-8')) print(op) else: @@ -1197,7 +1200,7 @@ def parse_args(): ap.add_argument('source_filter', nargs='*', help="Filter source file(s)") ap.add_argument('-k', '--keep-tmpfiles', action='store_true', - help="Keep temporary files") + help="Keep temporary files (tmp-xx-doc/ directories, including tmp-lua2dox-doc/ for lua2dox.lua quasi-C output)") ap.add_argument('-t', '--target', help=f'One of ({targets}), defaults to "all"') return ap.parse_args() @@ -1245,8 +1248,13 @@ if __name__ == "__main__": log.setLevel(args.log_level) log.addHandler(logging.StreamHandler()) + # When invoked as a filter, args won't be passed, so use an env var. + if args.keep_tmpfiles: + os.environ['NVIM_KEEP_TMPFILES'] = '1' + keep_tmpfiles = ('NVIM_KEEP_TMPFILES' in os.environ) + if len(args.source_filter) > 0: - filter_source(args.source_filter[0]) + filter_source(args.source_filter[0], keep_tmpfiles) else: main(Doxyfile, args) diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index d5b693a1a7..b99cd955f4 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -24,13 +24,17 @@ Lua-to-Doxygen converter Partially from lua2dox http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm -Running +RUNNING ------- -This script "lua2dox.lua" gets called by "gen_vimdoc.py". To debug, run gen_vimdoc.py with ---keep-tmpfiles: +This script "lua2dox.lua" gets called by "gen_vimdoc.py". - python3 scripts/gen_vimdoc.py -t treesitter --keep-tmpfiles +DEBUGGING/DEVELOPING +--------------------- + +1. To debug, run gen_vimdoc.py with --keep-tmpfiles: + python3 scripts/gen_vimdoc.py -t treesitter --keep-tmpfiles +2. The filtered result will be written to ./tmp-lua2dox-doc/….lua.c Doxygen must be on your system. You can experiment like so: @@ -52,6 +56,9 @@ However I have put in a hack that will insert the "missing" close paren. The effect is that you will get the function documented, but not with the parameter list you might expect. ]] +local _debug_outfile = nil +local _debug_output = {} + local function class() local newClass = {} -- a new class newClass -- the class will be the metatable for all its newInstanceects, @@ -78,15 +85,16 @@ end local function TCore_IO_write(Str) if Str then io.write(Str) + if _debug_outfile then + table.insert(_debug_output, Str) + end end end -- write to stdout local function TCore_IO_writeln(Str) - if Str then - io.write(Str) - end - io.write('\n') + TCore_IO_write(Str) + TCore_IO_write('\n') end -- trims a string @@ -296,8 +304,8 @@ local tagged_types = { 'TSNode', 'LanguageTree' } -- Document these as 'table' local alias_types = { 'Range4', 'Range6' } --- run the filter -function TLua2DoX_filter.readfile(this, AppStamp, Filename) +-- Processes the file and writes filtered output to stdout. +function TLua2DoX_filter.filter(this, AppStamp, Filename) local inStream = TStream_Read() local outStream = TStream_Write() this.outStream = outStream -- save to this obj @@ -554,8 +562,7 @@ local This_app = TApp() --main -local argv1 = arg[1] -if argv1 == '--help' then +if arg[1] == '--help' then TCore_IO_writeln(This_app:getVersion()) TCore_IO_writeln(This_app:getCopyright()) TCore_IO_writeln([[ @@ -566,16 +573,30 @@ if argv1 == '--help' then : interprets filename --version : show version/copyright info --help : this help text]]) -elseif argv1 == '--version' then +elseif arg[1] == '--version' then TCore_IO_writeln(This_app:getVersion()) TCore_IO_writeln(This_app:getCopyright()) -else - -- it's a filter - local appStamp = This_app:getRunStamp() - local filename = argv1 +else -- It's a filter. + local filename = arg[1] + + if arg[2] == '--outdir' then + local outdir = arg[3] + if type(outdir) ~= 'string' or (0 ~= vim.fn.filereadable(outdir) and 0 == vim.fn.isdirectory(outdir)) then + error(('invalid --outdir: "%s"'):format(tostring(outdir))) + end + vim.fn.mkdir(outdir, 'p') + _debug_outfile = string.format('%s/%s.c', outdir, vim.fs.basename(filename)) + end + local appStamp = This_app:getRunStamp() local filter = TLua2DoX_filter() - filter:readfile(appStamp, filename) + filter:filter(appStamp, filename) + + if _debug_outfile then + local f = assert(io.open(_debug_outfile, 'w')) + f:write(table.concat(_debug_output)) + f:close() + end end --eof -- cgit From 533d671271eb76373d9940161e7bfd201b7e7c2b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sun, 5 Mar 2023 18:15:29 -0500 Subject: docs: module-level docstrings (@defgroup) #22498 Problem: gen_vimdoc.py / lua2dox.lua does not support @defgroup or \defgroup except for "api-foo" modules. Solution: Modify `gen_vimdoc.py` to look for section names based on `helptag_fmt`. TODO: - Support @module ? https://github.com/LuaLS/lua-language-server/wiki/Annotations#module --- scripts/gen_vimdoc.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 9e9e966627..0164278b34 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -1054,17 +1054,18 @@ def main(doxygen_config, args): fn_map_full = {} # Collects all functions as each module is processed. sections = {} - intros = {} + section_docs = {} sep = '=' * text_width base = os.path.join(output_dir, 'xml') dom = minidom.parse(os.path.join(base, 'index.xml')) - # generate docs for section intros + # Generate module-level (section) docs (@defgroup). for compound in dom.getElementsByTagName('compound'): if compound.getAttribute('kind') != 'group': continue + # Doxygen "@defgroup" directive. groupname = get_text(find_first(compound, 'name')) groupxml = os.path.join(base, '%s.xml' % compound.getAttribute('refid')) @@ -1083,33 +1084,39 @@ def main(doxygen_config, args): if doc: doc_list.append(doc) - intros[groupname] = "\n".join(doc_list) + section_docs[groupname] = "\n".join(doc_list) + # Generate docs for all functions in the current module. for compound in dom.getElementsByTagName('compound'): if compound.getAttribute('kind') != 'file': continue filename = get_text(find_first(compound, 'name')) if filename.endswith('.c') or filename.endswith('.lua'): - xmlfile = os.path.join(base, - '{}.xml'.format(compound.getAttribute('refid'))) + xmlfile = os.path.join(base, '{}.xml'.format(compound.getAttribute('refid'))) # Extract unformatted (*.mpack). fn_map, _ = extract_from_xml(xmlfile, target, 9999, False) # Extract formatted (:help). functions_text, deprecated_text = fmt_doxygen_xml_as_vimhelp( - os.path.join(base, '{}.xml'.format( - compound.getAttribute('refid'))), target) + os.path.join(base, '{}.xml'.format(compound.getAttribute('refid'))), target) if not functions_text and not deprecated_text: continue else: - name = os.path.splitext( - os.path.basename(filename))[0].lower() + filename = os.path.basename(filename) + name = os.path.splitext(filename)[0].lower() sectname = name.upper() if name == 'ui' else name.title() + sectname = CONFIG[target]['section_name'].get(filename, sectname) + title = CONFIG[target]['section_fmt'](sectname) + section_tag = CONFIG[target]['helptag_fmt'](sectname) + # Module/Section id matched against @defgroup. + # "*api-buffer*" => "api-buffer" + section_id = section_tag.strip('*') + doc = '' - intro = intros.get(f'api-{name}') - if intro: - doc += '\n\n' + intro + section_doc = section_docs.get(section_id) + if section_doc: + doc += '\n\n' + section_doc if functions_text: doc += '\n\n' + functions_text @@ -1119,12 +1126,7 @@ def main(doxygen_config, args): doc += deprecated_text if doc: - filename = os.path.basename(filename) - sectname = CONFIG[target]['section_name'].get( - filename, sectname) - title = CONFIG[target]['section_fmt'](sectname) - helptag = CONFIG[target]['helptag_fmt'](sectname) - sections[filename] = (title, helptag, doc) + sections[filename] = (title, section_tag, doc) fn_map_full.update(fn_map) if len(sections) == 0: @@ -1139,15 +1141,14 @@ def main(doxygen_config, args): for filename in CONFIG[target]['section_order']: try: - title, helptag, section_doc = sections.pop(filename) + title, section_tag, section_doc = sections.pop(filename) except KeyError: msg(f'warning: empty docs, skipping (target={target}): {filename}') msg(f' existing docs: {sections.keys()}') continue if filename not in CONFIG[target]['append_only']: docs += sep - docs += '\n%s%s' % (title, - helptag.rjust(text_width - len(title))) + docs += '\n{}{}'.format(title, section_tag.rjust(text_width - len(title))) docs += section_doc docs += '\n\n\n' -- cgit From 0e7196438d8f856eecd7c90e160b79cbc8fb08dc Mon Sep 17 00:00:00 2001 From: Kelly Lin Date: Sun, 19 Feb 2023 22:33:57 +1100 Subject: feat(lua): add semver api --- scripts/gen_vimdoc.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 0164278b34..45a6d8e402 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -152,6 +152,7 @@ CONFIG = { 'keymap.lua', 'fs.lua', 'secure.lua', + 'version.lua', ], 'files': [ 'runtime/lua/vim/_editor.lua', @@ -162,6 +163,7 @@ CONFIG = { 'runtime/lua/vim/keymap.lua', 'runtime/lua/vim/fs.lua', 'runtime/lua/vim/secure.lua', + 'runtime/lua/vim/version.lua', 'runtime/lua/vim/_inspector.lua', ], 'file_patterns': '*.lua', -- cgit From e31e49a8e3aac25e923dce15cc76dca4a447947f Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 6 Mar 2023 13:23:03 +0100 Subject: refactor(vim.version): cleanup - version.cmp(): assert valid version - add test for loading vim.version (the other tests use shared.lua in the test runner) - reduce test scopes, reword test descriptions --- scripts/gen_vimdoc.py | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 45a6d8e402..1e85fa49e9 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -194,6 +194,7 @@ CONFIG = { 'keymap': 'vim.keymap', 'fs': 'vim.fs', 'secure': 'vim.secure', + 'version': 'vim.version', }, 'append_only': [ 'shared.lua', -- cgit From af23d173883f47fd02a9a380c719e4428370b484 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Tue, 7 Mar 2023 04:13:04 +0100 Subject: test: move oldtests to test directory (#22536) The new oldtest directory is in test/old/testdir. The reason for this is that many tests have hardcoded the parent directory name to be 'testdir'. --- scripts/vim-patch.sh | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index f9f7330097..06ddf0f3b8 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -226,6 +226,10 @@ preprocess_patch() { local na_vimrcexample='vimrc_example\.vim' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/runtime/\<\%('${na_vimrcexample}'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" + # Rename src/testdir/ paths to test/old/testdir/ + LC_ALL=C sed -e 's/\( [ab]\)\/src\/testdir/\1\/test\/old\/testdir/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + # Rename src/ paths to src/nvim/ LC_ALL=C sed -e 's/\( [ab]\/src\)/\1\/nvim/g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" -- cgit From 0e7edd70a95d962dfbe5b52c2767887a7131e0a0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 8 Mar 2023 10:46:09 +0800 Subject: test(old): move memfile_test.c to test/old/ (#22567) --- scripts/vim-patch.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 06ddf0f3b8..20e337afcb 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -598,6 +598,7 @@ _set_missing_vimpatches() { # Massage arguments for git-log. declare -A git_log_replacements=( [^\(.*/\)?src/nvim/\(.*\)]="\${BASH_REMATCH[1]}src/\${BASH_REMATCH[2]}" + [^\(.*/\)?test/old/\(.*\)]="\${BASH_REMATCH[1]}src/\${BASH_REMATCH[2]}" [^\(.*/\)?\.vim-src/\(.*\)]="\${BASH_REMATCH[2]}" ) local i j -- cgit From 58bbc2ea0b3dfed13471e8cc0447d7598be24276 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 10 Mar 2023 16:40:27 +0000 Subject: refactor(treesitter): add Range type aliase for Range4|Range6 --- scripts/lua2dox.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index b99cd955f4..de9f2926f2 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -302,7 +302,7 @@ local types = { 'integer', 'number', 'string', 'table', 'list', 'boolean', 'func local tagged_types = { 'TSNode', 'LanguageTree' } -- Document these as 'table' -local alias_types = { 'Range4', 'Range6' } +local alias_types = { 'Range', 'Range4', 'Range6', 'TSMetadata' } -- Processes the file and writes filtered output to stdout. function TLua2DoX_filter.filter(this, AppStamp, Filename) -- cgit From 21eacbfef399f124e9d50f1757c89453c4e02944 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 15 Mar 2023 07:51:44 -0400 Subject: docs(html): render @see items as a list #22675 Needed for "flow" HTML layout. Flow layout before: See also: https://github.com/kikito/inspect.lua https://github.com/mpeterv/vinspect Flow layout after: See also: - https://github.com/kikito/inspect.lua - https://github.com/mpeterv/vinspect --- scripts/gen_vimdoc.py | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 1e85fa49e9..72f9df325b 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -537,7 +537,7 @@ def render_node(n, text, prefix='', indent='', width=text_width - indentation, text += '>{}{}\n<'.format(ensure_nl, o) elif is_inline(n): - text = doc_wrap(get_text(n), indent=indent, width=width) + text = doc_wrap(get_text(n), prefix=prefix, indent=indent, width=width) elif n.nodeName == 'verbatim': # TODO: currently we don't use this. The "[verbatim]" hint is there as # a reminder that we must decide how to format this if we do use it. @@ -550,19 +550,19 @@ def render_node(n, text, prefix='', indent='', width=text_width - indentation, indent=indent + (' ' * len(prefix)), width=width ) - if is_blank(result): continue - text += indent + prefix + result elif n.nodeName in ('para', 'heading'): + did_prefix = False for c in n.childNodes: if (is_inline(c) and '' != get_text(c).strip() and text and ' ' != text[-1]): text += ' ' - text += render_node(c, text, indent=indent, width=width) + text += render_node(c, text, prefix=(prefix if not did_prefix else ''), indent=indent, width=width) + did_prefix = True elif n.nodeName == 'itemizedlist': for c in n.childNodes: text += '{}\n'.format(render_node(c, text, prefix='• ', @@ -586,8 +586,15 @@ def render_node(n, text, prefix='', indent='', width=text_width - indentation, for c in n.childNodes: text += render_node(c, text, indent=' ', width=width) text += '\n' - elif (n.nodeName == 'simplesect' - and n.getAttribute('kind') in ('return', 'see')): + elif n.nodeName == 'simplesect' and 'see' == n.getAttribute('kind'): + text += ind(' ') + # Example: + # + # |autocommand| + # + for c in n.childNodes: + text += render_node(c, text, prefix='• ', indent=' ', width=width) + elif n.nodeName == 'simplesect' and 'return' == n.getAttribute('kind'): text += ind(' ') for c in n.childNodes: text += render_node(c, text, indent=' ', width=width) @@ -678,6 +685,10 @@ def para_as_map(parent, indent='', width=text_width - indentation, fmt_vimhelp=F chunks['return'].append(render_node( child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp)) for child in groups['seealso']: + # Example: + # + # |autocommand| + # chunks['seealso'].append(render_node( child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp)) -- cgit From a7b537c7a4e5b6114cd75df5178199f4449c6480 Mon Sep 17 00:00:00 2001 From: Ankit Goel Date: Wed, 22 Mar 2023 02:57:23 +0000 Subject: ci(lintcommit): allow colon in commit message scope Close #21464 --- scripts/lintcommit.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 7e08ca4ea0..92b07c4f73 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -69,7 +69,7 @@ local function validate_commit(commit_message) end local before_colon = commit_split[1] - local after_colon = commit_split[2] + local after_colon = commit_split[#commit_split] -- Check if commit introduces a breaking change. if vim.endswith(before_colon, "!") then @@ -90,7 +90,7 @@ local function validate_commit(commit_message) -- Check if scope is appropriate if before_colon:match("%(") then - local scope = vim.trim(before_colon:match("%((.*)%)")) + local scope = vim.trim(commit_message:match("%((.-)%)")) if scope == '' then return [[Scope can't be empty]] @@ -234,6 +234,7 @@ function M._test() ['ci: Capitalized first word'] = false, ['ci: UPPER_CASE First Word'] = true, ['unknown: using unknown type'] = false, + ['feat(:grep): read from pipe'] = true, ['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, } -- cgit From 4e4203f71b0b9bb2ca4ad9abd2fbf4ea1deaf9a6 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Thu, 23 Mar 2023 11:23:51 +0000 Subject: fix(treesitter): annotations - Begin using `@package` in place of `@private` for functions that are accessed internally but outside their defined class. - Rename Node -> TSP.Node --- scripts/lua2dox.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index de9f2926f2..014934aebe 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -336,6 +336,8 @@ function TLua2DoX_filter.filter(this, AppStamp, Filename) offset = 1 end + line = line:gsub('@package', '@private') + if vim.startswith(line, '---@cast') or vim.startswith(line, '---@diagnostic') or vim.startswith(line, '---@type') then -- cgit From cbbf8bd666c8419fdab80a0887948c8a36279c19 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 24 Mar 2023 14:43:14 +0000 Subject: feat(treesitter)!: deprecate top level indexes to modules (#22761) The following top level Treesitter functions have been moved: - vim.treesitter.inspect_language() -> vim.treesitter.language.inspect() - vim.treesitter.get_query_files() -> vim.treesitter.query.get_files() - vim.treesitter.set_query() -> vim.treesitter.query.set() - vim.treesitter.query.set_query() -> vim.treesitter.query.set() - vim.treesitter.get_query() -> vim.treesitter.query.get() - vim.treesitter.query.get_query() -> vim.treesitter.query.get() - vim.treesitter.parse_query() -> vim.treesitter.query.parse() - vim.treesitter.query.parse_query() -> vim.treesitter.query.parse() - vim.treesitter.add_predicate() -> vim.treesitter.query.add_predicate() - vim.treesitter.add_directive() -> vim.treesitter.query.add_directive() - vim.treesitter.list_predicates() -> vim.treesitter.query.list_predicates() - vim.treesitter.list_directives() -> vim.treesitter.query.list_directives() - vim.treesitter.query.get_range() -> vim.treesitter.get_range() - vim.treesitter.query.get_node_text() -> vim.treesitter.get_node_text() --- scripts/gen_vimdoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 72f9df325b..de95caf376 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -290,7 +290,7 @@ CONFIG = { if fstem == 'treesitter' else f'*{name}()*' if name[0].isupper() - else f'*vim.treesitter.{name}()*'), + else f'*vim.treesitter.{fstem}.{name}()*'), 'module_override': {}, 'append_only': [], } -- cgit From 2257ade3dc2daab5ee12d27807c0b3bcf103cd29 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Sun, 26 Mar 2023 12:42:15 +0200 Subject: feat(lua): add `vim.loader` feat: new faster lua loader using byte-compilation --- scripts/gen_vimdoc.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index de95caf376..8860bdd5c6 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -146,6 +146,7 @@ CONFIG = { '_editor.lua', '_inspector.lua', 'shared.lua', + 'loader.lua', 'uri.lua', 'ui.lua', 'filetype.lua', @@ -157,6 +158,7 @@ CONFIG = { 'files': [ 'runtime/lua/vim/_editor.lua', 'runtime/lua/vim/shared.lua', + 'runtime/lua/vim/loader.lua', 'runtime/lua/vim/uri.lua', 'runtime/lua/vim/ui.lua', 'runtime/lua/vim/filetype.lua', @@ -190,6 +192,7 @@ CONFIG = { '_inspector': 'vim', 'uri': 'vim', 'ui': 'vim.ui', + 'loader': 'vim.loader', 'filetype': 'vim.filetype', 'keymap': 'vim.keymap', 'fs': 'vim.fs', -- cgit From d7f7450017b9b05303698a6cda54303ef22c63b3 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 31 Mar 2023 17:09:00 +0200 Subject: refactor(treesitter)!: rename help parser to vimdoc --- scripts/gen_help_html.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua index 2563f2f410..367ce60765 100644 --- a/scripts/gen_help_html.lua +++ b/scripts/gen_help_html.lua @@ -624,7 +624,7 @@ local function get_helptags(help_dir) return m end --- Use the help.so parser defined in the build, not whatever happens to be installed on the system. +-- Use the vimdoc parser defined in the build, not whatever happens to be installed on the system. local function ensure_runtimepath() if not vim.o.runtimepath:find('build/lib/nvim/') then vim.cmd[[set runtimepath^=./build/lib/nvim/]] @@ -643,8 +643,8 @@ local function parse_buf(fname) buf = fname vim.cmd('sbuffer '..tostring(fname)) -- Buffer number. end - -- vim.treesitter.require_language('help', './build/lib/nvim/parser/help.so') - local lang_tree = vim.treesitter.get_parser(buf, 'help') + -- vim.treesitter.require_language('help', './build/lib/nvim/parser/vimdoc.so') + local lang_tree = vim.treesitter.get_parser(buf) return lang_tree, buf end -- cgit From d4398f40214fb6175e2bff4c5823e0e6ca13fbda Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Fri, 7 Apr 2023 22:31:04 +0200 Subject: ci: don't automatically enable -Werror on CI environments This catches downstream consumers of neovim off guard when using neovim in an esoteric environment not tested in our own CI. Closes https://github.com/neovim/neovim/issues/22932 --- scripts/genappimage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/genappimage.sh b/scripts/genappimage.sh index dc46f4ce17..9944b5eb31 100755 --- a/scripts/genappimage.sh +++ b/scripts/genappimage.sh @@ -26,7 +26,7 @@ APP_DIR="$APP.AppDir" ######################################################################## # Build and install nvim into the AppImage -make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCI_BUILD=OFF -DCMAKE_INSTALL_PREFIX=${APP_DIR}/usr -DCMAKE_INSTALL_MANDIR=man" +make CMAKE_BUILD_TYPE=RelWithDebInfo CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=${APP_DIR}/usr -DCMAKE_INSTALL_MANDIR=man" make install ######################################################################## -- cgit From e23c6ebed7a6dcc878a64690bbd7252c18591d54 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 12 Apr 2023 09:50:48 +0800 Subject: ci(lintcommit): allow colon not followed by space in description (#23035) --- scripts/lintcommit.lua | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 92b07c4f73..f9a4631b7e 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -51,7 +51,7 @@ local function validate_commit(commit_message) return nil end - local commit_split = vim.split(commit_message, ":") + local commit_split = vim.split(commit_message, ":", {plain = true}) -- Return nil if the type is vim-patch since most of the normal rules don't -- apply. if commit_split[1] == "vim-patch" then @@ -63,13 +63,22 @@ local function validate_commit(commit_message) return [[Commit message is too long, a maximum of 80 characters is allowed.]] end + local before_colon = commit_split[1] - if vim.tbl_count(commit_split) < 2 then + local after_idx = 2 + if before_colon:match('^[^%(]*%([^%)]*$') then + -- Need to find the end of commit scope when commit scope contains colons. + while after_idx <= vim.tbl_count(commit_split) do + after_idx = after_idx + 1 + if commit_split[after_idx - 1]:find(')') then + break + end + end + end + if after_idx > vim.tbl_count(commit_split) then return [[Commit message does not include colons.]] end - - local before_colon = commit_split[1] - local after_colon = commit_split[#commit_split] + local after_colon = commit_split[after_idx] -- Check if commit introduces a breaking change. if vim.endswith(before_colon, "!") then @@ -77,7 +86,7 @@ local function validate_commit(commit_message) end -- Check if type is correct - local type = vim.split(before_colon, "%(")[1] + local type = vim.split(before_colon, "(", {plain = true})[1] 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( @@ -234,7 +243,16 @@ function M._test() ['ci: Capitalized first word'] = false, ['ci: UPPER_CASE First Word'] = true, ['unknown: using unknown type'] = false, + ['feat: foo:bar'] = true, + ['feat(something): foo:bar'] = true, ['feat(:grep): read from pipe'] = true, + ['feat(:grep/:make): read from pipe'] = true, + ['feat(:grep): foo:bar'] = true, + ['feat(:grep/:make): foo:bar'] = true, + ['feat(:grep)'] = false, + ['feat(:grep/:make)'] = false, + ['feat(:grep'] = false, + ['feat(:grep/:make'] = 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, } -- cgit From c8c7912a4deed6351e77b42d42742d675f5d45c6 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 13 Apr 2023 19:07:42 +0800 Subject: build(vim-patch.sh): ignore test_behave.vim (#23062) --- scripts/vim-patch.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 20e337afcb..385005a442 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -212,7 +212,7 @@ preprocess_patch() { 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\<\%('"${na_src_testdir}"'\)\>@norm! d/\v(^diff)|%$ ' +w +q "$file" # Remove testdir/test_*.vim files - local na_src_testdir='balloon.*\|channel.*\|crypt\.vim\|cscope\.vim\|gui.*\|hardcopy\.vim\|job_fails\.vim\|json\.vim\|mzscheme\.vim\|netbeans.*\|paste\.vim\|popupwin.*\|restricted\.vim\|shortpathname\.vim\|tcl\.vim\|terminal.*\|xxd\.vim' + local na_src_testdir='balloon.*\|behave\.vim\|channel.*\|crypt\.vim\|cscope\.vim\|gui.*\|hardcopy\.vim\|job_fails\.vim\|json\.vim\|mzscheme\.vim\|netbeans.*\|paste\.vim\|popupwin.*\|restricted\.vim\|shortpathname\.vim\|tcl\.vim\|terminal.*\|xxd\.vim' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/testdir/\@norm! d/\v(^diff)|%$ ' +w +q "$file" # Remove version.c #7555 -- cgit From 4d04feb6629cb049cb2a13ba35f0c8d3c6b67ff4 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Fri, 14 Apr 2023 10:39:57 +0200 Subject: feat(lua): vim.tbl_contains supports general tables and predicates (#23040) * feat(lua): vim.tbl_contains supports general tables and predicates Problem: `vim.tbl_contains` only works for list-like tables (integer keys without gaps) and primitive values (in particular, not for nested tables). Solution: Rename `vim.tbl_contains` to `vim.list_contains` and add new `vim.tbl_contains` that works for general tables and optionally allows `value` to be a predicate function that is checked for every key. --- scripts/gen_help_html.lua | 8 ++++---- scripts/lintcommit.lua | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_help_html.lua b/scripts/gen_help_html.lua index 367ce60765..e2ab70eca2 100644 --- a/scripts/gen_help_html.lua +++ b/scripts/gen_help_html.lua @@ -491,7 +491,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) return '' -- Discard common "noise" lines. end -- XXX: Avoid newlines (too much whitespace) after block elements in old (preformatted) layout. - local div = opt.old and root:child(0) and vim.tbl_contains({'column_heading', 'h1', 'h2', 'h3'}, root:child(0):type()) + local div = opt.old and root:child(0) and vim.list_contains({'column_heading', 'h1', 'h2', 'h3'}, root:child(0):type()) return string.format('%s%s', div and trim(text) or text, div and '' or '\n') elseif node_name == 'line_li' then local sib = root:prev_sibling() @@ -522,7 +522,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) s = fix_tab_after_conceal(s, node_text(root:next_sibling())) end return s - elseif vim.tbl_contains({'codespan', 'keycode'}, node_name) then + elseif vim.list_contains({'codespan', 'keycode'}, node_name) then if root:has_error() then return text end @@ -554,7 +554,7 @@ local function visit_node(root, level, lang_tree, headings, opt, stats) if root:has_error() then return text end - local in_heading = vim.tbl_contains({'h1', 'h2', 'h3'}, parent) + local in_heading = vim.list_contains({'h1', 'h2', 'h3'}, parent) local cssclass = (not in_heading and get_indent(node_text()) > 8) and 'help-tag-right' or 'help-tag' local tagname = node_text(root:child(1), false) if vim.tbl_count(stats.first_tags) < 2 then @@ -601,7 +601,7 @@ local function get_helpfiles(include) for f, type in vim.fs.dir(dir) do if (vim.endswith(f, '.txt') and type == 'file' - and (not include or vim.tbl_contains(include, f))) then + and (not include or vim.list_contains(include, f))) then local fullpath = vim.fn.fnamemodify(('%s/%s'):format(dir, f), ':p') table.insert(rv, fullpath) end diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index f9a4631b7e..7f3dffd22c 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -88,7 +88,7 @@ local function validate_commit(commit_message) -- Check if type is correct local type = vim.split(before_colon, "(", {plain = true})[1] local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch'} - if not vim.tbl_contains(allowed_types, type) then + if not vim.list_contains(allowed_types, type) then return string.format( [[Invalid commit type "%s". Allowed types are: %s. -- cgit From 5465adcbab29b57d497d7260c6f85ddbf76c43ab Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Fri, 14 Apr 2023 12:41:50 +0100 Subject: fix(lint): use tbl_contains --- scripts/lintcommit.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 7f3dffd22c..f9a4631b7e 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -88,7 +88,7 @@ local function validate_commit(commit_message) -- Check if type is correct local type = vim.split(before_colon, "(", {plain = true})[1] local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'vim-patch'} - if not vim.list_contains(allowed_types, type) then + if not vim.tbl_contains(allowed_types, type) then return string.format( [[Invalid commit type "%s". Allowed types are: %s. -- cgit From ab1edecfb7c73c82c2d5886cb8e270b44aca7d01 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Mon, 17 Apr 2023 12:54:19 -0600 Subject: feat(lua): add vim.iter (#23029) vim.iter wraps a table or iterator function into an `Iter` object with methods such as `filter`, `map`, and `fold` which can be chained to produce iterator pipelines that do not create new tables at each step. --- scripts/gen_vimdoc.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 8860bdd5c6..52d03d9746 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -154,8 +154,10 @@ CONFIG = { 'fs.lua', 'secure.lua', 'version.lua', + 'iter.lua', ], 'files': [ + 'runtime/lua/vim/iter.lua', 'runtime/lua/vim/_editor.lua', 'runtime/lua/vim/shared.lua', 'runtime/lua/vim/loader.lua', @@ -185,6 +187,8 @@ CONFIG = { 'fn_helptag_fmt': lambda fstem, name: ( f'*vim.{name}()*' if fstem.lower() == '_editor' + else f'*{name}()*' + if fstem in ('iter.lua') else f'*{fstem}.{name}()*'), 'module_override': { # `shared` functions are exposed on the `vim` module. -- cgit From 240c41e1af556cd17329d5c46d26a3ca91be2db8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 18 Apr 2023 09:40:05 +0800 Subject: fix(genvimvim): add special abbreviations of :delete (#23172) Also don't highlight :def as vimCommand. --- scripts/genvimvim.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'scripts') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 3e9e7077be..52bf46399d 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -37,6 +37,9 @@ local function cmd_kw(prev_cmd, cmd) while cmd:sub(shift, shift) == prev_cmd:sub(shift, shift) do shift = shift + 1 end + if cmd:sub(1, shift) == 'def' then + shift = shift + 1 + end if shift >= #cmd then return cmd else @@ -67,6 +70,20 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do if cmd:match('%w') and cmd ~= 'z' and not is_special_cased_cmd(cmd) then w(' ' .. cmd_kw(prev_cmd, cmd)) end + if cmd == 'delete' then + -- Add special abbreviations of :delete + w(' ' .. cmd_kw('d', 'dl')) + w(' ' .. cmd_kw('del', 'dell')) + w(' ' .. cmd_kw('dele', 'delel')) + w(' ' .. cmd_kw('delet', 'deletl')) + w(' ' .. cmd_kw('delete', 'deletel')) + w(' ' .. cmd_kw('d', 'dp')) + w(' ' .. cmd_kw('de', 'dep')) + w(' ' .. cmd_kw('del', 'delp')) + w(' ' .. cmd_kw('dele', 'delep')) + w(' ' .. cmd_kw('delet', 'deletp')) + w(' ' .. cmd_kw('delete', 'deletep')) + end prev_cmd = cmd end -- cgit From 1e60e8c0406f6b4b51c51abb5f53e25bd52fee5e Mon Sep 17 00:00:00 2001 From: bfredl Date: Sat, 15 Apr 2023 12:23:45 +0200 Subject: refactor(build): use vendored versions of mpack and luabitop --- scripts/genvimvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 52bf46399d..9f67d7c417 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -144,7 +144,7 @@ end w('\n\nsyn case match') local vimfun_start = 'syn keyword vimFuncName contained ' w('\n\n' .. vimfun_start) -local funcs = mpack.unpack(io.open(funcs_file, 'rb'):read("*all")) +local funcs = mpack.decode(io.open(funcs_file, 'rb'):read("*all")) for _, name in ipairs(funcs) do if name then if lld.line_length > 850 then -- cgit From ffaf74f1477d3182ffc70bcc9913effc44c90ea7 Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 20 Apr 2023 14:41:47 +0200 Subject: fix(build): distinguish vim.mpack from global require'mpack' problem: the api of vim.mpack is not compatible with a system provided mpack solution: don't require 'mpack' directly from the system path --- scripts/genvimvim.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index 9f67d7c417..18279d160e 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -1,4 +1,4 @@ -local mpack = require('mpack') +local mpack = vim.mpack if arg[1] == '--help' then print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim') -- cgit From 702892270dec627acb3dd585495ee0950f690bde Mon Sep 17 00:00:00 2001 From: bfredl Date: Fri, 21 Apr 2023 16:46:35 +0200 Subject: refactor(build): move the last generator from scripts/ to src/nvim/generators This one generates a runtime/ file instead of a source file. But otherwise it works the same like all other generators. It has the same prerequisites (shared and mpack modules, etc), and, importantly, it uses results from the source generators. The odd location makes it easy to overlook when refactoring generators (like I did last time, lol) --- scripts/genvimvim.lua | 158 -------------------------------------------------- 1 file changed, 158 deletions(-) delete mode 100644 scripts/genvimvim.lua (limited to 'scripts') diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua deleted file mode 100644 index 18279d160e..0000000000 --- a/scripts/genvimvim.lua +++ /dev/null @@ -1,158 +0,0 @@ -local mpack = vim.mpack - -if arg[1] == '--help' then - print('Usage: lua genvimvim.lua src/nvim runtime/syntax/vim/generated.vim') - os.exit(0) -end - -local nvimsrcdir = arg[1] -local syntax_file = arg[2] -local funcs_file = arg[3] - -package.path = nvimsrcdir .. '/?.lua;' .. package.pa