williamboman / mason.nvim

Portable package manager for Neovim that runs everywhere Neovim runs. Easily install and manage LSP servers, DAP servers, linters, and formatters.
Apache License 2.0
7.81k stars 273 forks source link

setting sumneko up #124

Closed bryant-the-coder closed 2 years ago

bryant-the-coder commented 2 years ago

how to set sumneko up? it keeps saying cant find executable

bryant-the-coder commented 2 years ago

i have installed sumneko. but it cant find the path

atahrijouti commented 2 years ago

What have you tried, and what errors (if any?) are you seeing?

bryant-the-coder commented 2 years ago

image

bryant-the-coder commented 2 years ago
-- sumneko_lua
local sumneko = {
    on_attach = on_attach,
    capabilities = capabilities,
    settings = {
        Lua = {
            diagnostics = {
                globals = { "vim" },
            },
            workspace = {
                library = {
                    [vim.fn.expand "$VIMRUNTIME/lua"] = true,
                    [vim.fn.stdpath "config" .. "/lua"] = true,
                },
            },
            hint = {
                enable = true,
                arrayIndex = "Enable", -- "Enable", "Auto", "Disable"
                await = true,
                paramName = "All", -- "All", "Literal", "Disable"
                paramType = true,
                semicolon = "All", -- "All", "SameLine", "Disable"
                setType = true,
            },
        },
    },
}
local use_lua_dev = true
if use_lua_dev then
    local luadev = require("lua-dev").setup {
        library = {
            vimruntime = true,
            types = true,
            plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
        },
        lspconfig = sumneko,
    }

    lspconfig.sumneko_lua.setup(luadev)
else
    lspconfig.sumneko_lua.setup(sumneko)
end
bryant-the-coder commented 2 years ago

other language servers work perfectly. (i am on windows)

williamboman commented 2 years ago

Since you're using lspconfig to set up servers, please make sure to use https://github.com/williamboman/mason-lspconfig.nvim

benomine commented 2 years ago

I just moved to mason and in order to make it work (everything is installed smoothly btw), I had to overwrite the cmd when trying to setup some of the lsp servers (like sumneko for example)

require('lspconfig')

local lsp_servers_path = vim.fn.stdpath('data') .. '/mason/packages'

local sumneko_path_bin = lsp_servers_path ..'/lua-language-server/extension/server/bin/'

and then (after defining the capabilities and all the stuff): cmd = { sumneko_path_bin .. 'lua-language-server.exe', '-E', sumneko_path_bin .. '/main.lua' };

maybe not the intended way, but it works.

bryant-the-coder commented 2 years ago

Since you're using lspconfig to set up servers, please make sure to use https://github.com/williamboman/mason-lspconfig.nvim

i installed it and lazyloaded it

williamboman commented 2 years ago

Cool! Remember to use one of the issue templates in the future, clearly stating (i) what isn't working, (ii) what you've done to try to fix it yourself, (iii) why you believe it's an error with the plugin, and (iiii) any additional information (providing more information early on helps everyone involved)

williamboman commented 2 years ago

I found an issue in mason-lspconfig where executables were not always expanded properly on Windows, fixed in https://github.com/williamboman/mason-lspconfig.nvim/pull/7. Might be related to your issues

benomine commented 2 years ago

I'm so dumb ahah. It did not work at first because I called the lspconfig before calling mason and mason-lspconfig. Now everything is working great and the code needed to call each and every lsp is just simpler. Thanks

kaptcha0 commented 2 years ago

I'm still facing this issue but with mason-tool-installer. I'm not using mason-lspconfig yet because I need to auto-install other tools. The following shows up when I run :MasonLog before the log file opens, as well as when sumneko is needed: image

kaptcha0 commented 2 years ago

I ended up adding Mason's binary path to $PATH in order for it to work out of the box. Not ideal, but it works.

williamboman commented 2 years ago

@re-kaptcha I checked your dotfiles and it seems like you’re relying on Neovims builtin runtime file loading. It will load your files in after/plugin/ in alphabetical order. You have to make sure Mason setup executes before you set up lspconfig servers.

kaptcha0 commented 2 years ago

@williamboman Thanks for the tip. I moved Mason's configuration into the lua directory, then called it in my lspconfig setup before initializing the servers. I thought letting making packer load Mason after lspconfig would work, but apparently not. Thanks again.