aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-06-03 19:04:52 +0200
committerGitHub <noreply@github.com>2022-06-03 19:04:52 +0200
commitf5f6538984b5bc9bccfc544960e05d47304f3c5e (patch)
tree9f1f0fcd3b35a7ace0efc9966b652bb9b8234121 /lua
parentadded wgsl_analyzer server (#719) (diff)
downloadmason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar.gz
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar.bz2
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar.lz
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar.xz
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.tar.zst
mason-f5f6538984b5bc9bccfc544960e05d47304f3c5e.zip
feat: add apex_ls (#746)
Closes #701.
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/_generated/filetype_map.lua1
-rw-r--r--lua/nvim-lsp-installer/_generated/metadata.lua3
-rw-r--r--lua/nvim-lsp-installer/core/functional/init.lua2
-rw-r--r--lua/nvim-lsp-installer/core/functional/list.lua5
-rw-r--r--lua/nvim-lsp-installer/core/functional/string.lua7
-rw-r--r--lua/nvim-lsp-installer/core/managers/cargo/client.lua2
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/client.lua5
-rw-r--r--lua/nvim-lsp-installer/servers/apex_ls/init.lua44
-rw-r--r--lua/nvim-lsp-installer/servers/init.lua1
9 files changed, 67 insertions, 3 deletions
diff --git a/lua/nvim-lsp-installer/_generated/filetype_map.lua b/lua/nvim-lsp-installer/_generated/filetype_map.lua
index 31470631..6ecc014e 100644
--- a/lua/nvim-lsp-installer/_generated/filetype_map.lua
+++ b/lua/nvim-lsp-installer/_generated/filetype_map.lua
@@ -2,6 +2,7 @@
-- stylua: ignore start
return {
OpenFOAM = { "foam_ls" },
+ apexcode = { "apex_ls" },
arduino = { "arduino_language_server" },
asm = { "asm_lsp" },
aspnetcorerazor = { "tailwindcss" },
diff --git a/lua/nvim-lsp-installer/_generated/metadata.lua b/lua/nvim-lsp-installer/_generated/metadata.lua
index 4de4b005..c0986d4c 100644
--- a/lua/nvim-lsp-installer/_generated/metadata.lua
+++ b/lua/nvim-lsp-installer/_generated/metadata.lua
@@ -7,6 +7,9 @@ return {
ansiblels = {
filetypes = { "yaml.ansible" }
},
+ apex_ls = {
+ filetypes = { "apexcode" }
+ },
arduino_language_server = {
filetypes = { "arduino" }
},
diff --git a/lua/nvim-lsp-installer/core/functional/init.lua b/lua/nvim-lsp-installer/core/functional/init.lua
index 6987e1a7..3e29037f 100644
--- a/lua/nvim-lsp-installer/core/functional/init.lua
+++ b/lua/nvim-lsp-installer/core/functional/init.lua
@@ -32,6 +32,7 @@ _.concat = list.concat
_.zip_table = list.zip_table
_.nth = list.nth
_.head = list.head
+_.length = list.length
-- relation
local relation = require "nvim-lsp-installer.core.functional.relation"
@@ -62,6 +63,7 @@ local string = require "nvim-lsp-installer.core.functional.string"
_.matches = string.matches
_.format = string.format
_.split = string.split
+_.gsub = string.gsub
-- table
local tbl = require "nvim-lsp-installer.core.functional.table"
diff --git a/lua/nvim-lsp-installer/core/functional/list.lua b/lua/nvim-lsp-installer/core/functional/list.lua
index c12330dd..89393cfb 100644
--- a/lua/nvim-lsp-installer/core/functional/list.lua
+++ b/lua/nvim-lsp-installer/core/functional/list.lua
@@ -115,4 +115,9 @@ end, 2)
_.head = _.nth(1)
+---@param value string|any[]
+_.length = function(value)
+ return #value
+end
+
return _
diff --git a/lua/nvim-lsp-installer/core/functional/string.lua b/lua/nvim-lsp-installer/core/functional/string.lua
index 3fd3aa03..212fc0d9 100644
--- a/lua/nvim-lsp-installer/core/functional/string.lua
+++ b/lua/nvim-lsp-installer/core/functional/string.lua
@@ -20,4 +20,11 @@ _.split = fun.curryN(function(sep, str)
return vim.split(str, sep)
end, 2)
+---@param pattern string
+---@param repl string|function|table
+---@param str string
+_.gsub = fun.curryN(function(pattern, repl, str)
+ return string.gsub(str, pattern, repl)
+end, 3)
+
return _
diff --git a/lua/nvim-lsp-installer/core/managers/cargo/client.lua b/lua/nvim-lsp-installer/core/managers/cargo/client.lua
index 7e69cdf4..d4f0e2a7 100644
--- a/lua/nvim-lsp-installer/core/managers/cargo/client.lua
+++ b/lua/nvim-lsp-installer/core/managers/cargo/client.lua
@@ -6,7 +6,7 @@ local M = {}
---@async
---@param crate string
----@return Result @of [Crate]
+---@return Result @of Crate
function M.fetch_crate(crate)
return fetch(("https://crates.io/api/v1/crates/%s"):format(crate)):map_catching(vim.json.decode)
end
diff --git a/lua/nvim-lsp-installer/core/managers/github/client.lua b/lua/nvim-lsp-installer/core/managers/github/client.lua
index bf79fec6..530fee06 100644
--- a/lua/nvim-lsp-installer/core/managers/github/client.lua
+++ b/lua/nvim-lsp-installer/core/managers/github/client.lua
@@ -24,6 +24,7 @@ end
---@async
---@param repo string @The GitHub repo ("username/repo").
+---@return Result @of GitHubRelease[]
function M.fetch_releases(repo)
log.fmt_trace("Fetching GitHub releases for repo=%s", repo)
local path = ("repos/%s/releases"):format(repo)
@@ -87,7 +88,7 @@ end
---@async
---@param repo string @The GitHub repo ("username/repo").
----@return Result @of [GitHubTag[]]
+---@return Result @of GitHubTag[]
function M.fetch_tags(repo)
local path = ("repos/%s/tags"):format(repo)
return api_call(path):map_err(function()
@@ -97,7 +98,7 @@ end
---@async
---@param repo string @The GitHub repo ("username/repo").
----@return Result @of [GitHubTag]
+---@return Result @of GitHubTag
function M.fetch_latest_tag(repo)
return M.fetch_tags(repo):map_catching(function(tags)
if vim.tbl_count(tags) == 0 then
diff --git a/lua/nvim-lsp-installer/servers/apex_ls/init.lua b/lua/nvim-lsp-installer/servers/apex_ls/init.lua
new file mode 100644
index 00000000..56585b78
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/apex_ls/init.lua
@@ -0,0 +1,44 @@
+local server = require "nvim-lsp-installer.server"
+local github = require "nvim-lsp-installer.core.managers.github"
+local github_client = require "nvim-lsp-installer.core.managers.github.client"
+local git = require "nvim-lsp-installer.core.managers.git"
+local Optional = require "nvim-lsp-installer.core.optional"
+local path = require "nvim-lsp-installer.core.path"
+local _ = require "nvim-lsp-installer.core.functional"
+
+return function(name, root_dir)
+ local JAR_FILE = "apex-jorje-lsp.jar"
+
+ return server.Server:new {
+ name = name,
+ root_dir = root_dir,
+ homepage = "https://github.com/forcedotcom/salesforcedx-vscode",
+ languages = { "apex" },
+ ---@async
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local repo = "forcedotcom/salesforcedx-vscode"
+
+ -- See https://github.com/forcedotcom/salesforcedx-vscode/issues/4184#issuecomment-1146052086
+ ---@type GitHubRelease
+ local release = github_client
+ .fetch_releases(repo)
+ :map(_.find_first(_.prop_satisfies(_.compose(_.gt(0), _.length), "assets")))
+ :map(Optional.of_nilable)
+ :get_or_throw() -- Result unwrap
+ :or_else_throw "Failed to find release with assets." -- Optional unwrap
+
+ github.unzip_release_file({
+ version = Optional.of(release.tag_name),
+ asset_file = _.compose(_.format "salesforcedx-vscode-apex-%s.vsix", _.gsub("^v", "")),
+ repo = repo,
+ }).with_receipt()
+
+ ctx.fs:rename(path.concat { "extension", "out", JAR_FILE }, JAR_FILE)
+ ctx.fs:rmrf "extension"
+ end,
+ default_options = {
+ apex_jar_path = path.concat { root_dir, JAR_FILE },
+ },
+ }
+end
diff --git a/lua/nvim-lsp-installer/servers/init.lua b/lua/nvim-lsp-installer/servers/init.lua
index fc049589..861f4e09 100644
--- a/lua/nvim-lsp-installer/servers/init.lua
+++ b/lua/nvim-lsp-installer/servers/init.lua
@@ -34,6 +34,7 @@ local INSTALL_DIRS = {
local CORE_SERVERS = _.set_of {
"angularls",
"ansiblels",
+ "apex_ls",
"arduino_language_server",
"asm_lsp",
"astro",