aboutsummaryrefslogtreecommitdiff
path: root/plugin/40-lsp.lua
blob: af95c47db520f15f66f23045318a6272a4f4572f (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
local opts = {
  ensure_installed = {
    "bash-language-server",
    "termux-language-server",
    "lua-language-server",
    "clangd",
    "clang-format",
    "taplo",
    "jq",
    "json-lsp",
    "svelte-language-server",
    "emmet-language-server",
    "html-lsp",
    "css-lsp",
    "typescript-language-server",
    "pyright",
    "glsl_analyzer",
    "kotlin-lsp",
    "jdtls",
    "csharp-language-server",
    "unocss-language-server",
  },
  PATH = "skip",
  ui = {
    icons = {
      package_pending = " ",
      package_installed = "󰄳 ",
      package_uninstalled = " 󰚌",
    },
    keymaps = {
      toggle_server_expand = "<CR>",
      install_server = "i",
      update_server = "u",
      check_server_version = "c",
      update_all_servers = "U",
      check_outdated_servers = "C",
      uninstall_server = "X",
      cancel_installation = "<C-c>",
    },
  },
  max_concurrent_installers = 10,
}

vim.api.nvim_create_user_command("MasonInstallAll", function ()
  if opts.ensure_installed and #opts.ensure_installed > 0 then
    vim.cmd("MasonInstall " .. table.concat(opts.ensure_installed, " "))
  end
end, {
  desc = "Install all required mason packages",
})

vim.pack.add({
  "https://github.com/neovim/nvim-lspconfig",
  "https://github.com/mason-org/mason.nvim",
})

require("mason").setup(opts)

if not (vim.uv or vim.loop).fs_stat(vim.g.mason_path) then
  vim.cmd("MasonInstallAll")
end