Skip to content

Commit

Permalink
fix: automatically add /lua when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 1, 2024
1 parent b2da629 commit feef58f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lua/lazydev/buf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ M.library = {}
M.query = nil

function M.setup()
table.insert(M.library, vim.fs.normalize(Config.runtime) .. "/lua")
vim.list_extend(M.library, Config.library)
M.add(Config.runtime)
for _, lib in ipairs(Config.library) do
M.add(lib)
end

M.query = vim.treesitter.query.parse(
"lua",
Expand Down Expand Up @@ -53,6 +55,17 @@ function M.setup()
M.on_change()
end

---@param path string
function M.add(path)
path = vim.fs.normalize(path)
if not path:find("/lua/?$") and vim.uv.fs_stat(path .. "/lua") then
path = path .. "/lua"
end
if not vim.tbl_contains(M.library, path) then
table.insert(M.library, path)
end
end

function M.get_clients()
---@param client vim.lsp.Client
return vim.tbl_filter(function(client)
Expand Down

0 comments on commit feef58f

Please sign in to comment.