})
<
Parameters: ~
• {args} (`table`) Table specifying which matching strategy to use.
Accepted keys are:
• {buf}? (`integer`) Buffer number to use for matching.
Mutually exclusive with {contents}
• {filename}? (`string`) Filename to use for matching. When
{buf} is given, defaults to the filename of the given buffer
number. The file need not actually exist in the filesystem.
When used without {buf} only the name of the file is used
for filetype matching. This may result in failure to detect
the filetype in cases where the filename alone is not enough
to disambiguate the filetype.
• {contents}? (`string[]`) An array of lines representing file
contents to use for matching. Can be used with {filename}.
Mutually exclusive with {buf}.
Return (multiple): ~
(`string?`) If a match was found, the matched filetype.
(`function?`) A function that modifies buffer state when called (for
example, to set some filetype specific buffer variables). The function
accepts a buffer number as its only argument.
==============================================================================
Lua module: vim.keymap *vim.keymap*
vim.keymap.del({modes}, {lhs}, {opts}) *vim.keymap.del()*
Remove an existing mapping. Examples: >lua
vim.keymap.del('n', 'lhs')
vim.keymap.del({'n', 'i', 'v'}, '<leader>w', { buffer = 5 })
<
Parameters: ~
• {modes} (`string|string[]`)
• {lhs} (`string`)
• {opts} (`table?`) A table with the following fields:
• {buffer}? (`integer|boolean`) Remove a mapping from the
given buffer. When `0` or `true`, use the current buffer.
See also: ~
• |vim.keymap.set()|
vim.keymap.set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()*
Defines a |mapping| of |keycodes| to a function or keycodes.
Examples: >lua
-- Map "x" to a Lua function:
vim.keymap.set('n', 'x', function() print("real lua function") end)
-- Map "<leader>x" to multiple modes for the current buffer:
vim.keymap.set({'n', 'v'}, '<leader>x', vim.lsp.buf.references, { buffer = true })
-- Map <Tab> to an expression (|:map-<expr>|):
vim.keymap.set('i', '<Tab>', function()
return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>"
end, { expr = true })
-- Map "[%%" to a <Plug> mapping:
vim.keymap.set('n', '[%%', '<Plug>(MatchitNormalMultiBackward)')
<
Parameters: ~
• {mode} (`string|string[]`) Mode "short-name" (see
|nvim_set_keymap()|), or a list thereof.
• {lhs} (`string`) Left-hand side |{lhs}| of the mapping.
• {rhs} (`string|function`) Right-hand side |{rhs}| of the mapping,
can be a Lua function.
• {opts} (`table?`) Table of |:map-arguments|. Same as
|nvim_set_keymap()| {opts}, except:
• {replace_keycodes} defaults to `true` if "expr" is `true`.
Also accepts:
• {buffer}? (`integer|boolean`) Creates buffer-local mapping,
`0` or `true` for current buffer.
• {remap}? (`boolean`, default: `false`) Make the mapping
recursive. Inverse of {noremap}.
See also: ~
• |nvim_set_keymap()|
• |maparg()|
• |mapcheck()|
• |mapset()|
==============================================================================
Lua module: vim.fs *vim.fs*
*vim.fs.exists()*
Use |uv.fs_stat()| to check a file's type, and whether it exists.
Example: >lua
if vim.uv.fs_stat(file)