diff options
-rw-r--r-- | .github/workflows/ci.yml | 88 | ||||
-rw-r--r-- | runtime/doc/api.txt | 2 | ||||
-rw-r--r-- | runtime/doc/map.txt | 4 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 2 | ||||
-rw-r--r-- | src/nvim/getchar.c | 12 | ||||
-rw-r--r-- | test/functional/api/keymap_spec.lua | 18 |
6 files changed, 51 insertions, 75 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b650c5dd85..c84c9f0bbd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -74,6 +74,11 @@ jobs: - cc: clang runner: macos-11.0 os: osx + - flavor: functionaltest-lua + cc: gcc + runner: ubuntu-20.04 + os: linux + cmake: minimum_required runs-on: ${{ matrix.runner }} timeout-minutes: 45 if: github.event.pull_request.draft == false @@ -92,6 +97,24 @@ jobs: sudo apt-get update sudo apt-get install -y autoconf automake build-essential ccache cmake cpanminus cscope gcc-multilib gdb gettext gperf language-pack-tr libtool-bin locales ninja-build pkg-config python3 python3-pip python3-setuptools unzip valgrind xclip + - name: Install minimum required version of cmake + if: matrix.cmake == 'minimum_required' + env: + CMAKE_URL: 'https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.sh' + CMAKE_VERSION: '3.10.0' + shell: bash + run: | + curl --retry 5 --silent --show-error --fail -o /tmp/cmake-installer.sh "$CMAKE_URL" + mkdir -p "$HOME/.local/bin" /opt/cmake-custom + chmod a+x /tmp/cmake-installer.sh + /tmp/cmake-installer.sh --prefix=/opt/cmake-custom --skip-license + ln -sfn /opt/cmake-custom/bin/cmake "$HOME/.local/bin/cmake" + cmake_version="$(cmake --version | head -1)" + echo "$cmake_version" | grep -qF "cmake version $CMAKE_VERSION" || { + echo "Unexpected CMake version: $cmake_version" + exit 1 + } + - name: Install new clang if: matrix.flavor == 'asan' || matrix.flavor == 'tsan' run: | @@ -152,68 +175,3 @@ jobs: run: powershell ci\build.ps1 env: CONFIGURATION: ${{ matrix.config }} - - functionaltest: - name: ${{ matrix.runner }} ${{ matrix.flavor }} (cc=${{ matrix.cc }}) - strategy: - fail-fast: false - matrix: - include: - - flavor: functionaltest-lua - cc: gcc - runner: ubuntu-20.04 - os: linux - runs-on: ${{ matrix.runner }} - timeout-minutes: 45 - env: - CC: ${{ matrix.cc }} - CI_OS_NAME: ${{ matrix.os }} - steps: - - uses: actions/checkout@v2 - - - name: Setup common environment variables - run: ./.github/workflows/env.sh ${{ matrix.flavor }} - - - name: Install apt packages - run: | - sudo apt-get update - sudo apt-get install -y autoconf automake build-essential ccache cmake cpanminus cscope gcc-multilib gdb gettext gperf language-pack-tr libtool-bin locales ninja-build pkg-config python3 python3-pip python3-setuptools unzip valgrind xclip - - - name: Install minimum required version of cmake - env: - CMAKE_URL: 'https://cmake.org/files/v3.10/cmake-3.10.0-Linux-x86_64.sh' - CMAKE_VERSION: '3.10.0' - shell: bash - run: | - curl --retry 5 --silent --show-error --fail -o /tmp/cmake-installer.sh "$CMAKE_URL" - mkdir -p "$HOME/.local/bin" /opt/cmake-custom - chmod a+x /tmp/cmake-installer.sh - /tmp/cmake-installer.sh --prefix=/opt/cmake-custom --skip-license - ln -sfn /opt/cmake-custom/bin/cmake "$HOME/.local/bin/cmake" - cmake_version="$(cmake --version | head -1)" - echo "$cmake_version" | grep -qF "cmake version $CMAKE_VERSION" || { - echo "Unexpected CMake version: $cmake_version" - exit 1 - } - - - name: Setup interpreter packages - run: | - ./ci/install.sh - - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: | - ${{ env.CACHE_NVIM_DEPS_DIR }} - ~/.ccache - key: ${{ matrix.runner }}-${{ matrix.flavor }}-${{ matrix.cc }}-${{ hashFiles('cmake/*', 'third-party/**', '**/CMakeLists.txt') }}-${{ github.base_ref }} - - - name: Build third-party - run: ./ci/before_script.sh - - - name: Build and test - run: ./ci/script.sh - - - name: Cache dependencies - if: ${{ success() }} - run: ./ci/before_cache.sh diff --git a/runtime/doc/api.txt b/runtime/doc/api.txt index 7a5aeee603..1e1534c31f 100644 --- a/runtime/doc/api.txt +++ b/runtime/doc/api.txt @@ -1584,7 +1584,7 @@ nvim_set_keymap({mode}, {lhs}, {rhs}, {*opts}) *nvim_set_keymap()* {rhs} Right-hand-side |{rhs}| of the mapping. {opts} Optional parameters map. Accepts all |:map-arguments| as keys excluding |<buffer>| but - including |noremap| and "desc". |desc| can be used + including |noremap| and "desc". "desc" can be used to give a description to keymap. When called from Lua, also accepts a "callback" key that takes a Lua function to call when the mapping is executed. diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 2d2795b1ca..358e944261 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -502,7 +502,9 @@ Note: When using mappings for Visual mode, you can use the "'<" mark, which is the start of the last selected Visual area in the current buffer |'<|. The |:filter| command can be used to select what mappings to list. The -pattern is matched against the {lhs} and {rhs} in the raw form. +pattern is matched against the {lhs} and {rhs} in the raw form. If a +description was added using |nvim_set_keymap()| or |nvim_buf_set_keymap()| +then the pattern is also matched against it. *:map-verbose* When 'verbose' is non-zero, listing a key map will also display where it was diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 0c11ea7e6e..11bb1750e4 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1588,7 +1588,7 @@ ArrayOf(Dictionary) nvim_get_keymap(uint64_t channel_id, String mode) /// @param rhs Right-hand-side |{rhs}| of the mapping. /// @param opts Optional parameters map. Accepts all |:map-arguments| /// as keys excluding |<buffer>| but including |noremap| and "desc". -/// |desc| can be used to give a description to keymap. +/// "desc" can be used to give a description to keymap. /// When called from Lua, also accepts a "callback" key that takes /// a Lua function to call when the mapping is executed. /// Values are Booleans. Unknown key is an error. diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 5d8a8ddbfe..6978823f2b 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2679,8 +2679,7 @@ void set_maparg_lhs_rhs(const char_u *orig_lhs, const size_t orig_lhs_len, mapargs->orig_rhs_len = 0; // stores <lua>ref_no<cr> in map_str mapargs->rhs_len = (size_t)vim_snprintf(S_LEN(tmp_buf), "%c%c%c%d\r", K_SPECIAL, - (char_u)KEY2TERMCAP0(K_LUA), KEY2TERMCAP1(K_LUA), - rhs_lua); + (char_u)KS_EXTRA, KE_LUA, rhs_lua); mapargs->rhs = vim_strsave((char_u *)tmp_buf); } @@ -3434,8 +3433,8 @@ static void showmap(mapblock_T *mp, bool local) { size_t len = 1; - if (message_filtered(mp->m_keys) - && mp->m_str != NULL && message_filtered(mp->m_str)) { + if (message_filtered(mp->m_keys) && message_filtered(mp->m_str) + && (mp->m_desc == NULL || message_filtered((char_u *)mp->m_desc))) { return; } @@ -3484,7 +3483,7 @@ static void showmap(mapblock_T *mp, bool local) char msg[100]; snprintf(msg, sizeof(msg), "<Lua function %d>", mp->m_luaref); msg_puts_attr(msg, HL_ATTR(HLF_8)); - } else if (mp->m_str == NULL) { + } else if (mp->m_str[0] == NUL) { msg_puts_attr("<Nop>", HL_ATTR(HLF_8)); } else { // Remove escaping of K_SPECIAL, because "m_str" is in a format to be used @@ -3584,8 +3583,7 @@ int map_to_exists_mode(const char *const rhs, const int mode, const bool abbr) mp = maphash[hash]; } for (; mp; mp = mp->m_next) { - if ((mp->m_mode & mode) - && mp->m_str != NULL && strstr((char *)mp->m_str, rhs) != NULL) { + if ((mp->m_mode & mode) && strstr((char *)mp->m_str, rhs) != NULL) { return true; } } diff --git a/test/functional/api/keymap_spec.lua b/test/functional/api/keymap_spec.lua index 450a76ddac..e49e0b8cc4 100644 --- a/test/functional/api/keymap_spec.lua +++ b/test/functional/api/keymap_spec.lua @@ -877,6 +877,24 @@ describe('nvim_set_keymap, nvim_del_keymap', function() eq("\nn lhs rhs\n map description", helpers.exec_capture("nmap lhs")) end) + + it ('can :filter maps based on description', function() + meths.set_keymap('n', 'asdf1', 'qwert', {desc='do the one thing'}) + meths.set_keymap('n', 'asdf2', 'qwert', {desc='doesnot really do anything'}) + meths.set_keymap('n', 'asdf3', 'qwert', {desc='do the other thing'}) + eq([[ + +n asdf3 qwert + do the other thing +n asdf1 qwert + do the one thing]], + helpers.exec_capture('filter the nmap')) + end) + + it ('shows <nop> as map rhs', function() + meths.set_keymap('n', 'asdf', '<nop>', {}) + eq('\nn asdf <Nop>', helpers.exec_capture('nmap asdf')) + end) end) describe('nvim_buf_set_keymap, nvim_buf_del_keymap', function() |