aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/actions/cache/action.yml2
-rw-r--r--.github/workflows/build.yml43
-rw-r--r--.github/workflows/test.yml63
-rw-r--r--src/nvim/eval.c79
-rw-r--r--src/nvim/lua/stdlib.c2
-rw-r--r--src/nvim/runtime.c82
6 files changed, 136 insertions, 135 deletions
diff --git a/.github/actions/cache/action.yml b/.github/actions/cache/action.yml
index da36c71a1d..07f8feaa84 100644
--- a/.github/actions/cache/action.yml
+++ b/.github/actions/cache/action.yml
@@ -16,7 +16,7 @@ runs:
# files to search through.
- uses: actions/cache@v3
with:
- path: ${{ env.DEPS_BUILD_DIR }}
+ path: .deps
key: ${{ env.CACHE_KEY }}-${{ hashFiles('cmake**', 'ci/**',
'.github/workflows/test.yml', 'CMakeLists.txt',
'runtime/CMakeLists.txt', 'src/nvim/**/CMakeLists.txt') }}
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 10e3e2bdeb..fa1f74e4d1 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -71,46 +71,3 @@ jobs:
- name: Install
run: make install
-
- with-external-deps:
- runs-on: ubuntu-22.04
- timeout-minutes: 10
- steps:
- - uses: actions/checkout@v3
-
- - name: Install dependencies
- run: |
- sudo add-apt-repository ppa:neovim-ppa/stable
- ./.github/scripts/install_deps.sh
- sudo apt-get install -y \
- libluajit-5.1-dev \
- libmsgpack-dev \
- libtermkey-dev \
- libtree-sitter-dev \
- libunibilium-dev \
- libuv1-dev \
- lua-busted \
- lua-filesystem \
- lua-inspect \
- lua-lpeg \
- lua-nvim \
- luajit
- # libvterm-dev \
- # lua-luv-dev
-
- # Remove comments from packages once we start using these external
- # dependencies.
-
- - name: Build third-party deps
- run: |
- # Ideally all dependencies should external for this job, but some
- # dependencies don't have the required version available. We use the
- # bundled versions for these with the hopes of being able to remove them
- # later on.
- cmake -S cmake.deps -B .deps -G Ninja -D USE_BUNDLED=OFF -D USE_BUNDLED_LUV=ON -D USE_BUNDLED_LIBVTERM=ON
- cmake --build .deps
-
- - name: Build
- run: |
- cmake -B build -G Ninja
- cmake --build build
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 22be9bf719..e6ff09d351 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -19,7 +19,6 @@ env:
ASAN_OPTIONS: detect_leaks=1:check_initialization_order=1:handle_abort=1:handle_sigill=1:log_path=${{ github.workspace }}/build/log/asan:intercept_tls_get_addr=0
BIN_DIR: ${{ github.workspace }}/bin
BUILD_DIR: ${{ github.workspace }}/build
- DEPS_BUILD_DIR: ${{ github.workspace }}/nvim-deps
INSTALL_PREFIX: ${{ github.workspace }}/nvim-install
LOG_DIR: ${{ github.workspace }}/build/log
NVIM_LOG_FILE: ${{ github.workspace }}/build/.nvimlog
@@ -72,8 +71,8 @@ jobs:
- name: Build third-party deps
run: |
- cmake -S cmake.deps -B $DEPS_BUILD_DIR -G Ninja
- cmake --build $DEPS_BUILD_DIR
+ cmake -S cmake.deps -B .deps -G Ninja
+ cmake --build .deps
- if: success() || failure() && steps.abort_job.outputs.status == 'success'
name: configure
@@ -193,8 +192,8 @@ jobs:
- name: Build third-party deps
run: |
- cmake -S cmake.deps -B $DEPS_BUILD_DIR -G Ninja ${{ matrix.deps_flags }}
- cmake --build $DEPS_BUILD_DIR
+ cmake -S cmake.deps -B .deps -G Ninja ${{ matrix.deps_flags }}
+ cmake --build .deps
- name: Build
run: |
@@ -273,8 +272,8 @@ jobs:
- name: Build third-party deps
run: |
- cmake -S cmake.deps -B $DEPS_BUILD_DIR -G "Ninja Multi-Config"
- cmake --build $DEPS_BUILD_DIR
+ cmake -S cmake.deps -B .deps -G "Ninja Multi-Config"
+ cmake --build .deps
- name: Configure
run: cmake -B build -G "Ninja Multi-Config" -D CMAKE_C_COMPILER=gcc
@@ -309,8 +308,8 @@ jobs:
- name: Build deps
run: |
- cmake -S cmake.deps -B $env:DEPS_BUILD_DIR -G Ninja -D CMAKE_BUILD_TYPE='RelWithDebInfo'
- cmake --build $env:DEPS_BUILD_DIR
+ cmake -S cmake.deps -B .deps -G Ninja -D CMAKE_BUILD_TYPE='RelWithDebInfo'
+ cmake --build .deps
- name: Build
run: |
@@ -330,9 +329,6 @@ jobs:
# Sanity check
python -c "import pynvim; print(str(pynvim))"
- gem.cmd install --pre neovim
- Get-Command -CommandType Application neovim-ruby-host.bat
-
node --version
npm.cmd --version
@@ -360,3 +356,46 @@ jobs:
$env:PATH = "C:\msys64\usr\bin;$env:PATH"
& "C:\msys64\mingw64\bin\mingw32-make.exe" -C $(Convert-Path test\old\testdir) VERBOSE=1
$env:PATH = $OldPath
+
+ with-external-deps:
+ runs-on: ubuntu-22.04
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v3
+
+ - name: Install dependencies
+ run: |
+ sudo add-apt-repository ppa:neovim-ppa/stable
+ ./.github/scripts/install_deps.sh
+ sudo apt-get install -y \
+ libluajit-5.1-dev \
+ libmsgpack-dev \
+ libtermkey-dev \
+ libtree-sitter-dev \
+ libunibilium-dev \
+ libuv1-dev \
+ lua-filesystem \
+ lua-lpeg \
+ lua-mpack \
+ luajit
+ # libvterm-dev \
+ # lua-luv-dev
+
+ # Remove comments from packages once we start using these external
+ # dependencies.
+
+ - uses: ./.github/actions/cache
+
+ - name: Build third-party deps
+ run: |
+ # Ideally all dependencies should external for this job, but some
+ # dependencies don't have the required version available. We use the
+ # bundled versions for these with the hopes of being able to remove them
+ # later on.
+ cmake -S cmake.deps -B .deps -G Ninja -D USE_BUNDLED=OFF -D USE_BUNDLED_LUV=ON -D USE_BUNDLED_LIBVTERM=ON
+ cmake --build .deps
+
+ - name: Build
+ run: |
+ cmake -B build -G Ninja
+ cmake --build build
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 9b42375120..384e088bcf 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -114,9 +114,6 @@ bool *eval_lavars_used = NULL;
static int echo_attr = 0; // attributes used for ":echo"
-// The names of packages that once were loaded are remembered.
-static garray_T ga_loaded = { 0, 0, sizeof(char *), 4, NULL };
-
/// Info used by a ":for" loop.
typedef struct {
int fi_semicolon; // true if ending in '; var]'
@@ -503,7 +500,7 @@ void eval_clear(void)
# endif
// autoloaded script names
- ga_clear_strings(&ga_loaded);
+ free_autoload_scriptnames();
// unreferenced lists and dicts
(void)garbage_collect(false);
@@ -7530,80 +7527,6 @@ const char *find_option_end(const char **const arg, int *const scope)
return p;
}
-/// Return the autoload script name for a function or variable name
-/// Caller must make sure that "name" contains AUTOLOAD_CHAR.
-///
-/// @param[in] name Variable/function name.
-/// @param[in] name_len Name length.
-///
-/// @return [allocated] autoload script name.
-char *autoload_name(const char *const name, const size_t name_len)
- FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT
-{
- // Get the script file name: replace '#' with '/', append ".vim".
- char *const scriptname = xmalloc(name_len + sizeof("autoload/.vim"));
- memcpy(scriptname, "autoload/", sizeof("autoload/") - 1);
- memcpy(scriptname + sizeof("autoload/") - 1, name, name_len);
- size_t auchar_idx = 0;
- for (size_t i = sizeof("autoload/") - 1;
- i - sizeof("autoload/") + 1 < name_len;
- i++) {
- if (scriptname[i] == AUTOLOAD_CHAR) {
- scriptname[i] = '/';
- auchar_idx = i;
- }
- }
- memcpy(scriptname + auchar_idx, ".vim", sizeof(".vim"));
-
- return scriptname;
-}
-
-/// If name has a package name try autoloading the script for it
-///
-/// @param[in] name Variable/function name.
-/// @param[in] name_len Name length.
-/// @param[in] reload If true, load script again when already loaded.
-///
-/// @return true if a package was loaded.
-bool script_autoload(const char *const name, const size_t name_len, const bool reload)
-{
- // If there is no '#' after name[0] there is no package name.
- const char *p = memchr(name, AUTOLOAD_CHAR, name_len);
- if (p == NULL || p == name) {
- return false;
- }
-
- bool ret = false;
- char *tofree = autoload_name(name, name_len);
- char *scriptname = tofree;
-
- // Find the name in the list of previously loaded package names. Skip
- // "autoload/", it's always the same.
- int i = 0;
- for (; i < ga_loaded.ga_len; i++) {
- if (strcmp(((char **)ga_loaded.ga_data)[i] + 9, scriptname + 9) == 0) {
- break;
- }
- }
- if (!reload && i < ga_loaded.ga_len) {
- ret = false; // Was loaded already.
- } else {
- // Remember the name if it wasn't loaded already.
- if (i == ga_loaded.ga_len) {
- GA_APPEND(char *, &ga_loaded, scriptname);
- tofree = NULL;
- }
-
- // Try loading the package from $VIMRUNTIME/autoload/<name>.vim
- if (source_runtime(scriptname, 0) == OK) {
- ret = true;
- }
- }
-
- xfree(tofree);
- return ret;
-}
-
static var_flavour_T var_flavour(char *varname)
FUNC_ATTR_PURE
{
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c
index b6e56c35d6..852e10c8d8 100644
--- a/src/nvim/lua/stdlib.c
+++ b/src/nvim/lua/stdlib.c
@@ -22,7 +22,6 @@
#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer_defs.h"
-#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
#include "nvim/ex_eval.h"
@@ -38,6 +37,7 @@
#include "nvim/memory.h"
#include "nvim/pos.h"
#include "nvim/regexp.h"
+#include "nvim/runtime.h"
#include "nvim/types.h"
#include "nvim/vim.h"
diff --git a/src/nvim/runtime.c b/src/nvim/runtime.c
index 3326f4e096..c316b61082 100644
--- a/src/nvim/runtime.c
+++ b/src/nvim/runtime.c
@@ -75,6 +75,9 @@ struct source_cookie {
garray_T exestack = { 0, 0, sizeof(estack_T), 50, NULL };
garray_T script_items = { 0, 0, sizeof(scriptitem_T *), 20, NULL };
+/// The names of packages that once were loaded are remembered.
+static garray_T ga_loaded = { 0, 0, sizeof(char *), 4, NULL };
+
/// Initialize the execution stack.
void estack_init(void)
{
@@ -2339,6 +2342,11 @@ void free_scriptnames(void)
}
#endif
+void free_autoload_scriptnames(void)
+{
+ ga_clear_strings(&ga_loaded);
+}
+
linenr_T get_sourced_lnum(LineGetter fgetline, void *cookie)
FUNC_ATTR_PURE
{
@@ -2630,3 +2638,77 @@ bool source_finished(LineGetter fgetline, void *cookie)
return getline_equal(fgetline, cookie, getsourceline)
&& ((struct source_cookie *)getline_cookie(fgetline, cookie))->finished;
}
+
+/// Return the autoload script name for a function or variable name
+/// Caller must make sure that "name" contains AUTOLOAD_CHAR.
+///
+/// @param[in] name Variable/function name.
+/// @param[in] name_len Name length.
+///
+/// @return [allocated] autoload script name.
+char *autoload_name(const char *const name, const size_t name_len)
+ FUNC_ATTR_MALLOC FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ // Get the script file name: replace '#' with '/', append ".vim".
+ char *const scriptname = xmalloc(name_len + sizeof("autoload/.vim"));
+ memcpy(scriptname, "autoload/", sizeof("autoload/") - 1);
+ memcpy(scriptname + sizeof("autoload/") - 1, name, name_len);
+ size_t auchar_idx = 0;
+ for (size_t i = sizeof("autoload/") - 1;
+ i - sizeof("autoload/") + 1 < name_len;
+ i++) {
+ if (scriptname[i] == AUTOLOAD_CHAR) {
+ scriptname[i] = '/';
+ auchar_idx = i;
+ }
+ }
+ memcpy(scriptname + auchar_idx, ".vim", sizeof(".vim"));
+
+ return scriptname;
+}
+
+/// If name has a package name try autoloading the script for it
+///
+/// @param[in] name Variable/function name.
+/// @param[in] name_len Name length.
+/// @param[in] reload If true, load script again when already loaded.
+///
+/// @return true if a package was loaded.
+bool script_autoload(const char *const name, const size_t name_len, const bool reload)
+{
+ // If there is no '#' after name[0] there is no package name.
+ const char *p = memchr(name, AUTOLOAD_CHAR, name_len);
+ if (p == NULL || p == name) {
+ return false;
+ }
+
+ bool ret = false;
+ char *tofree = autoload_name(name, name_len);
+ char *scriptname = tofree;
+
+ // Find the name in the list of previously loaded package names. Skip
+ // "autoload/", it's always the same.
+ int i = 0;
+ for (; i < ga_loaded.ga_len; i++) {
+ if (strcmp(((char **)ga_loaded.ga_data)[i] + 9, scriptname + 9) == 0) {
+ break;
+ }
+ }
+ if (!reload && i < ga_loaded.ga_len) {
+ ret = false; // Was loaded already.
+ } else {
+ // Remember the name if it wasn't loaded already.
+ if (i == ga_loaded.ga_len) {
+ GA_APPEND(char *, &ga_loaded, scriptname);
+ tofree = NULL;
+ }
+
+ // Try loading the package from $VIMRUNTIME/autoload/<name>.vim
+ if (source_runtime(scriptname, 0) == OK) {
+ ret = true;
+ }
+ }
+
+ xfree(tofree);
+ return ret;
+}