-- ┌                                               ┐
-- │                      LUA                      │
-- └                                               ┘
local lsp = vim.lsp

local capabilities = require("lsp-options").capabilities
local on_attach = require("lsp-options").on_attach

lsp.config("lua_ls", {
	capabilities = capabilities,
	on_attach = on_attach,
	settings = {
		Lua = {
			-- make the language server recognize "vim" global
			diagnostics = {
				globals = { "vim" },
			},
			workspace = {
				-- make language server aware of runtime files
				library = {
					vim.fn.expand("$VIMRUNTIME/lua"),
					vim.fn.stdpath("config") .. "/lua",
					vim.fn.expand("~/.luarocks/share/lua/5.4"),
                    -- To use LÖVR, follow https://lovr.org/docs/dev/VS_Code_Setup#manual-installation
                    -- TL;DR run lovr api cats in the lovr-docs repo and update the path below
                    -- Then update the blow path (if you have not used the script in this repo)
					vim.fn.expand("~/.local/share/lovr-docs/api/cats"),
                    vim.fn.expand(vim.fn.getcwd() .. "/lua_modules/share/lua/5.4"),
					"/usr/share/lua/5.4",
				},
			},
		},
	},
})

-- ── Enable configs ───────────────────────────────────────────────
local enable = vim.lsp.enable
enable("lua_ls")
