Skip to main content
Module

x/ddc_vim/deps.ts>fn.mapcheck

Dark deno-powered completion framework for neovim/Vim
Latest
function fn.mapcheck
import { fn } from "https://deno.land/x/ddc_vim@v4.3.1/deps.ts";
const { mapcheck } = fn;

Check if there is a mapping that matches with {name} in mode {mode}. See maparg() for {mode} and special names in {name}. When {abbr} is there and it is TRUE use abbreviations instead of mappings. A match happens with a mapping that starts with {name} and with a mapping which is equal to the start of {name}.

    matches mapping "a"     "ab"    "abc"

mapcheck("a") yes yes yes mapcheck("abc") yes yes yes mapcheck("ax") yes no no mapcheck("b") no no no

The difference with maparg() is that mapcheck() finds a mapping that matches with {name}, while maparg() only finds a mapping for {name} exactly. When there is no mapping that starts with {name}, an empty String is returned. If there is one, the RHS of that mapping is returned. If there are several mappings that start with {name}, the RHS of one of them is returned. This will be "<Nop>" if the RHS is empty. The mappings local to the current buffer are checked first, then the global mappings. This function can be used to check if a mapping can be added without being ambiguous. Example:

:if mapcheck("_vv") == ""
:   map _vv :set guifont=7x13<CR>
:endif

This avoids adding the "_vv" mapping when there already is a mapping for "_v" or for "_vvv".

Can also be used as a method:

GetKey()->mapcheck('n')

Parameters

denops: Denops
name: unknown
optional
mode: unknown
optional
abbr: unknown

Returns

Promise<string>