From 264d499bcdc3d48a76b0344ad243fc9a2d033142 Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 2 Jan 2022 14:08:54 +0100 Subject: [PATCH] add taplo (#373) --- README.md | 1 + .../_generated/filetype_map.lua | 1 + .../_generated/language_autocomplete_map.lua | 1 + .../_generated/metadata.lua | 3 ++ lua/nvim-lsp-installer/installers/cargo.lua | 30 +++++++++++++++++++ lua/nvim-lsp-installer/servers/init.lua | 1 + lua/nvim-lsp-installer/servers/taplo/init.lua | 15 ++++++++++ 7 files changed, 52 insertions(+) create mode 100644 lua/nvim-lsp-installer/installers/cargo.lua create mode 100644 lua/nvim-lsp-installer/servers/taplo/init.lua diff --git a/README.md b/README.md index 97b4e42ace..bd33ca70b7 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ lsp_installer.settings({ | Stylelint | `stylelint_lsp` | | Svelte | `svelte` | | Swift | `sourcekit` | +| TOML | `taplo` | | Tailwind CSS | `tailwindcss` | | Terraform | `terraformls` | | Terraform [(docs)][tflint] | `tflint` | diff --git a/lua/nvim-lsp-installer/_generated/filetype_map.lua b/lua/nvim-lsp-installer/_generated/filetype_map.lua index 04e8405b38..dcc5fc29c1 100644 --- a/lua/nvim-lsp-installer/_generated/filetype_map.lua +++ b/lua/nvim-lsp-installer/_generated/filetype_map.lua @@ -98,6 +98,7 @@ return { swift = { "sourcekit" }, terraform = { "terraformls", "tflint" }, tex = { "ltex", "texlab" }, + toml = { "taplo" }, twig = { "tailwindcss" }, typescript = { "angularls", "cssmodules_ls", "denols", "ember", "eslint", "rome", "stylelint_lsp", "tailwindcss", "tsserver" }, ["typescript.tsx"] = { "angularls", "denols", "eslint", "rome", "tsserver" }, diff --git a/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua b/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua index 4cac6df678..1660191423 100644 --- a/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua +++ b/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua @@ -25,6 +25,7 @@ return { sql = { "sqlls", "sqls" }, swift = { "sourcekit" }, terraform = { "terraformls", "tflint" }, + toml = { "taplo" }, typescript = { "eslint", "rome", "tsserver" }, vue = { "volar", "vuels" }, xml = { "lemminx" }, diff --git a/lua/nvim-lsp-installer/_generated/metadata.lua b/lua/nvim-lsp-installer/_generated/metadata.lua index 2a68c2eb2c..0533afd675 100644 --- a/lua/nvim-lsp-installer/_generated/metadata.lua +++ b/lua/nvim-lsp-installer/_generated/metadata.lua @@ -208,6 +208,9 @@ return { tailwindcss = { filetypes = { "aspnetcorerazor", "astro", "astro-markdown", "blade", "django-html", "edge", "eelixir", "ejs", "erb", "eruby", "gohtml", "haml", "handlebars", "hbs", "html", "html-eex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte" } }, + taplo = { + filetypes = { "toml" } + }, terraformls = { filetypes = { "terraform" } }, diff --git a/lua/nvim-lsp-installer/installers/cargo.lua b/lua/nvim-lsp-installer/installers/cargo.lua new file mode 100644 index 0000000000..8f4bf0edea --- /dev/null +++ b/lua/nvim-lsp-installer/installers/cargo.lua @@ -0,0 +1,30 @@ +local process = require "nvim-lsp-installer.process" +local path = require "nvim-lsp-installer.path" + +local M = {} + +---@param crates string[] The crates to install. +function M.crates(crates) + ---@type ServerInstallerFunction + return function(_, callback, ctx) + local args = { "install", "--root", ".", "--locked" } + if ctx.requested_server_version then + vim.list_extend(args, { "--version", ctx.requested_server_version }) + end + vim.list_extend(args, crates) + + process.spawn("cargo", { + cwd = ctx.install_dir, + args = args, + stdio_sink = ctx.stdio_sink, + }, callback) + end +end + +---@param root_dir string The directory to resolve the executable from. +---@param executable string +function M.executable(root_dir, executable) + return path.concat { root_dir, "bin", executable } +end + +return M diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua index 7990ebd128..b3c2ba0c8c 100644 --- a/lua/nvim-lsp-installer/servers/init.lua +++ b/lua/nvim-lsp-installer/servers/init.lua @@ -100,6 +100,7 @@ local CORE_SERVERS = Data.set_of { "sumneko_lua", "svelte", "tailwindcss", + "taplo", "terraformls", "texlab", "tflint", diff --git a/lua/nvim-lsp-installer/servers/taplo/init.lua b/lua/nvim-lsp-installer/servers/taplo/init.lua new file mode 100644 index 0000000000..2aacdaefa2 --- /dev/null +++ b/lua/nvim-lsp-installer/servers/taplo/init.lua @@ -0,0 +1,15 @@ +local server = require "nvim-lsp-installer.server" +local cargo = require "nvim-lsp-installer.installers.cargo" + +return function(name, root_dir) + return server.Server:new { + name = name, + root_dir = root_dir, + languages = { "toml" }, + homepage = "https://taplo.tamasfe.dev/lsp/", + installer = cargo.crates { "taplo-lsp" }, + default_options = { + cmd = { cargo.executable(root_dir, "taplo-lsp"), "run" }, + }, + } +end