Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/remove deprecated apis #53

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lua/yaml-companion/context/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ M.setup = function(bufnr, client)
-- remove yamlls from not yaml files
-- https://github.com/towolf/vim-helm/issues/15
if vim.bo[bufnr].buftype ~= "" or vim.bo[bufnr].filetype == "helm" then
vim.diagnostic.disable(bufnr)
vim.diagnostic.enable(false, { bufnr = bufnr })
vim.defer_fn(function()
vim.diagnostic.reset(nil, bufnr)
end, 1000)
Expand Down
4 changes: 3 additions & 1 deletion lua/yaml-companion/lsp/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ local sync_timeout = 5000
---@param bufnr number
---@return vim.lsp.client | nil
M.get_client = function(bufnr)
return vim.lsp.get_active_clients({ name = "yamlls", bufnr = bufnr })[1]
---@diagnostic disable-next-line: deprecated
local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients
return get_clients({ name = "yamlls", bufnr = bufnr })[1]
end

---@param bufnr number
Expand Down
2 changes: 1 addition & 1 deletion lua/yaml-companion/select/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ M.open_ui_select = function()

vim.ui.select(
schemas,
{ format_item = display_schema_item, prompt = "Select YAML Schema" },
{ format_item = display_schema_item, prompt = "Select YAML Schema: " },
select_schema
)
end
Expand Down
12 changes: 8 additions & 4 deletions tests/schema_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ end
local function buf(input, ft, name)
local b = vim.api.nvim_create_buf(false, false)
vim.api.nvim_buf_set_name(b, name)
vim.api.nvim_buf_set_option(b, "filetype", ft)
vim.api.nvim_set_option_value("filetype", ft, { buf = b })
vim.api.nvim_command("buffer " .. b)
vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n"))
return wait_until(function()
local clients = vim.lsp.get_active_clients()
---@diagnostic disable-next-line: deprecated
local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients
local clients = get_clients()
if #clients > 0 then
return true
end
Expand All @@ -40,11 +42,13 @@ describe("user defined schemas:", function()
vim.api.nvim_buf_delete(0, { force = true })
vim.fn.delete("foo.yaml", "rf")
assert(wait_until(function()
local clients = vim.lsp.get_active_clients()
---@diagnostic disable-next-line: deprecated
local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients
local clients = get_clients()
if #clients == 0 then
return true
end
vim.lsp.stop_client(vim.lsp.get_active_clients(), true)
vim.lsp.stop_client(get_clients(), true)
end))
end)

Expand Down
6 changes: 4 additions & 2 deletions tests/yaml-companion_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ end
local function buf(input, ft, name)
local b = vim.api.nvim_create_buf(false, false)
vim.api.nvim_buf_set_name(b, name)
vim.api.nvim_buf_set_option(b, "filetype", ft)
vim.api.nvim_set_option_value("filetype", ft, { buf = b })
vim.api.nvim_command("buffer " .. b)
vim.api.nvim_buf_set_lines(b, 0, -1, true, vim.split(input, "\n"))
return wait_until(function()
local clients = vim.lsp.get_active_clients()
---@diagnostic disable-next-line: deprecated
local get_clients = vim.lsp.get_clients and vim.lsp.get_clients or vim.lsp.get_active_clients
local clients = get_clients()
if #clients > 0 then
return true
end
Expand Down
Loading