Skip to content

Commit

Permalink
add taplo (chipsalliance#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman authored Jan 2, 2022
1 parent 09e602e commit 264d499
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-lsp-installer/_generated/filetype_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ return {
sql = { "sqlls", "sqls" },
swift = { "sourcekit" },
terraform = { "terraformls", "tflint" },
toml = { "taplo" },
typescript = { "eslint", "rome", "tsserver" },
vue = { "volar", "vuels" },
xml = { "lemminx" },
Expand Down
3 changes: 3 additions & 0 deletions lua/nvim-lsp-installer/_generated/metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
},
Expand Down
30 changes: 30 additions & 0 deletions lua/nvim-lsp-installer/installers/cargo.lua
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lua/nvim-lsp-installer/servers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ local CORE_SERVERS = Data.set_of {
"sumneko_lua",
"svelte",
"tailwindcss",
"taplo",
"terraformls",
"texlab",
"tflint",
Expand Down
15 changes: 15 additions & 0 deletions lua/nvim-lsp-installer/servers/taplo/init.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 264d499

Please sign in to comment.