nvim-lua / kickstart.nvim

A launch point for your personal nvim configuration
MIT License
19.1k stars 22.15k forks source link

Issues with setting up Gleam LSP #1119

Closed davidabram closed 1 month ago

davidabram commented 1 month ago

Describe the bug

I have a giant skill issue, I am unable to setup Gleam LSP. Gleam LSP was removed from Mason as it's directly distributed by Gleam installation. In docs lsp can be setup by lspconfig.gleam.setup({}) as seen in docs here.

To Reproduce

I have tried adding it into the servers variable in init.lua.

      local servers = {
        gleam = {},
        -- clangd = {},
        -- gopls = {},
        -- pyright = {},
        -- rust_analyzer = {},
        -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
        -
        -- Some languages (like typescript) have entire language plugins that can be useful:
        --    https://github.com/pmizio/typescript-tools.nvim
        --
        -- But for many setups, the LSP (`tsserver`) will work just fine
        -- tsserver = {},
        --

        lua_ls = {
          -- cmd = {...},
          -- filetypes = { ...},
          -- capabilities = {},
          settings = {
            Lua = {
              completion = {
                callSnippet = 'Replace',
              },
              -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings
              -- diagnostics = { disable = { 'missing-fields' } },
            },
          },
        },
      }

But when rerun nvim I get error:

image


I have also tried just adding

      local lspconfig = require 'lspconfig'
      lspconfig.gleam.setup {}

But the problem happens when I open a .gleam file and lsp doesn't attach to the buffer. Running `:LspInfo':

image

Desktop

Neovim Version

NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1713484068
VlaDexa commented 1 month ago

You have correctly figured out that the first error comes due to Gleam being removed from Mason registry.

The problem you encounter if your second attempt is that gleam lsp can't find the root directory of your project. lspconfig looks for either gleam.toml file or .git dir (it does it while walking up the directory chain) and it seems that it can't find any. Try editing a gleam file in a git initialized directory, and I assume it will work.

davidabram commented 1 month ago

Thanks @VlaDexa!

Setup like it's described here works in a dir where gleam.toml (for example, set up with gleam new) works properly.

Thank you for helping a skill issued colleague.