aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-12-06 16:59:06 +0100
committerGitHub <noreply@github.com>2021-12-06 16:59:06 +0100
commit1f6f518f752b9e71c5eaa0ed156bedea25f12a14 (patch)
tree2c7e0e39fa500d37c6c437f92df61ffcf0365885 /lua
parentAdd arduino-language-server support (#298) (diff)
downloadmason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar.gz
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar.bz2
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar.lz
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar.xz
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.tar.zst
mason-1f6f518f752b9e71c5eaa0ed156bedea25f12a14.zip
add quick_lint_js (#313)
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/_generated/filetype_map.lua2
-rw-r--r--lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua2
-rw-r--r--lua/nvim-lsp-installer/_generated/metadata.lua3
-rw-r--r--lua/nvim-lsp-installer/installers/context.lua37
-rw-r--r--lua/nvim-lsp-installer/servers/init.lua1
-rw-r--r--lua/nvim-lsp-installer/servers/quick_lint_js/init.lua30
6 files changed, 72 insertions, 3 deletions
diff --git a/lua/nvim-lsp-installer/_generated/filetype_map.lua b/lua/nvim-lsp-installer/_generated/filetype_map.lua
index b88bc2a8..22e655e9 100644
--- a/lua/nvim-lsp-installer/_generated/filetype_map.lua
+++ b/lua/nvim-lsp-installer/_generated/filetype_map.lua
@@ -44,7 +44,7 @@ return {
["html-eex"] = { "tailwindcss" },
jade = { "tailwindcss" },
java = { "jdtls" },
- javascript = { "denols", "ember", "eslint", "rome", "stylelint_lsp", "tailwindcss", "tsserver" },
+ javascript = { "denols", "ember", "eslint", "quick_lint_js", "rome", "stylelint_lsp", "tailwindcss", "tsserver" },
["javascript.jsx"] = { "denols", "eslint", "tsserver" },
javascriptreact = { "denols", "eslint", "graphql", "rome", "stylelint_lsp", "tailwindcss", "tsserver" },
json = { "jsonls", "rome" },
diff --git a/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua b/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua
index 4bf055a3..2cf7568c 100644
--- a/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua
+++ b/lua/nvim-lsp-installer/_generated/language_autocomplete_map.lua
@@ -9,7 +9,7 @@ return {
fortran = { "fortls" },
haskell = { "hls" },
java = { "jdtls" },
- javascript = { "rome", "tsserver" },
+ javascript = { "quick_lint_js", "rome", "tsserver" },
latex = { "ltex", "texlab" },
lua = { "sumneko_lua" },
["objective-c"] = { "ccls" },
diff --git a/lua/nvim-lsp-installer/_generated/metadata.lua b/lua/nvim-lsp-installer/_generated/metadata.lua
index ef766355..a150227e 100644
--- a/lua/nvim-lsp-installer/_generated/metadata.lua
+++ b/lua/nvim-lsp-installer/_generated/metadata.lua
@@ -148,6 +148,9 @@ return {
pyright = {
filetypes = { "python" }
},
+ quick_lint_js = {
+ filetypes = { "javascript" }
+ },
rescriptls = {
filetypes = { "rescript" }
},
diff --git a/lua/nvim-lsp-installer/installers/context.lua b/lua/nvim-lsp-installer/installers/context.lua
index e80485a4..d76bd6ba 100644
--- a/lua/nvim-lsp-installer/installers/context.lua
+++ b/lua/nvim-lsp-installer/installers/context.lua
@@ -63,6 +63,41 @@ local function fetch(url, callback)
end
---@param repo string @The GitHub repo ("username/repo").
+function M.use_github_latest_tag(repo)
+ ---@type ServerInstallerFunction
+ return function(_, callback, context)
+ if context.requested_server_version then
+ log.fmt_debug(
+ "Requested server version already provided (%s), skipping fetching tags from GitHub.",
+ context.requested_server_version
+ )
+ -- User has already provided a version - don't fetch the tags from GitHub
+ return callback(true)
+ end
+ context.stdio_sink.stdout "Fetching tags from GitHub API...\n"
+ fetch(
+ ("https://api.github.com/repos/%s/tags"):format(repo),
+ vim.schedule_wrap(function(err, raw_data)
+ if err then
+ context.stdio_sink.stderr(tostring(err) .. "\n")
+ callback(false)
+ return
+ end
+
+ local data = Data.json_decode(raw_data)
+ if vim.tbl_count(data) == 0 then
+ context.stdio_sink.stderr("No tags found for GitHub repo %s.\n", repo)
+ callback(false)
+ return
+ end
+ context.requested_server_version = data[1].name
+ callback(true)
+ end)
+ )
+ end
+end
+
+---@param repo string @The GitHub repo ("username/repo").
function M.use_github_release(repo)
---@type ServerInstallerFunction
return function(server, callback, context)
@@ -79,7 +114,7 @@ function M.use_github_release(repo)
("https://api.github.com/repos/%s/releases/latest"):format(repo),
vim.schedule_wrap(function(err, response)
if err then
- context.stdio_sink.stderr(tostring(err))
+ context.stdio_sink.stderr(tostring(err) .. "\n")
return callback(false)
end
local version = Data.json_decode(response).tag_name
diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua
index f92b7ade..0dd8c30c 100644
--- a/lua/nvim-lsp-installer/servers/init.lua
+++ b/lua/nvim-lsp-installer/servers/init.lua
@@ -80,6 +80,7 @@ local CORE_SERVERS = Data.set_of {
"purescriptls",
"pylsp",
"pyright",
+ "quick_lint_js",
"rescriptls",
"rome",
"rust_analyzer",
diff --git a/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua
new file mode 100644
index 00000000..2c1d2e54
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua
@@ -0,0 +1,30 @@
+local server = require "nvim-lsp-installer.server"
+local std = require "nvim-lsp-installer.installers.std"
+local context = require "nvim-lsp-installer.installers.context"
+local platform = require "nvim-lsp-installer.platform"
+local path = require "nvim-lsp-installer.path"
+
+return function(name, root_dir)
+ return server.Server:new {
+ name = name,
+ root_dir = root_dir,
+ homepage = "https://quick-lint-js.com/",
+ languages = { "javascript" },
+ installer = {
+ context.use_github_latest_tag "quick-lint/quick-lint-js",
+ context.capture(function(ctx)
+ local url = "https://c.quick-lint-js.com/releases/%s/manual/%s%s"
+ if platform.is_mac then
+ return std.untargz_remote(url:format(ctx.requested_server_version, "macos", ".tar.gz"))
+ elseif platform.is_windows then
+ return std.unzip_remote(url:format(ctx.requested_server_version, "windows", ".zip"))
+ elseif platform.is_linux then
+ return std.untargz_remote(url:format(ctx.requested_server_version, "linux", ".tar.gz"))
+ end
+ end),
+ },
+ default_options = {
+ cmd = { path.concat { root_dir, "quick-lint-js", "bin", "quick-lint-js" }, "--lsp-server" },
+ },
+ }
+end