diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/bump-deps.sh | 104 | ||||
-rw-r--r-- | scripts/bump_deps.lua | 343 | ||||
-rwxr-xr-x | scripts/download-unicode-files.sh | 4 | ||||
-rwxr-xr-x | scripts/gen_vimdoc.py | 183 | ||||
-rw-r--r-- | scripts/genvimvim.lua | 10 | ||||
-rw-r--r-- | scripts/lintcommit.lua | 44 | ||||
-rw-r--r-- | scripts/lua2dox.lua | 25 | ||||
-rwxr-xr-x | scripts/pvscheck.sh | 2 | ||||
-rwxr-xr-x | scripts/stripdecls.py | 140 | ||||
-rwxr-xr-x | scripts/uncrustify.sh | 11 | ||||
-rwxr-xr-x | scripts/update_terminfo.sh | 6 | ||||
-rwxr-xr-x | scripts/update_version_stamp.lua | 54 | ||||
-rwxr-xr-x | scripts/vim-patch.sh | 61 | ||||
-rw-r--r-- | scripts/windows.ti | 4 |
14 files changed, 668 insertions, 323 deletions
diff --git a/scripts/bump-deps.sh b/scripts/bump-deps.sh new file mode 100755 index 0000000000..85c7f72700 --- /dev/null +++ b/scripts/bump-deps.sh @@ -0,0 +1,104 @@ +#!/usr/bin/env bash +set -e +set -u +# Use privileged mode, which e.g. skips using CDPATH. +set -p + +# Ensure that the user has a bash that supports -A +if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then + echo >&2 "error: script requires bash 4+ (you have ${BASH_VERSION})." + exit 1 +fi + +readonly NVIM_SOURCE_DIR="${NVIM_SOURCE_DIR:-$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)}" +readonly VIM_SOURCE_DIR_DEFAULT="${NVIM_SOURCE_DIR}/.vim-src" +readonly VIM_SOURCE_DIR="${VIM_SOURCE_DIR:-${VIM_SOURCE_DIR_DEFAULT}}" +BASENAME="$(basename "${0}")" +readonly BASENAME + +usage() { + echo "Bump Neovim dependencies" + echo + echo "Usage: ${BASENAME} [ -h | --pr | --branch=<dep> | --dep=<dependency> ]" + echo + echo "Options:" + echo " -h show this message and exit." + echo " --pr submit pr for bumping deps." + echo " --branch=<dep> create a branch bump-<dep> from current branch." + echo " --dep=<dependency> bump to a specific release or tag." + echo + echo "Dependency Options:" + echo " --version=<tag> bump to a specific release or tag." + echo " --commit=<hash> bump to a specific commit." + echo " --HEAD bump to a current head." + echo + echo " <dependency> is one of:" + echo " \"LuaJIT\", \"libuv\", \"Luv\", \"tree-sitter\"" +} + +# Checks if a program is in the user's PATH, and is executable. +check_executable() { + test -x "$(command -v "${1}")" +} + +require_executable() { + if ! check_executable "${1}"; then + echo >&2 "${BASENAME}: '${1}' not found in PATH or not executable." + exit 1 + fi +} + +require_executable "nvim" + +if [ $# -eq 0 ]; then + usage + exit 1 +fi + +PARSED_ARGS=$(getopt -a -n "$BASENAME" -o h --long pr,branch:,dep:,version:,commit:,HEAD -- "$@") + +DEPENDENCY="" +eval set -- "$PARSED_ARGS" +while :; do + case "$1" in + -h) + usage + exit 0 + ;; + --pr) + nvim -es +"lua require('scripts.bump_deps').submit_pr()" + exit 0 + ;; + --branch) + DEP=$2 + nvim -es +"lua require('scripts.bump_deps').create_branch('$DEP')" + exit 0 + ;; + --dep) + DEPENDENCY=$2 + shift 2 + ;; + --version) + VERSION=$2 + nvim -es +"lua require('scripts.bump_deps').version('$DEPENDENCY', '$VERSION')" + exit 0 + ;; + --commit) + COMMIT=$2 + nvim -es +"lua require('scripts.bump_deps').commit('$DEPENDENCY', '$COMMIT')" + exit 0 + ;; + --HEAD) + nvim -es +"lua require('scripts.bump_deps').head('$DEPENDENCY')" + exit 0 + ;; + *) + break + ;; + esac +done + +usage +exit 1 + +# vim: et sw=2 diff --git a/scripts/bump_deps.lua b/scripts/bump_deps.lua new file mode 100644 index 0000000000..17e3fd35d6 --- /dev/null +++ b/scripts/bump_deps.lua @@ -0,0 +1,343 @@ +-- Usage: +-- # bump to version +-- nvim -es +"lua require('scripts.bump_deps').version(dependency, version_tag)" +-- +-- # bump to commit +-- nvim -es +"lua require('scripts.bump_deps').commit(dependency, commit_hash)" +-- +-- # bump to HEAD +-- nvim -es +"lua require('scripts.bump_deps').head(dependency)" +-- +-- # submit PR +-- nvim -es +"lua require('scripts.bump_deps').submit_pr()" +-- +-- # create branch +-- nvim -es +"lua require('scripts.bump_deps').create_branch()" + +local M = {} + +local _trace = false +local required_branch_prefix = "bump-" +local commit_prefix = "build(deps): " + +-- Print message +local function p(s) + vim.cmd("set verbose=1") + vim.api.nvim_echo({ { s, "" } }, false, {}) + vim.cmd("set verbose=0") +end + +local function die() + p("") + vim.cmd("cquit 1") +end + +-- Executes and returns the output of `cmd`, or nil on failure. +-- if die_on_fail is true, process dies with die_msg on failure +-- +-- Prints `cmd` if `trace` is enabled. +local function _run(cmd, die_on_fail, die_msg) + if _trace then + p("run: " .. vim.inspect(cmd)) + end + local rv = vim.trim(vim.fn.system(cmd)) or "" + if vim.v.shell_error ~= 0 then + if die_on_fail then + if _trace then + p(rv) + end + p(die_msg) + die() + end + return nil + end + return rv +end + +-- Run a command, return nil on failure +local function run(cmd) + return _run(cmd, false, "") +end + +-- Run a command, die on failure with err_msg +local function run_die(cmd, err_msg) + return _run(cmd, true, err_msg) +end + +local function require_executable(cmd) + local cmd_path = run_die({ "command", "-v", cmd }, cmd .. " not found!") + run_die({ "test", "-x", cmd_path }, cmd .. " is not executable") +end + +local function rm_file_if_present(path_to_file) + run({ "rm", "-f", path_to_file }) +end + +local nvim_src_dir = vim.fn.getcwd() +local temp_dir = nvim_src_dir .. "/tmp" +run({ "mkdir", "-p", temp_dir }) + +local function get_dependency(dependency_name) + local dependency_table = { + ["LuaJIT"] = { + repo = "LuaJIT/LuaJIT", + symbol = "LUAJIT", + }, + ["libuv"] = { + repo = "libuv/libuv", + symbol = "LIBUV", + }, + ["Luv"] = { + repo = "luvit/luv", + symbol = "LUV", + }, + ["tree-sitter"] = { + repo = "tree-sitter/tree-sitter", + symbol = "TREESITTER", + }, + } + local dependency = dependency_table[dependency_name] + if dependency == nil then + p("Not a dependency: " .. dependency_name) + die() + end + dependency.name = dependency_name + return dependency +end + +local function get_gh_commit_sha(repo, ref) + require_executable("gh") + + local sha = run_die( + { "gh", "api", "repos/" .. repo .. "/commits/" .. ref, "--jq", ".sha" }, + "Failed to get commit hash from GitHub. Not a valid ref?" + ) + return sha +end + +local function get_archive_info(repo, ref) + require_executable("curl") + + local archive_name = ref .. ".tar.gz" + local archive_path = temp_dir .. "/" .. archive_name + local archive_url = "https://github.com/" .. repo .. "/archive/" .. archive_name + + rm_file_if_present(archive_path) + run_die({ "curl", "-sL", archive_url, "-o", archive_path }, "Failed to download archive from GitHub") + + local archive_sha = run({ "sha256sum", archive_path }):gmatch("%w+")() + return { url = archive_url, sha = archive_sha } +end + +local function write_cmakelists_line(symbol, kind, value) + require_executable("sed") + + local cmakelists_path = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" + run_die({ + "sed", + "-i", + "-e", + "s/set(" .. symbol .. "_" .. kind .. ".*$" .. "/set(" .. symbol .. "_" .. kind .. " " .. value .. ")" .. "/", + cmakelists_path, + }, "Failed to write " .. cmakelists_path) +end + +local function explicit_create_branch(dep) + require_executable("git") + + local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) + if checked_out_branch ~= "master" then + p("Not on master!") + die() + end + run_die({ "git", "checkout", "-b", "bump-" .. dep }, "git failed to create branch") +end + +local function verify_branch(new_branch_suffix) + require_executable("git") + + local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) + if not checked_out_branch:match("^" .. required_branch_prefix) then + p("Current branch '" .. checked_out_branch .. "' doesn't seem to start with " .. required_branch_prefix) + p("Checking out to bump-" .. new_branch_suffix) + explicit_create_branch(new_branch_suffix) + end +end + +local function update_cmakelists(dependency, archive, comment) + require_executable("git") + + verify_branch(dependency.name) + + local changed_file = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" + + p("Updating " .. dependency.name .. " to " .. archive.url .. "\n") + write_cmakelists_line(dependency.symbol, "URL", archive.url:gsub("/", "\\/")) + write_cmakelists_line(dependency.symbol, "SHA256", archive.sha) + run_die( + { "git", "commit", changed_file, "-m", commit_prefix .. "bump " .. dependency.name .. " to " .. comment }, + "git failed to commit" + ) +end + +local function verify_cmakelists_committed() + require_executable("git") + + local cmakelists_path = nvim_src_dir .. "/" .. "cmake.deps/CMakeLists.txt" + run_die({ "git", "diff", "--quiet", "HEAD", "--", cmakelists_path }, cmakelists_path .. " has uncommitted changes") +end + +local function warn_luv_symbol() + p("warning: " .. get_dependency("Luv").symbol .. "_VERSION will not be updated") +end + +-- return first 9 chars of commit +local function short_commit(commit) + return string.sub(commit, 1, 9) +end + +-- TODO: remove hardcoded fork +local function gh_pr(pr_title, pr_body) + require_executable("gh") + + local pr_url = run_die({ + "gh", + "pr", + "create", + "--title", + pr_title, + "--body", + pr_body, + }, "Failed to create PR") + return pr_url +end + +local function find_git_remote(fork) + require_executable("git") + + local remotes = run({ "git", "remote", "-v" }) + local git_remote = "" + for remote in remotes:gmatch("[^\r\n]+") do + local words = {} + for word in remote:gmatch("%w+") do + table.insert(words, word) + end + local match = words[1]:match("/github.com[:/]neovim/neovim/") + if fork == "fork" then + match = not match + end + if match and words[3] == "(fetch)" then + git_remote = words[0] + break + end + end + if git_remote == "" then + git_remote = "origin" + end + return git_remote +end + +local function create_pr(pr_title, pr_body) + require_executable("git") + + local push_first = true + + local checked_out_branch = run({ "git", "rev-parse", "--abbrev-ref", "HEAD" }) + if push_first then + local push_remote = run({ "git", "config", "--get", "branch." .. checked_out_branch .. ".pushRemote" }) + if push_remote == nil then + push_remote = run({ "git", "config", "--get", "remote.pushDefault" }) + if push_remote == nil then + push_remote = run({ "git", "config", "--get", "branch." .. checked_out_branch .. ".remote" }) + if push_remote == nil or push_remote == find_git_remote(nil) then + push_remote = find_git_remote("fork") + end + end + end + + p("Pushing to " .. push_remote .. "/" .. checked_out_branch) + run_die({ "git", "push", push_remote, checked_out_branch }, "Git failed to push") + end + + local pr_url = gh_pr(pr_title, pr_body) + p("\nCreated PR: " .. pr_url .. "\n") +end + +function M.commit(dependency_name, commit) + local dependency = get_dependency(dependency_name) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, commit) + if commit_sha ~= commit then + p("Not a commit: " .. commit .. ". Did you mean version?") + die() + end + local archive = get_archive_info(dependency.repo, commit) + if dependency_name == "Luv" then + warn_luv_symbol() + end + update_cmakelists(dependency, archive, short_commit(commit)) +end + +function M.version(dependency_name, version) + local dependency = get_dependency(dependency_name) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, version) + if commit_sha == version then + p("Not a version: " .. version .. ". Did you mean commit?") + die() + end + local archive = get_archive_info(dependency.repo, version) + if dependency_name == "Luv" then + write_cmakelists_line(dependency.symbol, "VERSION", version) + end + update_cmakelists(dependency, archive, version) +end + +function M.head(dependency_name) + local dependency = get_dependency(dependency_name) + verify_cmakelists_committed() + local commit_sha = get_gh_commit_sha(dependency.repo, "HEAD") + local archive = get_archive_info(dependency.repo, commit_sha) + if dependency_name == "Luv" then + warn_luv_symbol() + end + update_cmakelists(dependency, archive, "HEAD - " .. short_commit(commit_sha)) +end + +function M.create_branch(dep) + explicit_create_branch(dep) +end + +function M.submit_pr() + require_executable("git") + + verify_branch("deps") + + local nvim_remote = find_git_remote(nil) + local relevant_commit = run_die({ + "git", + "log", + "--grep=" .. commit_prefix, + "--reverse", + "--format='%s'", + nvim_remote .. "/master..HEAD", + "-1", + }, "Failed to fetch commits") + + local pr_title + local pr_body + + if relevant_commit == "" then + pr_title = commit_prefix .. "bump some dependencies" + pr_body = "bump some dependencies" + else + relevant_commit = relevant_commit:gsub("'", "") + pr_title = relevant_commit + pr_body = relevant_commit:gsub(commit_prefix:gsub("%(", "%%("):gsub("%)", "%%)"), "") + end + pr_body = pr_body .. "\n\n(add explanations if needed)" + p(pr_title .. "\n" .. pr_body .. "\n") + create_pr(pr_title, pr_body) +end + +return M diff --git a/scripts/download-unicode-files.sh b/scripts/download-unicode-files.sh index 12474d3c1e..4482cefa34 100755 --- a/scripts/download-unicode-files.sh +++ b/scripts/download-unicode-files.sh @@ -4,7 +4,7 @@ set -e data_files="UnicodeData.txt CaseFolding.txt EastAsianWidth.txt" emoji_files="emoji-data.txt" -UNIDIR_DEFAULT=unicode +UNIDIR_DEFAULT=src/unicode DOWNLOAD_URL_BASE_DEFAULT='http://unicode.org/Public' if test x$1 = 'x--help' ; then @@ -39,5 +39,5 @@ done ( cd "$UNIDIR" - git commit -m "Update unicode files" -- $files + git commit -m "feat: update unicode tables" -- $files ) diff --git a/scripts/gen_vimdoc.py b/scripts/gen_vimdoc.py index 3e9fb21039..22fd155d32 100755 --- a/scripts/gen_vimdoc.py +++ b/scripts/gen_vimdoc.py @@ -52,12 +52,21 @@ import logging from xml.dom import minidom -MIN_PYTHON_VERSION = (3, 5) +MIN_PYTHON_VERSION = (3, 6) +MIN_DOXYGEN_VERSION = (1, 9, 0) if sys.version_info < MIN_PYTHON_VERSION: print("requires Python {}.{}+".format(*MIN_PYTHON_VERSION)) sys.exit(1) +doxygen_version = tuple((int(i) for i in subprocess.check_output(["doxygen", "-v"], + universal_newlines=True).split()[0].split('.'))) + +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) + # DEBUG = ('DEBUG' in os.environ) INCLUDE_C_DECL = ('INCLUDE_C_DECL' in os.environ) INCLUDE_DEPRECATED = ('INCLUDE_DEPRECATED' in os.environ) @@ -70,13 +79,11 @@ LOG_LEVELS = { ] } -fmt_vimhelp = False # HACK text_width = 78 script_path = os.path.abspath(__file__) base_dir = os.path.dirname(os.path.dirname(script_path)) out_dir = os.path.join(base_dir, 'tmp-{target}-doc') filter_cmd = '%s %s' % (sys.executable, script_path) -seen_funcs = set() msgs = [] # Messages to show on exit. lua2dox_filter = os.path.join(base_dir, 'scripts', 'lua2dox_filter') @@ -84,22 +91,22 @@ CONFIG = { 'api': { 'mode': 'c', 'filename': 'api.txt', - # String used to find the start of the generated part of the doc. - 'section_start_token': '*api-global*', # Section ordering. 'section_order': [ 'vim.c', 'vimscript.c', + 'command.c', + 'options.c', 'buffer.c', 'extmark.c', 'window.c', 'win_config.c', 'tabpage.c', + 'autocmd.c', 'ui.c', - 'extmark.c', ], - # List of files/directories for doxygen to read, separated by blanks - 'files': os.path.join(base_dir, 'src/nvim/api'), + # List of files/directories for doxygen to read, relative to `base_dir` + 'files': ['src/nvim/api'], # file patterns used by doxygen 'file_patterns': '*.h *.c', # Only function with this prefix are considered @@ -122,31 +129,41 @@ CONFIG = { 'lua': { 'mode': 'lua', 'filename': 'lua.txt', - 'section_start_token': '*lua-vim*', 'section_order': [ - 'vim.lua', + '_editor.lua', 'shared.lua', 'uri.lua', 'ui.lua', 'filetype.lua', 'keymap.lua', + 'fs.lua', + ], + 'files': [ + 'runtime/lua/vim/_editor.lua', + 'runtime/lua/vim/shared.lua', + 'runtime/lua/vim/uri.lua', + 'runtime/lua/vim/ui.lua', + 'runtime/lua/vim/filetype.lua', + 'runtime/lua/vim/keymap.lua', + 'runtime/lua/vim/fs.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'src/nvim/lua/vim.lua'), - os.path.join(base_dir, 'runtime/lua/vim/shared.lua'), - os.path.join(base_dir, 'runtime/lua/vim/uri.lua'), - os.path.join(base_dir, 'runtime/lua/vim/ui.lua'), - os.path.join(base_dir, 'runtime/lua/vim/filetype.lua'), - os.path.join(base_dir, 'runtime/lua/vim/keymap.lua'), - ]), 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': { 'lsp.lua': 'core', }, - 'section_fmt': lambda name: f'Lua module: {name.lower()}', - 'helptag_fmt': lambda name: f'*lua-{name.lower()}*', - 'fn_helptag_fmt': lambda fstem, name: f'*{fstem}.{name}()*', + 'section_fmt': lambda name: ( + 'Lua module: vim' + if name.lower() == '_editor' + else f'Lua module: {name.lower()}'), + 'helptag_fmt': lambda name: ( + '*lua-vim*' + if name.lower() == '_editor' + else f'*lua-{name.lower()}*'), + 'fn_helptag_fmt': lambda fstem, name: ( + f'*vim.{name}()*' + if fstem.lower() == '_editor' + else f'*{fstem}.{name}()*'), 'module_override': { # `shared` functions are exposed on the `vim` module. 'shared': 'vim', @@ -154,6 +171,7 @@ CONFIG = { 'ui': 'vim.ui', 'filetype': 'vim.filetype', 'keymap': 'vim.keymap', + 'fs': 'vim.fs', }, 'append_only': [ 'shared.lua', @@ -162,7 +180,6 @@ CONFIG = { 'lsp': { 'mode': 'lua', 'filename': 'lsp.txt', - 'section_start_token': '*lsp-core*', 'section_order': [ 'lsp.lua', 'buf.lua', @@ -176,10 +193,10 @@ CONFIG = { 'sync.lua', 'protocol.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'runtime/lua/vim/lsp'), - os.path.join(base_dir, 'runtime/lua/vim/lsp.lua'), - ]), + 'files': [ + 'runtime/lua/vim/lsp', + 'runtime/lua/vim/lsp.lua', + ], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {'lsp.lua': 'lsp'}, @@ -205,11 +222,10 @@ CONFIG = { 'diagnostic': { 'mode': 'lua', 'filename': 'diagnostic.txt', - 'section_start_token': '*diagnostic-api*', 'section_order': [ 'diagnostic.lua', ], - 'files': os.path.join(base_dir, 'runtime/lua/vim/diagnostic.lua'), + 'files': ['runtime/lua/vim/diagnostic.lua'], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {'diagnostic.lua': 'diagnostic'}, @@ -222,7 +238,6 @@ CONFIG = { 'treesitter': { 'mode': 'lua', 'filename': 'treesitter.txt', - 'section_start_token': '*lua-treesitter-core*', 'section_order': [ 'treesitter.lua', 'language.lua', @@ -230,10 +245,10 @@ CONFIG = { 'highlighter.lua', 'languagetree.lua', ], - 'files': ' '.join([ - os.path.join(base_dir, 'runtime/lua/vim/treesitter.lua'), - os.path.join(base_dir, 'runtime/lua/vim/treesitter/'), - ]), + 'files': [ + 'runtime/lua/vim/treesitter.lua', + 'runtime/lua/vim/treesitter/', + ], 'file_patterns': '*.lua', 'fn_name_prefix': '', 'section_name': {}, @@ -268,16 +283,13 @@ param_exclude = ( # Annotations are displayed as line items after API function descriptions. annotation_map = { - 'FUNC_API_FAST': '{fast}', + 'FUNC_API_FAST': '|api-fast|', 'FUNC_API_CHECK_TEXTLOCK': 'not allowed when |textlock| is active', + 'FUNC_API_REMOTE_ONLY': '|RPC| only', + 'FUNC_API_LUA_ONLY': '|vim.api| only', } -# Tracks `xrefsect` titles. As of this writing, used only for separating -# deprecated functions. -xrefs = set() - - # Raises an error with details about `o`, if `cond` is in object `o`, # or if `cond()` is callable and returns True. def debug_this(o, cond=True): @@ -340,14 +352,6 @@ def self_or_child(n): return n.childNodes[0] -def clean_text(text): - """Cleans text. - - Only cleans superfluous whitespace at the moment. - """ - return ' '.join(text.split()).strip() - - def clean_lines(text): """Removes superfluous lines. @@ -368,12 +372,12 @@ def get_text(n, preformatted=False): if n.nodeName == 'computeroutput': for node in n.childNodes: text += get_text(node) - return '`{}` '.format(text) + return '`{}`'.format(text) for node in n.childNodes: if node.nodeType == node.TEXT_NODE: - text += node.data if preformatted else clean_text(node.data) + text += node.data elif node.nodeType == node.ELEMENT_NODE: - text += ' ' + get_text(node, preformatted) + text += get_text(node, preformatted) return text @@ -479,10 +483,8 @@ def update_params_map(parent, ret_map, width=62): return ret_map -def render_node(n, text, prefix='', indent='', width=62): +def render_node(n, text, prefix='', indent='', width=62, fmt_vimhelp=False): """Renders a node as Vim help text, recursively traversing all descendants.""" - global fmt_vimhelp - global has_seen_preformatted def ind(s): return s if fmt_vimhelp else '' @@ -560,7 +562,7 @@ def render_node(n, text, prefix='', indent='', width=62): return text -def para_as_map(parent, indent='', width=62): +def para_as_map(parent, indent='', width=62, fmt_vimhelp=False): """Extracts a Doxygen XML <para> node to a map. Keys: @@ -593,7 +595,8 @@ def para_as_map(parent, indent='', width=62): last = '' if is_inline(parent): # Flatten inline text from a tree of non-block nodes. - text = doc_wrap(render_node(parent, ""), indent=indent, width=width) + text = doc_wrap(render_node(parent, "", fmt_vimhelp=fmt_vimhelp), + indent=indent, width=width) else: prev = None # Previous node for child in parent.childNodes: @@ -609,7 +612,8 @@ def para_as_map(parent, indent='', width=62): elif kind == 'see': groups['seealso'].append(child) elif kind in ('note', 'warning'): - text += render_node(child, text, indent=indent, width=width) + text += render_node(child, text, indent=indent, + width=width, fmt_vimhelp=fmt_vimhelp) else: raise RuntimeError('unhandled simplesect: {}\n{}'.format( child.nodeName, child.toprettyxml(indent=' ', newl='\n'))) @@ -622,7 +626,8 @@ def para_as_map(parent, indent='', width=62): and ' ' != text[-1]): text += ' ' - text += render_node(child, text, indent=indent, width=width) + text += render_node(child, text, indent=indent, width=width, + fmt_vimhelp=fmt_vimhelp) prev = child chunks['text'] += text @@ -633,10 +638,12 @@ def para_as_map(parent, indent='', width=62): update_params_map(child, ret_map=chunks['params'], width=width) for child in groups['return']: chunks['return'].append(render_node( - child, '', indent=indent, width=width)) + child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp)) for child in groups['seealso']: chunks['seealso'].append(render_node( - child, '', indent=indent, width=width)) + child, '', indent=indent, width=width, fmt_vimhelp=fmt_vimhelp)) + + xrefs = set() for child in groups['xrefs']: # XXX: Add a space (or any char) to `title` here, otherwise xrefs # ("Deprecated" section) acts very weird... @@ -646,10 +653,10 @@ def para_as_map(parent, indent='', width=62): chunks['xrefs'].append(doc_wrap(xrefdesc, prefix='{}: '.format(title), width=width) + '\n') - return chunks + return chunks, xrefs -def fmt_node_as_vimhelp(parent, width=62, indent=''): +def fmt_node_as_vimhelp(parent, width=62, indent='', fmt_vimhelp=False): """Renders (nested) Doxygen <para> nodes as Vim :help text. NB: Blank lines in a docstring manifest as <para> tags. @@ -672,7 +679,7 @@ def fmt_node_as_vimhelp(parent, width=62, indent=''): return True for child in parent.childNodes: - para = para_as_map(child, indent, width) + para, _ = para_as_map(child, indent, width, fmt_vimhelp) # Generate text from the gathered items. chunks = [para['text']] @@ -696,19 +703,16 @@ def fmt_node_as_vimhelp(parent, width=62, indent=''): return clean_lines('\n'.join(rendered_blocks).strip()) -def extract_from_xml(filename, target, width): +def extract_from_xml(filename, target, width, fmt_vimhelp): """Extracts Doxygen info as maps without formatting the text. Returns two maps: 1. Functions 2. Deprecated functions - The `fmt_vimhelp` global controls some special cases for use by + The `fmt_vimhelp` variable controls some special cases for use by fmt_doxygen_xml_as_vimhelp(). (TODO: ugly :) """ - global xrefs - global fmt_vimhelp - xrefs.clear() fns = {} # Map of func_name:docstring. deprecated_fns = {} # Map of func_name:docstring. @@ -815,16 +819,22 @@ def extract_from_xml(filename, target, width): signature = prefix + suffix signature += vimtag.rjust(width - len(signature)) + # Tracks `xrefsect` titles. As of this writing, used only for separating + # deprecated functions. + xrefs_all = set() paras = [] brief_desc = find_first(member, 'briefdescription') if brief_desc: for child in brief_desc.childNodes: - paras.append(para_as_map(child)) + para, xrefs = para_as_map(child) + xrefs_all.update(xrefs) desc = find_first(member, 'detaileddescription') if desc: for child in desc.childNodes: - paras.append(para_as_map(child)) + para, xrefs = para_as_map(child) + paras.append(para) + xrefs_all.update(xrefs) log.debug( textwrap.indent( re.sub(r'\n\s*\n+', '\n', @@ -840,7 +850,8 @@ def extract_from_xml(filename, target, width): 'seealso': [], } if fmt_vimhelp: - fn['desc_node'] = desc # HACK :( + fn['desc_node'] = desc + fn['brief_desc_node'] = brief_desc for m in paras: if 'text' in m: @@ -857,18 +868,16 @@ def extract_from_xml(filename, target, width): if INCLUDE_C_DECL: fn['c_decl'] = c_decl - if 'Deprecated' in str(xrefs): + if 'Deprecated' in str(xrefs_all): deprecated_fns[name] = fn elif name.startswith(CONFIG[target]['fn_name_prefix']): fns[name] = fn - xrefs.clear() - fns = collections.OrderedDict(sorted( fns.items(), key=lambda key_item_tuple: key_item_tuple[0].lower())) deprecated_fns = collections.OrderedDict(sorted(deprecated_fns.items())) - return (fns, deprecated_fns) + return fns, deprecated_fns def fmt_doxygen_xml_as_vimhelp(filename, target): @@ -878,16 +887,16 @@ def fmt_doxygen_xml_as_vimhelp(filename, target): 1. Vim help text for functions found in `filename`. 2. Vim help text for deprecated functions. """ - global fmt_vimhelp - fmt_vimhelp = True fns_txt = {} # Map of func_name:vim-help-text. deprecated_fns_txt = {} # Map of func_name:vim-help-text. - fns, _ = extract_from_xml(filename, target, width=text_width) + fns, _ = extract_from_xml(filename, target, text_width, True) for name, fn in fns.items(): # Generate Vim :help for parameters. if fn['desc_node']: - doc = fmt_node_as_vimhelp(fn['desc_node']) + doc = fmt_node_as_vimhelp(fn['desc_node'], fmt_vimhelp=True) + if not doc and fn['brief_desc_node']: + doc = fmt_node_as_vimhelp(fn['brief_desc_node']) if not doc: doc = 'TODO: Documentation' @@ -938,14 +947,9 @@ def fmt_doxygen_xml_as_vimhelp(filename, target): func_doc = "\n".join(split_lines) - if 'Deprecated' in xrefs: - deprecated_fns_txt[name] = func_doc - elif name.startswith(CONFIG[target]['fn_name_prefix']): + if name.startswith(CONFIG[target]['fn_name_prefix']): fns_txt[name] = func_doc - xrefs.clear() - - fmt_vimhelp = False return ('\n\n'.join(list(fns_txt.values())), '\n\n'.join(list(deprecated_fns_txt.values()))) @@ -997,7 +1001,8 @@ def main(config, args): stderr=(subprocess.STDOUT if debug else subprocess.DEVNULL)) p.communicate( config.format( - input=CONFIG[target]['files'], + input=' '.join( + [f'"{file}"' for file in CONFIG[target]['files']]), output=output_dir, filter=filter_cmd, file_patterns=CONFIG[target]['file_patterns']) @@ -1048,7 +1053,7 @@ def main(config, args): xmlfile = os.path.join(base, '{}.xml'.format(compound.getAttribute('refid'))) # Extract unformatted (*.mpack). - fn_map, _ = extract_from_xml(xmlfile, target, width=9999) + 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( @@ -1087,10 +1092,10 @@ def main(config, args): raise RuntimeError( 'found new modules "{}"; update the "section_order" map'.format( set(sections).difference(CONFIG[target]['section_order']))) + first_section_tag = sections[CONFIG[target]['section_order'][0]][1] docs = '' - i = 0 for filename in CONFIG[target]['section_order']: try: title, helptag, section_doc = sections.pop(filename) @@ -1098,7 +1103,6 @@ def main(config, args): msg(f'warning: empty docs, skipping (target={target}): {filename}') msg(f' existing docs: {sections.keys()}') continue - i += 1 if filename not in CONFIG[target]['append_only']: docs += sep docs += '\n%s%s' % (title, @@ -1112,7 +1116,8 @@ def main(config, args): doc_file = os.path.join(base_dir, 'runtime', 'doc', CONFIG[target]['filename']) - delete_lines_below(doc_file, CONFIG[target]['section_start_token']) + if os.path.exists(doc_file): + delete_lines_below(doc_file, first_section_tag) with open(doc_file, 'ab') as fp: fp.write(docs.encode('utf8')) diff --git a/scripts/genvimvim.lua b/scripts/genvimvim.lua index ff60b6cce7..868084a583 100644 --- a/scripts/genvimvim.lua +++ b/scripts/genvimvim.lua @@ -44,12 +44,14 @@ local function cmd_kw(prev_cmd, cmd) end -- Exclude these from the vimCommand keyword list, they are handled specially --- in syntax/vim.vim (vimAugroupKey, vimAutoCmd). #9327 -local function is_autocmd_cmd(cmd) +-- in syntax/vim.vim (vimAugroupKey, vimAutoCmd, vimGlobal, vimSubst). #9327 +local function is_special_cased_cmd(cmd) return (cmd == 'augroup' or cmd == 'autocmd' or cmd == 'doautocmd' - or cmd == 'doautoall') + or cmd == 'doautoall' + or cmd == 'global' + or cmd == 'substitute') end local vimcmd_start = 'syn keyword vimCommand contained ' @@ -60,7 +62,7 @@ for _, cmd_desc in ipairs(ex_cmds.cmds) do w('\n' .. vimcmd_start) end local cmd = cmd_desc.command - if cmd:match('%w') and cmd ~= 'z' and not is_autocmd_cmd(cmd) then + if cmd:match('%w') and cmd ~= 'z' and not is_special_cased_cmd(cmd) then w(' ' .. cmd_kw(prev_cmd, cmd)) end prev_cmd = cmd diff --git a/scripts/lintcommit.lua b/scripts/lintcommit.lua index 0a7da4d4ef..16326cfe66 100644 --- a/scripts/lintcommit.lua +++ b/scripts/lintcommit.lua @@ -45,8 +45,13 @@ end -- Returns nil if the given commit message is valid, or returns a string -- message explaining why it is invalid. local function validate_commit(commit_message) - local commit_split = vim.split(commit_message, ":") + -- Return nil if the commit message starts with "fixup" as it signifies it's + -- a work in progress and shouldn't be linted yet. + if vim.startswith(commit_message, "fixup") then + return nil + end + local commit_split = vim.split(commit_message, ":") -- Return nil if the type is vim-patch since most of the normal rules don't -- apply. if commit_split[1] == "vim-patch" then @@ -73,7 +78,7 @@ 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', 'chore', 'vim-patch'} + local allowed_types = {'build', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'test', 'dist', 'vim-patch'} if not vim.tbl_contains(allowed_types, type) then return string.format( 'Invalid commit type "%s". Allowed types are:\n %s', @@ -94,10 +99,24 @@ local function validate_commit(commit_message) return [[Description ends with a period (".").]] end - -- Check that description has exactly one whitespace after colon, followed by - -- a lowercase letter and then any number of letters. - if not string.match(after_colon, '^ %l%a*') then - return [[There should be one whitespace after the colon and the first letter should lowercase.]] + -- Check that description starts with a whitespace. + if after_colon:sub(1,1) ~= " " then + return [[There should be a whitespace after the colon.]] + end + + -- Check that description doesn't start with multiple whitespaces. + if after_colon:sub(1,2) == " " then + 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 + + -- Check that description isn't just whitespaces + if vim.trim(after_colon) == "" then + return [[Description shouldn't be empty.]] end return nil @@ -162,18 +181,23 @@ function M._test() ['refactor: normal message'] = true, ['revert: normal message'] = true, ['test: normal message'] = true, - ['chore: 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, ['vim-patch:8.2.3374: Pyret files are not recognized (#15642)'] = true, ['vim-patch:8.1.1195,8.2.{3417,3419}'] = true, + ['revert: "ci: use continue-on-error instead of "|| true""'] = true, + ['fixup'] = true, + ['fixup: commit message'] = true, + ['fixup! commit message'] = true, [':no type before colon 1'] = false, [' :no type before colon 2'] = false, [' :no type before colon 3'] = false, ['ci(empty description):'] = false, - ['ci(whitespace as description): '] = false, + ['ci(only whitespace as description): '] = false, ['docs(multiple whitespaces as description): '] = false, + ['revert(multiple whitespaces and then characters as description): description'] = false, ['ci no colon after type'] = false, ['test: extra space after colon'] = false, ['ci: tab after colon'] = false, @@ -181,10 +205,10 @@ function M._test() ['ci :extra space before colon'] = false, ['refactor(): empty scope'] = false, ['ci( ): whitespace as scope'] = false, - ['chore: period at end of sentence.'] = false, + ['ci: period at end of sentence.'] = false, ['ci: Starting sentence capitalized'] = false, ['unknown: using unknown type'] = false, - ['chore: you\'re saying this commit message just goes on and on and on and on and on and on for way too long?'] = 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, } local failed = 0 diff --git a/scripts/lua2dox.lua b/scripts/lua2dox.lua index d110e34c6a..6a206066b8 100644 --- a/scripts/lua2dox.lua +++ b/scripts/lua2dox.lua @@ -295,7 +295,7 @@ function TStream_Write.writelnTail(this,Line) table.insert(this.tailLine,Line) end ---! \brief outout tail lines +--! \brief output tail lines function TStream_Write.write_tailLines(this) for _,line in ipairs(this.tailLine) do TCore_IO_writeln(line) @@ -403,6 +403,29 @@ function TLua2DoX_filter.readfile(this,AppStamp,Filename) if 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) + + local magic_split = string_split(magic, ' ') + + local type_index = 2 + if magic_split[1] == 'param' then + type_index = type_index + 1 + end + + if magic_split[type_index] == 'number' or + magic_split[type_index] == 'number|nil' or + magic_split[type_index] == 'string' or + magic_split[type_index] == 'string|nil' or + magic_split[type_index] == 'table' or + magic_split[type_index] == 'table|nil' or + magic_split[type_index] == 'boolean' or + magic_split[type_index] == 'boolean|nil' or + magic_split[type_index] == 'function' or + magic_split[type_index] == 'function|nil' + then + magic_split[type_index] = '(' .. magic_split[type_index] .. ')' + end + magic = table.concat(magic_split, ' ') + outStream:writeln('/// @' .. magic) fn_magic = checkComment4fn(fn_magic,magic) elseif string.sub(line,3,3)=='-' then -- it's a nonmagic doc comment diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index 195a76763f..a931231fbd 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -380,7 +380,7 @@ run_analysis() {( --sourcetree-root . || true rm -rf PVS-studio.{xml,err,tsk,html.d} - local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011,V1042,V1051,V1074" + local plog_args="PVS-studio.log --srcRoot . --excludedCodes V011,V1042,V1051,V1074,V002" plog-converter $plog_args --renderTypes xml --output PVS-studio.xml plog-converter $plog_args --renderTypes errorfile --output PVS-studio.err plog-converter $plog_args --renderTypes tasklist --output PVS-studio.tsk diff --git a/scripts/stripdecls.py b/scripts/stripdecls.py deleted file mode 100755 index b4ac34dcfe..0000000000 --- a/scripts/stripdecls.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/python -# vim: set fileencoding=utf-8: - -from __future__ import print_function, unicode_literals, division - -from clang.cindex import Index, CursorKind -from collections import namedtuple, OrderedDict, defaultdict -import sys -import os - - -DECL_KINDS = { - CursorKind.FUNCTION_DECL, -} - - -Strip = namedtuple('Strip', 'start_line start_column end_line end_column') - - -def main(progname, cfname, only_static, move_all): - cfname = os.path.abspath(os.path.normpath(cfname)) - - hfname1 = os.path.splitext(cfname)[0] + os.extsep + 'h' - hfname2 = os.path.splitext(cfname)[0] + '_defs' + os.extsep + 'h' - - files_to_modify = (cfname, hfname1, hfname2) - - index = Index.create() - src_dirname = os.path.join(os.path.dirname(__file__), '..', 'src') - src_dirname = os.path.abspath(os.path.normpath(src_dirname)) - relname = os.path.join(src_dirname, 'nvim') - unit = index.parse(cfname, args=('-I' + src_dirname, - '-DUNIX', - '-DEXITFREE', - '-DFEAT_USR_CMDS', - '-DFEAT_CMDL_COMPL', - '-DFEAT_COMPL_FUNC', - '-DPROTO', - '-DUSE_MCH_ERRMSG')) - cursor = unit.cursor - - tostrip = defaultdict(OrderedDict) - definitions = set() - - for child in cursor.get_children(): - if not (child.location and child.location.file): - continue - fname = os.path.abspath(os.path.normpath(child.location.file.name)) - if fname not in files_to_modify: - continue - if child.kind not in DECL_KINDS: - continue - if only_static and next(child.get_tokens()).spelling == 'static': - continue - - if child.is_definition() and fname == cfname: - definitions.add(child.spelling) - else: - stripdict = tostrip[fname] - assert(child.spelling not in stripdict) - stripdict[child.spelling] = Strip( - child.extent.start.line, - child.extent.start.column, - child.extent.end.line, - child.extent.end.column, - ) - - for (fname, stripdict) in tostrip.items(): - if not move_all: - for name in set(stripdict) - definitions: - stripdict.pop(name) - - if not stripdict: - continue - - if fname.endswith('.h'): - is_h_file = True - include_line = next(reversed(stripdict.values())).start_line + 1 - else: - is_h_file = False - include_line = next(iter(stripdict.values())).start_line - - lines = None - generated_existed = os.path.exists(fname + '.generated.h') - with open(fname, 'rb') as F: - lines = list(F) - - stripped = [] - - for name, position in reversed(stripdict.items()): - sl = slice(position.start_line - 1, position.end_line) - if is_h_file: - include_line -= sl.stop - sl.start - stripped += lines[sl] - lines[sl] = () - - if not generated_existed: - lines[include_line:include_line] = [ - '#ifdef INCLUDE_GENERATED_DECLARATIONS\n', - '# include "{0}.generated.h"\n'.format( - os.path.relpath(fname, relname)), - '#endif\n', - ] - - with open(fname, 'wb') as F: - F.writelines(lines) - - -if __name__ == '__main__': - progname = sys.argv[0] - args = sys.argv[1:] - if not args or '--help' in args: - print('Usage:') - print('') - print(' {0} [--static [--all]] file.c...'.format(progname)) - print('') - print('Stripts all declarations from file.c, file.h and file_defs.h.') - print('If --static argument is given then only static declarations are') - print('stripped. Declarations are stripped only if corresponding') - print('definition is found unless --all argument was given.') - print('') - print('Note: it is assumed that static declarations starts with "static"') - print(' keyword.') - sys.exit(0 if args else 1) - - if args[0] == '--static': - only_static = True - args = args[1:] - else: - only_static = False - - if args[0] == '--all': - move_all = True - args = args[1:] - else: - move_all = False - - for cfname in args: - print('Processing {0}'.format(cfname)) - main(progname, cfname, only_static, move_all) diff --git a/scripts/uncrustify.sh b/scripts/uncrustify.sh new file mode 100755 index 0000000000..ac5d542c29 --- /dev/null +++ b/scripts/uncrustify.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -e + +# Check that you have uncrustify +hash uncrustify + +COMMITISH="${1:-master}" +for file in $(git diff --diff-filter=d --name-only $COMMITISH | grep '\.[ch]$'); do + uncrustify -c src/uncrustify.cfg -l C --replace --no-backup "$file" +done diff --git a/scripts/update_terminfo.sh b/scripts/update_terminfo.sh index 0cfc230ca6..8a0937cc8c 100755 --- a/scripts/update_terminfo.sh +++ b/scripts/update_terminfo.sh @@ -64,6 +64,8 @@ cat > "$target" <<EOF // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +// uncrustify:off + // // Generated by scripts/update_terminfo.sh and $(tic -V) // @@ -84,8 +86,8 @@ for term in $sorted_terms; do infocmp -L -1 -A "$db" "$term" | sed -e '1d' -e 's#^#// #' | tr '\t' ' ' printf 'static const int8_t %s[] = {\n' "${entries[$term]}" printf ' ' - od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ',' | tr -d '\n' - printf ' // NOLINT\n};\n' + od -v -t d1 < "$path" | cut -c9- | xargs | tr ' ' ',' + printf '};\n' done >> "$target" cat >> "$target" <<EOF diff --git a/scripts/update_version_stamp.lua b/scripts/update_version_stamp.lua deleted file mode 100755 index 0342e08f31..0000000000 --- a/scripts/update_version_stamp.lua +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env lua --- --- Script to update the Git version stamp during build. --- This is called via the custom update_version_stamp target in --- src/nvim/CMakeLists.txt. --- --- arg[1]: file in which to update the version string --- arg[2]: prefix to use always ("vX.Y.Z") - -local function die(msg) - io.stderr:write(string.format('%s: %s\n', arg[0], msg)) - -- No error, fall back to using generated "-dev" version. - os.exit(0) -end - -local function iswin() - return package.config:sub(1,1) == '\\' -end - -if #arg ~= 2 then - die(string.format("Expected two args, got %d", #arg)) -end - -local versiondeffile = arg[1] -local prefix = arg[2] - -local dev_null = iswin() and 'NUL' or '/dev/null' -local described = io.popen('git describe --first-parent --dirty 2>'..dev_null):read('*l') -if not described then - described = io.popen('git describe --first-parent --tags --always --dirty'):read('*l') -end -if not described then - io.open(versiondeffile, 'w'):write('\n') - die('git-describe failed, using empty include file.') -end - --- `git describe` annotates the most recent tagged release; for pre-release --- builds we append that to the dev version -local with_prefix = prefix -if prefix:match('-dev$') ~= nil then - with_prefix = prefix .. '+' .. described:gsub('^v%d+%.%d+%.%d+-', '') -end - --- Read existing include file. -local current = io.open(versiondeffile, 'r') -if current then - current = current:read('*l') -end - --- Write new include file, if different. -local new = '#define NVIM_VERSION_MEDIUM "'..with_prefix..'"' -if current ~= new then - io.open(versiondeffile, 'w'):write(new .. '\n') -end diff --git a/scripts/vim-patch.sh b/scripts/vim-patch.sh index 1c265f0f40..d5424f51ab 100755 --- a/scripts/vim-patch.sh +++ b/scripts/vim-patch.sh @@ -4,6 +4,8 @@ set -e set -u # Use privileged mode, which e.g. skips using CDPATH. set -p +# https://www.shellcheck.net/wiki/SC2031 +shopt -s lastpipe # Ensure that the user has a bash that supports -A if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then @@ -36,7 +38,7 @@ usage() { echo " can be a Vim version (8.0.xxx) or a Git hash." echo " -P {vim-revision} Download, generate and apply a Vim patch." echo " -g {vim-revision} Download a Vim patch." - echo " -s Create a vim-patch pull request." + echo " -s [pr args] Create a vim-patch pull request." echo " -r {pr-number} Review a vim-patch pull request." echo " -V Clone the Vim source code to \$VIM_SOURCE_DIR." echo @@ -190,8 +192,8 @@ preprocess_patch() { 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/\<\%('"${na_files}"'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove *.proto, Make*, INSTALL*, gui_*, beval.*, some if_*, gvim, libvterm, tee, VisVim, xpm, xxd - local na_src='auto\|configure.*\|GvimExt\|libvterm\|proto\|tee\|VisVim\|xpm\|xxd\|Make*\|INSTALL*\|beval.*\|gui_*\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%(testdir/\)\@<!\%('"${na_src}"'\)@norm! d/\v(^diff)|%$
' +w +q "$file" + local na_src='auto\|configure.*\|GvimExt\|libvterm\|proto\|tee\|VisVim\|xpm\|xxd\|Make.*\|INSTALL.*\|beval.*\|gui.*\|if_lua\|if_mzsch\|if_olepp\|if_ole\|if_perl\|if_py\|if_ruby\|if_tcl\|if_xcmdsrv' + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\S*\<\%(testdir/\)\@<!\%('"${na_src}"'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove unwanted Vim doc files. local na_doc='channel\.txt\|netbeans\.txt\|os_\w\+\.txt\|term\.txt\|todo\.txt\|version\d\.txt\|vim9\.txt\|sponsor\.txt\|intro\.txt\|tags' @@ -201,19 +203,18 @@ preprocess_patch() { 2>/dev/null $nvim --cmd 'set dir=/tmp' +'%s/^@@.*\n.*For Vim version.*Last change.*\n.*For Vim version.*Last change.*//' +w +q "$file" # Remove gui, option, setup, screen dumps, testdir/Make_*.mak files - local na_src_testdir='gen_opt_test.vim\|gui_.*\|Make_amiga.mak\|Make_dos.mak\|Make_ming.mak\|Make_vms.mms\|dumps/.*.dump\|setup_gui.vim' + local na_src_testdir='gen_opt_test\.vim\|gui_.*\|Make_amiga\.mak\|Make_dos\.mak\|Make_ming\.mak\|Make_vms\.mms\|dumps/.*\.dump\|setup_gui\.vim' 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\|gui.*\|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.*\|channel.*\|crypt\.vim\|gui.*\|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/\<test_\%('"${na_src_testdir}"'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove version.c #7555 - local na_po='version.c' - 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" + 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/\<\%(version\.c\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove some *.po files. #5622 - local na_po='sjiscorr.c\|ja.sjis.po\|ko.po\|pl.cp1250.po\|pl.po\|ru.cp1251.po\|uk.cp1251.po\|zh_CN.cp936.po\|zh_CN.po\|zh_TW.po' + local na_po='sjiscorr\.c\|ja\.sjis\.po\|ko\.po\|pl\.cp1250\.po\|pl\.po\|ru\.cp1251\.po\|uk\.cp1251\.po\|zh_CN\.cp936\.po\|zh_CN\.po\|zh_TW\.po' 2>/dev/null $nvim --cmd 'set dir=/tmp' +'g@^diff --git a/src/po/\<\%('${na_po}'\)\>@norm! d/\v(^diff)|%$
' +w +q "$file" # Remove vimrc_example.vim @@ -232,16 +233,32 @@ preprocess_patch() { LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/userfunc\.c/\1\/eval\/userfunc\.c/g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" + # Rename map.c to mapping.c + LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/map\(\.[ch]\)/\1\/mapping\2/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + # Rename session.c to ex_session.c LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/session\(\.[ch]\)/\1\/ex_session\2/g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" + # Rename highlight.c to highlight_group.c + LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/highlight\(\.[ch]\)/\1\/highlight_group\2/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + + # Rename keymap.h to keycodes.h + LC_ALL=C sed -e 's/\( [ab]\/src\/nvim\)\/keymap\.h/\1\/keycodes.h/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + + # Rename terminal.txt to nvim_terminal_emulator.txt + LC_ALL=C sed -e 's/\( [ab]\/runtime\/doc\)\/terminal\.txt/\1\/nvim_terminal_emulator.txt/g' \ + "$file" > "$file".tmp && mv "$file".tmp "$file" + # Rename test_urls.vim to check_urls.vim - LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls.vim\)@\1/scripts/check\2@g' \ + LC_ALL=C sed -e 's@\( [ab]\)/runtime/doc/test\(_urls\.vim\)@\1/scripts/check\2@g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" # Rename path to check_colors.vim - LC_ALL=C sed -e 's@\( [ab]/runtime\)/colors/\(tools/check_colors.vim\)@\1/\2@g' \ + LC_ALL=C sed -e 's@\( [ab]/runtime\)/colors/\(tools/check_colors\.vim\)@\1/\2@g' \ "$file" > "$file".tmp && mv "$file".tmp "$file" } @@ -329,22 +346,29 @@ stage_patch() { * Do this only for _related_ patches (otherwise it increases the size of the pull request, making it harder to review) - When you are done, try "%s -s" to create the pull request. + When you are done, try "%s -s" to create the pull request, + or "%s -s --draft" to create a draft pull request. See the wiki for more information: * https://github.com/neovim/neovim/wiki/Merging-patches-from-upstream-vim -' "${vim_version}" "${BASENAME}" "${BASENAME}" +' "${vim_version}" "${BASENAME}" "${BASENAME}" "${BASENAME}" return $ret } gh_pr() { - gh pr create --title "$1" --body "$2" + local pr_title + local pr_body + pr_title="$1" + pr_body="$2" + shift 2 + gh pr create --title "${pr_title}" --body "${pr_body}" "$@" } git_hub_pr() { local pr_message pr_message="$(printf '%s\n\n%s\n' "$1" "$2")" - git hub pull new -m "${pr_message}" + shift 2 + git hub pull new -m "${pr_message}" "$@" } submit_pr() { @@ -408,7 +432,7 @@ submit_pr() { fi echo "Creating pull request." - if output="$($submit_fn "$pr_title" "$pr_body" 2>&1)"; then + if output="$($submit_fn "$pr_title" "$pr_body" "$@" 2>&1)"; then msg_ok "$output" else msg_err "$output" @@ -576,13 +600,13 @@ show_vimpatches() { runtime_commits[$commit]=1 done - while read -r vim_commit; do + list_missing_vimpatches 1 "$@" | while read -r vim_commit; do if [[ "${runtime_commits[$vim_commit]-}" ]]; then printf ' • %s (+runtime)\n' "${vim_commit}" else printf ' • %s\n' "${vim_commit}" fi - done <<< "$(list_missing_vimpatches 1 "$@")" + done cat << EOF @@ -799,7 +823,8 @@ while getopts "hlLmMVp:P:g:r:s" opt; do exit 0 ;; s) - submit_pr + shift # remove opt + submit_pr "$@" exit 0 ;; V) diff --git a/scripts/windows.ti b/scripts/windows.ti index 4f4832b786..c3a367e6d4 100644 --- a/scripts/windows.ti +++ b/scripts/windows.ti @@ -34,7 +34,7 @@ conemu|ANIS X3.64 and Xterm 256 colors for ConEmu with libuv, smcup=\E[?1049h, rmir@, rmkx@, rmm@, rs1@, rs2@, setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p6%t;1%;m, - sgr0=\E[0m, smam@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@, + sgr0=\E[0m, smam@, smglr@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@, Cr@, Cs@, Ms@, XM@, kDC3@, kDC4@, kDC5@, kDC6@, kDC7@, kDN@, kDN3@, kDN4@, kDN5@, kDN6@, kDN7@, kEND3@, kEND4@, kEND5@, kEND6@, kEND7@, @@ -57,7 +57,7 @@ vtpcon|ANIS emulation for console virtual terminal sequence with libuv, mc0@, mc4@, mc5@, meml@, memu@, oc@, rmam@, rmcup=\E[?1049l, smcup=\E[?1049h, rmir@, rmkx@, rmm@, rs1@, rs2@, sgr=\E[0%?%p1%p3%|%t;7%;%?%p2%t;4%;%?%p6%t;1%;m, - sgr0=\E[0m, smam@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@, + sgr0=\E[0m, smam@, smglr@, smir@, smkx@, smm@, tbc@, u6@, u7@, u8@, u9@, Cr@, Cs@, Ms@, XM@, kDC3@, kDC4@, kDC5@, kDC6@, kDC7@, kDN@, kDN3@, kDN4@, kDN5@, kDN6@, kDN7@, kEND3@, kEND4@, kEND5@, kEND6@, kEND7@, |