lopi-py / luau-lsp.nvim

A luau-lsp extension to improve your experience in neovim.
MIT License
46 stars 10 forks source link

Plugin isn't setting up custom server settings anymore. #25

Closed jipgg closed 3 months ago

jipgg commented 3 months ago

Currently my LSP options seemingly aren't getting initialized correctly anymore since syncing the plugin to the latest commits. In my case imports and strict datamodel types aren't being set to their respective state that i specified; Being import disabled and server diagnostics being non-strict while having both configured to be the opposite. In case it could be an error on my part, below is my current config for the plugin that is passed to the mason handlers setup:

require("luau-lsp").setup({
        platform = {
            type = "roblox",
        },
        plugin = {
            enabled = true,
            port = 3667,
        },
        types = {
            roblox_security_level = "PluginSecurity"
        },
        server = {
            settings = {
                ["luau-lsp"] = {
                    completion = {
                        diagnostics = {
                            strictDatamodelTypes = true,
                        },
                        imports = {
                            suggestServices = true,
                            suggestRequires = false,
                            enabled = true,
                        },
                    },
                },
            },
        },
    })
lopi-py commented 3 months ago

My settings still are being respected, can you run :LspInfo and :checkhealth luau-lsp when luau-lsp is attached and send the output?

jipgg commented 3 months ago

The outputs: Healthcheck LspInfo I've made a public repo of my nvim config (its not a sizable one) in case that would help resolving the issue. I've tried loading it from an exrc file with no luck. The other options seem to be working correctly, just the server configurations.

lopi-py commented 3 months ago

Edit: @jipgg btw I just realized you put diagnostics settings under completion, so thats probably why strictDatamodelTypes doesn't work, it should be under luau-lsp. I replicated the settings for auto imports and it works only for services and not for requires as expected.


  1. I've updated the plugin (unrelated changes tbh but who knows), so download the latest version
  2. Try visualizing the settings, open a luau file and run :lua vim.print(require("luau-lsp.util").get_client().settings) or :LazyDev lsp
  3. If it shows as expected, try :LuauLsp restart
  4. If still does not work, try pinning luau-lsp.nvim commits in this specific order: 131d385 ae76ec9 3ad89b5 (run :Lazy sync)
  5. Try loading luau-lsp.nvim at startup and leave the mason handler empty (function() end) Actually I think this shouldn't change anything because you seem to already load luau-lsp at startup

I'm using the latest commit right now and the settings are all respected

jipgg commented 3 months ago

Pinning to 3ad89b5 resolves the issue. Looking at the output of :LspInfo it seems to be rawdogging the executable on the other versions (image on my previous comment), and only invoking the mason CMD file on the older commit.

LspInfo-older-commit

I do have a separate luau-lsp.exe added to my PATH which seems to be the one that is getting invoked instead of the mason copy thats in nvim-data. Removing said executable from my path breaks functionality entirely and gives an error message on the later commits while silently breaking functionality on the commit that works.

errMsg-when- removing- bin

This is however speculation based on a severe lack of knowledge about LSPs, but hopefully this extra information might make it easier for you to diagnose what the problem might be. Regardless, thank you for your help. it's working as expected now.

lopi-py commented 3 months ago

Ok, I see the problem: mason-lspconfig.nvim will modify the cmd on Windows. mason.nvim creates a luau-lsp.CMD file under the binaries directory. vim.lsp.start_client uses uv.spawn under the hood, which doesn't execute batch scripts (.CMD files). It wasn't a problem before the commit you are using because I was depending on lspconfig, and mason-lspconfig would "fix" that. I'll add tests for Windows and fix that. Thanks!

lopi-py commented 2 months ago

@jipgg Hello, I recently discovered this was related to the fact that you didn't send the capabilities in the server config, I've updated the plugin, so no changes are required on your side, you just need to update the plugin