From 3f16037e45cfd7e66986e938ff2a6ff6165ebbed Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 25 Oct 2025 16:46:25 +0200 Subject: docs: getpos, getregion, lsp --- runtime/doc/lua.txt | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'runtime/doc/lua.txt') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 35c0353fce..4c361f30f3 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -2410,15 +2410,13 @@ vim.filetype.match({args}) *vim.filetype.match()* 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. - (`boolean?`) Return true if a match was found by falling back to a - generic configuration file (i.e., ".conf"). If true, the filetype - should be set with `:setf FALLBACK conf`, which enables a later - |:setf| command to override the filetype. See `:help setf` for more - information. + (`string?`) The matched filetype, if any. + (`function?`) A function `fun(buf: integer)` that modifies buffer + state when called (for example, to set some filetype specific buffer + variables). + (`boolean?`) true if a match was found by falling back to a generic + filetype (i.e., ".conf"), which indicates the filetype should be set + with `:setf FALLBACK conf`. See |:setfiletype|. ============================================================================== @@ -2434,6 +2432,13 @@ Example: >lua end < + *vim.fs.read()* +You can use |readblob()| to get a file's contents without explicitly opening/closing it. + +Example: >lua + vim.print(vim.fn.readblob('.git/config')) +< + vim.fs.abspath({path}) *vim.fs.abspath()* Convert path to an absolute path. A tilde (~) character at the beginning @@ -3438,6 +3443,18 @@ vim.keymap.set({mode}, {lhs}, {rhs}, {opts}) *vim.keymap.set()* end, { expr = true }) -- Map "[%%" to a mapping: vim.keymap.set('n', '[%%', '(MatchitNormalMultiBackward)') + + -- Use `getregionpos(getpos('v'))` to get the "current visual selection": + vim.keymap.set('x', 'M', function() + local region = vim.fn.getregionpos(vim.fn.getpos('v'), vim.fn.getpos('.'), { + type = 'v', + exclusive = false, + eol = false, + }) + local line1 = region[1][1][2] + local line2 = region[#region][1][2] + vim.print({ line1, line2 }) + end) < Parameters: ~ -- cgit