Compare commits

...

4 Commits

Author SHA1 Message Date
Gregory Anders bb1093fc79
Merge d72a4beebe into c18d7941ef 2024-05-09 16:49:03 +01:00
dundargoc c18d7941ef build: allow sccache as compiler cache
Also enable caching for dependencies.

Closes https://github.com/neovim/neovim/issues/28670
2024-05-09 16:39:45 +02:00
Gregory Anders d72a4beebe Make "default" in maparg dict optional int instead of boolean 2024-04-28 10:22:45 -05:00
Gregory Anders 94c92e8659 feat: add "default" field to maparg() return value
With so many default mappings, plugins are not able to detect if an
existing mapping is one created by the user or one created by Nvim.

Add a "default" field to the dict return value of maparg() that plugins
can use to determine if a mapping is a default mapping provided by Nvim
(which they can safely override).
2024-04-26 13:23:22 -05:00
5 changed files with 31 additions and 6 deletions

View File

@ -50,11 +50,6 @@ file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
set_directory_properties(PROPERTIES
EP_PREFIX "${DEPS_BUILD_DIR}")
find_program(CCACHE_PRG ccache)
if(CCACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CCACHE_PRG})
endif()
if(NOT CI_BUILD)
set(CMAKE_INSTALL_MESSAGE NEVER)
endif()

View File

@ -23,6 +23,12 @@ if(POLICY CMP0092)
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_POLICY_DEFAULT_CMP0092=NEW)
endif()
find_program(CACHE_PRG NAMES ccache sccache)
if(CACHE_PRG)
set(CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND} -E env CCACHE_SLOPPINESS=pch_defines,time_macros ${CACHE_PRG})
list(APPEND DEPS_CMAKE_CACHE_ARGS -DCMAKE_C_COMPILER_LAUNCHER:STRING=${CMAKE_C_COMPILER_LAUNCHER})
endif()
# MAKE_PRG
if(UNIX)
find_program(MAKE_PRG NAMES gmake make)
@ -58,7 +64,8 @@ function(get_externalproject_options name DEPS_IGNORE_SHA)
set(EXTERNALPROJECT_OPTIONS
DOWNLOAD_NO_PROGRESS TRUE
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL})
EXTERNALPROJECT_OPTIONS URL ${${name_allcaps}_URL}
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
if(NOT ${DEPS_IGNORE_SHA})
list(APPEND EXTERNALPROJECT_OPTIONS URL_HASH SHA256=${${name_allcaps}_SHA256})

View File

@ -46,6 +46,7 @@
#include "nvim/lua/treesitter.h"
#include "nvim/macros_defs.h"
#include "nvim/main.h"
#include "nvim/mapping.h"
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/memory_defs.h"
@ -2358,11 +2359,17 @@ void nlua_init_defaults(void)
lua_State *const L = global_lstate;
assert(L);
// All maps created here are marked as default maps.
map_set_default(true);
lua_getglobal(L, "require");
lua_pushstring(L, "vim._defaults");
if (nlua_pcall(L, 1, 0)) {
fprintf(stderr, "%s\n", lua_tostring(L, -1));
}
// All maps created after this function exits are not default maps.
map_set_default(false);
}
/// check lua function exist

View File

@ -132,6 +132,16 @@ static const char e_entries_missing_in_mapset_dict_argument[]
static const char e_illegal_map_mode_string_str[]
= N_("E1276: Illegal map mode string: '%s'");
/// Whether new mappings should be marked as "default". This is modified only in map_set_default().
static bool create_default_maps;
/// Enable or disable creationg of default mappings.
///
/// @param value True if new mappings should be marked as default mappings.
void map_set_default(bool value) {
create_default_maps = value;
}
/// Get the start of the hashed map list for "state" and first character "c".
mapblock_T *get_maphash_list(int state, int c)
{
@ -541,6 +551,8 @@ static void map_add(buf_T *buf, mapblock_T **map_table, mapblock_T **abbr_table,
mp->m_desc = xstrdup(args->desc);
}
mp->m_default = create_default_maps;
// add the new entry in front of the abbrlist or maphash[] list
if (is_abbr) {
mp->m_next = *abbr_table;
@ -2118,6 +2130,9 @@ static Dictionary mapblock_fill_dict(const mapblock_T *const mp, const char *lhs
PUT_C(dict, "mode", CSTR_AS_OBJ(mapmode));
PUT_C(dict, "abbr", INTEGER_OBJ(abbr ? 1 : 0));
PUT_C(dict, "mode_bits", INTEGER_OBJ(mp->m_mode));
if (mp->m_default) {
PUT_C(dict, "default", INTEGER_OBJ(1));
}
return dict;
}

View File

@ -24,4 +24,5 @@ struct mapblock {
sctx_T m_script_ctx; ///< SCTX where map was defined
char *m_desc; ///< description of mapping
bool m_replace_keycodes; ///< replace keycodes in result of expression
bool m_default; ///< true if this is a |default-mapping|
};