aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/vim.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-05-26 00:17:36 +0300
committerZyX <kp-pav@yandex.ru>2017-05-28 23:55:51 +0300
commita409fa2b3f821a40a01d3919cd93384b1403156f (patch)
treecab3a8f59abd9f2fe733b1e0169d2de1451c2f29 /src/nvim/lua/vim.lua
parent58f6ef50a86b968b923dfcf5efffacb665fdfa44 (diff)
downloadrneovim-a409fa2b3f821a40a01d3919cd93384b1403156f.tar.gz
rneovim-a409fa2b3f821a40a01d3919cd93384b1403156f.tar.bz2
rneovim-a409fa2b3f821a40a01d3919cd93384b1403156f.zip
lua: Use automatic determining of suffixes only for package.cpath
Diffstat (limited to 'src/nvim/lua/vim.lua')
-rw-r--r--src/nvim/lua/vim.lua23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/nvim/lua/vim.lua b/src/nvim/lua/vim.lua
index 736182de11..c7952520b0 100644
--- a/src/nvim/lua/vim.lua
+++ b/src/nvim/lua/vim.lua
@@ -9,7 +9,6 @@ local function _update_package_paths()
local sep = package.config:sub(1, 1)
for _, key in ipairs({'path', 'cpath'}) do
local orig_str = package[key] .. ';'
- local pathtrails = {}
local pathtrails_ordered = {}
local orig = {}
-- Note: ignores trailing item without trailing `;`. Not using something
@@ -17,13 +16,21 @@ local function _update_package_paths()
for s in orig_str:gmatch('[^;]*;') do
s = s:sub(1, -2) -- Strip trailing semicolon
orig[#orig + 1] = s
- -- Find out path patterns. pathtrail should contain something like
- -- /?.so, /?/init.lua, /?.lua. This allows not to bother determining what
- -- correct suffixes are.
- local pathtrail = s:match('[/\\][^/\\]*%?.*$')
- if pathtrail and not pathtrails[pathtrail] then
- pathtrails[pathtrail] = true
- pathtrails_ordered[#pathtrails_ordered + 1] = pathtrail
+ end
+ if key == 'path' then
+ -- /?.lua and /?/init.lua
+ pathtrails_ordered = {sep .. '?.lua', sep .. '?' .. sep .. 'init.lua'}
+ else
+ local pathtrails = {}
+ for _, s in ipairs(orig) do
+ -- Find out path patterns. pathtrail should contain something like
+ -- /?.so, \?.dll. This allows not to bother determining what correct
+ -- suffixes are.
+ local pathtrail = s:match('[/\\][^/\\]*%?.*$')
+ if pathtrail and not pathtrails[pathtrail] then
+ pathtrails[pathtrail] = true
+ pathtrails_ordered[#pathtrails_ordered + 1] = pathtrail
+ end
end
end
local new = {}