diff --git a/init.lua b/init.lua index dfed48e..6fe389b 100644 --- a/init.lua +++ b/init.lua @@ -1,6 +1,6 @@ vim.loader.enable() -local log = require("ow.log") +local log = require("log") local files = { "globals", @@ -10,7 +10,7 @@ local files = { } for _, file in ipairs(files) do - local pkg = "ow.core." .. file + local pkg = "core." .. file local ok, err = pcall(require, pkg) if not ok then log.error("Error while loading package " .. pkg) @@ -19,7 +19,7 @@ for _, file in ipairs(files) do end end -local ok, err = pcall(require, "ow.bootstrap") +local ok, err = pcall(require, "bootstrap") if not ok then log.error("Error during bootstrap") log.error(err:gsub("\t", " ")) @@ -60,4 +60,4 @@ local opts = { }, } -require("lazy").setup("ow.plugins", opts) +require("lazy").setup("plugins", opts) diff --git a/lua/ow/bootstrap.lua b/lua/bootstrap.lua similarity index 96% rename from lua/ow/bootstrap.lua rename to lua/bootstrap.lua index 133f358..3761385 100644 --- a/lua/ow/bootstrap.lua +++ b/lua/bootstrap.lua @@ -8,7 +8,7 @@ if version.major == 0 then end end -local util = require("ow.util") +local util = require("util") -- Install lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" diff --git a/lua/ow/core/autocommands.lua b/lua/core/autocommands.lua similarity index 100% rename from lua/ow/core/autocommands.lua rename to lua/core/autocommands.lua diff --git a/lua/ow/core/globals.lua b/lua/core/globals.lua similarity index 100% rename from lua/ow/core/globals.lua rename to lua/core/globals.lua diff --git a/lua/ow/core/mappings.lua b/lua/core/mappings.lua similarity index 100% rename from lua/ow/core/mappings.lua rename to lua/core/mappings.lua diff --git a/lua/ow/core/options.lua b/lua/core/options.lua similarity index 100% rename from lua/ow/core/options.lua rename to lua/core/options.lua diff --git a/lua/ow/dap/hover.lua b/lua/dap/hover.lua similarity index 95% rename from lua/ow/dap/hover.lua rename to lua/dap/hover.lua index 184481b..9a01a86 100644 --- a/lua/ow/dap/hover.lua +++ b/lua/dap/hover.lua @@ -1,7 +1,7 @@ -local Item = require("ow.dap.item") -local Node = require("ow.dap.hover.node") -local Window = require("ow.dap.hover.window") -local log = require("ow.log") +local Item = require("dap.item") +local Node = require("dap.hover.node") +local Window = require("dap.hover.window") +local log = require("log") ---@async local function hover_async() diff --git a/lua/ow/dap/hover/content.lua b/lua/dap/hover/content.lua similarity index 100% rename from lua/ow/dap/hover/content.lua rename to lua/dap/hover/content.lua diff --git a/lua/ow/dap/hover/node.lua b/lua/dap/hover/node.lua similarity index 98% rename from lua/ow/dap/hover/node.lua rename to lua/dap/hover/node.lua index 37fcf56..73e5821 100644 --- a/lua/ow/dap/hover/node.lua +++ b/lua/dap/hover/node.lua @@ -1,5 +1,5 @@ -local Item = require("ow.dap.item") -local log = require("ow.log") +local Item = require("dap.item") +local log = require("log") ---@class ow.dap.hover.Node ---@field lang string diff --git a/lua/ow/dap/hover/window.lua b/lua/dap/hover/window.lua similarity index 98% rename from lua/ow/dap/hover/window.lua rename to lua/dap/hover/window.lua index 95b13f3..b9de58f 100644 --- a/lua/ow/dap/hover/window.lua +++ b/lua/dap/hover/window.lua @@ -1,5 +1,5 @@ -local Content = require("ow.dap.hover.content") -local log = require("ow.log") +local Content = require("dap.hover.content") +local log = require("log") ---@class ow.dap.hover.Window ---@field NAMESPACE string @@ -14,7 +14,7 @@ local log = require("ow.log") local Window = {} Window.__index = Window -Window.NAMESPACE = "ow.dap.hover.Window" +Window.NAMESPACE = "dap.hover.Window" Window.NS_ID = vim.api.nvim_create_namespace(Window.NAMESPACE) local function setup_highlights() diff --git a/lua/ow/dap/item.lua b/lua/dap/item.lua similarity index 84% rename from lua/ow/dap/item.lua rename to lua/dap/item.lua index 8e7cd5f..09b044d 100644 --- a/lua/ow/dap/item.lua +++ b/lua/dap/item.lua @@ -23,12 +23,7 @@ end ---@param var dap.Variable ---@return ow.dap.Item function Item.from_var(var) - return Item.new( - var.name, - var.type, - var.value, - var.variablesReference - ) + return Item.new(var.name, var.type, var.value, var.variablesReference) end return Item diff --git a/lua/ow/log.lua b/lua/log.lua similarity index 100% rename from lua/ow/log.lua rename to lua/log.lua diff --git a/lua/ow/lsp.lua b/lua/lsp.lua similarity index 97% rename from lua/ow/lsp.lua rename to lua/lsp.lua index 91f7953..6d5df9e 100644 --- a/lua/ow/lsp.lua +++ b/lua/lsp.lua @@ -1,10 +1,10 @@ ---@type fun(name: string, cfg: vim.lsp.Config) vim.lsp.config = vim.lsp.config -local keymap = require("ow.lsp.keymap") -local linter = require("ow.lsp.linter") -local log = require("ow.log") -local util = require("ow.util") +local Keymap = require("lsp.keymap") +local Linter = require("lsp.linter") +local log = require("log") +local util = require("util") local M = {} @@ -27,7 +27,7 @@ function M.with_defaults(server, fn) default_cb(client, bufnr) end - keymap.set_defaults(bufnr) + Keymap.set_defaults(bufnr) -- For document highlight vim.cmd.highlight({ "link LspReferenceRead Visual", bang = true }) @@ -134,7 +134,7 @@ function M.setup() "zsh", }, on_attach = M.with_defaults("bashls", function(_, bufnr) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "lf", @@ -164,7 +164,7 @@ function M.setup() }, single_file_support = true, on_attach = M.with_defaults("clangd", function(_, bufnr) - linter.add(bufnr, { + Linter.add(bufnr, { cmd = { "clang-tidy", "-p=build", @@ -191,7 +191,7 @@ function M.setup() zero_idx_lnum = true, ignore_stderr = true, }) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "gs", @@ -215,7 +215,7 @@ function M.setup() }, }, on_attach = M.with_defaults("gopls", function(_, bufnr) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "lf", @@ -249,7 +249,7 @@ function M.setup() }, }, on_attach = M.with_defaults("intelephense", function(_, bufnr) - linter.add(bufnr, { + Linter.add(bufnr, { cmd = { "phpcs", "--standard=PSR12", @@ -271,7 +271,7 @@ function M.setup() zero_idx_lnum = true, }) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "lf", @@ -364,7 +364,7 @@ function M.setup() }, }, on_attach = M.with_defaults("lua_ls", function(_, bufnr) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "lf", @@ -425,7 +425,7 @@ function M.setup() vim.lsp.config("ruff", { on_attach = M.with_defaults("ruff", function(_, bufnr) - keymap.set(bufnr, { + Keymap.set(bufnr, { { mode = "n", lhs = "lf", diff --git a/lua/ow/lsp/keymap.lua b/lua/lsp/keymap.lua similarity index 92% rename from lua/ow/lsp/keymap.lua rename to lua/lsp/keymap.lua index 5fa6d3c..e857105 100644 --- a/lua/ow/lsp/keymap.lua +++ b/lua/lsp/keymap.lua @@ -1,16 +1,16 @@ -local util = require("ow.util") +local util = require("util") ----@class Keymap +---@class ow.lsp.Keymap ---@field mode string|string[] ---@field lhs string ---@field rhs string|function ---@field opts? vim.keymap.set.Opts -local M = {} +local Keymap = {} ---@param bufnr integer ----@param keymaps Keymap[] -function M.set(bufnr, keymaps) +---@param keymaps ow.lsp.Keymap[] +function Keymap.set(bufnr, keymaps) for _, keymap in ipairs(keymaps) do keymap.opts = vim.tbl_extend( "force", @@ -22,8 +22,8 @@ function M.set(bufnr, keymaps) end ---@param bufnr integer -function M.set_defaults(bufnr) - ---@type Keymap[] +function Keymap.set_defaults(bufnr) + ---@type ow.lsp.Keymap[] local keymaps = { { mode = { "n" }, lhs = "df", rhs = vim.diagnostic.open_float }, { @@ -105,7 +105,7 @@ function M.set_defaults(bufnr) }) end - M.set(bufnr, keymaps) + Keymap.set(bufnr, keymaps) end -return M +return Keymap diff --git a/lua/ow/lsp/linter.lua b/lua/lsp/linter.lua similarity index 90% rename from lua/ow/lsp/linter.lua rename to lua/lsp/linter.lua index 6e47764..6cdd319 100644 --- a/lua/ow/lsp/linter.lua +++ b/lua/lsp/linter.lua @@ -1,15 +1,7 @@ -local log = require("ow.log") -local util = require("ow.util") +local log = require("log") +local util = require("util") ----@class Linter ----@field namespace number ----@field augroup number ----@field bufnr number ----@field config LinterConfig -M = {} -M.__index = M - ----@alias Group +---@alias ow.lsp.linter.Group ---| "lnum" ---| "end_lnum" ---| "col" @@ -19,7 +11,7 @@ M.__index = M ---| "source" ---| "code" ----@class JsonConfig +---@class ow.lsp.linter.JsonConfig ---@field diagnostics_root? string ---@field lnum? string ---@field end_lnum? string @@ -31,11 +23,11 @@ M.__index = M ---@field code? string ---@field callback? fun(diag: vim.Diagnostic) ----@class DiagnosticTagMap +---@class ow.lsp.linter.DiagnosticTagMap ---@field unnecessary? string[] ---@field deprecated? string[] ----@class LinterConfig +---@class ow.lsp.linter.Config --- Command to run. The following keywords get replaces by the specified values: --- * %file% - path to the current file --- * %filename% - name of the current file @@ -53,7 +45,7 @@ M.__index = M --- Regex pattern to parse diagnostic lines (required if not using json) ---@field pattern? string --- Named capture groups for pattern matching (required if not using json) ----@field groups? Group[] +---@field groups? ow.lsp.linter.Group[] --- Map severity strings to vim diagnostic levels ---@field severity_map? table --- Source name for diagnostics (default: command name) @@ -61,9 +53,9 @@ M.__index = M --- Debounce delay in ms (default: 100) ---@field debounce? number --- Configuration for JSON output parsing ----@field json? JsonConfig +---@field json? ow.lsp.linter.JsonConfig --- Map diagnostic codes to tags ----@field tags? DiagnosticTagMap +---@field tags? ow.lsp.linter.DiagnosticTagMap --- Line numbers are 0-indexed (default: false, 1-indexed) ---@field zero_idx_lnum? boolean --- Column numbers are 0-indexed (default: false, 1-indexed) @@ -71,14 +63,21 @@ M.__index = M --- Don't log stderr as errors (default: false) ---@field ignore_stderr? boolean --- Post-process diagnostics ----@field hook? fun(self: Linter, diagnostics: vim.Diagnostic[]) -M.config = {} +---@field hook? fun(self: ow.lsp.Linter, diagnostics: vim.Diagnostic[]) + +---@class ow.lsp.Linter +---@field namespace number +---@field augroup number +---@field bufnr number +---@field config ow.lsp.linter.Config +Linter = {} +Linter.__index = Linter -- Extract a value from a JSON object using a path ---@param obj table The JSON object ---@param path string Path to the value (dot notation string) ---@return any The value at the specified path, or nil if not found -function M.get_json_value(obj, path) +function Linter.get_json_value(obj, path) if not obj then return nil end @@ -110,7 +109,7 @@ end --- Clamp column to line length ---@param diag vim.Diagnostic -function M:clamp_col(diag) +function Linter:clamp_col(diag) local lines = vim.api.nvim_buf_get_lines(self.bufnr, diag.lnum, diag.lnum + 1, false) if #lines == 0 then @@ -125,7 +124,7 @@ end --- Add diagnostic tags ---@param diag vim.Diagnostic -function M:add_tags(diag) +function Linter:add_tags(diag) if not self.config.tags then return end @@ -158,7 +157,7 @@ end --- Resolve 0/1-based indexing for lnum/col ---@param diag vim.Diagnostic -function M:fix_indexing(diag) +function Linter:fix_indexing(diag) if not self.config.zero_idx_lnum then if diag.lnum then diag.lnum = diag.lnum - 1 @@ -180,13 +179,13 @@ function M:fix_indexing(diag) end end -function M:process_json_output(json) +function Linter:process_json_output(json) ---@type vim.Diagnostic[] local diagnostics = {} local items = json if self.config.json.diagnostics_root then - items = M.get_json_value(json, self.config.json.diagnostics_root) + items = Linter.get_json_value(json, self.config.json.diagnostics_root) end if type(items) ~= "table" then @@ -203,7 +202,7 @@ function M:process_json_output(json) for field, path in pairs(self.config.json) do if field ~= "diagnostics_root" and field ~= "callback" then - diag[field] = M.get_json_value(item, path) + diag[field] = Linter.get_json_value(item, path) end end @@ -232,9 +231,9 @@ function M:process_json_output(json) end --- Validate input ----@param config LinterConfig +---@param config ow.lsp.linter.Config ---@return boolean -function M.validate(config) +function Linter.validate(config) local ok, resp = pcall(vim.validate, { config = { config, "table" }, }) @@ -308,7 +307,7 @@ function M.validate(config) end ---@return boolean success -function M:run() +function Linter:run() local input if self.config.stdin then @@ -410,9 +409,9 @@ function M:run() end ---@param bufnr integer ----@param config LinterConfig -function M.add(bufnr, config) - if not M.validate(config) then +---@param config ow.lsp.linter.Config +function Linter.add(bufnr, config) + if not Linter.validate(config) then return end @@ -420,16 +419,13 @@ function M.add(bufnr, config) config.events = config.events or { "TextChanged", "TextChangedI" } local linter = { - namespace = vim.api.nvim_create_namespace("ow.lsp.linter"), - augroup = vim.api.nvim_create_augroup( - "ow.lsp.linter", - { clear = false } - ), + namespace = vim.api.nvim_create_namespace("lsp.linter"), + augroup = vim.api.nvim_create_augroup("lsp.linter", { clear = false }), bufnr = bufnr, config = config, } - linter = setmetatable(linter, M) + linter = setmetatable(linter, Linter) local success = linter:run() if not success then @@ -456,4 +452,4 @@ function M.add(bufnr, config) end end -return M +return Linter diff --git a/lua/ow/meta/uv.lua b/lua/meta/uv.lua similarity index 100% rename from lua/ow/meta/uv.lua rename to lua/meta/uv.lua diff --git a/lua/ow/plugins/aerial.lua b/lua/plugins/aerial.lua similarity index 100% rename from lua/ow/plugins/aerial.lua rename to lua/plugins/aerial.lua diff --git a/lua/ow/plugins/comment.lua b/lua/plugins/comment.lua similarity index 100% rename from lua/ow/plugins/comment.lua rename to lua/plugins/comment.lua diff --git a/lua/ow/plugins/fidget.lua b/lua/plugins/fidget.lua similarity index 100% rename from lua/ow/plugins/fidget.lua rename to lua/plugins/fidget.lua diff --git a/lua/ow/plugins/flog.lua b/lua/plugins/flog.lua similarity index 100% rename from lua/ow/plugins/flog.lua rename to lua/plugins/flog.lua diff --git a/lua/ow/plugins/fugitive.lua b/lua/plugins/fugitive.lua similarity index 100% rename from lua/ow/plugins/fugitive.lua rename to lua/plugins/fugitive.lua diff --git a/lua/ow/plugins/gitsigns.lua b/lua/plugins/gitsigns.lua similarity index 100% rename from lua/ow/plugins/gitsigns.lua rename to lua/plugins/gitsigns.lua diff --git a/lua/ow/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua similarity index 62% rename from lua/ow/plugins/lspconfig.lua rename to lua/plugins/lspconfig.lua index b3f273f..fbe741f 100644 --- a/lua/ow/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,5 +1,5 @@ ---@type LazyPluginSpec return { "neovim/nvim-lspconfig", - config = require("ow.lsp").setup, + config = require("lsp").setup, } diff --git a/lua/ow/plugins/mason-auto-install.lua b/lua/plugins/mason-auto-install.lua similarity index 100% rename from lua/ow/plugins/mason-auto-install.lua rename to lua/plugins/mason-auto-install.lua diff --git a/lua/ow/plugins/mason.lua b/lua/plugins/mason.lua similarity index 100% rename from lua/ow/plugins/mason.lua rename to lua/plugins/mason.lua diff --git a/lua/ow/plugins/notify.lua b/lua/plugins/notify.lua similarity index 100% rename from lua/ow/plugins/notify.lua rename to lua/plugins/notify.lua diff --git a/lua/ow/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua similarity index 99% rename from lua/ow/plugins/nvim-cmp.lua rename to lua/plugins/nvim-cmp.lua index 1d97355..1e4fd2d 100644 --- a/lua/ow/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -38,7 +38,7 @@ return { require("luasnip.loaders.from_vscode").lazy_load() end, build = ( - require("ow.util").os_name ~= "Windows_NT" + require("util").os_name ~= "Windows_NT" and "make install_jsregexp" or nil ), diff --git a/lua/ow/plugins/nvim-colorizer.lua b/lua/plugins/nvim-colorizer.lua similarity index 100% rename from lua/ow/plugins/nvim-colorizer.lua rename to lua/plugins/nvim-colorizer.lua diff --git a/lua/ow/plugins/nvim-dap-ui.lua b/lua/plugins/nvim-dap-ui.lua similarity index 100% rename from lua/ow/plugins/nvim-dap-ui.lua rename to lua/plugins/nvim-dap-ui.lua diff --git a/lua/ow/plugins/nvim-dap.lua b/lua/plugins/nvim-dap.lua similarity index 98% rename from lua/ow/plugins/nvim-dap.lua rename to lua/plugins/nvim-dap.lua index 8e7e3ac..e4cc562 100644 --- a/lua/ow/plugins/nvim-dap.lua +++ b/lua/plugins/nvim-dap.lua @@ -1,6 +1,6 @@ -- https://github.com/mfussenegger/nvim-dap -local log = require("ow.log") -local hover = require("ow.dap.hover") +local hover = require("dap.hover") +local log = require("log") ---@type LazyPluginSpec return { diff --git a/lua/ow/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua similarity index 99% rename from lua/ow/plugins/nvim-tree.lua rename to lua/plugins/nvim-tree.lua index 7e802c6..0f40944 100644 --- a/lua/ow/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -1,4 +1,4 @@ -local util = require("ow.util") +local util = require("util") local function override_highlights() -- File Icon @@ -89,7 +89,7 @@ return { end end - local signs = require("ow.lsp").diagnostic_signs + local signs = require("lsp").diagnostic_signs require("nvim-tree").setup({ on_attach = function(bufnr) local function opts(desc) diff --git a/lua/ow/plugins/nvim-treesitter-context.lua b/lua/plugins/nvim-treesitter-context.lua similarity index 100% rename from lua/ow/plugins/nvim-treesitter-context.lua rename to lua/plugins/nvim-treesitter-context.lua diff --git a/lua/ow/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua similarity index 100% rename from lua/ow/plugins/nvim-treesitter.lua rename to lua/plugins/nvim-treesitter.lua diff --git a/lua/ow/plugins/oil.lua b/lua/plugins/oil.lua similarity index 100% rename from lua/ow/plugins/oil.lua rename to lua/plugins/oil.lua diff --git a/lua/ow/plugins/onedark.lua b/lua/plugins/onedark.lua similarity index 100% rename from lua/ow/plugins/onedark.lua rename to lua/plugins/onedark.lua diff --git a/lua/ow/plugins/orgmode.lua b/lua/plugins/orgmode.lua similarity index 100% rename from lua/ow/plugins/orgmode.lua rename to lua/plugins/orgmode.lua diff --git a/lua/ow/plugins/telescope.lua b/lua/plugins/telescope.lua similarity index 100% rename from lua/ow/plugins/telescope.lua rename to lua/plugins/telescope.lua diff --git a/lua/ow/plugins/undotree.lua b/lua/plugins/undotree.lua similarity index 100% rename from lua/ow/plugins/undotree.lua rename to lua/plugins/undotree.lua diff --git a/lua/ow/util.lua b/lua/util.lua similarity index 92% rename from lua/ow/util.lua rename to lua/util.lua index 3424eb2..bae0eb5 100644 --- a/lua/ow/util.lua +++ b/lua/util.lua @@ -1,8 +1,8 @@ -local log = require("ow.log") +local log = require("log") -local M = {} +local Util = {} -M.os_name = vim.uv.os_uname().sysname +Util.os_name = vim.uv.os_uname().sysname --- Get the module path of a file ---@param file string @@ -45,16 +45,16 @@ end --- Check that an executable is available --- @param exe string Array to look for --- @return boolean -function M.is_executable(exe) +function Util.is_executable(exe) return vim.fn.executable(exe) == 1 end --- Check that at least one executable is available --- @param exes table Array of exes --- @return boolean -function M.any_installed(exes) +function Util.any_installed(exes) for _, e in ipairs(exes) do - if M.is_executable(e) then + if Util.is_executable(e) then return true end end @@ -65,16 +65,16 @@ end --- Asserts that an executable is available --- Raises error if missing. --- @param exe string Array to look for -function M.assert_installed(exe) - assert(M.is_executable(exe), "Missing executable '" .. exe .. "'.") +function Util.assert_installed(exe) + assert(Util.is_executable(exe), "Missing executable '" .. exe .. "'.") end --- Asserts that at least one executable is available --- Raises error if missing. --- @param exes table Array of exes -function M.assert_any_installed(exes) +function Util.assert_any_installed(exes) assert( - M.any_installed(exes), + Util.any_installed(exes), "At least one of the following is required:\n" .. table.concat(exes, ", ") ) @@ -82,8 +82,8 @@ end --- Asserts that a python module is installed ---@param mod string The python module to check -function M.python3_module_is_installed(mod) - if not M.is_executable("python3") then +function Util.python3_module_is_installed(mod) + if not Util.is_executable("python3") then return false end @@ -93,8 +93,8 @@ end --- Asserts that a python module is installed ---@param mod string The python module to check -function M.assert_python3_module_installed(mod) - if not M.python3_module_is_installed(mod) then +function Util.assert_python3_module_installed(mod) + if not Util.python3_module_is_installed(mod) then error("Python3 module " .. mod .. " not installed") end end @@ -102,7 +102,7 @@ end --- Attempts to load a module and logs errors on failure. ---@param module string The module to attempt to load. ---@return any module The loaded module if successful, otherwise nil. -function M.try_require(module) +function Util.try_require(module) local has_module, resp = pcall(require, module) if has_module then @@ -115,7 +115,7 @@ end --- Checks if it is possible to require a module ---@param module string ---@return boolean -function M.has_module(module) +function Util.has_module(module) local has_module, _ = pcall(require, module) return has_module end @@ -144,7 +144,7 @@ end --- Format buffer ---@param opts FormatOptions -function M.format(opts) +function Util.format(opts) opts = { cmd = opts.cmd, output = opts.output, @@ -308,7 +308,7 @@ end ---@param kt type ---@param vt type ---@return boolean -function M.is_map(val, kt, vt) +function Util.is_map(val, kt, vt) if type(val) ~= "table" then return false end @@ -330,7 +330,7 @@ end ---@param val any ---@param t? type ---@return boolean -function M.is_list(val, t) +function Util.is_list(val, t) if not vim.islist(val) then return false end @@ -352,11 +352,11 @@ end ---@param val? any ---@param t? type ---@return boolean -function M.is_list_or_nil(val, t) +function Util.is_list_or_nil(val, t) if val == nil then return true else - return M.is_list(val, t) + return Util.is_list(val, t) end end @@ -365,7 +365,7 @@ end ---@param fn fun(...) Function to be debounced ---@param delay number Debounce delay in milliseconds ---@return fun(...) function Debounced function -function M.debounce(fn, delay) +function Util.debounce(fn, delay) ---@type uv_timer_t? local timer = nil @@ -388,7 +388,7 @@ end ---@param fn fun(...) Function to be debounced ---@param delay number Debounce delay in milliseconds ---@return fun(id: any, ...) function Debounced function, where `id` is a unique identifier -function M.debounce_with_id(fn, delay) +function Util.debounce_with_id(fn, delay) local map = {} return function(id, ...) @@ -405,7 +405,7 @@ function M.debounce_with_id(fn, delay) end end -function M.get_hl_source(name) +function Util.get_hl_source(name) local hl = vim.api.nvim_get_hl(0, { name = name }) while hl.link do hl = vim.api.nvim_get_hl(0, { name = hl.link }) @@ -414,4 +414,4 @@ function M.get_hl_source(name) return hl end -return M +return Util