mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat: use LazyVim everywhere instead of require("lazyvim.util")
This commit is contained in:
parent
3a87c08cda
commit
7a5dbeae75
41 changed files with 188 additions and 229 deletions
|
@ -1,5 +1,3 @@
|
|||
local Util = require("lazyvim.util")
|
||||
|
||||
---@class lazyvim.util.root
|
||||
---@overload fun(): string
|
||||
local M = setmetatable({}, {
|
||||
|
@ -31,7 +29,7 @@ function M.detectors.lsp(buf)
|
|||
return {}
|
||||
end
|
||||
local roots = {} ---@type string[]
|
||||
for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do
|
||||
for _, client in pairs(LazyVim.lsp.get_clients({ bufnr = buf })) do
|
||||
-- only check workspace folders, since we're not interested in clients
|
||||
-- running in single file mode
|
||||
local workspace = client.config.workspace_folders
|
||||
|
@ -40,7 +38,7 @@ function M.detectors.lsp(buf)
|
|||
end
|
||||
end
|
||||
return vim.tbl_filter(function(path)
|
||||
path = Util.norm(path)
|
||||
path = LazyVim.norm(path)
|
||||
return path and bufpath:find(path, 1, true) == 1
|
||||
end, roots)
|
||||
end
|
||||
|
@ -66,7 +64,7 @@ function M.realpath(path)
|
|||
return nil
|
||||
end
|
||||
path = vim.uv.fs_realpath(path) or path
|
||||
return Util.norm(path)
|
||||
return LazyVim.norm(path)
|
||||
end
|
||||
|
||||
---@param spec LazyRootSpec
|
||||
|
@ -132,7 +130,7 @@ function M.info()
|
|||
lines[#lines + 1] = "```lua"
|
||||
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
|
||||
lines[#lines + 1] = "```"
|
||||
require("lazyvim.util").info(lines, { title = "LazyVim Roots" })
|
||||
LazyVim.info(lines, { title = "LazyVim Roots" })
|
||||
return roots[1] and roots[1].paths[1] or vim.uv.cwd()
|
||||
end
|
||||
|
||||
|
@ -141,7 +139,7 @@ M.cache = {}
|
|||
|
||||
function M.setup()
|
||||
vim.api.nvim_create_user_command("LazyRoot", function()
|
||||
Util.root.info()
|
||||
LazyVim.root.info()
|
||||
end, { desc = "LazyVim roots for the current buffer" })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, {
|
||||
|
@ -170,7 +168,7 @@ function M.get(opts)
|
|||
if opts and opts.normalize then
|
||||
return ret
|
||||
end
|
||||
return Util.is_win() and ret:gsub("/", "\\") or ret
|
||||
return LazyVim.is_win() and ret:gsub("/", "\\") or ret
|
||||
end
|
||||
|
||||
function M.git()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue