From a444f770b40bce70d2d4e0f88bcb8344958411d5 Mon Sep 17 00:00:00 2001 From: William Boman Date: Fri, 8 Jul 2022 23:16:01 +0200 Subject: feat(mason-lspconfig): add :LspInstall and :LspUninstall commands (#35) These should be in complete parity with the nvim-lsp-installer commands. Now even better than before. --- lua/mason-core/optional.lua | 8 ++ lua/mason-lspconfig/api/command.lua | 141 ++++++++++++++++++++++++++++++++ lua/mason-lspconfig/init.lua | 2 + lua/mason-lspconfig/mappings/server.lua | 2 +- lua/mason-schemas/lsp/deno-lsp.lua | 3 - lua/mason-schemas/lsp/deno.lua | 3 + lua/mason/api/command.lua | 44 ++++++---- lua/mason/mappings/language.lua | 103 +++++++++++++++++++++++ lua/mason/ui/init.lua | 11 ++- lua/mason/ui/instance.lua | 7 +- 10 files changed, 300 insertions(+), 24 deletions(-) create mode 100644 lua/mason-lspconfig/api/command.lua delete mode 100644 lua/mason-schemas/lsp/deno-lsp.lua create mode 100644 lua/mason-schemas/lsp/deno.lua create mode 100644 lua/mason/mappings/language.lua (limited to 'lua') diff --git a/lua/mason-core/optional.lua b/lua/mason-core/optional.lua index 10af8ccb..5710ce0c 100644 --- a/lua/mason-core/optional.lua +++ b/lua/mason-core/optional.lua @@ -93,6 +93,14 @@ function Optional:if_present(fn) return self end +---@param fn fun(value: any) +function Optional:if_not_present(fn) + if not self:is_present() then + fn(self._value) + end + return self +end + function Optional:is_present() return self._value ~= nil end diff --git a/lua/mason-lspconfig/api/command.lua b/lua/mason-lspconfig/api/command.lua new file mode 100644 index 00000000..22a96be5 --- /dev/null +++ b/lua/mason-lspconfig/api/command.lua @@ -0,0 +1,141 @@ +local a = require "mason-core.async" +local Optional = require "mason-core.optional" +local notify = require "mason-core.notify" +local _ = require "mason-core.functional" + +local M = {} + +---@async +---@param user_args string[] @The arguments, as provided by the user. +local function parse_packages_from_user_args(user_args) + local Package = require "mason-core.package" + local server_mapping = require "mason-lspconfig.mappings.server" + local language_mapping = require "mason.mappings.language" + + return _.filter_map(function(server_specifier) + local server_name, version = Package.Parse(server_specifier) + -- 1. first see if the provided arg is an actual lspconfig server name + return Optional + .of_nilable(server_mapping.lspconfig_to_package[server_name]) + -- 2. if not, check if it's a language specifier (e.g., "typescript" or "java") + :or_(function() + return Optional.of_nilable(language_mapping[server_name]):map(function(package_names) + local lsp_package_names = _.filter(function(package_name) + return server_mapping.package_to_lspconfig[package_name] ~= nil + end, package_names) + + if #lsp_package_names == 0 then + return nil + end + + return a.promisify(vim.ui.select)(lsp_package_names, { + prompt = ("Please select which server you want to install for language %q:"):format( + server_name + ), + format_item = function(item) + return server_mapping.package_to_lspconfig[item] + end, + }) + end) + end) + :map(function(package_name) + return { package = package_name, version = version } + end) + :if_not_present(function() + notify(("Could not find LSP server %q."):format(server_name), vim.log.levels.ERROR) + end) + end, user_args) +end + +---@async +local function parse_packages_from_heuristics() + local server_mapping = require "mason-lspconfig.mappings.server" + + -- Prompt user which server they want to install (based on the current filetype) + local current_ft = vim.api.nvim_buf_get_option(vim.api.nvim_get_current_buf(), "filetype") + local filetype_mapping = require "mason-lspconfig.mappings.filetype" + return Optional.of_nilable(filetype_mapping[current_ft]) + :map(function(server_names) + return a.promisify(vim.ui.select)(server_names, { + prompt = ("Please select which server you want to install for filetype %q:"):format(current_ft), + }) + end) + :map(function(server_name) + local package_name = server_mapping.lspconfig_to_package[server_name] + return { package = package_name, version = nil } + end) + :or_else_get(function() + notify(("No LSP servers found for filetype %q."):format(current_ft), vim.log.levels.ERROR) + return {} + end) +end + +local parse_packages_to_install = _.cond { + { _.compose(_.gt(0), _.length), parse_packages_from_user_args }, + { _.compose(_.equals(0), _.length), parse_packages_from_heuristics }, + { _.T, _.always {} }, +} + +vim.api.nvim_create_user_command( + "LspInstall", + a.scope(function(opts) + local packages_to_install = parse_packages_to_install(opts.fargs) + if #packages_to_install > 0 then + local registry = require "mason-registry" + _.each(function(target) + local pkg = registry.get_package(target.package) + pkg:install { version = target.version } + end, packages_to_install) + require("mason.ui").open() + require("mason.ui").set_view "LSP" + end + end), + { + desc = "Install one or more LSP servers.", + nargs = "*", + complete = "custom,v:lua.mason_lspconfig_completion.available_server_completion", + } +) + +vim.api.nvim_create_user_command("LspUninstall", function(opts) + require("mason.ui").open() + require("mason.ui").set_view "LSP" + local registry = require "mason-registry" + local server_mapping = require "mason-lspconfig.mappings.server" + for _, server_specifier in ipairs(opts.fargs) do + local package_name = server_mapping.lspconfig_to_package[server_specifier] + local pkg = registry.get_package(package_name) + pkg:uninstall() + end +end, { + desc = "Uninstall one or more LSP servers.", + nargs = "+", + complete = "custom,v:lua.mason_lspconfig_completion.installed_server_completion", +}) + +_G.mason_lspconfig_completion = { + available_server_completion = function() + local registry = require "mason-registry" + local server_mapping = require "mason-lspconfig.mappings.server" + local language_mapping = require "mason.mappings.language" + + local package_names = _.filter_map(function(pkg_name) + return Optional.of_nilable(server_mapping.package_to_lspconfig[pkg_name]) + end, registry.get_all_package_names()) + local completion = _.concat(package_names, _.keys(language_mapping)) + table.sort(completion) + return table.concat(completion, "\n") + end, + installed_server_completion = function() + local registry = require "mason-registry" + local server_mapping = require "mason-lspconfig.mappings.server" + + local server_names = _.filter_map(function(pkg_name) + return Optional.of_nilable(server_mapping.package_to_lspconfig[pkg_name]) + end, registry.get_installed_package_names()) + table.sort(server_names) + return table.concat(server_names, "\n") + end, +} + +return M diff --git a/lua/mason-lspconfig/init.lua b/lua/mason-lspconfig/init.lua index 67f4cd16..8682d2e8 100644 --- a/lua/mason-lspconfig/init.lua +++ b/lua/mason-lspconfig/init.lua @@ -103,6 +103,8 @@ function M.setup(config) setup_lspconfig_hook() ensure_installed() + + require "mason-lspconfig.api.command" end ---@param handlers table diff --git a/lua/mason-lspconfig/mappings/server.lua b/lua/mason-lspconfig/mappings/server.lua index 9d784c9b..582963f4 100644 --- a/lua/mason-lspconfig/mappings/server.lua +++ b/lua/mason-lspconfig/mappings/server.lua @@ -27,7 +27,7 @@ M.lspconfig_to_package = { ["cssls"] = "css-lsp", ["cssmodules_ls"] = "cucumber-language-server", ["cucumber_language_server"] = "cucumber-language-server", - ["denols"] = "deno-lsp", + ["denols"] = "deno", ["dhall_lsp_server"] = "dhall-lsp", ["diagnosticls"] = "diagnostic-languageserver", ["dockerls"] = "dockerfile-language-server", diff --git a/lua/mason-schemas/lsp/deno-lsp.lua b/lua/mason-schemas/lsp/deno-lsp.lua deleted file mode 100644 index 5ad46765..00000000 --- a/lua/mason-schemas/lsp/deno-lsp.lua +++ /dev/null @@ -1,3 +0,0 @@ --- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. --- stylua: ignore start -return {properties = {["deno.cache"] = {default = vim.NIL,markdownDescription = "A path to the cache directory for Deno. By default, the operating system's cache path plus `deno` is used, or the `DENO_DIR` environment variable, but if set, this path will be used instead.",scope = "window",type = "string"},["deno.certificateStores"] = {default = vim.NIL,items = {type = "string"},markdownDescription = "A list of root certificate stores used to validate TLS certificates when fetching and caching remote resources. This overrides the `DENO_TLS_CA_STORE` environment variable if set.",scope = "window",type = "array"},["deno.codeLens.implementations"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for implementations of items in the code.",scope = "window",type = "boolean"},["deno.codeLens.references"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for references of items in the code.",scope = "window",type = "boolean"},["deno.codeLens.referencesAllFunctions"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for all functions in the code.",scope = "window",type = "boolean"},["deno.codeLens.test"] = {default = false,markdownDescription = "Enables or disables the display of code lenses that allow running of individual tests in the code.",scope = "resource",type = "boolean"},["deno.codeLens.testArgs"] = {default = { "--allow-all", "--no-check" },items = {type = "string"},markdownDescription = 'Additional arguments to use with the run test code lens. Defaults to `[ "--allow-all", "--no-check" ]`.',scope = "resource",type = "array"},["deno.config"] = {default = vim.NIL,examples = { "./deno.jsonc", "/path/to/deno.jsonc", "C:\\path\\to\\deno.jsonc" },markdownDescription = "The file path to a configuration file. This is the equivalent to using `--config` on the command line. The path can be either be relative to the workspace, or an absolute path.\n\nIt is recommend you name it `deno.json` or `deno.jsonc`.\n\n**Not recommended to be set globally.**",scope = "window",type = "string"},["deno.enable"] = {default = false,examples = { true, false },markdownDescription = "Controls if the Deno Language Server is enabled. When enabled, the extension will disable the built-in VSCode JavaScript and TypeScript language services, and will use the Deno Language Server instead.\n\nIf you want to enable only part of your workspace folder, consider using `deno.enablePaths` setting instead.\n\n**Not recommended to be enabled globally.**",scope = "resource",type = "boolean"},["deno.enablePaths"] = {default = {},examples = { { "./worker" } },items = {type = "string"},markdownDescription = 'Enables the Deno Language Server for specific paths, instead of for the whole workspace folder. This will disable the built in TypeScript/JavaScript language server for those paths.\n\nWhen a value is set, the value of `"deno.enable"` is ignored.\n\nThe workspace folder is used as the base for the supplied paths. If for example you have all your Deno code in `worker` path in your workspace, you can add an item with the value of `./worker`, and the Deno will only provide diagnostics for the files within `worker` or any of its sub paths.\n\n**Not recommended to be enabled in user settings.**',scope = "resource",type = "array"},["deno.importMap"] = {default = vim.NIL,examples = { "./import_map.json", "/path/to/import_map.json", "C:\\path\\to\\import_map.json" },markdownDescription = 'The file path to an import map. This is the equivalent to using `--import-map` on the command line.\n\n[Import maps](https://deno.land/manual@v1.6.0/linking_to_external_code/import_maps) provide a way to "relocate" modules based on their specifiers. The path can either be relative to the workspace, or an absolute path.\n\n**Not recommended to be set globally.**',scope = "window",type = "string"},["deno.internalDebug"] = {default = false,examples = { true, false },markdownDescription = "Determines if the internal debugging information for the Deno language server will be logged to the _Deno Language Server_ console.",scope = "window",type = "boolean"},["deno.lint"] = {default = true,examples = { true, false },markdownDescription = "Controls if linting information will be provided by the Deno Language Server.\n\n**Not recommended to be enabled globally.**",scope = "window",type = "boolean"},["deno.path"] = {default = vim.NIL,examples = { "/usr/bin/deno", "C:\\Program Files\\deno\\deno.exe" },markdownDescription = "A path to the `deno` CLI executable. By default, the extension looks for `deno` in the `PATH`, but if set, will use the path specified instead.",scope = "window",type = "string"},["deno.suggest.autoImports"] = {default = true,scope = "window",type = "boolean"},["deno.suggest.completeFunctionCalls"] = {default = false,scope = "window",type = "boolean"},["deno.suggest.imports.autoDiscover"] = {default = true,markdownDescription = "If enabled, when new hosts/origins are encountered that support import suggestions, you will be prompted to enable or disable it. Defaults to `true`.",scope = "window",type = "boolean"},["deno.suggest.imports.hosts"] = {default = {["https://crux.land"] = true,["https://deno.land"] = true,["https://x.nest.land"] = true},examples = {["https://deno.land"] = true},markdownDescription = "Controls which hosts are enabled for import suggestions.",scope = "window",type = "object"},["deno.suggest.names"] = {default = true,scope = "window",type = "boolean"},["deno.suggest.paths"] = {default = true,scope = "window",type = "boolean"},["deno.testing.args"] = {default = { "--allow-all", "--no-check" },items = {type = "string"},markdownDescription = 'Arguments to use when running tests via the Test Explorer. Defaults to `[ "--allow-all" ]`.',scope = "window",type = "array"},["deno.testing.enable"] = {default = true,markdownDescription = "Enable the testing API for the language server. When folder is Deno enabled, tests will be available in the Test Explorer view.",scope = "window",type = "boolean"},["deno.tlsCertificate"] = {default = vim.NIL,markdownDescription = "A path to a PEM certificate to use as the certificate authority when validating TLS certificates when fetching and caching remote resources. This is like using `--cert` on the Deno CLI and overrides the `DENO_CERT` environment variable if set.",scope = "window",type = "string"},["deno.unsafelyIgnoreCertificateErrors"] = {default = vim.NIL,items = {type = "string"},markdownDescription = "**DANGER** disables verification of TLS certificates for the hosts provided. There is likely a better way to deal with any errors than use this option. This is like using `--unsafely-ignore-certificate-errors` in the Deno CLI.",scope = "window",type = "array"},["deno.unstable"] = {default = false,examples = { true, false },markdownDescription = "Controls if code will be type checked with Deno's unstable APIs. This is the equivalent to using `--unstable` on the command line.\n\n**Not recommended to be enabled globally.**",scope = "window",type = "boolean"}},title = "Deno",type = "object"} \ No newline at end of file diff --git a/lua/mason-schemas/lsp/deno.lua b/lua/mason-schemas/lsp/deno.lua new file mode 100644 index 00000000..5ad46765 --- /dev/null +++ b/lua/mason-schemas/lsp/deno.lua @@ -0,0 +1,3 @@ +-- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. +-- stylua: ignore start +return {properties = {["deno.cache"] = {default = vim.NIL,markdownDescription = "A path to the cache directory for Deno. By default, the operating system's cache path plus `deno` is used, or the `DENO_DIR` environment variable, but if set, this path will be used instead.",scope = "window",type = "string"},["deno.certificateStores"] = {default = vim.NIL,items = {type = "string"},markdownDescription = "A list of root certificate stores used to validate TLS certificates when fetching and caching remote resources. This overrides the `DENO_TLS_CA_STORE` environment variable if set.",scope = "window",type = "array"},["deno.codeLens.implementations"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for implementations of items in the code.",scope = "window",type = "boolean"},["deno.codeLens.references"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for references of items in the code.",scope = "window",type = "boolean"},["deno.codeLens.referencesAllFunctions"] = {default = false,examples = { true, false },markdownDescription = "Enables or disables the display of code lens information for all functions in the code.",scope = "window",type = "boolean"},["deno.codeLens.test"] = {default = false,markdownDescription = "Enables or disables the display of code lenses that allow running of individual tests in the code.",scope = "resource",type = "boolean"},["deno.codeLens.testArgs"] = {default = { "--allow-all", "--no-check" },items = {type = "string"},markdownDescription = 'Additional arguments to use with the run test code lens. Defaults to `[ "--allow-all", "--no-check" ]`.',scope = "resource",type = "array"},["deno.config"] = {default = vim.NIL,examples = { "./deno.jsonc", "/path/to/deno.jsonc", "C:\\path\\to\\deno.jsonc" },markdownDescription = "The file path to a configuration file. This is the equivalent to using `--config` on the command line. The path can be either be relative to the workspace, or an absolute path.\n\nIt is recommend you name it `deno.json` or `deno.jsonc`.\n\n**Not recommended to be set globally.**",scope = "window",type = "string"},["deno.enable"] = {default = false,examples = { true, false },markdownDescription = "Controls if the Deno Language Server is enabled. When enabled, the extension will disable the built-in VSCode JavaScript and TypeScript language services, and will use the Deno Language Server instead.\n\nIf you want to enable only part of your workspace folder, consider using `deno.enablePaths` setting instead.\n\n**Not recommended to be enabled globally.**",scope = "resource",type = "boolean"},["deno.enablePaths"] = {default = {},examples = { { "./worker" } },items = {type = "string"},markdownDescription = 'Enables the Deno Language Server for specific paths, instead of for the whole workspace folder. This will disable the built in TypeScript/JavaScript language server for those paths.\n\nWhen a value is set, the value of `"deno.enable"` is ignored.\n\nThe workspace folder is used as the base for the supplied paths. If for example you have all your Deno code in `worker` path in your workspace, you can add an item with the value of `./worker`, and the Deno will only provide diagnostics for the files within `worker` or any of its sub paths.\n\n**Not recommended to be enabled in user settings.**',scope = "resource",type = "array"},["deno.importMap"] = {default = vim.NIL,examples = { "./import_map.json", "/path/to/import_map.json", "C:\\path\\to\\import_map.json" },markdownDescription = 'The file path to an import map. This is the equivalent to using `--import-map` on the command line.\n\n[Import maps](https://deno.land/manual@v1.6.0/linking_to_external_code/import_maps) provide a way to "relocate" modules based on their specifiers. The path can either be relative to the workspace, or an absolute path.\n\n**Not recommended to be set globally.**',scope = "window",type = "string"},["deno.internalDebug"] = {default = false,examples = { true, false },markdownDescription = "Determines if the internal debugging information for the Deno language server will be logged to the _Deno Language Server_ console.",scope = "window",type = "boolean"},["deno.lint"] = {default = true,examples = { true, false },markdownDescription = "Controls if linting information will be provided by the Deno Language Server.\n\n**Not recommended to be enabled globally.**",scope = "window",type = "boolean"},["deno.path"] = {default = vim.NIL,examples = { "/usr/bin/deno", "C:\\Program Files\\deno\\deno.exe" },markdownDescription = "A path to the `deno` CLI executable. By default, the extension looks for `deno` in the `PATH`, but if set, will use the path specified instead.",scope = "window",type = "string"},["deno.suggest.autoImports"] = {default = true,scope = "window",type = "boolean"},["deno.suggest.completeFunctionCalls"] = {default = false,scope = "window",type = "boolean"},["deno.suggest.imports.autoDiscover"] = {default = true,markdownDescription = "If enabled, when new hosts/origins are encountered that support import suggestions, you will be prompted to enable or disable it. Defaults to `true`.",scope = "window",type = "boolean"},["deno.suggest.imports.hosts"] = {default = {["https://crux.land"] = true,["https://deno.land"] = true,["https://x.nest.land"] = true},examples = {["https://deno.land"] = true},markdownDescription = "Controls which hosts are enabled for import suggestions.",scope = "window",type = "object"},["deno.suggest.names"] = {default = true,scope = "window",type = "boolean"},["deno.suggest.paths"] = {default = true,scope = "window",type = "boolean"},["deno.testing.args"] = {default = { "--allow-all", "--no-check" },items = {type = "string"},markdownDescription = 'Arguments to use when running tests via the Test Explorer. Defaults to `[ "--allow-all" ]`.',scope = "window",type = "array"},["deno.testing.enable"] = {default = true,markdownDescription = "Enable the testing API for the language server. When folder is Deno enabled, tests will be available in the Test Explorer view.",scope = "window",type = "boolean"},["deno.tlsCertificate"] = {default = vim.NIL,markdownDescription = "A path to a PEM certificate to use as the certificate authority when validating TLS certificates when fetching and caching remote resources. This is like using `--cert` on the Deno CLI and overrides the `DENO_CERT` environment variable if set.",scope = "window",type = "string"},["deno.unsafelyIgnoreCertificateErrors"] = {default = vim.NIL,items = {type = "string"},markdownDescription = "**DANGER** disables verification of TLS certificates for the hosts provided. There is likely a better way to deal with any errors than use this option. This is like using `--unsafely-ignore-certificate-errors` in the Deno CLI.",scope = "window",type = "array"},["deno.unstable"] = {default = false,examples = { true, false },markdownDescription = "Controls if code will be type checked with Deno's unstable APIs. This is the equivalent to using `--unstable` on the command line.\n\n**Not recommended to be enabled globally.**",scope = "window",type = "boolean"}},title = "Deno",type = "object"} \ No newline at end of file diff --git a/lua/mason/api/command.lua b/lua/mason/api/command.lua index f3540fd9..064477f4 100644 --- a/lua/mason/api/command.lua +++ b/lua/mason/api/command.lua @@ -1,4 +1,5 @@ local notify = require "mason-core.notify" +local _ = require "mason-core.functional" local M = {} @@ -9,18 +10,30 @@ end, { nargs = 0, }) +-- This is needed because neovim doesn't do any validation of command args when using custom completion (I think?) +local filter_valid_packages = _.filter(function(pkg_specifier) + local Package = require "mason-core.package" + local registry = require "mason-registry" + local package_name = Package.Parse(pkg_specifier) + local ok = pcall(registry.get_package, package_name) + if ok then + return true + else + notify(("%q is not a valid package."):format(pkg_specifier), vim.log.levels.ERROR) + return false + end +end) + vim.api.nvim_create_user_command("MasonInstall", function(opts) local Package = require "mason-core.package" local registry = require "mason-registry" - for _, package_specifier in ipairs(opts.fargs) do - ---@type string - local package_name, version = Package.Parse(package_specifier) - local ok, pkg = pcall(registry.get_package, package_name) - if not ok then - notify(("Cannot find package %q."):format(package_name), vim.log.levels.ERROR) - return - end - local handle = pkg:install { version = version } + local valid_packages = filter_valid_packages(opts.fargs) + if #valid_packages > 0 then + _.each(function(pkg_specifier) + local package_name, version = Package.Parse(pkg_specifier) + local pkg = registry.get_package(package_name) + pkg:install { version = version } + end, valid_packages) require("mason.ui").open() end end, { @@ -31,13 +44,12 @@ end, { vim.api.nvim_create_user_command("MasonUninstall", function(opts) local registry = require "mason-registry" - for _, package_name in ipairs(opts.fargs) do - local ok, pkg = pcall(registry.get_package, package_name) - if not ok then - notify(("Cannot find package %q."):format(package_name), vim.log.levels.ERROR) - return - end - pkg:uninstall() + local valid_packages = filter_valid_packages(opts.fargs) + if #valid_packages > 0 then + _.each(function(package_name) + local pkg = registry.get_package(package_name) + pkg:uninstall() + end, filter_valid_packages) require("mason.ui").open() end end, { diff --git a/lua/mason/mappings/language.lua b/lua/mason/mappings/language.lua new file mode 100644 index 00000000..b005d2da --- /dev/null +++ b/lua/mason/mappings/language.lua @@ -0,0 +1,103 @@ +-- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY. +-- stylua: ignore start +return { + [".net"] = { "netcoredbg" }, + ["1ะก:enterprise"] = { "bsl-language-server" }, + angular = { "angular-language-server" }, + ansible = { "ansible-language-server" }, + apex = { "apex-language-server" }, + arduino = { "arduino-language-server" }, + assembly = { "asm-lsp" }, + astro = { "astro-language-server" }, + awk = { "awk-language-server" }, + bash = { "bash-language-server", "shellcheck" }, + beancount = { "beancount-language-server" }, + bicep = { "bicep-lsp" }, + c = { "ccls", "clangd", "codelldb", "cpptools" }, + ["c#"] = { "csharp-language-server", "netcoredbg", "omnisharp-roslyn" }, + ["c++"] = { "ccls", "clangd", "codelldb", "cpptools" }, + clarity = { "clarity-lsp" }, + clojure = { "clojure-lsp" }, + clojurescript = { "clojure-lsp" }, + cmake = { "cmake-language-server" }, + codeql = { "codeql" }, + crystal = { "crystalline" }, + css = { "css-lsp", "cssmodules-language-server", "tailwindcss-language-server" }, + cucumber = { "cucumber-language-server" }, + d = { "serve-d" }, + dhall = { "dhall-lsp" }, + dockerfile = { "dockerfile-language-server" }, + dot = { "dot-language-server" }, + elixir = { "elixir-ls" }, + elm = { "elm-format", "elm-language-server" }, + ember = { "ember-language-server" }, + emmet = { "emmet-ls" }, + erlang = { "erlang-ls" }, + ["f#"] = { "fsautocomplete" }, + flux = { "flux-lsp" }, + fortran = { "fortls" }, + go = { "delve", "go-debug-adapter", "golangci-lint", "golangci-lint-langserver", "gomodifytags", "gopls", "gotests", "impl" }, + graphql = { "graphql-language-service-cli" }, + groovy = { "groovy-language-server" }, + haskell = { "haskell-language-server" }, + haxe = { "haxe-language-server" }, + hoon = { "hoon-language-server" }, + html = { "html-lsp" }, + java = { "jdtls" }, + javascript = { "chrome-debug-adapter", "deno", "eslint-lsp", "eslint_d", "firefox-debug-adapter", "node-debug2-adapter", "quick-lint-js", "rome", "typescript-language-server" }, + json = { "json-lsp" }, + jsonnet = { "jsonnet-language-server" }, + julia = { "julia-lsp" }, + kotlin = { "kotlin-language-server", "ktlint" }, + latex = { "ltex-ls", "texlab" }, + lelwel = { "lelwel" }, + less = { "css-lsp" }, + liquid = { "shopify-theme-check" }, + lua = { "lemmy-help", "lua-language-server", "stylua" }, + markdown = { "grammarly-languageserver", "ltex-ls", "marksman", "prosemd-lsp", "remark-language-server", "zk" }, + ["metamath zero"] = { "metamath-zero-lsp" }, + nickel = { "nickel-lang-lsp" }, + nim = { "nimlsp" }, + nix = { "rnix-lsp" }, + ["obective-c"] = { "ccls" }, + ocaml = { "ocaml-lsp" }, + onescript = { "bsl-language-server" }, + opencl = { "opencl-language-server" }, + openfoam = { "foam-language-server" }, + perl = { "perlnavigator" }, + php = { "intelephense", "php-debug-adapter", "phpactor", "psalm" }, + powershell = { "powershell-editor-services" }, + prisma = { "prisma-language-server" }, + puppet = { "puppet-editor-services" }, + purescript = { "purescript-language-server" }, + python = { "debugpy", "jedi-language-server", "pyright", "python-lsp-server", "sourcery" }, + r = { "r-languageserver" }, + reason = { "reason-language-server" }, + rescript = { "rescript-lsp" }, + ["robot framework"] = { "robotframework-lsp" }, + ruby = { "solargraph", "sorbet" }, + rust = { "codelldb", "cpptools", "rust-analyzer" }, + salt = { "salt-lsp" }, + scss = { "css-lsp" }, + slint = { "slint-lsp" }, + solidity = { "solang", "solidity" }, + sphinx = { "esbonio" }, + sql = { "sqlls", "sqls" }, + stylelint = { "stylelint-lsp" }, + svelte = { "svelte-language-server" }, + systemverilog = { "svlangserver", "svls", "verible" }, + teal = { "teal-language-server" }, + terraform = { "terraform-ls", "tflint" }, + text = { "grammarly-languageserver", "ltex-ls" }, + toml = { "taplo" }, + typescript = { "chrome-debug-adapter", "deno", "eslint-lsp", "eslint_d", "firefox-debug-adapter", "node-debug2-adapter", "rome", "typescript-language-server" }, + v = { "vls" }, + vala = { "vala-language-server" }, + vimscript = { "vim-language-server" }, + visualforce = { "visualforce-language-server" }, + vue = { "vetur-vls", "vue-language-server" }, + wgsl = { "wgsl-analyzer" }, + xml = { "lemminx" }, + yaml = { "yaml-language-server" }, + zig = { "zls" } +} \ No newline at end of file diff --git a/lua/mason/ui/init.lua b/lua/mason/ui/init.lua index 56b0b382..2181a555 100644 --- a/lua/mason/ui/init.lua +++ b/lua/mason/ui/init.lua @@ -1,11 +1,16 @@ local settings = require "mason.settings" local M = {} -M.open = function() - local window = require "mason.ui.instance" - window.open { +function M.open() + local api = require "mason.ui.instance" + api.window.open { border = settings.current.ui.border, } end +function M.set_view(view) + local api = require "mason.ui.instance" + api.set_view(view) +end + return M diff --git a/lua/mason/ui/instance.lua b/lua/mason/ui/instance.lua index 95ebe20f..beb73705 100644 --- a/lua/mason/ui/instance.lua +++ b/lua/mason/ui/instance.lua @@ -604,4 +604,9 @@ window.init { highlight_groups = palette.highlight_groups, } -return window +return { + window = window, + set_view = function(view) + set_view { payload = view } + end, +} -- cgit v1.2.3-70-g09d2