Skip to content

Commit 9eedba6

Browse files
committed
Remove a few more uses of the vimscript API where Lua API now exists.
1 parent 330f82c commit 9eedba6

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

lua/lean/abbreviations.lua

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ function abbreviations.load()
1313
if _MEMOIZED ~= nil then
1414
return _MEMOIZED
1515
end
16-
local this_file = debug.getinfo(2, 'S').source:sub(2)
17-
local base_directory = vim.fn.fnamemodify(this_file, ':h:h:h')
18-
local path = base_directory .. '/vscode-lean/abbreviations.json'
19-
_MEMOIZED = vim.fn.json_decode(vim.fn.readfile(path))
16+
local this_dir = vim.fs.dirname(debug.getinfo(2, 'S').source:sub(2))
17+
local path = vim.fs.joinpath(this_dir, '../../vscode-lean/abbreviations.json')
18+
local file = io.open(path, 'r')
19+
if not file then
20+
error(('Unable to read abbreviations from %q'):format(path))
21+
end
22+
_MEMOIZED = vim.json.decode(file:read '*a')
23+
file:close()
2024
return _MEMOIZED
2125
end
2226

lua/lean/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function lean.current_search_paths()
201201
.system({ 'lake', 'setup-file', vim.api.nvim_buf_get_name(0) }, { cwd = root })
202202
:wait()
203203
if result.code == 0 then
204-
vim.list_extend(paths, vim.fn.json_decode(result.stdout).paths.srcPath)
204+
vim.list_extend(paths, vim.json.decode(result.stdout).paths.srcPath)
205205
end
206206

207207
return vim

lua/lean/loogle.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function loogle.search(type)
3030
error('Loogle returned status code: ' .. res.status)
3131
end
3232

33-
local body = vim.fn.json_decode(res.body)
33+
local body = vim.json.decode(res.body)
3434
if body.error then
3535
return nil, body.error
3636
end

scripts/minimal_init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ vim.o.display = 'lastline' -- Avoid neovim/neovim#11362
22
vim.o.directory = ''
33
vim.o.shada = ''
44

5-
local __file__ = debug.getinfo(1).source:match '@(.*)$'
6-
local lean_nvim_dir = vim.fn.fnamemodify(__file__, ':p:h:h')
7-
local packpath = lean_nvim_dir .. '/packpath/*'
5+
local this_dir = vim.fs.dirname(debug.getinfo(1, 'S').source:sub(2))
6+
local lean_nvim_dir = vim.fs.dirname(this_dir)
7+
local packpath = vim.fs.joinpath(lean_nvim_dir, 'packpath/*')
88
vim.opt.runtimepath:append(packpath)
99
vim.opt.runtimepath:append(lean_nvim_dir)
1010

@@ -18,7 +18,7 @@ vim.cmd [[
1818

1919
-- plenary forks subprocesses, so enable coverage here when appropriate
2020
if vim.env.LEAN_NVIM_COVERAGE then
21-
local luapath = lean_nvim_dir .. '/luapath'
21+
local luapath = vim.fs.joinpath(lean_nvim_dir, 'luapath')
2222
package.path = package.path
2323
.. ';'
2424
.. luapath

0 commit comments

Comments
 (0)