aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/shared.lua
diff options
context:
space:
mode:
authorMichael Lingelbach <m.j.lbach@gmail.com>2021-03-07 17:18:32 -0800
committerMichael Lingelbach <m.j.lbach@gmail.com>2021-03-09 20:14:08 -0800
commite4e51c69d740eb7dc4f3bf0479a92ac6442d979a (patch)
tree2c57ee29c483355ba631234a7fd7ea241c8d45dd /runtime/lua/vim/shared.lua
parentc12ea02e0b5d465e2c4b7d8bba028d069bdf7008 (diff)
downloadrneovim-e4e51c69d740eb7dc4f3bf0479a92ac6442d979a.tar.gz
rneovim-e4e51c69d740eb7dc4f3bf0479a92ac6442d979a.tar.bz2
rneovim-e4e51c69d740eb7dc4f3bf0479a92ac6442d979a.zip
lsp: add incremental text synchronization
* Implementation derived from and validated by vim-lsc authored by Nate Bosch
Diffstat (limited to 'runtime/lua/vim/shared.lua')
-rw-r--r--runtime/lua/vim/shared.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/runtime/lua/vim/shared.lua b/runtime/lua/vim/shared.lua
index 998e04f568..0a663628a5 100644
--- a/runtime/lua/vim/shared.lua
+++ b/runtime/lua/vim/shared.lua
@@ -400,6 +400,20 @@ function vim.tbl_count(t)
return count
end
+--- Creates a copy of a table containing only elements from start to end (inclusive)
+---
+--@param list table table
+--@param start integer Start range of slice
+--@param finish integer End range of slice
+--@returns Copy of table sliced from start to finish (inclusive)
+function vim.list_slice(list, start, finish)
+ local new_list = {}
+ for i = start or 1, finish or #list do
+ new_list[#new_list+1] = list[i]
+ end
+ return new_list
+end
+
--- Trim whitespace (Lua pattern "%s") from both sides of a string.
---
--@see https://www.lua.org/pil/20.2.html