Skip to content

Commit

Permalink
refactor: use newer APIs, fix previous work
Browse files Browse the repository at this point in the history
  • Loading branch information
iguanacucumber committed Oct 24, 2024
1 parent c1e6269 commit 81a0d1c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lua/cmp/utils/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ local M = {}
M.win_set_option = function(window, name, value)
local eventignore = vim.opt.eventignore:get()
vim.opt.eventignore:append('OptionSet')
vim.api.nvim_win_set_option(window, name, value)
if vim.fn.has("nvim-0.10") == 1 then
vim.api.nvim_set_option_value(name, value, { win = window } )
else
vim.api.nvim_win_set_option(window, name, value)
end
vim.opt.eventignore = eventignore
end

Expand Down
4 changes: 2 additions & 2 deletions lua/cmp/view/custom_entries_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ custom_entries_view.open = function(self, offset, entries)
else
vim.api.nvim_buf_set_lines(entries_buf, 0, -1, false, lines)
end
if vim.fn.has('nvim-0.10') then
if vim.fn.has('nvim-0.10') == 1 then
vim.api.nvim_set_option_value('modified', false, { buf = entries_buf })
else
vim.api.nvim_buf_set_option(entries_buf, 'modified', false)
Expand Down Expand Up @@ -311,7 +311,7 @@ custom_entries_view.draw = function(self)
vim.api.nvim_buf_set_lines(entries_buf, topline, botline, false, texts)
end

if vim.fn.has('nvim-0.10') then
if vim.fn.has('nvim-0.10') == 1 then
vim.api.nvim_set_option_value('modified', false, { buf = entries_buf })
else
vim.api.nvim_buf_set_option(entries_buf, 'modified', false)
Expand Down
2 changes: 1 addition & 1 deletion lua/cmp/view/wildmenu_entries_view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ wildmenu_entries_view.draw = function(self)
end

vim.api.nvim_buf_set_lines(entries_buf, 0, 1, false, { table.concat(texts, self:_get_separator()) })
if vim.fn.has('nvim-0.10') then
if vim.fn.has('nvim-0.10') == 1 then
vim.api.nvim_set_option_value('modified', false, { buf = entries_buf })
else
vim.api.nvim_buf_set_option(entries_buf, 'modified', false)
Expand Down

0 comments on commit 81a0d1c

Please sign in to comment.