diff --git a/lua/neoconf/build/annotations.lua b/lua/neoconf/build/annotations.lua index 6ab115d..ab47e00 100644 --- a/lua/neoconf/build/annotations.lua +++ b/lua/neoconf/build/annotations.lua @@ -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) diff --git a/lua/neoconf/build/schemas.lua b/lua/neoconf/build/schemas.lua index f0265c5..1f73c9a 100644 --- a/lua/neoconf/build/schemas.lua +++ b/lua/neoconf/build/schemas.lua @@ -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 @@ -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 diff --git a/lua/neoconf/commands.lua b/lua/neoconf/commands.lua index 6e3c041..71016b0 100644 --- a/lua/neoconf/commands.lua +++ b/lua/neoconf/commands.lua @@ -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 diff --git a/lua/neoconf/plugins/lspconfig.lua b/lua/neoconf/plugins/lspconfig.lua index d81b590..c416674 100644 --- a/lua/neoconf/plugins/lspconfig.lua +++ b/lua/neoconf/plugins/lspconfig.lua @@ -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 }) diff --git a/lua/neoconf/util.lua b/lua/neoconf/util.lua index 954a162..5f7fb81 100644 --- a/lua/neoconf/util.lua +++ b/lua/neoconf/util.lua @@ -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(...) @@ -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 @@ -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) @@ -263,12 +263,12 @@ 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 @@ -276,10 +276,13 @@ 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 diff --git a/lua/neoconf/view.lua b/lua/neoconf/view.lua index a752c4b..38ab387 100644 --- a/lua/neoconf/view.lua +++ b/lua/neoconf/view.lua @@ -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 @@ -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") diff --git a/lua/neoconf/workspace.lua b/lua/neoconf/workspace.lua index c0322a2..662be99 100644 --- a/lua/neoconf/workspace.lua +++ b/lua/neoconf/workspace.lua @@ -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