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

fix(deprecation): remove use of deprecated API functions #59

Merged
merged 3 commits into from
Jul 6, 2024
Merged
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/neoconf/build/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ function M.get_type(prop)
if vim.tbl_isempty(types) then
types = { "any" }
end
return table.concat(vim.tbl_flatten(types), "|")
return vim.iter(types):flatten():join("|")
end

function M.process_object(name, prop)
Expand Down
4 changes: 2 additions & 2 deletions lua/neoconf/build/schemas.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function M.translate(props, nls_url)
desc = nls[desc:gsub("%%", "")] or desc
if type(desc) == "table" then
local lines = vim.tbl_values(desc)
lines = vim.tbl_flatten(lines)
lines = vim.iter(lines):flatten():totable()
table.sort(lines)
desc = table.concat(lines, "\n\n")
end
Expand Down Expand Up @@ -182,7 +182,7 @@ end
function M.clean()
---@diagnostic disable-next-line: param-type-mismatch
for _, f in pairs(vim.fn.expand("schemas/*.json", false, true)) do
vim.loop.fs_unlink(f)
vim.uv.fs_unlink(f)
end
end

Expand Down
5 changes: 4 additions & 1 deletion lua/neoconf/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ function M.setup()
pattern = Util.file_patterns({ autocmd = true }),
group = group,
callback = function(event)
vim.api.nvim_buf_set_option(event.buf, "filetype", "jsonc")
vim.api.nvim_set_option_value("filetype", "jsonc", {
buf = event.buf,
scope = "local",
})
end,
})
else
Expand Down
2 changes: 1 addition & 1 deletion lua/neoconf/plugins/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ end
function M.on_update(fname)
local is_global = Util.is_global(fname)

local clients = vim.lsp.get_active_clients()
local clients = vim.lsp.get_clients()

for _, client in ipairs(clients) do
local settings_root = require("neoconf.workspace").find_root({ file = client.config.root_dir })
Expand Down
19 changes: 11 additions & 8 deletions lua/neoconf/util.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local Config = require("neoconf.config")

local M = {}

local uv = vim.uv or vim.loop
M.islist = vim.islist or vim.tbl_islist

function M.merge(...)
Expand Down Expand Up @@ -151,7 +151,7 @@ end

function M.fqn(fname)
fname = vim.fn.fnamemodify(fname, ":p")
return vim.loop.fs_realpath(fname) or fname
return uv.fs_realpath(fname) or fname
end

---@param root_dir string
Expand Down Expand Up @@ -187,7 +187,7 @@ function M.try(fn, msg)
end

function M.config_path()
return vim.loop.fs_realpath(vim.fn.stdpath("config"))
return uv.fs_realpath(vim.fn.stdpath("config"))
end

function M.is_nvim_config(path)
Expand Down Expand Up @@ -263,23 +263,26 @@ function M.json_format(obj)
end

function M.mtime(fname)
local stat = vim.loop.fs_stat(fname)
local stat = uv.fs_stat(fname)
return (stat and stat.type) and stat.mtime.sec or 0
end

function M.exists(fname)
local stat = vim.loop.fs_stat(fname)
local stat = uv.fs_stat(fname)
return (stat and stat.type) or false
end

function M.notify(msg, level)
vim.notify(msg, level, {
title = "settings.nvim",
on_open = function(win)
vim.api.nvim_win_set_option(win, "conceallevel", 3)
vim.api.nvim_set_option_value("conceallevel", 3, {
win = win,
scope = "local",
})
local buf = vim.api.nvim_win_get_buf(win)
vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
vim.api.nvim_win_set_option(win, "spell", false)
vim.api.nvim_set_option_value("filetype", "markdown", { buf = buf, scope = "local" })
vim.api.nvim_set_option_value("spell", false, { buf = buf, scope = "local" })
end,
})
end
Expand Down
18 changes: 10 additions & 8 deletions lua/neoconf/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ function M.show(str)

local win = vim.api.nvim_open_win(buf, true, opts)

vim.api.nvim_buf_set_option(buf, "filetype", "markdown")
vim.api.nvim_buf_set_option(buf, "modifiable", false)
vim.api.nvim_buf_set_option(buf, "buftype", "nofile")
vim.api.nvim_buf_set_option(buf, "bufhidden", "wipe")
local buf_scope = { buf = buf, scope = "local" }
vim.api.nvim_set_option_value("filetype", "markdown", buf_scope)
vim.api.nvim_set_option_value("buftype", "nofile", buf_scope)
vim.api.nvim_set_option_value("bufhidden", "wipe", buf_scope)
vim.api.nvim_set_option_value("modifiable", false, buf_scope)

vim.api.nvim_win_set_option(win, "conceallevel", 3)
vim.api.nvim_win_set_option(win, "spell", false)
vim.api.nvim_win_set_option(win, "wrap", true)
local win_scope = { win = win, scope = "local" }
vim.api.nvim_set_option_value("conceallevel", 3, win_scope)
vim.api.nvim_set_option_value("spell", false, win_scope)
vim.api.nvim_set_option_value("wrap", true, win_scope)

local function close()
if vim.api.nvim_buf_is_valid(buf) then
Expand All @@ -59,7 +61,7 @@ function M.show_lsp_settings()
local content = {
"# Lsp Settings\n",
}
local clients = vim.lsp.get_active_clients({ bufnr = vim.api.nvim_get_current_buf() })
local clients = vim.lsp.get_clients({ bufnr = vim.api.nvim_get_current_buf() })
for _, client in ipairs(clients) do
table.insert(content, "## " .. client.name .. "\n")

Expand Down
2 changes: 1 addition & 1 deletion lua/neoconf/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function M.find_root(opts)

-- fallback to lsp root_dir detection if in options
if not root_dir and opts.lsp then
for _, client in ipairs(vim.lsp.get_active_clients({ bufnr = buf })) do
for _, client in ipairs(vim.lsp.get_clients({ bufnr = buf })) do
root_dir = client.config.root_dir
break
end
Expand Down