lopi-py/luau-lsp.nvim

How do i use this with lsp config, and lazy.nvim.

CapedBojji opened this issue · 5 comments

Title is self explanatory, i dont get if this is a plugin or the lsp client itself

You need to download the client by yourself, I suggest to use mason. This plugin helps you to properly set up the client via lspconfig, install this like any other plugin. You can see how to integrate this with mason in the readme.md

I figured it out, I will submit an updated docs, because the docs is very confusing for begginers thank you

So what is confusing about the docs? tell me so I can improve the docs

i think, you should include examples on how to use it with the popular plugin managers. Its not as simple as requiring it, you also have to add the plugin as a dependency. i kept getting luau-lsp not found till i figured that out

return {
  {
    "williamboman/mason.nvim",
    dependencies = {
      "williamboman/mason-lspconfig.nvim",
      "lopi-py/luau-lsp.nvim",
    },
    config = function(_, opts)
      require("mason").setup(opts)
      local mr = require("mason-registry")
      mr:on("package:install:success", function()
        vim.defer_fn(function()
          -- trigger FileType event to possibly load this newly installed LSP server
          require("lazy.core.handler.event").trigger({
            event = "FileType",
            buf = vim.api.nvim_get_current_buf(),
          })
        end, 100)
      end)

      local mason_lspconfig = require("mason-lspconfig")
      mason_lspconfig.setup_handlers({
        luau_lsp = function()
          require("luau-lsp").setup({
            server = {
              filetypes = { "luau" }, -- default is { "luau" }
              capabilities = vim.lsp.protocol.make_client_capabilities(),
              root_dir = function(path)
                local util = require("lspconfig.util")
                return util.find_git_ancestor(path)
                  or util.root_pattern(
                    ".luaurc",
                    "selene.toml",
                    "stylua.toml",
                    "aftman.toml",
                    "wally.toml",
                    "mantle.yml",
                    "*.project.json"
                  )(path)
              end,
            },
            settings = {},
            types = {
              roblox = true,
            },
            sourcemap = {
              enable = true,
              rojo_path = "rojo",
            },
          })
        end,
      })
      mason_lspconfig.setup({
        ensure_installed = {
          "luau_lsp",
        },
        automatic_installation = true,
      })
    end,
  },

  {
    "neovim/nvim-lspconfig",
    opts = {
      servers = {
        luau_lsp = {},
      },
      setup = {},
    },
    event = {
      "BufReadPre",
      "BufNewFile",
      "BufEnter",
      "BufUnload",
    },
  },
}

This is the lazy.nvim version of it

image
here is a better image of it