aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/lsp/mason.lua
blob: 6948454cf3f19709077284d34961757056e24fab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local mason = require "mason"
local mason_lspconfig = require "mason-lspconfig"
local servers = require "alpha.lsp.servers"
local lspconfig = require "lspconfig"

mason.setup()

local mason_servers = {}

-- TODO: can be improve checking the setup function to see if sets the cmd
for server, _ in pairs(servers) do
  local cmd = lspconfig[server].document_config.default_config.cmd[1]
  if vim.fn.executable(cmd) == 0 then
    table.insert(mason_servers, server)
  end
end

mason_lspconfig.setup {
  ensure_installed = mason_servers,
}

-- filter the list for the ones not globally installed
require("mason-tool-installer").setup {
  ensure_installed = vim.tbl_filter(function (tool)
    return vim.fn.executable(tool) == 0
  end, require "alpha.lsp.tools"),
}