aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2020-01-12 23:41:55 -0800
committerGitHub <noreply@github.com>2020-01-12 23:41:55 -0800
commit92316849863bb2661ee5b4bb284f56163fed27ad (patch)
tree92b6f7d210c3dcca462b4ba48923dd65f61416ed /runtime/lua
parentdfb676fe0d64c708c0c334b09c947db1bae4736d (diff)
downloadrneovim-92316849863bb2661ee5b4bb284f56163fed27ad.tar.gz
rneovim-92316849863bb2661ee5b4bb284f56163fed27ad.tar.bz2
rneovim-92316849863bb2661ee5b4bb284f56163fed27ad.zip
doc [ci skip] #11656
Diffstat (limited to 'runtime/lua')
-rw-r--r--runtime/lua/vim/lsp.lua15
-rw-r--r--runtime/lua/vim/shared.lua20
2 files changed, 23 insertions, 12 deletions
diff --git a/runtime/lua/vim/lsp.lua b/runtime/lua/vim/lsp.lua
index c193fad6a4..cfa208f21c 100644
--- a/runtime/lua/vim/lsp.lua
+++ b/runtime/lua/vim/lsp.lua
@@ -914,7 +914,18 @@ function lsp.buf_notify(bufnr, method, params)
end)
end
---- Function which can be called to generate omnifunc compatible completion.
+--- Implements 'omnifunc' compatible LSP completion.
+---
+--@see |complete-functions|
+--@see |complete-items|
+--@see |CompleteDone|
+---
+--@param findstart 0 or 1, decides behavior
+--@param base If findstart=0, text to match against
+---
+--@return (number) Decided by `findstart`:
+--- - findstart=0: column where the completion starts, or -2 or -3
+--- - findstart=1: list of matches (actually just calls |complete()|)
function lsp.omnifunc(findstart, base)
local _ = log.debug() and log.debug("omnifunc.findstart", { findstart = findstart, base = base })
@@ -936,7 +947,7 @@ function lsp.omnifunc(findstart, base)
local line_to_cursor = line:sub(1, pos[2])
local _ = log.trace() and log.trace("omnifunc.line", pos, line)
- -- Get the start postion of the current keyword
+ -- Get the start position of the current keyword
local textMatch = vim.fn.match(line_to_cursor, '\\k*$')
local params = util.make_position_params()
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 6df9bf1c2f..a71e9878bb 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -331,21 +331,21 @@ function vim.pesc(s)
return s:gsub('[%(%)%.%%%+%-%*%?%[%]%^%$]', '%%%1')
end
---- Test if `prefix` is a prefix of `s` for strings.
---
--- @param s String to check
--- @param prefix Potential prefix
--- @return boolean True if prefix is a prefix of s
+--- Tests if `s` starts with `prefix`.
+---
+--@param s (string) a string
+--@param prefix (string) a prefix
+--@return (boolean) true if `prefix` is a prefix of s
function vim.startswith(s, prefix)
vim.validate { s = {s, 's'}; prefix = {prefix, 's'}; }
return s:sub(1, #prefix) == prefix
end
---- Test if `suffix` is a suffix of `s` for strings.
---
--- @param s String to check
--- @param suffix Potential suffix
--- @return boolean True if suffix is a suffix of s
+--- Tests if `s` ends with `suffix`.
+---
+--@param s (string) a string
+--@param suffix (string) a suffix
+--@return (boolean) true if `suffix` is a suffix of s
function vim.endswith(s, suffix)
vim.validate { s = {s, 's'}; suffix = {suffix, 's'}; }
return #suffix == 0 or s:sub(-#suffix) == suffix