Skip to content

Commit 7cf8942

Browse files
authored
Prefer vim.api over vim.fn (#8)
1 parent 6f8f4cf commit 7cf8942

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lua/popup/init.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function popup.create(what, vim_options)
3535
if type(what) == 'number' then
3636
bufnr = what
3737
else
38-
bufnr = vim.fn.nvim_create_buf(false, true)
38+
bufnr = vim.api.nvim_create_buf(false, true)
3939
assert(bufnr, "Failed to create buffer")
4040

4141
-- TODO: Handle list of lines
@@ -83,7 +83,7 @@ function popup.create(what, vim_options)
8383
end
8484
end
8585

86-
vim.fn.nvim_buf_set_lines(bufnr, 0, -1, true, what)
86+
vim.api.nvim_buf_set_lines(bufnr, 0, -1, true, what)
8787
end
8888

8989
local option_defaults = {
@@ -190,7 +190,7 @@ function popup.create(what, vim_options)
190190
if should_enter == nil then
191191
should_enter = true
192192
end
193-
win_id = vim.fn.nvim_open_win(bufnr, should_enter, win_opts)
193+
win_id = vim.api.nvim_open_win(bufnr, should_enter, win_opts)
194194
end
195195

196196

@@ -222,11 +222,11 @@ function popup.create(what, vim_options)
222222

223223
-- Buffer Options
224224
if vim_options.cursorline then
225-
vim.fn.nvim_win_set_option(win_id, 'cursorline', true)
225+
vim.api.nvim_win_set_option(win_id, 'cursorline', true)
226226
end
227227

228228
if vim_options.wrap ~= nil then
229-
vim.fn.nvim_win_set_option(win_id, 'wrap', vim_options.wrap)
229+
vim.api.nvim_win_set_option(win_id, 'wrap', vim_options.wrap)
230230
end
231231

232232
-- ===== Not Implemented Options =====

0 commit comments

Comments
 (0)