aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-21 12:09:59 +0200
committerGitHub <noreply@github.com>2022-04-21 12:09:59 +0200
commitb68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch)
treedf7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua
parentrun autogen_metadata.lua (diff)
downloadmason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.gz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.bz2
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.lz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.xz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.zst
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.zip
chore: refactor remaining installers to async impl (#616)
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer/_generated/schemas/jdtls.lua2
-rw-r--r--lua/nvim-lsp-installer/core/fetch.lua2
-rw-r--r--lua/nvim-lsp-installer/core/fs.lua15
-rw-r--r--lua/nvim-lsp-installer/core/installer/context.lua42
-rw-r--r--lua/nvim-lsp-installer/core/managers/gem/init.lua38
-rw-r--r--lua/nvim-lsp-installer/core/managers/git/init.lua11
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/client.lua51
-rw-r--r--lua/nvim-lsp-installer/core/managers/github/init.lua89
-rw-r--r--lua/nvim-lsp-installer/core/managers/go/init.lua2
-rw-r--r--lua/nvim-lsp-installer/core/managers/pip3/init.lua6
-rw-r--r--lua/nvim-lsp-installer/core/managers/powershell/init.lua6
-rw-r--r--lua/nvim-lsp-installer/core/managers/std/init.lua124
-rw-r--r--lua/nvim-lsp-installer/core/optional.lua12
-rw-r--r--lua/nvim-lsp-installer/core/result.lua9
-rw-r--r--lua/nvim-lsp-installer/core/spawn.lua20
-rw-r--r--lua/nvim-lsp-installer/data.lua12
-rw-r--r--lua/nvim-lsp-installer/platform.lua102
-rw-r--r--lua/nvim-lsp-installer/servers/arduino_language_server/init.lua228
-rw-r--r--lua/nvim-lsp-installer/servers/beancount/init.lua56
-rw-r--r--lua/nvim-lsp-installer/servers/bicep/init.lua38
-rw-r--r--lua/nvim-lsp-installer/servers/bsl_ls/init.lua32
-rw-r--r--lua/nvim-lsp-installer/servers/ccls/common.lua41
-rw-r--r--lua/nvim-lsp-installer/servers/ccls/init.lua186
-rw-r--r--lua/nvim-lsp-installer/servers/ccls/linux.lua75
-rw-r--r--lua/nvim-lsp-installer/servers/ccls/mac.lua22
-rw-r--r--lua/nvim-lsp-installer/servers/clangd/init.lua41
-rw-r--r--lua/nvim-lsp-installer/servers/clarity_lsp/init.lua24
-rw-r--r--lua/nvim-lsp-installer/servers/clojure_lsp/init.lua35
-rw-r--r--lua/nvim-lsp-installer/servers/codeqlls/init.lua24
-rw-r--r--lua/nvim-lsp-installer/servers/crystalline/init.lua57
-rw-r--r--lua/nvim-lsp-installer/servers/denols/init.lua24
-rw-r--r--lua/nvim-lsp-installer/servers/dhall_lsp_server/init.lua79
-rw-r--r--lua/nvim-lsp-installer/servers/elixirls/init.lua27
-rw-r--r--lua/nvim-lsp-installer/servers/erlangls/init.lua43
-rw-r--r--lua/nvim-lsp-installer/servers/groovyls/init.lua5
-rw-r--r--lua/nvim-lsp-installer/servers/hls/init.lua44
-rw-r--r--lua/nvim-lsp-installer/servers/jdtls/init.lua68
-rw-r--r--lua/nvim-lsp-installer/servers/julials/init.lua45
-rw-r--r--lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua19
-rw-r--r--lua/nvim-lsp-installer/servers/lemminx/init.lua61
-rw-r--r--lua/nvim-lsp-installer/servers/ltex/init.lua53
-rw-r--r--lua/nvim-lsp-installer/servers/mm0_ls/init.lua5
-rw-r--r--lua/nvim-lsp-installer/servers/omnisharp/init.lua76
-rw-r--r--lua/nvim-lsp-installer/servers/opencl_ls/init.lua45
-rw-r--r--lua/nvim-lsp-installer/servers/powershell_es/init.lua27
-rw-r--r--lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua37
-rw-r--r--lua/nvim-lsp-installer/servers/puppet/init.lua23
-rw-r--r--lua/nvim-lsp-installer/servers/quick_lint_js/init.lua105
-rw-r--r--lua/nvim-lsp-installer/servers/r_language_server/init.lua1
-rw-r--r--lua/nvim-lsp-installer/servers/reason_ls/init.lua34
-rw-r--r--lua/nvim-lsp-installer/servers/rescriptls/init.lua23
-rw-r--r--lua/nvim-lsp-installer/servers/rust_analyzer/init.lua91
-rw-r--r--lua/nvim-lsp-installer/servers/serve_d/init.lua51
-rw-r--r--lua/nvim-lsp-installer/servers/slint_lsp/init.lua38
-rw-r--r--lua/nvim-lsp-installer/servers/solang/init.lua69
-rw-r--r--lua/nvim-lsp-installer/servers/solc/init.lua31
-rw-r--r--lua/nvim-lsp-installer/servers/spectral/init.lua10
-rw-r--r--lua/nvim-lsp-installer/servers/sumneko_lua/init.lua65
-rw-r--r--lua/nvim-lsp-installer/servers/terraformls/init.lua59
-rw-r--r--lua/nvim-lsp-installer/servers/texlab/init.lua44
-rw-r--r--lua/nvim-lsp-installer/servers/tflint/init.lua75
-rw-r--r--lua/nvim-lsp-installer/servers/vala_ls/init.lua57
-rw-r--r--lua/nvim-lsp-installer/servers/verible/init.lua99
-rw-r--r--lua/nvim-lsp-installer/servers/zeta_note/init.lua29
-rw-r--r--lua/nvim-lsp-installer/servers/zk/init.lua51
-rw-r--r--lua/nvim-lsp-installer/servers/zls/init.lua48
-rw-r--r--lua/nvim-lsp-installer/ui/init.lua5
-rw-r--r--lua/nvim-lsp-installer/ui/status-win/init.lua10
68 files changed, 1700 insertions, 1378 deletions
diff --git a/lua/nvim-lsp-installer/_generated/schemas/jdtls.lua b/lua/nvim-lsp-installer/_generated/schemas/jdtls.lua
index e7a14602..e63b55e1 100644
--- a/lua/nvim-lsp-installer/_generated/schemas/jdtls.lua
+++ b/lua/nvim-lsp-installer/_generated/schemas/jdtls.lua
@@ -1,3 +1,3 @@
-- THIS FILE IS GENERATED. DO NOT EDIT MANUALLY.
-- stylua: ignore start
-return {properties = {["java.autobuild.enabled"] = {default = true,description = "Enable/disable the 'auto build'",scope = "window",type = "boolean"},["java.codeGeneration.generateComments"] = {default = false,description = "Generate method comments when generating the methods.",scope = "window",type = "boolean"},["java.codeGeneration.hashCodeEquals.useInstanceof"] = {default = false,description = "Use 'instanceof' to compare types when generating the hashCode and equals methods.",scope = "window",type = "boolean"},["java.codeGeneration.hashCodeEquals.useJava7Objects"] = {default = false,description = "Use Objects.hash and Objects.equals when generating the hashCode and equals methods. This setting only applies to Java 7 and higher.",scope = "window",type = "boolean"},["java.codeGeneration.insertionLocation"] = {default = "afterCursor",description = "Specifies the insertion location of the code generated by source actions.",enum = { "afterCursor", "beforeCursor", "lastMember" },enumDescriptions = { "Insert the generated code after the member where the cursor is located.", "Insert the generated code before the member where the cursor is located.", "Insert the generated code as the last member of the target type." },scope = "window",type = "string"},["java.codeGeneration.toString.codeStyle"] = {default = "STRING_CONCATENATION",description = "The code style for generating the toString method.",enum = { "STRING_CONCATENATION", "STRING_BUILDER", "STRING_BUILDER_CHAINED", "STRING_FORMAT" },enumDescriptions = { "String concatenation", "StringBuilder/StringBuffer", "StringBuilder/StringBuffer - chained call", "String.format/MessageFormat" },type = "string"},["java.codeGeneration.toString.limitElements"] = {default = 0,description = "Limit number of items in arrays/collections/maps to list, if 0 then list all.",scope = "window",type = "integer"},["java.codeGeneration.toString.listArrayContents"] = {default = true,description = "List contents of arrays instead of using native toString().",scope = "window",type = "boolean"},["java.codeGeneration.toString.skipNullValues"] = {default = false,description = "Skip null values when generating the toString method.",scope = "window",type = "boolean"},["java.codeGeneration.toString.template"] = {default = "${object.className} [${member.name()}=${member.value}, ${otherMembers}]",description = "The template for generating the toString method.",type = "string"},["java.codeGeneration.useBlocks"] = {default = false,description = "Use blocks in 'if' statements when generating the methods.",scope = "window",type = "boolean"},["java.completion.enabled"] = {default = true,description = "Enable/disable code completion support",scope = "window",type = "boolean"},["java.completion.favoriteStaticMembers"] = {default = { "org.junit.Assert.*", "org.junit.Assume.*", "org.junit.jupiter.api.Assertions.*", "org.junit.jupiter.api.Assumptions.*", "org.junit.jupiter.api.DynamicContainer.*", "org.junit.jupiter.api.DynamicTest.*", "org.mockito.Mockito.*", "org.mockito.ArgumentMatchers.*", "org.mockito.Answers.*" },description = "Defines a list of static members or types with static members. Content assist will propose those static members even if the import is missing.",scope = "window",type = "array"},["java.completion.filteredTypes"] = {default = { "java.awt.*", "com.sun.*", "sun.*", "jdk.*", "org.graalvm.*", "io.micrometer.shaded.*" },description = "Defines the type filters. All types whose fully qualified name matches the selected filter strings will be ignored in content assist or quick fix proposals and when organizing imports. For example 'java.awt.*' will hide all types from the awt packages.",scope = "window",type = "array"},["java.completion.guessMethodArguments"] = {default = false,description = "When set to true, method arguments are guessed when a method is selected from as list of code assist proposals.",scope = "window",type = "boolean"},["java.completion.importOrder"] = {default = { "java", "javax", "com", "org" },description = "Defines the sorting order of import statements. A package or type name prefix (e.g. 'org.eclipse') is a valid entry. An import is always added to the most specific group.",scope = "window",type = "array"},["java.completion.maxResults"] = {default = 0,markdownDescription = "Maximum number of completion results (not including snippets).\n`0` (the default value) disables the limit, all results are returned. In case of performance problems, consider setting a sensible limit.",scope = "window",type = "integer"},["java.completion.overwrite"] = {default = true,description = "When set to true, code completion overwrites the current text. When set to false, code is simply added instead.",scope = "window",type = "boolean"},["java.configuration.checkProjectSettingsExclusions"] = {default = false,deprecationMessage = "Please use 'java.import.generatesMetadataFilesAtProjectRoot' to control whether to generate the project metadata files at the project root. And use 'files.exclude' to control whether to hide the project metadata files from the file explorer.",description = "Controls whether to exclude extension-generated project settings files (.project, .classpath, .factorypath, .settings/) from the file explorer.",scope = "window",type = "boolean"},["java.configuration.maven.globalSettings"] = {default = vim.NIL,description = "Path to Maven's global settings.xml",scope = "window",type = "string"},["java.configuration.maven.notCoveredPluginExecutionSeverity"] = {default = "warning",description = "Specifies severity if the plugin execution is not covered by Maven build lifecycle.",enum = { "ignore", "warning", "error" },scope = "window",type = "string"},["java.configuration.maven.userSettings"] = {default = vim.NIL,description = "Path to Maven's user settings.xml",scope = "window",type = "string"},["java.configuration.runtimes"] = {default = {},description = "Map Java Execution Environments to local JDKs.",items = {additionalProperties = false,default = vim.empty_dict(),properties = {default = {description = "Is default runtime? Only one runtime can be default.",type = "boolean"},javadoc = {description = "JDK javadoc path.",type = "string"},name = {description = "Java Execution Environment name. Must be unique.",enum = { "J2SE-1.5", "JavaSE-1.6", "JavaSE-1.7", "JavaSE-1.8", "JavaSE-9", "JavaSE-10", "JavaSE-11", "JavaSE-12", "JavaSE-13", "JavaSE-14", "JavaSE-15", "JavaSE-16", "JavaSE-17", "JavaSE-18" },type = "string"},path = {description = 'JDK home path. Should be the JDK installation directory, not the Java bin path.\n On Windows, backslashes must be escaped, i.e.\n"path":"C:\\\\Program Files\\\\Java\\\\jdk1.8.0_161".',pattern = ".*(?<!\\/bin|\\/bin\\/|\\\\bin|\\\\bin\\\\)$",type = "string"},sources = {description = "JDK sources path.",type = "string"}},required = { "path", "name" },type = "object"},scope = "machine-overridable",type = "array"},["java.configuration.updateBuildConfiguration"] = {default = "interactive",description = "Specifies how modifications on build files update the Java classpath/configuration",enum = { "disabled", "interactive", "automatic" },scope = "window",type = { "string" }},["java.configuration.workspaceCacheLimit"] = {default = 90,description = "The number of days (if enabled) to keep unused workspace cache data. Beyond this limit, cached workspace data may be removed.",minimum = 1,scope = "application",type = { "null", "integer" }},["java.contentProvider.preferred"] = {default = vim.NIL,description = "Preferred content provider (a 3rd party decompiler id, usually)",scope = "window",type = "string"},["java.eclipse.downloadSources"] = {default = false,description = "Enable/disable download of Maven source artifacts for Eclipse projects.",scope = "window",type = "boolean"},["java.errors.incompleteClasspath.severity"] = {default = "warning",description = "Specifies the severity of the message when the classpath is incomplete for a Java file",enum = { "ignore", "info", "warning", "error" },scope = "window",type = { "string" }},["java.foldingRange.enabled"] = {default = true,description = "Enable/disable smart folding range support. If disabled, it will use the default indentation-based folding range provided by VS Code.",scope = "window",type = "boolean"},["java.format.comments.enabled"] = {default = true,description = "Includes the comments during code formatting.",scope = "window",type = "boolean"},["java.format.enabled"] = {default = true,description = "Enable/disable default Java formatter",scope = "window",type = "boolean"},["java.format.onType.enabled"] = {default = true,description = "Enable/disable automatic block formatting when typing `;`, `<enter>` or `}`",scope = "window",type = "boolean"},["java.format.settings.profile"] = {default = vim.NIL,description = "Optional formatter profile name from the Eclipse formatter settings.",scope = "window",type = "string"},["java.format.settings.url"] = {default = vim.NIL,markdownDescription = "Specifies the url or file path to the [Eclipse formatter xml settings](https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings).",scope = "window",type = "string"},["java.home"] = {default = vim.NIL,deprecationMessage = "This setting is deprecated, please use 'java.jdt.ls.java.home' instead.",description = 'Specifies the folder path to the JDK (11 or more recent) used to launch the Java Language Server.\nOn Windows, backslashes must be escaped, i.e.\n"java.home":"C:\\\\Program Files\\\\Java\\\\jdk11.0_8"',scope = "machine-overridable",type = { "string", "null" }},["java.implementationsCodeLens.enabled"] = {default = false,description = "Enable/disable the implementations code lens.",scope = "window",type = "boolean"},["java.import.exclusions"] = {default = { "**/node_modules/**", "**/.metadata/**", "**/archetype-resources/**", "**/META-INF/maven/**" },description = "Configure glob patterns for excluding folders. Use `!` to negate patterns to allow subfolders imports. You have to include a parent directory. The order is important.",scope = "window",type = "array"},["java.import.generatesMetadataFilesAtProjectRoot"] = {default = false,markdownDescription = "Specify whether the project metadata files(.project, .classpath, .factorypath, .settings/) will be generated at the project root. Click [HERE](command:_java.metadataFilesGeneration) to learn how to change the setting to make it take effect.",scope = "window",type = "boolean"},["java.import.gradle.arguments"] = {default = vim.NIL,description = "Arguments to pass to Gradle.",scope = "machine",type = "string"},["java.import.gradle.enabled"] = {default = true,description = "Enable/disable the Gradle importer.",scope = "window",type = "boolean"},["java.import.gradle.home"] = {default = vim.NIL,description = "Use Gradle from the specified local installation directory or GRADLE_HOME if the Gradle wrapper is missing or disabled and no 'java.import.gradle.version' is specified.",scope = "window",type = "string"},["java.import.gradle.java.home"] = {default = vim.NIL,description = "The location to the JVM used to run the Gradle daemon.",scope = "machine",type = "string"},["java.import.gradle.jvmArguments"] = {default = vim.NIL,description = "JVM arguments to pass to Gradle.",scope = "machine",type = "string"},["java.import.gradle.offline.enabled"] = {default = false,description = "Enable/disable the Gradle offline mode.",scope = "window",type = "boolean"},["java.import.gradle.user.home"] = {default = vim.NIL,description = "Setting for GRADLE_USER_HOME.",scope = "window",type = "string"},["java.import.gradle.version"] = {default = vim.NIL,description = "Use Gradle from the specific version if the Gradle wrapper is missing or disabled.",scope = "window",type = "string"},["java.import.gradle.wrapper.enabled"] = {default = true,description = "Use Gradle from the 'gradle-wrapper.properties' file.",scope = "window",type = "boolean"},["java.import.maven.enabled"] = {default = true,description = "Enable/disable the Maven importer.",scope = "window",type = "boolean"},["java.imports.gradle.wrapper.checksums"] = {default = {},description = "Defines allowed/disallowed SHA-256 checksums of Gradle Wrappers",items = {additionalProperties = false,default = vim.empty_dict(),properties = {allowed = {default = true,label = "Is allowed?",type = "boolean"},sha256 = {label = "SHA-256 checksum.",type = "string"}},required = { "sha256" },type = "object",uniqueItems = true},scope = "application",type = "array"},["java.inlayHints.parameterNames.enabled"] = {default = "literals",enum = { "none", "literals", "all" },enumDescriptions = { "Disable parameter name hints", "Enable parameter name hints only for literal arguments", "Enable parameter name hints for literal and non-literal arguments" },markdownDescription = "Enable/disable inlay hints for parameter names:\n```java\n\nInteger.valueOf(/* s: */ '123', /* radix: */ 10)\n \n```\n",scope = "window",type = "string"},["java.jdt.ls.java.home"] = {default = vim.NIL,description = "Specifies the folder path to the JDK (11 or more recent) used to launch the Java Language Server. This setting will replace the Java extension's embedded JRE to start the Java Language Server. \n\nOn Windows, backslashes must be escaped, i.e.\n\"java.jdt.ls.java.home\":\"C:\\\\Program Files\\\\Java\\\\jdk11.0_8\"",scope = "machine-overridable",type = { "string", "null" }},["java.jdt.ls.vmargs"] = {default = "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m",description = "Specifies extra VM arguments used to launch the Java Language Server. Eg. use `-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m ` to optimize memory usage with the parallel garbage collector",scope = "machine-overridable",type = { "string", "null" }},["java.maven.downloadSources"] = {default = false,description = "Enable/disable download of Maven source artifacts as part of importing Maven projects.",scope = "window",type = "boolean"},["java.maven.updateSnapshots"] = {default = false,description = "Force update of Snapshots/Releases.",scope = "window",type = "boolean"},["java.maxConcurrentBuilds"] = {default = 1,description = "Max simultaneous project builds",minimum = 1,scope = "window",type = "integer"},["java.progressReports.enabled"] = {default = true,description = "[Experimental] Enable/disable progress reports from background processes on the server.",scope = "window",type = "boolean"},["java.project.importHint"] = {default = true,description = "Enable/disable the server-mode switch information, when Java projects import is skipped on startup.",scope = "application",type = "boolean"},["java.project.importOnFirstTimeStartup"] = {default = "automatic",description = "Specifies whether to import the Java projects, when opening the folder in Hybrid mode for the first time.",enum = { "disabled", "interactive", "automatic" },scope = "application",type = "string"},["java.project.outputPath"] = {default = "",markdownDescription = "A relative path to the workspace where stores the compiled output. `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven or Gradle project.",scope = "window",type = { "string", "null" }},["java.project.referencedLibraries"] = {additionalProperties = false,default = { "lib/**/*.jar" },description = "Configure glob patterns for referencing local libraries to a Java project.",properties = {exclude = {type = "array"},include = {type = "array"},sources = {type = "object"}},required = { "include" },scope = "window",type = { "array", "object" }},["java.project.resourceFilters"] = {default = { "node_modules", ".git" },description = "Excludes files and folders from being refreshed by the Java Language Server, which can improve the overall performance. For example, [\"node_modules\",\".git\"] will exclude all files and folders named 'node_modules' or '.git'. Defaults to [\"node_modules\",\".git\"].",scope = "window",type = "array"},["java.project.sourcePaths"] = {default = {},items = {type = "string"},markdownDescription = "Relative paths to the workspace where stores the source files. `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven or Gradle project.",scope = "window",type = "array"},["java.quickfix.showAt"] = {default = "line",description = "Show quickfixes at the problem or line level.",enum = { "line", "problem" },scope = "window",type = "string"},["java.recommendations.dependency.analytics.show"] = {default = true,description = "Show the recommended Dependency Analytics extension.",scope = "window",type = "boolean"},["java.references.includeAccessors"] = {default = true,description = "Include getter, setter and builder/constructor when finding references.",scope = "window",type = "boolean"},["java.references.includeDecompiledSources"] = {default = true,description = "Include the decompiled sources when finding references.",scope = "window",type = "boolean"},["java.referencesCodeLens.enabled"] = {default = false,description = "Enable/disable the references code lens.",scope = "window",type = "boolean"},["java.saveActions.organizeImports"] = {default = false,description = "Enable/disable auto organize imports on save action",scope = "window",type = "boolean"},["java.selectionRange.enabled"] = {default = true,description = "Enable/disable Smart Selection support for Java. Disabling this option will not affect the VS Code built-in word-based and bracket-based smart selection.",scope = "window",type = "boolean"},["java.server.launchMode"] = {default = "Hybrid",description = "The launch mode for the Java extension",enum = { "Standard", "LightWeight", "Hybrid" },enumDescriptions = { "Provides full features such as intellisense, refactoring, building, Maven/Gradle support etc.", "Starts a syntax server with lower start-up cost. Only provides syntax features such as outline, navigation, javadoc, syntax errors.", "Provides full features with better responsiveness. It starts a standard language server and a secondary syntax server. The syntax server provides syntax features until the standard server is ready." },scope = "window",type = "string"},["java.settings.url"] = {default = vim.NIL,markdownDescription = "Specifies the url or file path to the workspace Java settings. See [Setting Global Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)",scope = "window",type = "string"},["java.showBuildStatusOnStart.enabled"] = {anyOf = { {enum = { "notification", "terminal", "off" },enumDescriptions = { "Show the build status via progress notification on start", "Show the build status via terminal on start", "Do not show any build status on start" }}, "boolean" },default = "notification",description = "Automatically show build status on startup.",scope = "window"},["java.signatureHelp.enabled"] = {default = false,description = "Enable/disable the signature help.",scope = "window",type = "boolean"},["java.sources.organizeImports.starThreshold"] = {default = 99,description = "Specifies the number of imports added before a star-import declaration is used.",minimum = 1,scope = "window",type = "integer"},["java.sources.organizeImports.staticStarThreshold"] = {default = 99,description = "Specifies the number of static imports added before a star-import declaration is used.",minimum = 1,scope = "window",type = "integer"},["java.symbols.includeSourceMethodDeclarations"] = {default = false,markdownDescription = "Include method declarations from source files in symbol search.",scope = "window",type = "boolean"},["java.templates.fileHeader"] = {default = {},markdownDescription = "Specifies the file header comment for new Java file. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).",scope = "window",type = "array"},["java.templates.typeComment"] = {default = {},markdownDescription = "Specifies the type comment for new Java type. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).",scope = "window",type = "array"},["java.trace.server"] = {default = "off",description = "Traces the communication between VS Code and the Java language server.",enum = { "off", "messages", "verbose" },scope = "window",type = "string"},["java.typeHierarchy.lazyLoad"] = {default = false,description = "Enable/disable lazy loading the content in type hierarchy. Lazy loading could save a lot of loading time but every type should be expanded manually to load its content.",scope = "window",type = "boolean"}},title = "Java",type = "object"} \ No newline at end of file
+return {properties = {["java.autobuild.enabled"] = {default = true,description = "Enable/disable the 'auto build'",scope = "window",type = "boolean"},["java.codeGeneration.generateComments"] = {default = false,description = "Generate method comments when generating the methods.",scope = "window",type = "boolean"},["java.codeGeneration.hashCodeEquals.useInstanceof"] = {default = false,description = "Use 'instanceof' to compare types when generating the hashCode and equals methods.",scope = "window",type = "boolean"},["java.codeGeneration.hashCodeEquals.useJava7Objects"] = {default = false,description = "Use Objects.hash and Objects.equals when generating the hashCode and equals methods. This setting only applies to Java 7 and higher.",scope = "window",type = "boolean"},["java.codeGeneration.insertionLocation"] = {default = "afterCursor",description = "Specifies the insertion location of the code generated by source actions.",enum = { "afterCursor", "beforeCursor", "lastMember" },enumDescriptions = { "Insert the generated code after the member where the cursor is located.", "Insert the generated code before the member where the cursor is located.", "Insert the generated code as the last member of the target type." },scope = "window",type = "string"},["java.codeGeneration.toString.codeStyle"] = {default = "STRING_CONCATENATION",description = "The code style for generating the toString method.",enum = { "STRING_CONCATENATION", "STRING_BUILDER", "STRING_BUILDER_CHAINED", "STRING_FORMAT" },enumDescriptions = { "String concatenation", "StringBuilder/StringBuffer", "StringBuilder/StringBuffer - chained call", "String.format/MessageFormat" },type = "string"},["java.codeGeneration.toString.limitElements"] = {default = 0,description = "Limit number of items in arrays/collections/maps to list, if 0 then list all.",scope = "window",type = "integer"},["java.codeGeneration.toString.listArrayContents"] = {default = true,description = "List contents of arrays instead of using native toString().",scope = "window",type = "boolean"},["java.codeGeneration.toString.skipNullValues"] = {default = false,description = "Skip null values when generating the toString method.",scope = "window",type = "boolean"},["java.codeGeneration.toString.template"] = {default = "${object.className} [${member.name()}=${member.value}, ${otherMembers}]",description = "The template for generating the toString method.",type = "string"},["java.codeGeneration.useBlocks"] = {default = false,description = "Use blocks in 'if' statements when generating the methods.",scope = "window",type = "boolean"},["java.completion.enabled"] = {default = true,description = "Enable/disable code completion support",scope = "window",type = "boolean"},["java.completion.favoriteStaticMembers"] = {default = { "org.junit.Assert.*", "org.junit.Assume.*", "org.junit.jupiter.api.Assertions.*", "org.junit.jupiter.api.Assumptions.*", "org.junit.jupiter.api.DynamicContainer.*", "org.junit.jupiter.api.DynamicTest.*", "org.mockito.Mockito.*", "org.mockito.ArgumentMatchers.*", "org.mockito.Answers.*" },description = "Defines a list of static members or types with static members. Content assist will propose those static members even if the import is missing.",scope = "window",type = "array"},["java.completion.filteredTypes"] = {default = { "java.awt.*", "com.sun.*", "sun.*", "jdk.*", "org.graalvm.*", "io.micrometer.shaded.*" },description = "Defines the type filters. All types whose fully qualified name matches the selected filter strings will be ignored in content assist or quick fix proposals and when organizing imports. For example 'java.awt.*' will hide all types from the awt packages.",scope = "window",type = "array"},["java.completion.guessMethodArguments"] = {default = false,description = "When set to true, method arguments are guessed when a method is selected from as list of code assist proposals.",scope = "window",type = "boolean"},["java.completion.importOrder"] = {default = { "java", "javax", "com", "org" },description = "Defines the sorting order of import statements. A package or type name prefix (e.g. 'org.eclipse') is a valid entry. An import is always added to the most specific group.",scope = "window",type = "array"},["java.completion.maxResults"] = {default = 0,markdownDescription = "Maximum number of completion results (not including snippets).\n`0` (the default value) disables the limit, all results are returned. In case of performance problems, consider setting a sensible limit.",scope = "window",type = "integer"},["java.completion.overwrite"] = {default = true,description = "When set to true, code completion overwrites the current text. When set to false, code is simply added instead.",scope = "window",type = "boolean"},["java.configuration.checkProjectSettingsExclusions"] = {default = false,deprecationMessage = "Please use 'java.import.generatesMetadataFilesAtProjectRoot' to control whether to generate the project metadata files at the project root. And use 'files.exclude' to control whether to hide the project metadata files from the file explorer.",description = "Controls whether to exclude extension-generated project settings files (.project, .classpath, .factorypath, .settings/) from the file explorer.",scope = "window",type = "boolean"},["java.configuration.maven.globalSettings"] = {default = vim.NIL,description = "Path to Maven's global settings.xml",scope = "window",type = "string"},["java.configuration.maven.notCoveredPluginExecutionSeverity"] = {default = "warning",description = "Specifies severity if the plugin execution is not covered by Maven build lifecycle.",enum = { "ignore", "warning", "error" },scope = "window",type = "string"},["java.configuration.maven.userSettings"] = {default = vim.NIL,description = "Path to Maven's user settings.xml",scope = "window",type = "string"},["java.configuration.runtimes"] = {default = {},description = "Map Java Execution Environments to local JDKs.",items = {additionalProperties = false,default = vim.empty_dict(),properties = {default = {description = "Is default runtime? Only one runtime can be default.",type = "boolean"},javadoc = {description = "JDK javadoc path.",type = "string"},name = {description = "Java Execution Environment name. Must be unique.",enum = { "J2SE-1.5", "JavaSE-1.6", "JavaSE-1.7", "JavaSE-1.8", "JavaSE-9", "JavaSE-10", "JavaSE-11", "JavaSE-12", "JavaSE-13", "JavaSE-14", "JavaSE-15", "JavaSE-16", "JavaSE-17", "JavaSE-18" },type = "string"},path = {description = 'JDK home path. Should be the JDK installation directory, not the Java bin path.\n On Windows, backslashes must be escaped, i.e.\n"path":"C:\\\\Program Files\\\\Java\\\\jdk1.8.0_161".',pattern = ".*(?<!\\/bin|\\/bin\\/|\\\\bin|\\\\bin\\\\)$",type = "string"},sources = {description = "JDK sources path.",type = "string"}},required = { "path", "name" },type = "object"},scope = "machine-overridable",type = "array"},["java.configuration.updateBuildConfiguration"] = {default = "interactive",description = "Specifies how modifications on build files update the Java classpath/configuration",enum = { "disabled", "interactive", "automatic" },scope = "window",type = { "string" }},["java.configuration.workspaceCacheLimit"] = {default = 90,description = "The number of days (if enabled) to keep unused workspace cache data. Beyond this limit, cached workspace data may be removed.",minimum = 1,scope = "application",type = { "null", "integer" }},["java.contentProvider.preferred"] = {default = vim.NIL,description = "Preferred content provider (a 3rd party decompiler id, usually)",scope = "window",type = "string"},["java.eclipse.downloadSources"] = {default = false,description = "Enable/disable download of Maven source artifacts for Eclipse projects.",scope = "window",type = "boolean"},["java.errors.incompleteClasspath.severity"] = {default = "warning",description = "Specifies the severity of the message when the classpath is incomplete for a Java file",enum = { "ignore", "info", "warning", "error" },scope = "window",type = { "string" }},["java.foldingRange.enabled"] = {default = true,description = "Enable/disable smart folding range support. If disabled, it will use the default indentation-based folding range provided by VS Code.",scope = "window",type = "boolean"},["java.format.comments.enabled"] = {default = true,description = "Includes the comments during code formatting.",scope = "window",type = "boolean"},["java.format.enabled"] = {default = true,description = "Enable/disable default Java formatter",scope = "window",type = "boolean"},["java.format.onType.enabled"] = {default = true,description = "Enable/disable automatic block formatting when typing `;`, `<enter>` or `}`",scope = "window",type = "boolean"},["java.format.settings.profile"] = {default = vim.NIL,description = "Optional formatter profile name from the Eclipse formatter settings.",scope = "window",type = "string"},["java.format.settings.url"] = {default = vim.NIL,markdownDescription = "Specifies the url or file path to the [Eclipse formatter xml settings](https://github.com/redhat-developer/vscode-java/wiki/Formatter-settings).",scope = "window",type = "string"},["java.home"] = {default = vim.NIL,deprecationMessage = "This setting is deprecated, please use 'java.jdt.ls.java.home' instead.",description = 'Specifies the folder path to the JDK (11 or more recent) used to launch the Java Language Server.\nOn Windows, backslashes must be escaped, i.e.\n"java.home":"C:\\\\Program Files\\\\Java\\\\jdk11.0_8"',scope = "machine-overridable",type = { "string", "null" }},["java.implementationsCodeLens.enabled"] = {default = false,description = "Enable/disable the implementations code lens.",scope = "window",type = "boolean"},["java.import.exclusions"] = {default = { "**/node_modules/**", "**/.metadata/**", "**/archetype-resources/**", "**/META-INF/maven/**" },description = "Configure glob patterns for excluding folders. Use `!` to negate patterns to allow subfolders imports. You have to include a parent directory. The order is important.",scope = "window",type = "array"},["java.import.generatesMetadataFilesAtProjectRoot"] = {default = false,markdownDescription = "Specify whether the project metadata files(.project, .classpath, .factorypath, .settings/) will be generated at the project root. Click [HERE](command:_java.metadataFilesGeneration) to learn how to change the setting to make it take effect.",scope = "window",type = "boolean"},["java.import.gradle.arguments"] = {default = vim.NIL,description = "Arguments to pass to Gradle.",scope = "machine",type = "string"},["java.import.gradle.enabled"] = {default = true,description = "Enable/disable the Gradle importer.",scope = "window",type = "boolean"},["java.import.gradle.home"] = {default = vim.NIL,description = "Use Gradle from the specified local installation directory or GRADLE_HOME if the Gradle wrapper is missing or disabled and no 'java.import.gradle.version' is specified.",scope = "window",type = "string"},["java.import.gradle.java.home"] = {default = vim.NIL,description = "The location to the JVM used to run the Gradle daemon.",scope = "machine",type = "string"},["java.import.gradle.jvmArguments"] = {default = vim.NIL,description = "JVM arguments to pass to Gradle.",scope = "machine",type = "string"},["java.import.gradle.offline.enabled"] = {default = false,description = "Enable/disable the Gradle offline mode.",scope = "window",type = "boolean"},["java.import.gradle.user.home"] = {default = vim.NIL,description = "Setting for GRADLE_USER_HOME.",scope = "window",type = "string"},["java.import.gradle.version"] = {default = vim.NIL,description = "Use Gradle from the specific version if the Gradle wrapper is missing or disabled.",scope = "window",type = "string"},["java.import.gradle.wrapper.enabled"] = {default = true,description = "Use Gradle from the 'gradle-wrapper.properties' file.",scope = "window",type = "boolean"},["java.import.maven.enabled"] = {default = true,description = "Enable/disable the Maven importer.",scope = "window",type = "boolean"},["java.imports.gradle.wrapper.checksums"] = {default = {},description = "Defines allowed/disallowed SHA-256 checksums of Gradle Wrappers",items = {additionalProperties = false,default = vim.empty_dict(),properties = {allowed = {default = true,label = "Is allowed?",type = "boolean"},sha256 = {label = "SHA-256 checksum.",type = "string"}},required = { "sha256" },type = "object",uniqueItems = true},scope = "application",type = "array"},["java.inlayHints.parameterNames.enabled"] = {default = "literals",enum = { "none", "literals", "all" },enumDescriptions = { "Disable parameter name hints", "Enable parameter name hints only for literal arguments", "Enable parameter name hints for literal and non-literal arguments" },markdownDescription = "Enable/disable inlay hints for parameter names:\n```java\n\nInteger.valueOf(/* s: */ '123', /* radix: */ 10)\n \n```\n",scope = "window",type = "string"},["java.jdt.ls.java.home"] = {default = vim.NIL,description = "Specifies the folder path to the JDK (11 or more recent) used to launch the Java Language Server. This setting will replace the Java extension's embedded JRE to start the Java Language Server. \n\nOn Windows, backslashes must be escaped, i.e.\n\"java.jdt.ls.java.home\":\"C:\\\\Program Files\\\\Java\\\\jdk11.0_8\"",scope = "machine-overridable",type = { "string", "null" }},["java.jdt.ls.vmargs"] = {default = "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m",description = "Specifies extra VM arguments used to launch the Java Language Server. Eg. use `-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx1G -Xms100m ` to optimize memory usage with the parallel garbage collector",scope = "machine-overridable",type = { "string", "null" }},["java.maven.downloadSources"] = {default = false,description = "Enable/disable download of Maven source artifacts as part of importing Maven projects.",scope = "window",type = "boolean"},["java.maven.updateSnapshots"] = {default = false,description = "Force update of Snapshots/Releases.",scope = "window",type = "boolean"},["java.maxConcurrentBuilds"] = {default = 1,description = "Max simultaneous project builds",minimum = 1,scope = "window",type = "integer"},["java.progressReports.enabled"] = {default = true,description = "[Experimental] Enable/disable progress reports from background processes on the server.",scope = "window",type = "boolean"},["java.project.encoding"] = {default = "ignore",enum = { "ignore", "warning", "setDefault" },enumDescriptions = { "Ignore project encoding settings", "Show warning if a project has no explicit encoding set", "Set the default workspace encoding settings" },markdownDescription = "Project encoding settings",scope = "window"},["java.project.importHint"] = {default = true,description = "Enable/disable the server-mode switch information, when Java projects import is skipped on startup.",scope = "application",type = "boolean"},["java.project.importOnFirstTimeStartup"] = {default = "automatic",description = "Specifies whether to import the Java projects, when opening the folder in Hybrid mode for the first time.",enum = { "disabled", "interactive", "automatic" },scope = "application",type = "string"},["java.project.outputPath"] = {default = "",markdownDescription = "A relative path to the workspace where stores the compiled output. `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven or Gradle project.",scope = "window",type = { "string", "null" }},["java.project.referencedLibraries"] = {additionalProperties = false,default = { "lib/**/*.jar" },description = "Configure glob patterns for referencing local libraries to a Java project.",properties = {exclude = {type = "array"},include = {type = "array"},sources = {type = "object"}},required = { "include" },scope = "window",type = { "array", "object" }},["java.project.resourceFilters"] = {default = { "node_modules", ".git" },description = "Excludes files and folders from being refreshed by the Java Language Server, which can improve the overall performance. For example, [\"node_modules\",\".git\"] will exclude all files and folders named 'node_modules' or '.git'. Defaults to [\"node_modules\",\".git\"].",scope = "window",type = "array"},["java.project.sourcePaths"] = {default = {},items = {type = "string"},markdownDescription = "Relative paths to the workspace where stores the source files. `Only` effective in the `WORKSPACE` scope. The setting will `NOT` affect Maven or Gradle project.",scope = "window",type = "array"},["java.quickfix.showAt"] = {default = "line",description = "Show quickfixes at the problem or line level.",enum = { "line", "problem" },scope = "window",type = "string"},["java.recommendations.dependency.analytics.show"] = {default = true,description = "Show the recommended Dependency Analytics extension.",scope = "window",type = "boolean"},["java.references.includeAccessors"] = {default = true,description = "Include getter, setter and builder/constructor when finding references.",scope = "window",type = "boolean"},["java.references.includeDecompiledSources"] = {default = true,description = "Include the decompiled sources when finding references.",scope = "window",type = "boolean"},["java.referencesCodeLens.enabled"] = {default = false,description = "Enable/disable the references code lens.",scope = "window",type = "boolean"},["java.saveActions.organizeImports"] = {default = false,description = "Enable/disable auto organize imports on save action",scope = "window",type = "boolean"},["java.selectionRange.enabled"] = {default = true,description = "Enable/disable Smart Selection support for Java. Disabling this option will not affect the VS Code built-in word-based and bracket-based smart selection.",scope = "window",type = "boolean"},["java.server.launchMode"] = {default = "Hybrid",description = "The launch mode for the Java extension",enum = { "Standard", "LightWeight", "Hybrid" },enumDescriptions = { "Provides full features such as intellisense, refactoring, building, Maven/Gradle support etc.", "Starts a syntax server with lower start-up cost. Only provides syntax features such as outline, navigation, javadoc, syntax errors.", "Provides full features with better responsiveness. It starts a standard language server and a secondary syntax server. The syntax server provides syntax features until the standard server is ready." },scope = "window",type = "string"},["java.settings.url"] = {default = vim.NIL,markdownDescription = "Specifies the url or file path to the workspace Java settings. See [Setting Global Preferences](https://github.com/redhat-developer/vscode-java/wiki/Settings-Global-Preferences)",scope = "window",type = "string"},["java.showBuildStatusOnStart.enabled"] = {anyOf = { {enum = { "notification", "terminal", "off" },enumDescriptions = { "Show the build status via progress notification on start", "Show the build status via terminal on start", "Do not show any build status on start" }}, "boolean" },default = "notification",description = "Automatically show build status on startup.",scope = "window"},["java.signatureHelp.description.enabled"] = {default = false,description = "Enable/disable to show the description in signature help.",scope = "window",type = "boolean"},["java.signatureHelp.enabled"] = {default = false,description = "Enable/disable the signature help.",scope = "window",type = "boolean"},["java.sources.organizeImports.starThreshold"] = {default = 99,description = "Specifies the number of imports added before a star-import declaration is used.",minimum = 1,scope = "window",type = "integer"},["java.sources.organizeImports.staticStarThreshold"] = {default = 99,description = "Specifies the number of static imports added before a star-import declaration is used.",minimum = 1,scope = "window",type = "integer"},["java.symbols.includeSourceMethodDeclarations"] = {default = false,markdownDescription = "Include method declarations from source files in symbol search.",scope = "window",type = "boolean"},["java.templates.fileHeader"] = {default = {},markdownDescription = "Specifies the file header comment for new Java file. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).",scope = "window",type = "array"},["java.templates.typeComment"] = {default = {},markdownDescription = "Specifies the type comment for new Java type. Supports configuring multi-line comments with an array of strings, and using ${variable} to reference the [predefined variables](command:_java.templateVariables).",scope = "window",type = "array"},["java.trace.server"] = {default = "off",description = "Traces the communication between VS Code and the Java language server.",enum = { "off", "messages", "verbose" },scope = "window",type = "string"},["java.typeHierarchy.lazyLoad"] = {default = false,description = "Enable/disable lazy loading the content in type hierarchy. Lazy loading could save a lot of loading time but every type should be expanded manually to load its content.",scope = "window",type = "boolean"}},title = "Java",type = "object"} \ No newline at end of file
diff --git a/lua/nvim-lsp-installer/core/fetch.lua b/lua/nvim-lsp-installer/core/fetch.lua
index 4c0d1f25..1c876bd1 100644
--- a/lua/nvim-lsp-installer/core/fetch.lua
+++ b/lua/nvim-lsp-installer/core/fetch.lua
@@ -26,7 +26,7 @@ local function fetch(url, opts)
if platform.is_win then
if opts.out_file then
platform_specific = powershell.command(
- ([[iwr %s -UseBasicParsing -Uri %q; -OutFile %q]]):format(HEADERS.iwr, url, opts.out_file)
+ ([[iwr %s -UseBasicParsing -Uri %q -OutFile %q;]]):format(HEADERS.iwr, url, opts.out_file)
)
else
platform_specific = powershell.command(
diff --git a/lua/nvim-lsp-installer/core/fs.lua b/lua/nvim-lsp-installer/core/fs.lua
index b915baf5..5106b40a 100644
--- a/lua/nvim-lsp-installer/core/fs.lua
+++ b/lua/nvim-lsp-installer/core/fs.lua
@@ -1,6 +1,8 @@
local uv = require "nvim-lsp-installer.core.async.uv"
local log = require "nvim-lsp-installer.log"
local a = require "nvim-lsp-installer.core.async"
+local Path = require "nvim-lsp-installer.path"
+local settings = require "nvim-lsp-installer.settings"
local M = {}
@@ -31,6 +33,12 @@ end
---@async
---@param path string
function M.rmrf(path)
+ assert(
+ Path.is_subdirectory(settings.current.install_root_dir, path),
+ (
+ "Refusing to rmrf %q which is outside of the allowed boundary %q. Please report this error at https://github.com/williamboman/nvim-lsp-installer/issues/new"
+ ):format(path, settings.current.install_root_dir)
+ )
log.debug("fs: rmrf", path)
if vim.in_fast_event() then
a.scheduler()
@@ -43,6 +51,13 @@ end
---@async
---@param path string
+function M.unlink(path)
+ log.debug("fs: unlink", path)
+ uv.fs_unlink(path)
+end
+
+---@async
+---@param path string
function M.mkdir(path)
log.debug("fs: mkdir", path)
uv.fs_mkdir(path, 493) -- 493(10) == 755(8)
diff --git a/lua/nvim-lsp-installer/core/installer/context.lua b/lua/nvim-lsp-installer/core/installer/context.lua
index f97f334f..366a3b77 100644
--- a/lua/nvim-lsp-installer/core/installer/context.lua
+++ b/lua/nvim-lsp-installer/core/installer/context.lua
@@ -63,6 +63,31 @@ function ContextualFs:dir_exists(rel_path)
return fs.dir_exists(path.concat { self.cwd:get(), rel_path })
end
+---@async
+---@param rel_path string @The relative path from the current working directory.
+function ContextualFs:rmrf(rel_path)
+ return fs.rmrf(path.concat { self.cwd:get(), rel_path })
+end
+
+---@async
+---@param rel_path string @The relative path from the current working directory.
+function ContextualFs:unlink(rel_path)
+ return fs.unlink(path.concat { self.cwd:get(), rel_path })
+end
+
+---@async
+---@param old_path string
+---@param new_path string
+function ContextualFs:rename(old_path, new_path)
+ return fs.rename(path.concat { self.cwd:get(), old_path }, path.concat { self.cwd:get(), new_path })
+end
+
+---@async
+---@param dirpath string
+function ContextualFs:mkdir(dirpath)
+ return fs.mkdir(path.concat { self.cwd:get(), dirpath })
+end
+
---@class CwdManager
---@field private boundary_path string @Defines the upper boundary for which paths are allowed as cwd.
---@field private cwd string
@@ -101,6 +126,7 @@ end
---@field public cwd CwdManager
---@field public destination_dir string
---@field public stdio_sink StdioSink
+---@field public boundary_path string
local InstallContext = {}
InstallContext.__index = InstallContext
@@ -112,6 +138,7 @@ function InstallContext.new(opts)
spawn = ContextualSpawn.new(cwd_manager, opts.stdio_sink),
fs = ContextualFs.new(cwd_manager),
receipt = receipt.InstallReceiptBuilder.new(),
+ boundary_path = opts.boundary_path,
destination_dir = opts.destination_dir,
requested_version = opts.requested_version,
stdio_sink = opts.stdio_sink,
@@ -154,4 +181,19 @@ function InstallContext:run_concurrently(suspend_fns)
end, suspend_fns))
end
+---@param rel_path string @The relative path from the current working directory to change cwd to. Will only restore to the initial cwd after execution of fn (if provided).
+---@param fn async fun() @(optional) The function to run in the context of the given path.
+function InstallContext:chdir(rel_path, fn)
+ local old_cwd = self.cwd:get()
+ self.cwd:set(path.concat { old_cwd, rel_path })
+ if fn then
+ local ok, result = pcall(fn)
+ self.cwd:set(old_cwd)
+ if not ok then
+ error(result, 0)
+ end
+ return result
+ end
+end
+
return InstallContext
diff --git a/lua/nvim-lsp-installer/core/managers/gem/init.lua b/lua/nvim-lsp-installer/core/managers/gem/init.lua
index 4191d587..c0d03731 100644
--- a/lua/nvim-lsp-installer/core/managers/gem/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/gem/init.lua
@@ -100,27 +100,25 @@ function M.check_outdated_primary_package(receipt, install_dir)
if receipt.primary_source.type ~= "gem" then
return Result.failure "Receipt does not have a primary source of type gem"
end
- return spawn.gem({ "outdated", cwd = install_dir, env = process.graft_env(M.env(install_dir)) }):map_catching(
- function(result)
- ---@type string[]
- local lines = vim.split(result.stdout, "\n")
- local outdated_gems = vim.tbl_map(M.parse_outdated_gem, vim.tbl_filter(not_empty, lines))
+ return spawn.gem({ "outdated", cwd = install_dir, env = M.env(install_dir) }):map_catching(function(result)
+ ---@type string[]
+ local lines = vim.split(result.stdout, "\n")
+ local outdated_gems = vim.tbl_map(M.parse_outdated_gem, vim.tbl_filter(not_empty, lines))
- local outdated_gem = list_find_first(outdated_gems, function(gem)
- return gem.name == receipt.primary_source.package and gem.current_version ~= gem.latest_version
- end)
+ local outdated_gem = list_find_first(outdated_gems, function(gem)
+ return gem.name == receipt.primary_source.package and gem.current_version ~= gem.latest_version
+ end)
- return Optional.of_nilable(outdated_gem)
- :map(function(gem)
- return {
- name = receipt.primary_source.package,
- current_version = assert(gem.current_version),
- latest_version = assert(gem.latest_version),
- }
- end)
- :or_else_throw "Primary package is not outdated."
- end
- )
+ return Optional.of_nilable(outdated_gem)
+ :map(function(gem)
+ return {
+ name = receipt.primary_source.package,
+ current_version = assert(gem.current_version),
+ latest_version = assert(gem.latest_version),
+ }
+ end)
+ :or_else_throw "Primary package is not outdated."
+ end)
end
---@async
@@ -130,7 +128,7 @@ function M.get_installed_primary_package_version(receipt, install_dir)
return spawn.gem({
"list",
cwd = install_dir,
- env = process.graft_env(M.env(install_dir)),
+ env = M.env(install_dir),
}):map_catching(function(result)
local gems = M.parse_gem_list_output(result.stdout)
return Optional.of_nilable(gems[receipt.primary_source.package]):or_else_throw "Failed to find gem package version."
diff --git a/lua/nvim-lsp-installer/core/managers/git/init.lua b/lua/nvim-lsp-installer/core/managers/git/init.lua
index f3c6ee65..6efa10b9 100644
--- a/lua/nvim-lsp-installer/core/managers/git/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/git/init.lua
@@ -13,11 +13,18 @@ local function with_receipt(repo)
end
---@async
----@param opts {[1]:string} @The first item in the table is the repository to clone.
+---@param opts {[1]: string, recursive: boolean} @The first item in the table is the repository to clone.
function M.clone(opts)
local ctx = installer.context()
local repo = assert(opts[1], "No git URL provided.")
- ctx.spawn.git { "clone", "--depth", "1", repo, "." }
+ ctx.spawn.git {
+ "clone",
+ "--depth",
+ "1",
+ opts.recursive and "--recursive" or vim.NIL,
+ repo,
+ ".",
+ }
ctx.requested_version:if_present(function(version)
ctx.spawn.git { "fetch", "--depth", "1", "origin", version }
ctx.spawn.git { "checkout", "FETCH_HEAD" }
diff --git a/lua/nvim-lsp-installer/core/managers/github/client.lua b/lua/nvim-lsp-installer/core/managers/github/client.lua
index a8766748..7cf80cf2 100644
--- a/lua/nvim-lsp-installer/core/managers/github/client.lua
+++ b/lua/nvim-lsp-installer/core/managers/github/client.lua
@@ -7,14 +7,13 @@ local list_find_first = Data.list_find_first
local M = {}
----@alias GitHubRelease {tag_name:string, prerelease: boolean, draft: boolean}
+---@alias GitHubReleaseAsset {url: string, id: integer, name: string, browser_download_url: string, created_at: string, updated_at: string, size: integer, download_count: integer}
+---@alias GitHubRelease {tag_name: string, prerelease: boolean, draft: boolean, assets:GitHubReleaseAsset[]}
---@alias GitHubTag {name: string}
----@async
----@param repo string The GitHub repo ("username/repo").
-function M.fetch_releases(repo)
- log.fmt_trace("Fetching GitHub releases for repo=%s", repo)
- local path = ("repos/%s/releases"):format(repo)
+---@param path string
+---@return Result @JSON decoded response.
+local function api_call(path)
return spawn.gh({ "api", path })
:map(function(result)
return result.stdout
@@ -25,10 +24,31 @@ function M.fetch_releases(repo)
:map_catching(vim.json.decode)
end
+---@async
+---@param repo string @The GitHub repo ("username/repo").
+function M.fetch_releases(repo)
+ log.fmt_trace("Fetching GitHub releases for repo=%s", repo)
+ local path = ("repos/%s/releases"):format(repo)
+ return api_call(path):map_err(function()
+ return ("Failed to fetch releases for GitHub repository %s."):format(repo)
+ end)
+end
+
+---@async
+---@param repo string @The GitHub repo ("username/repo").
+---@param tag_name string @The tag_name of the release to fetch.
+function M.fetch_release(repo, tag_name)
+ log.fmt_trace("Fetching GitHub release for repo=%s, tag_name=%s", repo, tag_name)
+ local path = ("repos/%s/releases/tags/%s"):format(repo, tag_name)
+ return api_call(path):map_err(function()
+ return ("Failed to fetch release %q for GitHub repository %s."):format(tag_name, repo)
+ end)
+end
+
---@alias FetchLatestGithubReleaseOpts {tag_name_pattern:string}
---@async
----@param repo string The GitHub repo ("username/repo").
+---@param repo string @The GitHub repo ("username/repo").
---@param opts FetchLatestGithubReleaseOpts|nil
---@return Result @of GitHubRelease
function M.fetch_latest_release(repo, opts)
@@ -61,21 +81,18 @@ function M.fetch_latest_release(repo, opts)
end
---@async
----@param repo string The GitHub repo ("username/repo").
+---@param repo string @The GitHub repo ("username/repo").
+---@return Result @of [GitHubTag[]]
function M.fetch_tags(repo)
local path = ("repos/%s/tags"):format(repo)
- return spawn.gh({ "api", path })
- :map(function(result)
- return result.stdout
- end)
- :recover_catching(function()
- return fetch(("https://api.github.com/%s"):format(path)):get_or_throw()
- end)
- :map_catching(vim.json.decode)
+ return api_call(path):map_err(function()
+ return ("Failed to fetch tags for GitHub repository %s."):format(repo)
+ end)
end
---@async
----@param repo string The GitHub repo ("username/repo").
+---@param repo string @The GitHub repo ("username/repo").
+---@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/core/managers/github/init.lua b/lua/nvim-lsp-installer/core/managers/github/init.lua
new file mode 100644
index 00000000..32afc03c
--- /dev/null
+++ b/lua/nvim-lsp-installer/core/managers/github/init.lua
@@ -0,0 +1,89 @@
+local installer = require "nvim-lsp-installer.core.installer"
+local std = require "nvim-lsp-installer.core.managers.std"
+local client = require "nvim-lsp-installer.core.managers.github.client"
+local platform = require "nvim-lsp-installer.platform"
+
+local M = {}
+
+---@param repo string
+---@param asset_file string
+---@param release string
+local function with_release_file_receipt(repo, asset_file, release)
+ return function()
+ local ctx = installer.context()
+ ctx.receipt:with_primary_source {
+ type = "github_release_file",
+ repo = repo,
+ file = asset_file,
+ release = release,
+ }
+ end
+end
+
+---@async
+---@param opts {repo: string, version: Optional|nil, asset_file: string|fun(release: string):string}
+function M.release_file(opts)
+ local ctx = installer.context()
+ local release = (opts.version or ctx.requested_version):or_else_get(function()
+ return client.fetch_latest_release(opts.repo)
+ :map(function(release)
+ return release.tag_name
+ end)
+ :get_or_throw "Failed to fetch latest release from GitHub API."
+ end)
+ ---@type string
+ local asset_file = type(opts.asset_file) == "function" and opts.asset_file(release) or opts.asset_file
+ if not asset_file then
+ error(
+ (
+ "Could not find which release file to download. Most likely the current operating system, architecture (%s), or libc (%s) is not supported."
+ ):format(platform.arch, platform.get_libc())
+ )
+ end
+ local download_url = ("https://github.com/%s/releases/download/%s/%s"):format(opts.repo, release, asset_file)
+ return {
+ release = release,
+ download_url = download_url,
+ asset_file = asset_file,
+ with_receipt = with_release_file_receipt(opts.repo, download_url, release),
+ }
+end
+
+---@param filename string
+---@param processor async fun()
+local function release_file_processor(filename, processor)
+ ---@async
+ ---@param opts {repo: string, asset_file: string|fun(release: string):string}
+ return function(opts)
+ local release_file_source = M.release_file(opts)
+ std.download_file(release_file_source.download_url, filename)
+ processor(release_file_source)
+ return release_file_source
+ end
+end
+
+M.unzip_release_file = release_file_processor("archive.zip", function()
+ std.unzip("archive.zip", ".")
+end)
+
+M.untarxz_release_file = release_file_processor("archive.tar.xz", function()
+ std.untarxz "archive.tar.xz"
+end)
+
+M.untargz_release_file = release_file_processor("archive.tar.gz", function()
+ std.untar "archive.tar.gz"
+end)
+
+---@async
+---@param opts {repo: string, out_file:string, asset_file: string|fun(release: string):string}
+function M.gunzip_release_file(opts)
+ local release_file_source = M.release_file(opts)
+ std.download_file(
+ release_file_source.download_url,
+ ("%s.gz"):format(assert(opts.out_file, "out_file must be specified"))
+ )
+ std.gunzip(opts.out_file)
+ return release_file_source
+end
+
+return M
diff --git a/lua/nvim-lsp-installer/core/managers/go/init.lua b/lua/nvim-lsp-installer/core/managers/go/init.lua
index 99be5618..f85987ef 100644
--- a/lua/nvim-lsp-installer/core/managers/go/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/go/init.lua
@@ -32,7 +32,7 @@ end
---@param packages string[] The Go packages to install. The first item in this list will be the recipient of the server version, should the user request a specific one.
function M.install(packages)
local ctx = installer.context()
- local env = process.graft_env {
+ local env = {
GOBIN = ctx.cwd:get(),
}
-- Install the head package
diff --git a/lua/nvim-lsp-installer/core/managers/pip3/init.lua b/lua/nvim-lsp-installer/core/managers/pip3/init.lua
index ab2ce221..d55c4ac0 100644
--- a/lua/nvim-lsp-installer/core/managers/pip3/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/pip3/init.lua
@@ -56,13 +56,13 @@ function M.install(packages)
Optional.of_nilable(executable)
:if_present(function()
ctx.spawn.python {
- env = process.graft_env(M.env(ctx.cwd:get())), -- use venv env
"-m",
"pip",
"install",
"-U",
settings.current.pip.install_args,
pkgs,
+ env = M.env(ctx.cwd:get()), -- use venv env
}
end)
:or_else_throw "Unable to create python3 venv environment."
@@ -95,7 +95,7 @@ function M.check_outdated_primary_package(receipt, install_dir)
"--outdated",
"--format=json",
cwd = install_dir,
- env = process.graft_env(M.env(install_dir)), -- use venv
+ env = M.env(install_dir), -- use venv
}):map_catching(function(result)
---@alias PipOutdatedPackage {name: string, version: string, latest_version: string}
---@type PipOutdatedPackage[]
@@ -131,7 +131,7 @@ function M.get_installed_primary_package_version(receipt, install_dir)
"list",
"--format=json",
cwd = install_dir,
- env = process.graft_env(M.env(install_dir)), -- use venv env
+ env = M.env(install_dir), -- use venv env
}):map_catching(function(result)
local pip_packages = vim.json.decode(result.stdout)
local normalized_pip_package = M.normalize_package(receipt.primary_source.package)
diff --git a/lua/nvim-lsp-installer/core/managers/powershell/init.lua b/lua/nvim-lsp-installer/core/managers/powershell/init.lua
index 94046b05..97e51b3e 100644
--- a/lua/nvim-lsp-installer/core/managers/powershell/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/powershell/init.lua
@@ -11,7 +11,6 @@ local PWSHOPT = {
---@param script string
---@param opts JobSpawnOpts
---@param custom_spawn JobSpawn
----@return Result
function M.script(script, opts, custom_spawn)
opts = opts or {}
---@type JobSpawn
@@ -25,14 +24,13 @@ function M.script(script, opts, custom_spawn)
stdin:write(script)
stdin:close()
end,
- env = process.graft_env(opts.env or {}, { "PSMODULEPATH" }),
+ env_raw = process.graft_env(opts.env or {}, { "PSMODULEPATH" }),
}, opts))
end
---@param command string
---@param opts JobSpawnOpts
---@param custom_spawn JobSpawn
----@return Result
function M.command(command, opts, custom_spawn)
opts = opts or {}
---@type JobSpawn
@@ -41,7 +39,7 @@ function M.command(command, opts, custom_spawn)
"-NoProfile",
"-Command",
PWSHOPT.progress_preference .. PWSHOPT.security_protocol .. command,
- env = process.graft_env(opts.env or {}, { "PSMODULEPATH" }),
+ env_raw = process.graft_env(opts.env or {}, { "PSMODULEPATH" }),
}, opts))
end
diff --git a/lua/nvim-lsp-installer/core/managers/std/init.lua b/lua/nvim-lsp-installer/core/managers/std/init.lua
index 49a7f53d..05495573 100644
--- a/lua/nvim-lsp-installer/core/managers/std/init.lua
+++ b/lua/nvim-lsp-installer/core/managers/std/init.lua
@@ -1,5 +1,10 @@
local a = require "nvim-lsp-installer.core.async"
local installer = require "nvim-lsp-installer.core.installer"
+local fetch = require "nvim-lsp-installer.core.fetch"
+local platform = require "nvim-lsp-installer.platform"
+local powershell = require "nvim-lsp-installer.core.managers.powershell"
+local path = require "nvim-lsp-installer.path"
+local Result = require "nvim-lsp-installer.core.result"
local M = {}
@@ -41,4 +46,123 @@ function M.ensure_executable(executable, opts)
}
end
+---@async
+---@param url string
+---@param out_file string
+function M.download_file(url, out_file)
+ local ctx = installer.context()
+ ctx.stdio_sink.stdout(("Downloading file %q...\n"):format(url))
+ fetch(url, {
+ out_file = path.concat { ctx.cwd:get(), out_file },
+ })
+ :map_err(function(err)
+ return ("Failed to download file %q.\n%s"):format(url, err)
+ end)
+ :get_or_throw()
+end
+
+---@async
+---@param file string
+---@param dest string
+function M.unzip(file, dest)
+ local ctx = installer.context()
+ platform.when {
+ unix = function()
+ ctx.spawn.unzip { "-d", dest, file }
+ end,
+ win = function()
+ powershell.command(
+ ("Microsoft.PowerShell.Archive\\Expand-Archive -Path %q -DestinationPath %q"):format(file, dest),
+ {},
+ ctx.spawn
+ )
+ end,
+ }
+ pcall(function()
+ -- make sure the .zip archive doesn't linger
+ ctx.fs:unlink(file)
+ end)
+end
+
+---@param file string
+local function win_extract(file)
+ local ctx = installer.context()
+ Result.run_catching(function()
+ ctx.spawn["7z"] { "x", "-y", "-r", file }
+ end)
+ :recover_catching(function()
+ ctx.spawn.peazip { "-ext2here", path.concat { ctx.cwd:get(), file } } -- peazip requires absolute paths
+ end)
+ :recover_catching(function()
+ ctx.spawn.wzunzip { file }
+ end)
+ :recover_catching(function()
+ ctx.spawn.winrar { "e", file }
+ end)
+ :get_or_throw(("Unable to unpack %s."):format(file))
+end
+
+---@async
+---@param file string
+---@param opts {strip_components:integer}
+function M.untar(file, opts)
+ opts = opts or {}
+ local ctx = installer.context()
+ ctx.spawn.tar {
+ opts.strip_components and { "--strip-components", opts.strip_components } or vim.NIL,
+ "-xvf",
+ file,
+ }
+ pcall(function()
+ ctx.fs:unlink(file)
+ end)
+end
+
+---@async
+---@param file string
+function M.untarxz(file)
+ local ctx = installer.context()
+ platform.when {
+ unix = function()
+ M.untar(file)
+ end,
+ win = function()
+ Result.run_catching(function()
+ win_extract(file) -- unpack .tar.xz to .tar
+ local uncompressed_tar = file:gsub(".xz$", "")
+ M.untar(uncompressed_tar)
+ end):recover(function()
+ ctx.spawn.arc { "unarchive", file }
+ pcall(function()
+ ctx.fs:unlink(file)
+ end)
+ end)
+ end,
+ }
+end
+
+---@async
+---@param file string
+function M.gunzip(file)
+ platform.when {
+ unix = function()
+ local ctx = installer.context()
+ ctx.spawn.gzip { "-d", file }
+ end,
+ win = function()
+ win_extract(file)
+ end,
+ }
+end
+
+---@async
+---@param flags string @The chmod flag to apply.
+---@param files string[] @A list of relative paths to apply the chmod on.
+function M.chmod(flags, files)
+ if platform.is_unix then
+ local ctx = installer.context()
+ ctx.spawn.chmod { flags, files }
+ end
+end
+
return M
diff --git a/lua/nvim-lsp-installer/core/optional.lua b/lua/nvim-lsp-installer/core/optional.lua
index 8e68648c..10af8ccb 100644
--- a/lua/nvim-lsp-installer/core/optional.lua
+++ b/lua/nvim-lsp-installer/core/optional.lua
@@ -1,4 +1,4 @@
----@class Optional
+---@class Optional<T>
---@field private _value unknown
local Optional = {}
Optional.__index = Optional
@@ -53,7 +53,17 @@ function Optional:or_else(value)
end
end
+---@param supplier fun(): any
+function Optional:or_else_get(supplier)
+ if self:is_present() then
+ return self._value
+ else
+ return supplier()
+ end
+end
+
---@param supplier fun(): Optional
+---@return Optional
function Optional:or_(supplier)
if self:is_present() then
return self
diff --git a/lua/nvim-lsp-installer/core/result.lua b/lua/nvim-lsp-installer/core/result.lua
index 74fb9bc8..132e2758 100644
--- a/lua/nvim-lsp-installer/core/result.lua
+++ b/lua/nvim-lsp-installer/core/result.lua
@@ -77,6 +77,15 @@ function Result:map(mapper_fn)
end
---@param mapper_fn fun(value: any): any
+function Result:map_err(mapper_fn)
+ if self:is_failure() then
+ return Result.failure(mapper_fn(self.value.error))
+ else
+ return self
+ end
+end
+
+---@param mapper_fn fun(value: any): any
function Result:map_catching(mapper_fn)
if self:is_success() then
local ok, result = pcall(mapper_fn, self.value)
diff --git a/lua/nvim-lsp-installer/core/spawn.lua b/lua/nvim-lsp-installer/core/spawn.lua
index 355df029..8b849f64 100644
--- a/lua/nvim-lsp-installer/core/spawn.lua
+++ b/lua/nvim-lsp-installer/core/spawn.lua
@@ -10,15 +10,8 @@ local spawn = {
npm = platform.is_win and "npm.cmd" or "npm",
gem = platform.is_win and "gem.cmd" or "gem",
composer = platform.is_win and "composer.bat" or "composer",
+ gradlew = platform.is_win and "gradlew.bat" or "gradlew",
},
- -- Utility function for optionally including arguments.
- ---@generic T
- ---@param condition boolean
- ---@param value T
- ---@return T
- _when = function(condition, value)
- return condition and value or vim.NIL
- end,
}
local function Failure(err, cmd)
@@ -50,11 +43,20 @@ setmetatable(spawn, {
return function(args)
local cmd_args = {}
parse_args(args, cmd_args)
+
+ ---@type table<string, string>
+ local env = args.env
+
+ if args.with_paths then
+ env = env or {}
+ env.PATH = process.extend_path(args.with_paths)
+ end
+
---@type JobSpawnOpts
local spawn_args = {
stdio_sink = args.stdio_sink,
cwd = args.cwd,
- env = args.env,
+ env = env and process.graft_env(env) or args.env_raw,
args = cmd_args,
}
diff --git a/lua/nvim-lsp-installer/data.lua b/lua/nvim-lsp-installer/data.lua
index 3c736c76..264fda80 100644
--- a/lua/nvim-lsp-installer/data.lua
+++ b/lua/nvim-lsp-installer/data.lua
@@ -69,7 +69,7 @@ function Data.when(condition, value)
return condition and value or nil
end
-function Data.lazy(condition, fn)
+function Data.lazy_when(condition, fn)
return condition and fn() or nil
end
@@ -140,4 +140,14 @@ function Data.memoize(fn, cache_key_generator)
end
end
+function Data.lazy(fn)
+ local ret_val
+ return function()
+ if not ret_val then
+ ret_val = Data.table_pack(fn())
+ end
+ return unpack(ret_val, 1, ret_val.n)
+ end
+end
+
return Data
diff --git a/lua/nvim-lsp-installer/platform.lua b/lua/nvim-lsp-installer/platform.lua
index 62c74046..7b54bc34 100644
--- a/lua/nvim-lsp-installer/platform.lua
+++ b/lua/nvim-lsp-installer/platform.lua
@@ -1,3 +1,6 @@
+local Data = require "nvim-lsp-installer.data"
+local Result = require "nvim-lsp-installer.core.result"
+local lazy = Data.lazy
local M = {}
local uname = vim.loop.os_uname()
@@ -40,4 +43,103 @@ M.path_sep = M.is_win and ";" or ":"
M.is_headless = #vim.api.nvim_list_uis() == 0
+---@generic T
+---@param platform_table table<Platform, T>
+---@return T
+local function get_by_platform(platform_table)
+ if M.is_mac then
+ return platform_table.mac or platform_table.unix
+ elseif M.is_linux then
+ return platform_table.linux or platform_table.unix
+ elseif M.is_unix then
+ return platform_table.unix
+ elseif M.is_win then
+ return platform_table.win
+ else
+ return nil
+ end
+end
+
+function M.when(cases)
+ local case = get_by_platform(cases)
+ if case then
+ return case()
+ else
+ error "Current platform is not supported."
+ end
+end
+
+---@type async fun(): table
+M.os_distribution = lazy(function()
+ ---Parses the provided contents of an /etc/\*-release file and identifies the Linux distribution.
+ ---@param contents string @The contents of a /etc/\*-release file.
+ ---@return table<string, any>
+ local function parse_linux_dist(contents)
+ local lines = vim.split(contents, "\n")
+
+ local entries = {}
+
+ for i = 1, #lines do
+ local line = lines[i]
+ local index = line:find "="
+ if index then
+ local key = line:sub(1, index - 1)
+ local value = line:sub(index + 1)
+ entries[key] = value
+ end
+ end
+
+ if entries.ID == "ubuntu" then
+ -- Parses the Ubuntu OS VERSION_ID into their version components, e.g. "18.04" -> {major=18, minor=04}
+ local version_id = entries.VERSION_ID:gsub([["]], "")
+ local version_parts = vim.split(version_id, "%.")
+ local major = tonumber(version_parts[1])
+ local minor = tonumber(version_parts[2])
+
+ return {
+ id = "ubuntu",
+ version_id = version_id,
+ version = { major = major, minor = minor },
+ }
+ else
+ return {
+ id = "linux-generic",
+ }
+ end
+ end
+
+ return M.when {
+ linux = function()
+ local spawn = require "nvim-lsp-installer.core.spawn"
+ return spawn.bash({ "-c", "cat /etc/*-release" })
+ :map_catching(function(result)
+ return parse_linux_dist(result.stdout)
+ end)
+ :recover(function()
+ return { id = "linux-generic" }
+ end)
+ :get_or_throw()
+ end,
+ mac = function()
+ return Result.success { id = "macOS" }
+ end,
+ win = function()
+ return Result.success { id = "windows" }
+ end,
+ }
+end)
+
+---@type async fun() Result @of String
+M.get_homebrew_prefix = lazy(function()
+ assert(M.is_mac, "Can only locate Homebrew installation on Mac systems.")
+ local spawn = require "nvim-lsp-installer.core.spawn"
+ return spawn.brew({ "--prefix" })
+ :map_catching(function(result)
+ return vim.trim(result.stdout)
+ end)
+ :map_err(function()
+ return "Failed to locate Homebrew installation."
+ end)
+end)
+
return M
diff --git a/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua b/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua
index 49da467a..81188828 100644
--- a/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua
+++ b/lua/nvim-lsp-installer/servers/arduino_language_server/init.lua
@@ -1,122 +1,164 @@
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local installers = require "nvim-lsp-installer.installers"
local server = require "nvim-lsp-installer.server"
-local go = require "nvim-lsp-installer.installers.go"
-local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local installer = require "nvim-lsp-installer.core.installer"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
+local Optional = require "nvim-lsp-installer.core.optional"
+local process = require "nvim-lsp-installer.process"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local arduino_cli_installer = installers.branch_context {
- context.set_working_dir "arduino-cli",
- context.set(function(ctx)
- -- The user's requested version should not apply to the CLI.
- ctx.requested_server_version = nil
- end),
- context.use_github_release_file("arduino/arduino-cli", function(version)
- local target_file = coalesce(
- when(platform.is_mac, "arduino-cli_%s_macOS_64bit.tar.gz"),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "x64", "arduino-cli_%s_Linux_64bit.tar.gz"),
- when(platform.arch == "x86", "arduino-cli_%s_Linux_32bit.tar.gz"),
- when(platform.arch == "arm64", "arduino-cli_%s_Linux_ARM64.tar.gz"),
- when(platform.arch == "armv6", "arduino-cli_%s_Linux_ARMv6.tar.gz"),
- when(platform.arch == "armv7", "arduino-cli_%s_Linux_ARMv7.tar.gz")
- )
- ),
- when(
- platform.is_win,
- coalesce(
- when(platform.arch == "x64", "arduino-cli_%s_Windows_64bit.zip"),
- when(platform.arch == "x86", "arduino-cli_%s_Windows_32bit.zip")
+ ---@async
+ local function arduino_cli_installer()
+ local ctx = installer.context()
+
+ ctx.fs:mkdir "arduino-cli"
+ ctx:chdir("arduino-cli", function()
+ local opts = {
+ repo = "arduino/arduino-cli",
+ version = Optional.empty(),
+ asset_file = function(release)
+ local target = coalesce(
+ when(platform.is_mac, "arduino-cli_%s_macOS_64bit.tar.gz"),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "x64", "arduino-cli_%s_Linux_64bit.tar.gz"),
+ when(platform.arch == "x86", "arduino-cli_%s_Linux_32bit.tar.gz"),
+ when(platform.arch == "arm64", "arduino-cli_%s_Linux_ARM64.tar.gz"),
+ when(platform.arch == "armv6", "arduino-cli_%s_Linux_ARMv6.tar.gz"),
+ when(platform.arch == "armv7", "arduino-cli_%s_Linux_ARMv7.tar.gz")
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(
+ when(platform.arch == "x64", "arduino-cli_%s_Windows_64bit.zip"),
+ when(platform.arch == "x86", "arduino-cli_%s_Windows_32bit.zip")
+ )
+ )
)
- )
- )
- return target_file and target_file:format(version)
- end),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untargz_remote(ctx.github_release_file)
- end
- end),
- std.chmod("+x", { "arduino-cli" }),
- ---@type ServerInstallerFunction
- function(_, callback, ctx)
- process.spawn(path.concat { ctx.install_dir, "arduino-cli" }, {
- args = { "config", "init", "--dest-file", "arduino-cli.yaml", "--overwrite" },
- cwd = ctx.install_dir,
- stdio_sink = ctx.stdio_sink,
- }, callback)
- end,
- context.receipt(function(receipt, ctx)
- receipt:with_secondary_source(receipt.github_release_file(ctx))
- end),
- }
+ return target and target:format(release)
+ end,
+ }
- local arduino_language_server_installer = installers.branch_context {
- context.set_working_dir "arduino-language-server",
- go.packages { "github.com/arduino/arduino-language-server" },
- }
+ platform.when {
+ unix = function()
+ github.untargz_release_file(opts)
+ std.chmod("+x", { "arduino-cli" })
+ end,
+ win = function()
+ github.unzip_release_file(opts)
+ end,
+ }
- local clangd_installer = installers.branch_context {
- context.set(function(ctx)
- -- The user's requested version should not apply to clangd.
- ctx.requested_server_version = nil
- end),
- context.use_github_release_file("clangd/clangd", function(version)
- local target_file = coalesce(
- when(platform.is_mac, "clangd-mac-%s.zip"),
- when(platform.is_linux and platform.arch == "x64", "clangd-linux-%s.zip"),
- when(platform.is_win, "clangd-windows-%s.zip")
- )
- return target_file and target_file:format(version)
- end),
- context.capture(function(ctx)
- return installers.pipe {
- std.unzip_remote(ctx.github_release_file),
- std.rename(("clangd_%s"):format(ctx.requested_server_version), "clangd"),
+ ctx.spawn["arduino-cli"] {
+ "config",
+ "init",
+ "--dest-file",
+ "arduino-cli.yaml",
+ "--overwrite",
+ with_paths = { ctx.cwd:get() },
}
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_secondary_source(receipt.github_release_file(ctx))
- end),
- }
+ end)
+ end
+
+ local function arduino_language_server_installer()
+ local ctx = installer.context()
+ ctx.fs:mkdir "arduino-language-server"
+ ctx:chdir("arduino-language-server", function()
+ local opts = {
+ repo = "arduino/arduino-language-server",
+ asset_file = function(release)
+ local target = coalesce(
+ when(platform.is_mac, "arduino-language-server_%s_macOS_64bit.tar.gz"),
+ when(
+ platform.is_linux and platform.arch == "x64",
+ "arduino-language-server_%s_Linux_64bit.tar.gz"
+ ),
+ when(
+ platform.is_linux and platform.arch == "x86",
+ "arduino-language-server_%s_Linux_32bit.tar.gz"
+ ),
+ when(
+ platform.is_linux and platform.arch == "arm64",
+ "arduino-language-server_%s_Linux_ARM64.tar.gz"
+ ),
+ when(
+ platform.is_win and platform.arch == "x64",
+ "arduino-language-server_0.6.0_Windows_64bit.zip"
+ ),
+ when(
+ platform.is_win and platform.arch == "x86",
+ "arduino-language-server_0.6.0_Windows_32bit.zip"
+ )
+ )
+
+ return target and target:format(release)
+ end,
+ }
+ platform.when {
+ unix = function()
+ github.untargz_release_file(opts)
+ end,
+ win = function()
+ github.unzip_release_file(opts)
+ end,
+ }
+ end)
+ end
+
+ local function clangd_installer()
+ local ctx = installer.context()
+
+ local source = github.unzip_release_file {
+ repo = "clangd/clangd",
+ version = Optional.empty(),
+ asset_file = function(release)
+ local target_file = coalesce(
+ when(platform.is_mac, "clangd-mac-%s.zip"),
+ when(platform.is_linux and platform.arch == "x64", "clangd-linux-%s.zip"),
+ when(platform.is_win, "clangd-windows-%s.zip")
+ )
+ return target_file and target_file:format(release)
+ end,
+ }
+
+ ctx.fs:rename(("clangd_%s"):format(source.release), "clangd")
+ end
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/arduino/arduino-language-server",
languages = { "arduino" },
- installer = {
- clangd_installer,
- arduino_cli_installer,
- arduino_language_server_installer,
- context.receipt(function(receipt)
- -- We install 3 different components to 3 different subdirectories. This is currently not captured in
- -- the receipt structure.
- receipt:mark_invalid()
- end),
- },
+ async = true,
+ installer = function()
+ clangd_installer()
+ arduino_cli_installer()
+ arduino_language_server_installer()
+ end,
default_options = {
cmd = {
-- This cmd is incomplete. Users need to manually append their FQBN (e.g., -fqbn arduino:avr:nano)
"arduino-language-server",
"-cli",
- path.concat { root_dir, "arduino-cli", platform.is_win and "arduino-cli.exe" or "arduino-cli" },
+ "arduino-cli",
+ "-clangd",
+ "clangd",
"-cli-config",
path.concat { root_dir, "arduino-cli", "arduino-cli.yaml" },
- "-clangd",
- path.concat { root_dir, "clangd", "bin", platform.is_win and "clangd.bat" or "clangd" },
},
- cmd_env = go.env(path.concat { root_dir, "arduino-language-server" }),
+ cmd_env = {
+ PATH = process.extend_path {
+ path.concat { root_dir, "arduino-language-server" },
+ path.concat { root_dir, "arduino-cli" },
+ path.concat { root_dir, "clangd", "bin" },
+ },
+ },
},
}
end
diff --git a/lua/nvim-lsp-installer/servers/beancount/init.lua b/lua/nvim-lsp-installer/servers/beancount/init.lua
index b9908488..e857e44b 100644
--- a/lua/nvim-lsp-installer/servers/beancount/init.lua
+++ b/lua/nvim-lsp-installer/servers/beancount/init.lua
@@ -1,8 +1,6 @@
local server = require "nvim-lsp-installer.server"
-local installers = require "nvim-lsp-installer.installers"
-local context = require "nvim-lsp-installer.installers.context"
-local pip3 = require "nvim-lsp-installer.installers.pip3"
-local std = require "nvim-lsp-installer.installers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
+local pip3 = require "nvim-lsp-installer.core.managers.pip3"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
@@ -10,47 +8,37 @@ local process = require "nvim-lsp-installer.process"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local file_ext = platform.is_win and ".exe" or ""
return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "beancount" },
homepage = "https://github.com/polarmutex/beancount-language-server",
- installer = {
- context.use_github_release_file(
- "polarmutex/beancount-language-server",
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local asset_file = assert(
coalesce(
when(platform.is_mac, "beancount-language-server-macos-x64.zip"),
when(platform.is_linux and platform.arch == "x64", "beancount-language-server-linux-x64.zip"),
when(platform.is_win and platform.arch == "x64", "beancount-language-server-windows-x64.zip")
- )
- ),
- context.capture(function(ctx)
- return installers.pipe {
- std.unzip_remote(ctx.github_release_file),
- -- We rename the binary to conform with lspconfig
- std.rename(
- ("beancount-language-server%s"):format(file_ext),
- ("beancount-langserver%s"):format(file_ext)
- ),
- }
- end),
- context.promote_install_dir(),
- installers.branch_context {
- context.set(function(ctx)
- ctx.requested_server_version = nil
- end),
- pip3.packages { "beancount" },
- },
- context.receipt(function(receipt, ctx)
- receipt
- :with_primary_source(receipt.github_release_file(ctx))
- :with_secondary_source(receipt.pip3 "beancount")
- end),
- },
+ ),
+ "Unsupported platform"
+ )
+ github.unzip_release_file({
+ repo = "polarmutex/beancount-language-server",
+ asset_file = asset_file,
+ }).with_receipt()
+
+ local file_ext = platform.is_win and ".exe" or ""
+ -- We rename the binary to conform with lspconfig
+ ctx.fs:rename(("beancount-language-server%s"):format(file_ext), ("beancount-langserver%s"):format(file_ext))
+
+ pip3.install { "beancount" }
+ ctx.receipt:with_secondary_source(ctx.receipt.pip3 "beancount")
+ end,
default_options = {
cmd_env = {
- PATH = process.extend_path { root_dir, pip3.path(root_dir) },
+ PATH = process.extend_path { root_dir, pip3.venv_path(root_dir) },
},
},
}
diff --git a/lua/nvim-lsp-installer/servers/bicep/init.lua b/lua/nvim-lsp-installer/servers/bicep/init.lua
index 89770999..6f5f7064 100644
--- a/lua/nvim-lsp-installer/servers/bicep/init.lua
+++ b/lua/nvim-lsp-installer/servers/bicep/init.lua
@@ -1,7 +1,7 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
return server.Server:new {
@@ -9,23 +9,23 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "bicep" },
homepage = "https://github.com/Azure/bicep",
- installer = {
- std.ensure_executables {
- { "dotnet", "dotnet is required to run the bicep language server." },
- },
- -- The bicep-langserver.zip is a bit broken on POSIX systems - so we download it via the VSCode distribution
- -- instead. See https://github.com/Azure/bicep/issues/3704.
- context.use_github_release_file("Azure/bicep", "vscode-bicep.vsix"),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file, "vscode")
- end),
- std.rename(path.concat { "vscode", "extension", "bicepLanguageServer" }, "langserver"),
- std.rmrf "vscode",
- context.set_working_dir "langserver",
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" })
+ ctx.fs:mkdir "vscode"
+ ctx:chdir("vscode", function()
+ -- The bicep-langserver.zip is a bit broken on POSIX systems - so we download it via the VSCode distribution
+ -- instead. See https://github.com/Azure/bicep/issues/3704.
+ github.unzip_release_file({
+ repo = "Azure/bicep",
+ asset_file = "vscode-bicep.vsix",
+ }).with_receipt()
+ end)
+ ctx.fs:rename(path.concat { "vscode", "extension", "bicepLanguageServer" }, "langserver")
+ ctx.fs:rmrf "vscode"
+ ctx:chdir "langserver"
+ end,
default_options = {
cmd = { "dotnet", path.concat { root_dir, "Bicep.LangServer.dll" } },
},
diff --git a/lua/nvim-lsp-installer/servers/bsl_ls/init.lua b/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
index 9036ea7d..62c85079 100644
--- a/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/bsl_ls/init.lua
@@ -1,7 +1,7 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
return function(name, root_dir)
return server.Server:new {
@@ -9,21 +9,19 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://1c-syntax.github.io/bsl-language-server",
languages = { "onescript" },
- installer = {
- std.ensure_executables {
- { "java", "java was not found in path." },
- },
- context.use_github_release_file("1c-syntax/bsl-language-server", function(tag)
- local version = tag:gsub("^v", "")
- return ("bsl-language-server-%s-exec.jar"):format(version)
- end),
- context.capture(function(ctx)
- return std.download_file(ctx.github_release_file, "bsl-lsp.jar")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ std.ensure_executable "java"
+ local source = github.release_file {
+ repo = "1c-syntax/bsl-language-server",
+ asset_file = function(release)
+ local version = release:gsub("^v", "")
+ return ("bsl-language-server-%s-exec.jar"):format(version)
+ end,
+ }
+ source.with_receipt()
+ std.download_file(source.download_url, "bsl-lsp.jar")
+ end,
default_options = {
cmd = {
"java",
diff --git a/lua/nvim-lsp-installer/servers/ccls/common.lua b/lua/nvim-lsp-installer/servers/ccls/common.lua
new file mode 100644
index 00000000..2d212a06
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/ccls/common.lua
@@ -0,0 +1,41 @@
+local path = require "nvim-lsp-installer.path"
+local platform = require "nvim-lsp-installer.platform"
+local installer = require "nvim-lsp-installer.core.installer"
+local git = require "nvim-lsp-installer.core.managers.git"
+local Optional = require "nvim-lsp-installer.core.optional"
+
+---@async
+---@param opts {llvm_dir: string}
+return function(opts)
+ local ctx = installer.context()
+ local clang_resource_dir = path.concat { ctx.destination_dir, "clang-resource" }
+ local install_prefix = ctx.cwd:get()
+
+ ctx.fs:mkdir "ccls-git"
+ ctx:chdir("ccls-git", function()
+ git.clone { "https://github.com/MaskRay/ccls", recursive = true }
+ ctx.spawn.cmake {
+ "-DCMAKE_BUILD_TYPE=Release",
+ "-DUSE_SYSTEM_RAPIDJSON=OFF",
+ "-DCMAKE_FIND_FRAMEWORK=LAST",
+ "-Wno-dev",
+ ("-DCMAKE_INSTALL_PREFIX=%s"):format(install_prefix),
+ Optional.of_nilable(opts.llvm_dir)
+ :map(function(llvm_dir)
+ return {
+ ("-DCMAKE_PREFIX_PATH=%s"):format(llvm_dir),
+ -- On Mac we use Homebrew LLVM which will persist after installation.
+ -- On Linux, and when a custom llvm_dir is provided, its clang resource dir will be the only
+ -- artifact persisted after installation, as the locally installed llvm installation will be
+ -- cleaned up after compilation.
+ not platform.is_mac and ("-DCLANG_RESOURCE_DIR=%s"):format(clang_resource_dir) or vim.NIL,
+ }
+ end)
+ :or_else(vim.NIL),
+ platform.is_mac and "-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk" or vim.NIL,
+ }
+
+ ctx.spawn.make { "install" }
+ end)
+ ctx.fs:rmrf "ccls-git"
+end
diff --git a/lua/nvim-lsp-installer/servers/ccls/init.lua b/lua/nvim-lsp-installer/servers/ccls/init.lua
index 5482af87..9fec618c 100644
--- a/lua/nvim-lsp-installer/servers/ccls/init.lua
+++ b/lua/nvim-lsp-installer/servers/ccls/init.lua
@@ -1,193 +1,21 @@
--- __________________
--- < Here be dragons! >
--- ------------------
--- \ ^ /^
--- \ / \ // \
--- \ |\___/| / \// .\
--- \ /O O \__ / // | \ \ *----*
--- / / \/_/ // | \ \ \ |
--- @___@` \/_ // | \ \ \/\ \
--- 0/0/| \/_ // | \ \ \ \
--- 0/0/0/0/| \/// | \ \ | |
--- 0/0/0/0/0/_|_ / ( // | \ _\ | /
--- 0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
--- ,-} _ *-.|.-~-. .~ ~
--- \ \__/ `/\ / ~-. _ .-~ /
--- \____(@@) *. } { /
--- ( (--) .----~-.\ \-` .~
--- //__\\ \__ Ack! ///.----..< \ _ -~
--- // \\ ///-._ _ _ _ _ _ _{^ - - - - ~
---
-
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local installers = require "nvim-lsp-installer.installers"
-local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
-local context = require "nvim-lsp-installer.installers.context"
local process = require "nvim-lsp-installer.process"
-local fs = require "nvim-lsp-installer.fs"
-
-local coalesce, when, list_not_nil = Data.coalesce, Data.when, Data.list_not_nil
return function(name, root_dir)
- local llvm_installer
-
- do
- ---@param version string
- ---@param os_distribution table<string, string>|nil
- ---@return string|nil
- local function get_archive_name(version, os_distribution)
- local name_template = coalesce(
- when(
- platform.is_linux,
- coalesce(
- when(
- platform.arch == "x64",
- coalesce(
- when(
- os_distribution.id == "ubuntu" and os_distribution.version.major >= 20,
- "clang+llvm-%s-x86_64-linux-gnu-ubuntu-20.04"
- ),
- when(
- os_distribution.id == "ubuntu" and os_distribution.version.major >= 16,
- "clang+llvm-%s-x86_64-linux-gnu-ubuntu-16.04"
- )
- )
- ),
- when(platform.arch == "arm64", "clang+llvm-%s-aarch64-linux-gnu"),
- when(platform.arch == "armv7", "clang+llvm-%s-armv7a-linux-gnueabihf")
- )
- )
- )
- return name_template and name_template:format(version)
- end
-
- ---@param version string
- local function normalize_version(version)
- local s = version:gsub("^llvmorg%-", "")
- return s
- end
-
- llvm_installer = installers.branch_context {
- context.use_os_distribution(),
- context.set(function(ctx)
- -- We unset the requested version for llvm because it's not the primary target - the user's requested version should only apply to ccls.
- ctx.requested_server_version = nil
- end),
- installers.first_successful {
- installers.pipe {
- context.capture(function(ctx)
- return context.use_github_release_file("llvm/llvm-project", function(version)
- -- Strip the "llvmorg-" prefix from tags (llvm releases tags like llvmorg-13.0.0)
- local archive_name = get_archive_name(normalize_version(version), ctx.os_distribution)
- return archive_name and ("%s.tar.xz"):format(archive_name)
- end)
- end),
- context.capture(function(ctx)
- return installers.pipe {
- std.untarxz_remote(ctx.github_release_file),
- std.rename(
- get_archive_name(normalize_version(ctx.requested_server_version), ctx.os_distribution),
- "llvm"
- ),
- -- We move the clang headers out, because they need to be persisted
- std.rename(
- path.concat { "llvm", "lib", "clang", normalize_version(ctx.requested_server_version) },
- "clang-resource"
- ),
- }
- end),
- },
- -- If the previous step fails, default to building using system clang+llvm.
- context.set(function(ctx)
- ctx.stdio_sink.stdout "\nUsing system clang+LLVM! Build will fail if clang/LLVM is not installed on the system.\n"
- ctx.use_system_llvm = true
- end),
- },
- }
- end
-
- local ccls_installer = installers.pipe {
- std.git_clone("https://github.com/MaskRay/ccls", {
- directory = "ccls-git",
- recursive = true,
- }),
- function(srv, callback, ctx)
- local c = process.chain {
- cwd = path.concat { ctx.install_dir, "ccls-git" },
- stdio_sink = ctx.stdio_sink,
- }
-
- local clang_resource_dir = path.concat { srv.root_dir, "clang-resource" }
-
- c.run(
- "cmake",
- list_not_nil(
- "-DCMAKE_BUILD_TYPE=Release",
- "-DUSE_SYSTEM_RAPIDJSON=OFF",
- "-DCMAKE_FIND_FRAMEWORK=LAST",
- "-Wno-dev",
- ("-DCMAKE_INSTALL_PREFIX=%s"):format(ctx.install_dir),
- when(not ctx.use_system_llvm, ("-DCMAKE_PREFIX_PATH=%s"):format(ctx.llvm_dir)),
- when(
- not platform.is_mac and not ctx.use_system_llvm,
- ("-DCLANG_RESOURCE_DIR=%s"):format(clang_resource_dir)
- ),
- when(platform.is_mac, "-DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk")
- )
- )
- c.run("make", { "install" })
- c.spawn(callback)
- end,
- std.rmrf "ccls-git",
- }
-
- local linux_ccls_installer = installers.pipe {
- llvm_installer,
- context.set(function(ctx)
- ctx.llvm_dir = path.concat { ctx.install_dir, "llvm" }
- end),
- ccls_installer,
- installers.always_succeed(std.rmrf "llvm"),
- }
-
- local mac_ccls_installer = installers.pipe {
- context.use_homebrew_prefix(),
- context.set(function(ctx)
- ctx.llvm_dir = path.concat { ctx.homebrew_prefix, "opt", "llvm", "lib", "cmake" }
- end),
- function(_, callback, ctx)
- if not fs.dir_exists(ctx.llvm_dir) then
- ctx.stdio_sink.stderr(
- (
- "LLVM does not seem to be installed on this system (looked in %q). Please install LLVM via Homebrew:\n $ brew install llvm\n"
- ):format(ctx.llvm_dir)
- )
- callback(false)
- return
- end
- callback(true)
- end,
- ccls_installer,
- }
-
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/MaskRay/ccls",
languages = { "c", "c++", "objective-c" },
- installer = {
- installers.when {
- mac = mac_ccls_installer,
- linux = linux_ccls_installer,
- },
- context.receipt(function(receipt)
- -- The cloned ccls git repo gets deleted during installation, so we have no local copy.
- receipt:mark_invalid()
- end),
- },
+ async = true,
+ installer = function()
+ platform.when {
+ mac = require "nvim-lsp-installer.servers.ccls.mac",
+ linux = require "nvim-lsp-installer.servers.ccls.linux",
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/ccls/linux.lua b/lua/nvim-lsp-installer/servers/ccls/linux.lua
new file mode 100644
index 00000000..db4e8a3b
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/ccls/linux.lua
@@ -0,0 +1,75 @@
+local path = require "nvim-lsp-installer.path"
+local platform = require "nvim-lsp-installer.platform"
+local installer = require "nvim-lsp-installer.core.installer"
+local github = require "nvim-lsp-installer.core.managers.github"
+local Data = require "nvim-lsp-installer.data"
+local Result = require "nvim-lsp-installer.core.result"
+local Optional = require "nvim-lsp-installer.core.optional"
+
+local ccls_installer = require "nvim-lsp-installer.servers.ccls.common"
+
+local coalesce, when = Data.coalesce, Data.when
+
+---@param release string
+local function normalize_llvm_release(release)
+ -- Strip the "llvmorg-" prefix from tags (llvm releases tags like llvmorg-13.0.0)
+ local normalized_release = release:gsub("^llvmorg%-", "")
+ return normalized_release
+end
+
+---@async
+local function llvm_installer()
+ local ctx = installer.context()
+ local os_dist = platform.os_distribution()
+
+ local asset_name = coalesce(
+ when(
+ platform.is_linux,
+ coalesce(
+ when(
+ platform.arch == "x64",
+ coalesce(
+ when(
+ os_dist.id == "ubuntu" and os_dist.version.major >= 20,
+ "clang+llvm-%s-x86_64-linux-gnu-ubuntu-20.04"
+ ),
+ when(
+ os_dist.id == "ubuntu" and os_dist.version.major >= 16,
+ "clang+llvm-%s-x86_64-linux-gnu-ubuntu-16.04"
+ )
+ )
+ ),
+ when(platform.arch == "arm64", "clang+llvm-%s-aarch64-linux-gnu"),
+ when(platform.arch == "armv7", "clang+llvm-%s-armv7a-linux-gnueabihf")
+ )
+ )
+ )
+
+ local source = github.untarxz_release_file {
+ repo = "llvm/llvm-project",
+ version = Optional.of "llvmorg-13.0.0",
+ asset_file = function(release)
+ local normalized_release = normalize_llvm_release(release)
+ return asset_name and ("%s.tar.xz"):format(asset_name):format(normalized_release)
+ end,
+ }
+
+ ctx.fs:rename(asset_name:format(normalize_llvm_release(source.release)), "llvm")
+ -- We move the clang headers out, because they need to be persisted
+ ctx.fs:rename(path.concat { "llvm", "lib", "clang", normalize_llvm_release(source.release) }, "clang-resource")
+
+ return path.concat { ctx.cwd:get(), "llvm" }
+end
+
+---@async
+return function()
+ local ctx = installer.context()
+ Result.run_catching(llvm_installer)
+ :map(function(llvm_dir)
+ ccls_installer { llvm_dir = llvm_dir }
+ end)
+ :recover(function()
+ ccls_installer {}
+ end)
+ ctx.fs:rmrf "llvm"
+end
diff --git a/lua/nvim-lsp-installer/servers/ccls/mac.lua b/lua/nvim-lsp-installer/servers/ccls/mac.lua
new file mode 100644
index 00000000..dc53bde5
--- /dev/null
+++ b/lua/nvim-lsp-installer/servers/ccls/mac.lua
@@ -0,0 +1,22 @@
+local path = require "nvim-lsp-installer.path"
+local platform = require "nvim-lsp-installer.platform"
+local installer = require "nvim-lsp-installer.core.installer"
+local fs = require "nvim-lsp-installer.core.fs"
+
+local ccls_installer = require "nvim-lsp-installer.servers.ccls.common"
+
+---@async
+return function()
+ local ctx = installer.context()
+ local homebrew_prefix = platform.get_homebrew_prefix():get_or_throw()
+ local llvm_dir = path.concat { homebrew_prefix, "opt", "llvm", "lib", "cmake" }
+ if not fs.dir_exists(llvm_dir) then
+ ctx.stdio_sink.stderr(
+ (
+ "LLVM does not seem to be installed on this system (looked in %q). Please install LLVM via Homebrew:\n $ brew install llvm\n"
+ ):format(llvm_dir)
+ )
+ error "Unable to find LLVM."
+ end
+ ccls_installer { llvm_dir = llvm_dir }
+end
diff --git a/lua/nvim-lsp-installer/servers/clangd/init.lua b/lua/nvim-lsp-installer/servers/clangd/init.lua
index e4e819b8..c4025fd5 100644
--- a/lua/nvim-lsp-installer/servers/clangd/init.lua
+++ b/lua/nvim-lsp-installer/servers/clangd/init.lua
@@ -2,9 +2,10 @@ local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local process = require "nvim-lsp-installer.process"
local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
local platform = require "nvim-lsp-installer.platform"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
+
+local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
return server.Server:new {
@@ -12,25 +13,23 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://clangd.llvm.org",
languages = { "c", "c++" },
- installer = {
- context.use_github_release_file("clangd/clangd", function(version)
- local target_file = Data.coalesce(
- Data.when(platform.is_mac, "clangd-mac-%s.zip"),
- Data.when(platform.is_linux and platform.arch == "x64", "clangd-linux-%s.zip"),
- Data.when(platform.is_win, "clangd-windows-%s.zip")
- )
- return target_file and target_file:format(version)
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.capture(function(ctx)
- return std.rename(("clangd_%s"):format(ctx.requested_server_version), "clangd")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local source = github.unzip_release_file {
+ repo = "clangd/clangd",
+ asset_file = function(release)
+ local target = coalesce(
+ when(platform.is_mac, "clangd-mac-%s.zip"),
+ when(platform.is_linux and platform.arch == "x64", "clangd-linux-%s.zip"),
+ when(platform.is_win, "clangd-windows-%s.zip")
+ )
+ return target and target:format(release)
+ end,
+ }
+ source.with_receipt()
+ ctx.fs:rename(("clangd_%s"):format(source.release), "clangd")
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "clangd", "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/clarity_lsp/init.lua b/lua/nvim-lsp-installer/servers/clarity_lsp/init.lua
index 9c470790..ae5bea52 100644
--- a/lua/nvim-lsp-installer/servers/clarity_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/clarity_lsp/init.lua
@@ -1,8 +1,7 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
local Data = require "nvim-lsp-installer.data"
local coalesce, when = Data.coalesce, Data.when
@@ -13,22 +12,17 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/hirosystems/clarity-lsp",
languages = { "clarity" },
- installer = {
- context.use_github_release_file(
- "hirosystems/clarity-lsp",
- coalesce(
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "hirosystems/clarity-lsp",
+ asset_file = coalesce(
when(platform.is_mac, "clarity-lsp-macos-x64.zip"),
when(platform.is_linux and platform.arch == "x64", "clarity-lsp-linux-x64.zip"),
when(platform.is_win and platform.arch == "x64", "clarity-lsp-windows-x64.zip")
- )
- ),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
index 5e13fa00..a160a9a6 100644
--- a/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/clojure_lsp/init.lua
@@ -1,9 +1,11 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
+
+local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
return server.Server:new {
@@ -11,23 +13,18 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://clojure-lsp.io",
languages = { "clojure" },
- installer = {
- context.use_github_release_file(
- "clojure-lsp/clojure-lsp",
- Data.coalesce(
- Data.when(platform.is_mac, "clojure-lsp-native-macos-amd64.zip"),
- Data.when(platform.is_linux, "clojure-lsp-native-linux-amd64.zip"),
- Data.when(platform.is_win, "clojure-lsp-native-windows-amd64.zip")
- )
- ),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- std.chmod("+x", { "clojure-lsp" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "clojure-lsp/clojure-lsp",
+ asset_file = coalesce(
+ when(platform.is_mac, "clojure-lsp-native-macos-amd64.zip"),
+ when(platform.is_linux, "clojure-lsp-native-linux-amd64.zip"),
+ when(platform.is_win, "clojure-lsp-native-windows-amd64.zip")
+ ),
+ }).with_receipt()
+ std.chmod("+x", { "clojure-lsp" })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/codeqlls/init.lua b/lua/nvim-lsp-installer/servers/codeqlls/init.lua
index 9bb82d98..87106e1e 100644
--- a/lua/nvim-lsp-installer/servers/codeqlls/init.lua
+++ b/lua/nvim-lsp-installer/servers/codeqlls/init.lua
@@ -1,8 +1,7 @@
local server = require "nvim-lsp-installer.server"
-local std = require "nvim-lsp-installer.installers.std"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
local process = require "nvim-lsp-installer.process"
local path = require "nvim-lsp-installer.path"
@@ -13,22 +12,17 @@ return function(name, root_dir)
name = name,
root_dir = root_dir,
languages = { "codeql" },
- installer = {
- context.use_github_release_file(
- "github/codeql-cli-binaries",
- coalesce(
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "github/codeql-cli-binaries",
+ asset_file = coalesce(
when(platform.is_mac, "codeql-osx64.zip"),
when(platform.is_unix, "codeql-linux64.zip"),
when(platform.is_win, "codeql-win64.zip")
- )
- ),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "codeql" } },
diff --git a/lua/nvim-lsp-installer/servers/crystalline/init.lua b/lua/nvim-lsp-installer/servers/crystalline/init.lua
index 01c8ac24..67d61a9e 100644
--- a/lua/nvim-lsp-installer/servers/crystalline/init.lua
+++ b/lua/nvim-lsp-installer/servers/crystalline/init.lua
@@ -1,11 +1,10 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
-local installers = require "nvim-lsp-installer.installers"
local Data = require "nvim-lsp-installer.data"
local path = require "nvim-lsp-installer.path"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
@@ -15,48 +14,18 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/elbywan/crystalline",
languages = { "crystal" },
- installer = {
- -- Crystalline (LSP)
- installers.branch_context {
- context.use_github_release_file(
- "elbywan/crystalline",
- coalesce(
- when(platform.is_mac and platform.arch == "x64", "crystalline_x86_64-apple-darwin.gz"),
- when(platform.is_linux and platform.arch == "x64", "crystalline_x86_64-unknown-linux-gnu.gz")
- )
+ async = true,
+ installer = function()
+ github.gunzip_release_file({
+ repo = "elbywan/crystalline",
+ asset_file = coalesce(
+ when(platform.is_mac and platform.arch == "x64", "crystalline_x86_64-apple-darwin.gz"),
+ when(platform.is_linux and platform.arch == "x64", "crystalline_x86_64-unknown-linux-gnu.gz")
),
- context.capture(function(ctx)
- return std.gunzip_remote(
- ctx.github_release_file,
- platform.is_win and "crystalline.exe" or "crystalline"
- )
- end),
- std.chmod("+x", { "crystalline" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
- -- Crystal
- installers.branch_context {
- context.use_github_release_file("crystal-lang/crystal", function(version)
- local target_file = coalesce(
- when(platform.is_mac, "crystal-%s-1-darwin-universal.tar.gz"),
- when(platform.is_linux and platform.arch == "x64", "crystal-%s-1-linux-x86_64-bundled.tar.gz")
- )
- return target_file and target_file:format(version)
- end),
- context.capture(function(ctx)
- return installers.pipe {
- std.untargz_remote(ctx.github_release_file),
- std.rename(("crystal-%s-1"):format(ctx.requested_server_version), "crystal"),
- }
- end),
- std.chmod("+x", { "crystalline" }),
- context.receipt(function(receipt, ctx)
- receipt:with_secondary_source(receipt.github_release_file(ctx))
- end),
- },
- },
+ out_file = "crystalline",
+ }).with_receipt()
+ std.chmod("+x", { "crystalline" })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir, path.concat { root_dir, "crystal", "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/denols/init.lua b/lua/nvim-lsp-installer/servers/denols/init.lua
index dfd0ab2a..37ae7e6d 100644
--- a/lua/nvim-lsp-installer/servers/denols/init.lua
+++ b/lua/nvim-lsp-installer/servers/denols/init.lua
@@ -2,8 +2,7 @@ local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -13,10 +12,11 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://deno.land/x/deno/cli/lsp",
languages = { "deno" },
- installer = {
- context.use_github_release_file(
- "denoland/deno",
- coalesce(
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "denoland/deno",
+ asset_file = coalesce(
when(
platform.is_mac,
coalesce(
@@ -26,15 +26,9 @@ return function(name, root_dir)
),
when(platform.is_linux, "deno-x86_64-unknown-linux-gnu.zip"),
when(platform.is_win, "deno-x86_64-pc-windows-msvc.zip")
- )
- ),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/dhall_lsp_server/init.lua b/lua/nvim-lsp-installer/servers/dhall_lsp_server/init.lua
index 407f9d5a..27604f0c 100644
--- a/lua/nvim-lsp-installer/servers/dhall_lsp_server/init.lua
+++ b/lua/nvim-lsp-installer/servers/dhall_lsp_server/init.lua
@@ -2,17 +2,12 @@ local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github_client = require "nvim-lsp-installer.core.managers.github.client"
+local Optional = require "nvim-lsp-installer.core.optional"
-local coalesce, when = Data.coalesce, Data.when
-
-local target = coalesce(
- when(platform.is_mac, "dhall-lsp-server-1.0.18-x86_64-macos.tar.bz2"),
- when(platform.is_linux, "dhall-lsp-server-1.0.18-x86_64-linux.tar.bz2"),
- when(platform.is_win, "dhall-lsp-server-1.0.18-x86_64-windows.zip")
-)
+local coalesce, when, list_find_first = Data.coalesce, Data.when, Data.list_find_first
return function(name, root_dir)
return server.Server:new {
@@ -20,26 +15,56 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://dhall-lang.org/",
languages = { "dhall" },
- installer = {
- context.set(function(ctx)
- ctx.requested_server_version = Data.coalesce(
- ctx.requested_server_version,
- "1.41.1" -- https://github.com/williamboman/nvim-lsp-installer/pull/512#discussion_r817062340
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local repo = "dhall-lang/dhall-haskell"
+ ---@type GitHubRelease
+ local gh_release = ctx.requested_version
+ :map(function(version)
+ return github_client.fetch_release(repo, version)
+ end)
+ :or_else_get(function()
+ return github_client.fetch_latest_release(repo)
+ end)
+ :get_or_throw()
+
+ local asset_name_pattern = assert(
+ coalesce(
+ when(platform.is_mac, "dhall%-lsp%-server%-.+%-x86_64%-macos.tar.bz2"),
+ when(platform.is_linux, "dhall%-lsp%-server%-.+%-x86_64%-linux.tar.bz2"),
+ when(platform.is_win, "dhall%-lsp%-server%-.+%-x86_64%-windows.zip")
)
- end),
- context.use_github_release_file("dhall-lang/dhall-haskell", target),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untargz_remote(ctx.github_release_file)
+ )
+ local dhall_lsp_server_asset = list_find_first(
+ gh_release.assets,
+ ---@param asset GitHubReleaseAsset
+ function(asset)
+ return asset.name:match(asset_name_pattern)
end
- end),
- std.chmod("+x", { path.concat { "bin", "dhall-lsp-server" } }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ )
+ Optional.of_nilable(dhall_lsp_server_asset)
+ :if_present(
+ ---@param asset GitHubReleaseAsset
+ function(asset)
+ if platform.is_win then
+ std.download_file(asset.browser_download_url, "dhall-lsp-server.zip")
+ std.unzip("dhall-lsp-server.zip", ".")
+ else
+ std.download_file(asset.browser_download_url, "dhall-lsp-server.tar.bz2")
+ std.untar "dhall-lsp-server.tar.bz2"
+ std.chmod("+x", { path.concat { "bin", "dhall-lsp-server" } })
+ end
+ ctx.receipt:with_primary_source {
+ type = "github_release_file",
+ repo = repo,
+ file = asset.browser_download_url,
+ release = gh_release.tag_name,
+ }
+ end
+ )
+ :or_else_throw "Unable to find the dhall-lsp-server release asset in the GitHub release."
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/elixirls/init.lua b/lua/nvim-lsp-installer/servers/elixirls/init.lua
index 7a8f8bea..006c0222 100644
--- a/lua/nvim-lsp-installer/servers/elixirls/init.lua
+++ b/lua/nvim-lsp-installer/servers/elixirls/init.lua
@@ -1,8 +1,8 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
return function(name, root_dir)
return server.Server:new {
@@ -10,16 +10,19 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/elixir-lsp/elixir-ls",
languages = { "elixir" },
- installer = {
- context.use_github_release_file("elixir-lsp/elixir-ls", "elixir-ls.zip"),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file, "elixir-ls")
- end),
- std.chmod("+x", { "elixir-ls/language_server.sh" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ -- We write to the elixir-ls directory for backwards compatibility reasons
+ ctx.fs:mkdir "elixir-ls"
+ ctx:chdir("elixir-ls", function()
+ github.unzip_release_file({
+ repo = "elixir-lsp/elixir-ls",
+ asset_file = "elixir-ls.zip",
+ }).with_receipt()
+ std.chmod("+x", { "language_server.sh" })
+ end)
+ end,
default_options = {
cmd = {
path.concat {
diff --git a/lua/nvim-lsp-installer/servers/erlangls/init.lua b/lua/nvim-lsp-installer/servers/erlangls/init.lua
index 749a57b0..52b2e8ea 100644
--- a/lua/nvim-lsp-installer/servers/erlangls/init.lua
+++ b/lua/nvim-lsp-installer/servers/erlangls/init.lua
@@ -1,9 +1,11 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local process = require "nvim-lsp-installer.process"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
+local std = require "nvim-lsp-installer.core.managers.std"
+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"
return function(name, root_dir)
local rebar3 = platform.is_win and "rebar3.cmd" or "rebar3"
@@ -13,25 +15,24 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "erlang" },
homepage = "https://erlang-ls.github.io/",
- installer = {
- std.ensure_executables {
- { rebar3, ("%s was not found in path. Refer to http://rebar3.org/docs/."):format(rebar3) },
- },
- context.use_github_latest_tag "erlang-ls/erlang_ls",
- std.git_clone "https://github.com/erlang-ls/erlang_ls.git",
- function(_, callback, ctx)
- local c = process.chain {
- cwd = ctx.install_dir,
- stdio_sink = ctx.stdio_sink,
- }
- c.run(rebar3, { "escriptize" })
- c.run(rebar3, { "as", "dap", "escriptize" })
- c.spawn(callback)
- end,
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_tag(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable(rebar3, { help_url = "http://rebar3.org/docs/" })
+
+ local repo = "erlang-ls/erlang_ls"
+ ctx.requested_version = ctx.requested_version:or_(function()
+ return Optional.of(github_client.fetch_latest_tag(repo)
+ :map(function(tag)
+ return tag.name
+ end)
+ :get_or_throw "Failed to fetch latest tag.")
+ end)
+ git.clone({ ("https://github.com/%s.git"):format(repo) }).with_receipt()
+
+ ctx.spawn[rebar3] { "escriptize" }
+ ctx.spawn[rebar3] { "as", "dap", "escriptize" }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "_build", "default", "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/groovyls/init.lua b/lua/nvim-lsp-installer/servers/groovyls/init.lua
index a40dc32e..8f7b4617 100644
--- a/lua/nvim-lsp-installer/servers/groovyls/init.lua
+++ b/lua/nvim-lsp-installer/servers/groovyls/init.lua
@@ -2,7 +2,6 @@ local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local std = require "nvim-lsp-installer.core.managers.std"
local git = require "nvim-lsp-installer.core.managers.git"
-local process = require "nvim-lsp-installer.process"
return function(name, root_dir)
return server.Server:new {
@@ -18,9 +17,7 @@ return function(name, root_dir)
ctx:promote_cwd()
ctx.spawn.gradlew {
"build",
- env = process.graft_env {
- PATH = process.extend_path { ctx.cwd:get() },
- },
+ with_paths = { ctx.cwd:get() },
}
end,
default_options = {
diff --git a/lua/nvim-lsp-installer/servers/hls/init.lua b/lua/nvim-lsp-installer/servers/hls/init.lua
index a5966045..a154a4f2 100644
--- a/lua/nvim-lsp-installer/servers/hls/init.lua
+++ b/lua/nvim-lsp-installer/servers/hls/init.lua
@@ -1,11 +1,10 @@
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
-local installers = require "nvim-lsp-installer.installers"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
-local shell = require "nvim-lsp-installer.installers.shell"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
+
+local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
return server.Server:new {
@@ -13,25 +12,24 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://haskell-language-server.readthedocs.io/en/latest/",
languages = { "haskell" },
- installer = {
- context.use_github_release_file("haskell/haskell-language-server", function(version)
- return Data.coalesce(
- Data.when(platform.is_mac, "haskell-language-server-macOS-%s.tar.gz"),
- Data.when(platform.is_linux, "haskell-language-server-Linux-%s.tar.gz"),
- Data.when(platform.is_win, "haskell-language-server-Windows-%s.tar.gz")
- ):format(version)
- end),
- context.capture(function(ctx)
- return std.untargz_remote(ctx.github_release_file)
- end),
- installers.on {
- -- we can't use std.chmod because of shell wildcard expansion
- unix = shell.sh [[ chmod +x haskell* ]],
- },
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ github.untargz_release_file({
+ repo = "haskell/haskell-language-server",
+ asset_file = function(version)
+ local target = coalesce(
+ when(platform.is_mac, "haskell-language-server-macOS-%s.tar.gz"),
+ when(platform.is_linux, "haskell-language-server-Linux-%s.tar.gz"),
+ when(platform.is_win, "haskell-language-server-Windows-%s.tar.gz")
+ )
+ return target and target:format(version)
+ end,
+ }).with_receipt()
+ if platform.is_unix then
+ ctx.spawn.sh { "-c", [[ chmod +x haskell* ]] }
+ end
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/jdtls/init.lua b/lua/nvim-lsp-installer/servers/jdtls/init.lua
index 1e466c85..c36a8f87 100644
--- a/lua/nvim-lsp-installer/servers/jdtls/init.lua
+++ b/lua/nvim-lsp-installer/servers/jdtls/init.lua
@@ -1,11 +1,10 @@
local server = require "nvim-lsp-installer.server"
-local a = require "nvim-lsp-installer.core.async"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
+local installer = require "nvim-lsp-installer.core.installer"
local eclipse = require "nvim-lsp-installer.core.clients.eclipse"
+local std = require "nvim-lsp-installer.core.managers.std"
return function(name, root_dir)
---@param workspace_root string
@@ -47,46 +46,39 @@ return function(name, root_dir)
}
end
+ local function download_jdtls()
+ local ctx = installer.context()
+ local version = ctx.requested_version:or_else_get(function()
+ return eclipse.fetch_latest_jdtls_version():get_or_throw()
+ end)
+
+ std.download_file(
+ ("https://download.eclipse.org/jdtls/snapshots/jdt-language-server-%s.tar.gz"):format(version),
+ "archive.tar.gz"
+ )
+ std.untar "archive.tar.gz"
+
+ ctx.receipt:with_primary_source {
+ type = "jdtls",
+ version = version,
+ }
+ end
+
+ local function download_lombok()
+ std.download_file("https://projectlombok.org/downloads/lombok.jar", "lombok.jar")
+ end
+
return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "java" },
homepage = "https://github.com/eclipse/eclipse.jdt.ls",
- installer = {
- std.ensure_executables {
- { "java", "java was not found in path." },
- },
- ---@type ServerInstallerFunction
- function(_, callback, ctx)
- if ctx.requested_server_version then
- callback(true)
- return
- end
- a.run(eclipse.fetch_latest_jdtls_version, function(success, latest_version)
- if not success or latest_version:is_failure() then
- ctx.stdio_sink.stderr "Failed to fetch latest verison.\n"
- callback(false)
- else
- ctx.requested_server_version = latest_version:get_or_nil()
- callback(true)
- end
- end)
- end,
- context.capture(function(ctx)
- return std.untargz_remote(
- ("https://download.eclipse.org/jdtls/snapshots/jdt-language-server-%s.tar.gz"):format(
- ctx.requested_server_version
- )
- )
- end),
- std.download_file("https://projectlombok.org/downloads/lombok.jar", "lombok.jar"),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source {
- type = "jdtls",
- version = ctx.requested_server_version,
- }
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable "java"
+ ctx:run_concurrently { download_jdtls, download_lombok }
+ end,
default_options = {
cmd = get_cmd(
vim.env.WORKSPACE and vim.env.WORKSPACE or path.concat { vim.env.HOME, "workspace" },
diff --git a/lua/nvim-lsp-installer/servers/julials/init.lua b/lua/nvim-lsp-installer/servers/julials/init.lua
index 690dd9d4..afbb16eb 100644
--- a/lua/nvim-lsp-installer/servers/julials/init.lua
+++ b/lua/nvim-lsp-installer/servers/julials/init.lua
@@ -1,7 +1,7 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local context = require "nvim-lsp-installer.installers.context"
-local std = require "nvim-lsp-installer.installers.std"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
local server_script = [[
@@ -26,31 +26,34 @@ runserver(stdin,
root_dir = root_dir,
homepage = "https://github.com/julia-vscode/LanguageServer.jl",
languages = { "julia" },
- installer = {
- std.ensure_executables {
- { "julia", "julia was not found in path, refer to https://julialang.org/downloads/." },
- },
- context.use_github_release_file("julia-vscode/julia-vscode", function(version)
- local version_number = version:gsub("^v", "")
- return ("language-julia-%s.vsix"):format(version_number)
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file, "vscode-package")
- end),
- std.rename(
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable("julia", { help_url = "https://julialang.org/downloads/" })
+
+ ctx.fs:mkdir "vscode-package"
+ ctx:chdir("vscode-package", function()
+ github.unzip_release_file({
+ repo = "julia-vscode/julia-vscode",
+ asset_file = function(version)
+ local version_number = version:gsub("^v", "")
+ return ("language-julia-%s.vsix"):format(version_number)
+ end,
+ }).with_receipt()
+ end)
+
+ ctx.fs:rename(
path.concat {
"vscode-package",
"extension",
"scripts",
},
"scripts"
- ),
- std.rmrf "vscode-package",
- std.write_file("nvim-lsp.jl", server_script),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ )
+ ctx.fs:rmrf "vscode-package"
+
+ ctx.fs:write_file("nvim-lsp.jl", server_script)
+ end,
default_options = {
cmd = {
"julia",
diff --git a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
index 4909b56d..a8330fca 100644
--- a/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
+++ b/lua/nvim-lsp-installer/servers/kotlin_language_server/init.lua
@@ -1,8 +1,7 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
return server.Server:new {
@@ -10,15 +9,13 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/fwcd/kotlin-language-server",
languages = { "kotlin" },
- installer = {
- context.use_github_release_file("fwcd/kotlin-language-server", "server.zip"),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "fwcd/kotlin-language-server",
+ asset_file = "server.zip",
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path {
diff --git a/lua/nvim-lsp-installer/servers/lemminx/init.lua b/lua/nvim-lsp-installer/servers/lemminx/init.lua
index b7eebd23..97de73f4 100644
--- a/lua/nvim-lsp-installer/servers/lemminx/init.lua
+++ b/lua/nvim-lsp-installer/servers/lemminx/init.lua
@@ -1,54 +1,43 @@
local server = require "nvim-lsp-installer.server"
-local std = require "nvim-lsp-installer.installers.std"
local Data = require "nvim-lsp-installer.data"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local unzipped_file = coalesce(
- when(platform.is_mac, "lemminx-osx-x86_64"),
- when(platform.is_linux, "lemminx-linux"),
- when(platform.is_win, "lemminx-win32")
- )
-
return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "xml" },
homepage = "https://github.com/eclipse/lemminx",
- installer = {
- function(_, callback, ctx)
- if not unzipped_file then
- ctx.stdio_sink.stderr(
- ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
- )
- callback(false)
- else
- callback(true)
- end
- end,
- context.set(function(ctx)
- ctx.requested_server_version = coalesce(ctx.requested_server_version, "0.19.2-655")
- end),
- context.capture(function(ctx)
- return std.unzip_remote(
- ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
- ctx.requested_server_version,
- unzipped_file
- )
- )
- end),
- std.rename(
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local unzipped_file = assert(
+ coalesce(
+ when(platform.is_mac, "lemminx-osx-x86_64"),
+ when(platform.is_linux, "lemminx-linux"),
+ when(platform.is_win, "lemminx-win32")
+ ),
+ ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
+ )
+
+ std.download_file(
+ ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
+ ctx.requested_version:or_else "0.19.2-655", -- TODO: resolve latest version dynamically
+ unzipped_file
+ ),
+ "lemminx.zip"
+ )
+ std.unzip("lemminx.zip", ".")
+ ctx.fs:rename(
platform.is_win and ("%s.exe"):format(unzipped_file) or unzipped_file,
platform.is_win and "lemminx.exe" or "lemminx"
- ),
- context.receipt(function(receipt)
- receipt:with_primary_source(receipt.unmanaged)
- end),
- },
+ )
+ ctx.receipt:with_primary_source(ctx.receipt.unmanaged)
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/ltex/init.lua b/lua/nvim-lsp-installer/servers/ltex/init.lua
index 5eb10dc0..a9c09b8d 100644
--- a/lua/nvim-lsp-installer/servers/ltex/init.lua
+++ b/lua/nvim-lsp-installer/servers/ltex/init.lua
@@ -1,10 +1,9 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -14,28 +13,34 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://valentjn.github.io/vscode-ltex",
languages = { "latex" },
- installer = {
- context.use_github_release_file("valentjn/ltex-ls", function(version)
- return coalesce(
- when(platform.is_mac, "ltex-ls-%s-mac-x64.tar.gz"),
- when(platform.is_linux, "ltex-ls-%s-linux-x64.tar.gz"),
- when(platform.is_win, "ltex-ls-%s-windows-x64.zip")
- ):format(version)
- end),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untargz_remote(ctx.github_release_file)
- end
- end),
- context.capture(function(ctx)
- return std.rename(("ltex-ls-%s"):format(ctx.requested_server_version), "ltex-ls")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ if platform.is_win then
+ local release_source = github.unzip_release_file {
+ repo = "valentjn/ltex-ls",
+ asset_file = function(version)
+ return ("ltex-ls-%s-windows-x64.zip"):format(version)
+ end,
+ }
+ release_source.with_receipt()
+ ctx.fs:rename(("ltex-ls-%s"):format(release_source.release), "ltex-ls")
+ else
+ local release_source = github.untargz_release_file {
+ repo = "valentjn/ltex-ls",
+ asset_file = function(version)
+ local target = coalesce(
+ when(platform.is_mac, "ltex-ls-%s-mac-x64.tar.gz"),
+ when(platform.is_linux, "ltex-ls-%s-linux-x64.tar.gz"),
+ when(platform.is_win, "ltex-ls-%s-windows-x64.zip")
+ )
+ return target:format(version)
+ end,
+ }
+ release_source.with_receipt()
+ ctx.fs:rename(("ltex-ls-%s"):format(release_source.release), "ltex-ls")
+ end
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "ltex-ls", "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/mm0_ls/init.lua b/lua/nvim-lsp-installer/servers/mm0_ls/init.lua
index a50c7879..6050f3f3 100644
--- a/lua/nvim-lsp-installer/servers/mm0_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/mm0_ls/init.lua
@@ -13,8 +13,9 @@ return function(name, root_dir)
---@param ctx InstallContext
installer = function(ctx)
git.clone({ "https://github.com/digama0/mm0" }).with_receipt()
- ctx.spawn.cargo { "build", "--release", cwd = path.concat { ctx.cwd:get(), "mm0-rs" } }
- ctx.receipt:with_primary_source(ctx.receipt.git_remote "https://github.com/digama0/mm0")
+ ctx:chdir("mm0-rs", function()
+ ctx.spawn.cargo { "build", "--release" }
+ end)
end,
default_options = {
cmd_env = {
diff --git a/lua/nvim-lsp-installer/servers/omnisharp/init.lua b/lua/nvim-lsp-installer/servers/omnisharp/init.lua
index 19960003..f45df354 100644
--- a/lua/nvim-lsp-installer/servers/omnisharp/init.lua
+++ b/lua/nvim-lsp-installer/servers/omnisharp/init.lua
@@ -2,8 +2,8 @@ local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local path = require "nvim-lsp-installer.path"
local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
@@ -13,46 +13,42 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/OmniSharp/omnisharp-roslyn",
languages = { "c#" },
- installer = {
- std.ensure_executables {
- {
- "dotnet",
- "dotnet was not found in path. Refer to https://dotnet.microsoft.com/download for installation instructions.",
- },
- },
- context.use_github_release_file(
- "OmniSharp/omnisharp-roslyn",
- coalesce(
- when(
- platform.is_mac,
- coalesce(
- when(platform.arch == "x64", "omnisharp-osx-x64-net6.0.zip"),
- when(platform.arch == "arm64", "omnisharp-osx-arm64-net6.0.zip")
- )
- ),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "x64", "omnisharp-linux-x64-net6.0.zip"),
- when(platform.arch == "arm64", "omnisharp-linux-arm64-net6.0.zip")
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable("dotnet", { help_url = "https://dotnet.microsoft.com/download" })
+
+ -- We write to the omnisharp directory for backwards compatibility reasons
+ ctx.fs:mkdir "omnisharp"
+ ctx:chdir("omnisharp", function()
+ github.unzip_release_file({
+ repo = "OmniSharp/omnisharp-roslyn",
+ asset_file = coalesce(
+ when(
+ platform.is_mac,
+ coalesce(
+ when(platform.arch == "x64", "omnisharp-osx-x64-net6.0.zip"),
+ when(platform.arch == "arm64", "omnisharp-osx-arm64-net6.0.zip")
+ )
+ ),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "x64", "omnisharp-linux-x64-net6.0.zip"),
+ when(platform.arch == "arm64", "omnisharp-linux-arm64-net6.0.zip")
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(
+ when(platform.arch == "x64", "omnisharp-win-x64-net6.0.zip"),
+ when(platform.arch == "arm64", "omnisharp-win-arm64-net6.0.zip")
+ )
)
),
- when(
- platform.is_win,
- coalesce(
- when(platform.arch == "x64", "omnisharp-win-x64-net6.0.zip"),
- when(platform.arch == "arm64", "omnisharp-win-arm64-net6.0.zip")
- )
- )
- )
- ),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file, "omnisharp")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ }).with_receipt()
+ end)
+ end,
default_options = {
cmd = {
"dotnet",
diff --git a/lua/nvim-lsp-installer/servers/opencl_ls/init.lua b/lua/nvim-lsp-installer/servers/opencl_ls/init.lua
index 5586fe6d..50ed529d 100644
--- a/lua/nvim-lsp-installer/servers/opencl_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/opencl_ls/init.lua
@@ -1,9 +1,8 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -13,27 +12,27 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/Galarius/opencl-language-server",
languages = { "opencl" },
- installer = {
- context.use_github_release_file(
- "Galarius/opencl-language-server",
- coalesce(
- when(platform.is_mac, "opencl-language-server-darwin-x86_64.tar.gz"),
- when(platform.is_linux and platform.arch == "x64", "opencl-language-server-linux-x86_64.tar.gz"),
- when(platform.is_win and platform.arch == "x64", "opencl-language-server-win32-x86_64.zip")
- )
- ),
- context.capture(coalesce(
- when(platform.is_unix, function(ctx)
- return std.untargz_remote(ctx.github_release_file)
- end),
- when(platform.is_win, function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end)
- )),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ platform.when {
+ unix = function()
+ local asset_file = coalesce(
+ when(platform.is_mac, "opencl-language-server-darwin-x86_64.tar.gz"),
+ when(platform.is_linux and platform.arch == "x64", "opencl-language-server-linux-x86_64.tar.gz")
+ )
+ github.untargz_release_file({
+ repo = "Galarius/opencl-language-server",
+ asset_file = asset_file,
+ }).with_receipt()
+ end,
+ win = function()
+ github.unzip_release_file({
+ repo = "Galarius/opencl-language-server",
+ asset_file = "opencl-language-server-win32-x86_64.zip",
+ }).with_receipt()
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/powershell_es/init.lua b/lua/nvim-lsp-installer/servers/powershell_es/init.lua
index 35facc2d..8e2edd4d 100644
--- a/lua/nvim-lsp-installer/servers/powershell_es/init.lua
+++ b/lua/nvim-lsp-installer/servers/powershell_es/init.lua
@@ -1,7 +1,7 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
return server.Server:new {
@@ -9,21 +9,14 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/PowerShell/PowerShellEditorServices",
languages = { "powershell" },
- installer = {
- std.ensure_executables {
- {
- "pwsh",
- "pwsh was not found in path. Refer to https://github.com/PowerShell/PowerShell#get-powershell for instructions.",
- },
- },
- context.use_github_release_file("PowerShell/PowerShellEditorServices", "PowerShellEditorServices.zip"),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ std.ensure_executable("pwsh", { help_url = "https://github.com/PowerShell/PowerShell#get-powershell" })
+ github.unzip_release_file({
+ repo = "PowerShell/PowerShellEditorServices",
+ asset_file = "PowerShellEditorServices.zip",
+ }).with_receipt()
+ end,
default_options = {
bundle_path = path.concat { root_dir },
},
diff --git a/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua b/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
index b7d3f687..7ee6ff6f 100644
--- a/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/prosemd_lsp/init.lua
@@ -1,37 +1,32 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local target = coalesce(
- when(platform.is_mac, "prosemd-lsp-macos"),
- when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"),
- when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe")
- )
-
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/kitten/prosemd-lsp",
languages = { "markdown" },
- installer = {
- context.use_github_release_file("kitten/prosemd-lsp", target),
- context.capture(function(ctx)
- return std.download_file(
- ctx.github_release_file,
- platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp"
- )
- end),
- std.chmod("+x", { "prosemd-lsp" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ local source = github.release_file {
+ repo = "kitten/prosemd-lsp",
+ asset_file = coalesce(
+ when(platform.is_mac, "prosemd-lsp-macos"),
+ when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"),
+ when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe")
+ ),
+ }
+ source.with_receipt()
+ std.download_file(source.download_url, platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp")
+ std.chmod("+x", { "prosemd-lsp" })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/puppet/init.lua b/lua/nvim-lsp-installer/servers/puppet/init.lua
index 09842f30..9d302c2e 100644
--- a/lua/nvim-lsp-installer/servers/puppet/init.lua
+++ b/lua/nvim-lsp-installer/servers/puppet/init.lua
@@ -1,7 +1,6 @@
local server = require "nvim-lsp-installer.server"
-local context = require "nvim-lsp-installer.installers.context"
-local std = require "nvim-lsp-installer.installers.std"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
return server.Server:new {
@@ -9,17 +8,15 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/puppetlabs/puppet-editor-services",
languages = { "puppet" },
- installer = {
- context.use_github_release_file("puppetlabs/puppet-editor-services", function(version)
- return ("puppet_editor_services_%s.zip"):format(version)
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "puppetlabs/puppet-editor-services",
+ asset_file = function(version)
+ return ("puppet_editor_services_%s.zip"):format(version)
+ end,
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua
index 1f292ae9..a90d86cc 100644
--- a/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua
+++ b/lua/nvim-lsp-installer/servers/quick_lint_js/init.lua
@@ -1,64 +1,75 @@
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 installers = require "nvim-lsp-installer.installers"
local path = require "nvim-lsp-installer.path"
local Data = require "nvim-lsp-installer.data"
local process = require "nvim-lsp-installer.process"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github_client = require "nvim-lsp-installer.core.managers.github.client"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local release_file = coalesce(
- when(
- platform.is_mac,
- coalesce(
- when(platform.arch == "x64", "macos.tar.gz"),
- when(platform.arch == "arm64", "macos-aarch64.tar.gz")
- )
- ),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "x64", "linux.tar.gz"),
- when(platform.arch == "arm64", "linux-aarch64.tar.gz"),
- when(platform.arch == "arm", "linux-armhf.tar.gz")
- )
- ),
- when(
- platform.is_win,
- coalesce(
- when(platform.arch == "x64", "windows.zip"),
- when(platform.arch == "arm64", "windows-arm64.zip"),
- when(platform.arch == "arm", "windows-arm.zip")
- )
- )
- )
-
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"
-
- if platform.is_windows then
- return std.unzip_remote(url:format(ctx.requested_server_version, release_file))
- else
- return std.untargz_remote(url:format(ctx.requested_server_version, release_file))
- end
- end),
- installers.on {
- unix = context.set_working_dir "quick-lint-js",
- },
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_tag(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local repo = "quick-lint/quick-lint-js"
+ local release_file = assert(
+ coalesce(
+ when(
+ platform.is_mac,
+ coalesce(
+ when(platform.arch == "x64", "macos.tar.gz"),
+ when(platform.arch == "arm64", "macos-aarch64.tar.gz")
+ )
+ ),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "x64", "linux.tar.gz"),
+ when(platform.arch == "arm64", "linux-aarch64.tar.gz"),
+ when(platform.arch == "arm", "linux-armhf.tar.gz")
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(
+ when(platform.arch == "x64", "windows.zip"),
+ when(platform.arch == "arm64", "windows-arm64.zip"),
+ when(platform.arch == "arm", "windows-arm.zip")
+ )
+ )
+ ),
+ "Current platform is not supported."
+ )
+ local version = ctx.requested_version:or_else_get(function()
+ return github_client.fetch_latest_tag(repo)
+ :map(function(tag)
+ return tag.name
+ end)
+ :get_or_throw()
+ end)
+ local url = ("https://c.quick-lint-js.com/releases/%s/manual/%s"):format(version, release_file)
+ platform.when {
+ unix = function()
+ std.download_file(url, "archive.tar.gz")
+ std.untar("archive.tar.gz", { strip_components = 1 })
+ end,
+ win = function()
+ std.download_file(url, "archive.zip")
+ std.unzip("archive.zip", ".")
+ end,
+ }
+ ctx.receipt:with_primary_source {
+ type = "github_tag",
+ repo = repo,
+ tag = version,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/r_language_server/init.lua b/lua/nvim-lsp-installer/servers/r_language_server/init.lua
index 56877f9c..5a637271 100644
--- a/lua/nvim-lsp-installer/servers/r_language_server/init.lua
+++ b/lua/nvim-lsp-installer/servers/r_language_server/init.lua
@@ -8,6 +8,7 @@ options(langserver_library = %q);
options(langserver_quiet = FALSE);
options(repos = list(CRAN = "http://cran.rstudio.com/"));
rlsLib <- getOption("langserver_library");
+.libPaths(new = rlsLib);
didInstallRemotes <- FALSE;
tryCatch(
diff --git a/lua/nvim-lsp-installer/servers/reason_ls/init.lua b/lua/nvim-lsp-installer/servers/reason_ls/init.lua
index 5cb94119..ceca2612 100644
--- a/lua/nvim-lsp-installer/servers/reason_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/reason_ls/init.lua
@@ -1,36 +1,32 @@
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local archive_name = coalesce(
- when(platform.is_mac, "rls-macos"),
- when(platform.is_linux, "rls-linux"),
- when(platform.is_win, "rls-windows")
- )
return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "reason" },
homepage = "https://github.com/jaredly/reason-language-server",
- installer = {
- context.use_github_release_file("jaredly/reason-language-server", ("%s.zip"):format(archive_name)),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.capture(function()
- return std.rename(archive_name, "reason")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local archive_name = coalesce(
+ when(platform.is_mac, "rls-macos"),
+ when(platform.is_linux, "rls-linux"),
+ when(platform.is_win, "rls-windows")
+ )
+ github.unzip_release_file({
+ repo = "jaredly/reason-language-server",
+ asset_file = ("%s.zip"):format(archive_name),
+ }).with_receipt()
+ ctx.fs:rename(archive_name, "reason")
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "reason" } },
diff --git a/lua/nvim-lsp-installer/servers/rescriptls/init.lua b/lua/nvim-lsp-installer/servers/rescriptls/init.lua
index 4f0e7865..d8a13231 100644
--- a/lua/nvim-lsp-installer/servers/rescriptls/init.lua
+++ b/lua/nvim-lsp-installer/servers/rescriptls/init.lua
@@ -1,7 +1,6 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
return server.Server:new {
@@ -9,17 +8,15 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "rescript" },
homepage = "https://github.com/rescript-lang/rescript-vscode",
- installer = {
- context.use_github_release_file("rescript-lang/rescript-vscode", function(version)
- return ("rescript-vscode-%s.vsix"):format(version)
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "rescript-lang/rescript-vscode",
+ asset_file = function(version)
+ return ("rescript-vscode-%s.vsix"):format(version)
+ end,
+ }).with_receipt()
+ end,
default_options = {
cmd = { "node", path.concat { root_dir, "extension", "server", "out", "server.js" }, "--stdio" },
},
diff --git a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
index 16689571..56acc3b5 100644
--- a/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
+++ b/lua/nvim-lsp-installer/servers/rust_analyzer/init.lua
@@ -1,63 +1,62 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
-local libc = platform.get_libc()
-
-local target = coalesce(
- when(
- platform.is_mac,
- coalesce(
- when(platform.arch == "arm64", "rust-analyzer-aarch64-apple-darwin.gz"),
- when(platform.arch == "x64", "rust-analyzer-x86_64-apple-darwin.gz")
- )
- ),
- when(
- platform.is_linux,
- coalesce(
- when(
- libc == "glibc",
- coalesce(
- when(platform.arch == "arm64", "rust-analyzer-aarch64-unknown-linux-gnu.gz"),
- when(platform.arch == "x64", "rust-analyzer-x86_64-unknown-linux-gnu.gz")
- )
- ),
- when(libc == "musl", coalesce(when(platform.arch == "x64", "rust-analyzer-x86_64-unknown-linux-musl.gz")))
- )
- ),
- when(
- platform.is_win,
- coalesce(
- when(platform.arch == "arm64", "rust-analyzer-aarch64-pc-windows-msvc.gz"),
- when(platform.arch == "x64", "rust-analyzer-x86_64-pc-windows-msvc.gz")
- )
- )
-)
-
return function(name, root_dir)
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://rust-analyzer.github.io",
languages = { "rust" },
- installer = {
- context.use_github_release_file("rust-lang/rust-analyzer", target),
- context.capture(function(ctx)
- return std.gunzip_remote(
- ctx.github_release_file,
- platform.is_win and "rust-analyzer.exe" or "rust-analyzer"
+ async = true,
+ installer = function()
+ local libc = platform.get_libc()
+
+ local asset_file = coalesce(
+ when(
+ platform.is_mac,
+ coalesce(
+ when(platform.arch == "arm64", "rust-analyzer-aarch64-apple-darwin.gz"),
+ when(platform.arch == "x64", "rust-analyzer-x86_64-apple-darwin.gz")
+ )
+ ),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(
+ libc == "glibc",
+ coalesce(
+ when(platform.arch == "arm64", "rust-analyzer-aarch64-unknown-linux-gnu.gz"),
+ when(platform.arch == "x64", "rust-analyzer-x86_64-unknown-linux-gnu.gz")
+ )
+ ),
+ when(
+ libc == "musl",
+ coalesce(when(platform.arch == "x64", "rust-analyzer-x86_64-unknown-linux-musl.gz"))
+ )
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(
+ when(platform.arch == "arm64", "rust-analyzer-aarch64-pc-windows-msvc.gz"),
+ when(platform.arch == "x64", "rust-analyzer-x86_64-pc-windows-msvc.gz")
+ )
)
- end),
- std.chmod("+x", { "rust-analyzer" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ )
+
+ github.gunzip_release_file({
+ repo = "rust-lang/rust-analyzer",
+ asset_file = asset_file,
+ out_file = platform.is_win and "rust-analyzer.exe" or "rust-analyzer",
+ }).with_receipt()
+ std.chmod("+x", { "rust-analyzer" })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/serve_d/init.lua b/lua/nvim-lsp-installer/servers/serve_d/init.lua
index 092cbada..bbb7169c 100644
--- a/lua/nvim-lsp-installer/servers/serve_d/init.lua
+++ b/lua/nvim-lsp-installer/servers/serve_d/init.lua
@@ -1,9 +1,10 @@
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
+
+local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
return server.Server:new {
@@ -11,25 +12,33 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/Pure-D/serve-d",
languages = { "d" },
- installer = {
- context.use_github_release_file("Pure-D/serve-d", function(version)
- return Data.coalesce(
- Data.when(platform.is_mac, "serve-d_%s-osx-x86_64.tar.xz"),
- Data.when(platform.is_linux, "serve-d_%s-linux-x86_64.tar.xz"),
- Data.when(platform.is_win, "serve-d_%s-windows-x86_64.zip")
- ):format(version:gsub("^v", ""))
- end),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untarxz_remote(ctx.github_release_file)
- end
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ local repo = "Pure-D/serve-d"
+ platform.when {
+ unix = function()
+ github.untarxz_release_file({
+ repo = repo,
+ asset_file = function(release)
+ local target = coalesce(
+ when(platform.is_mac, "serve-d_%s-osx-x86_64.tar.xz"),
+ when(platform.is_linux and platform.arch == "x64", "serve-d_%s-linux-x86_64.tar.xz")
+ )
+ return target and target:format(release:gsub("^v", ""))
+ end,
+ }).with_receipt()
+ end,
+ win = function()
+ github.unzip_release_file({
+ repo = repo,
+ asset_file = function(release)
+ local target = coalesce(when(platform.arch == "x64"), "serve-d_%s-windows-x86_64.zip")
+ return target and target:format(release:gsub("^v", ""))
+ end,
+ }).with_receipt()
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/slint_lsp/init.lua b/lua/nvim-lsp-installer/servers/slint_lsp/init.lua
index 2cdfbd63..877adf12 100644
--- a/lua/nvim-lsp-installer/servers/slint_lsp/init.lua
+++ b/lua/nvim-lsp-installer/servers/slint_lsp/init.lua
@@ -1,33 +1,33 @@
local server = require "nvim-lsp-installer.server"
-local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
local path = require "nvim-lsp-installer.path"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
-local context = require "nvim-lsp-installer.installers.context"
-
-local coalesce, when = Data.coalesce, Data.when
+local github = require "nvim-lsp-installer.core.managers.github"
return function(name, root_dir)
- local archive_name = coalesce(
- when(platform.is_linux and platform.arch == "x64", "slint-lsp-linux.tar.gz"),
- when(platform.is_win and platform.arch == "x64", "slint-lsp-windows.zip")
- )
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://slint-ui.com/",
languages = { "slint" },
- installer = {
- context.use_github_release_file("slint-ui/slint", archive_name),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untargz_remote(ctx.github_release_file)
- end
- end),
- },
+ async = true,
+ installer = function()
+ local repo = "slint-ui/slint"
+ platform.when {
+ win = function()
+ github.unzip_release_file({
+ repo = repo,
+ asset_file = "slint-lsp-windows.zip",
+ }).with_receipt()
+ end,
+ linux = function()
+ github.untargz_release_file({
+ repo = repo,
+ asset_file = "slint-lsp-linux.tar.gz",
+ }).with_receipt()
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "slint-lsp" } },
diff --git a/lua/nvim-lsp-installer/servers/solang/init.lua b/lua/nvim-lsp-installer/servers/solang/init.lua
index e8223def..8a382cf3 100644
--- a/lua/nvim-lsp-installer/servers/solang/init.lua
+++ b/lua/nvim-lsp-installer/servers/solang/init.lua
@@ -1,64 +1,63 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
-local installers = require "nvim-lsp-installer.installers"
local process = require "nvim-lsp-installer.process"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local solang_executable_installer = installers.pipe {
- context.use_github_release_file(
- "hyperledger-labs/solang",
- coalesce(
+ ---@async
+ local function download_solang()
+ local source = github.release_file {
+ repo = "hyperledger-labs/solang",
+ asset_file = coalesce(
when(platform.is_mac and platform.arch == "x64", "solang-mac-intel"),
when(platform.is_mac and platform.arch == "arm64", "solang-mac-arm"),
when(platform.is_linux and platform.arch == "arm64", "solang-linux-arm64"),
when(platform.is_linux and platform.arch == "x64", "solang-linux-x86-64"),
when(platform.is_win, "solang.exe")
- )
- ),
- context.capture(function(ctx)
- return std.download_file(ctx.github_release_file, platform.is_win and "solang.exe" or "solang")
- end),
- std.chmod("+x", { "solang" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- }
+ ),
+ }
+ source.with_receipt()
+ std.download_file(source.download_url, platform.is_win and "solang.exe" or "solang")
+ std.chmod("+x", { "solang" })
+ return source
+ end
- local llvm_installer = installers.pipe {
- context.use_github_release_file(
- "hyperledger-labs/solang",
- coalesce(
+ ---@async
+ local function download_llvm()
+ local source = github.release_file {
+ repo = "hyperledger-labs/solang",
+ asset_file = coalesce(
when(platform.is_mac and platform.arch == "x64", "llvm13.0-mac-intel.tar.xz"),
when(platform.is_mac and platform.arch == "arm64", "llvm13.0-mac-arm.tar.xz"),
when(platform.is_linux and platform.arch == "x64", "llvm13.0-linux-x86-64.tar.xz"),
when(platform.is_linux and platform.arch == "arm64", "llvm13.0-linux-arm64.tar.xz"),
when(platform.is_win, "llvm13.0-win.zip")
- )
- ),
- context.capture(function(ctx)
- if platform.is_win then
- return std.unzip_remote(ctx.github_release_file)
- else
- return std.untarxz_remote(ctx.github_release_file)
- end
- end),
- }
+ ),
+ }
+ if platform.is_win then
+ std.download_file(source.download_url, "llvm.zip")
+ std.unzip("llvm.zip", ".")
+ else
+ std.download_file(source.download_url, "llvm.tar.xz")
+ std.untar "llvm.tar.xz"
+ end
+ end
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://solang.readthedocs.io/en/latest/",
languages = { "solidity" },
- installer = {
- solang_executable_installer,
- llvm_installer,
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ ctx:run_concurrently { download_solang, download_llvm }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path {
diff --git a/lua/nvim-lsp-installer/servers/solc/init.lua b/lua/nvim-lsp-installer/servers/solc/init.lua
index bdd2b331..941399ae 100644
--- a/lua/nvim-lsp-installer/servers/solc/init.lua
+++ b/lua/nvim-lsp-installer/servers/solc/init.lua
@@ -1,36 +1,33 @@
local server = require "nvim-lsp-installer.server"
local Data = require "nvim-lsp-installer.data"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local bin_name = platform.is_win and "solc.exe" or "solc"
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/ethereum/solidity",
languages = { "solidity" },
- installer = {
- context.use_github_release_file(
- "ethereum/solidity",
- coalesce(
+ async = true,
+ installer = function()
+ local source = github.release_file {
+ repo = "ethereum/solidity",
+ asset_file = coalesce(
when(platform.is_mac, "solc-macos"),
when(platform.is_linux, "solc-static-linux"),
when(platform.is_win, "solc-windows.exe")
- )
- ),
- context.capture(function(ctx)
- return std.download_file(ctx.github_release_file, bin_name)
- end),
- std.chmod("+x", { bin_name }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }
+ source.with_receipt()
+ local bin_name = platform.is_win and "solc.exe" or "solc"
+ std.download_file(source.download_url, bin_name)
+ std.chmod("+x", { bin_name })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/spectral/init.lua b/lua/nvim-lsp-installer/servers/spectral/init.lua
index 61047942..8b174d22 100644
--- a/lua/nvim-lsp-installer/servers/spectral/init.lua
+++ b/lua/nvim-lsp-installer/servers/spectral/init.lua
@@ -13,14 +13,14 @@ return function(name, root_dir)
---@param ctx InstallContext
installer = function(ctx)
git.clone({ "https://github.com/stoplightio/vscode-spectral" }).with_receipt()
- local server_dir = path.concat { ctx.cwd:get(), "server" }
ctx.spawn.npm { "install" }
- ctx.spawn.npm { "install", cwd = server_dir }
+ ctx:chdir("server", function()
+ ctx.spawn.npm { "install" }
+ end)
pcall(npm.run, { "compile" })
- -- TODO: don't do this
- ctx.cwd:set(server_dir)
- ctx.receipt:mark_invalid() -- Due to the `context.set_working_dir` after clone, we essentially erase any trace of the cloned git repo, so we mark this as invalid.
+ ctx:chdir "server"
+ ctx.receipt:mark_invalid() -- Due to the `chdir`, we essentially erase any trace of the cloned git repo, so we mark this as invalid.
end,
default_options = {
cmd = { "node", path.concat { root_dir, "out", "server.js" }, "--stdio" },
diff --git a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
index 4bf97f7b..943b41f0 100644
--- a/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
+++ b/lua/nvim-lsp-installer/servers/sumneko_lua/init.lua
@@ -2,9 +2,8 @@ local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -14,41 +13,39 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "lua" },
homepage = "https://github.com/sumneko/lua-language-server",
- installer = {
- context.use_github_release_file("sumneko/vscode-lua", function(version)
- local target = coalesce(
- when(
- platform.is_mac,
- coalesce(
- when(platform.arch == "x64", "vscode-lua-%s-darwin-x64.vsix"),
- when(platform.arch == "arm64", "vscode-lua-%s-darwin-arm64.vsix")
- )
- ),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "x64", "vscode-lua-%s-linux-x64.vsix"),
- when(platform.arch == "arm64", "vscode-lua-%s-linux-arm64.vsix")
- )
- ),
- when(
- platform.is_win,
- coalesce(
- when(platform.arch == "x64", "vscode-lua-%s-win32-x64.vsix"),
- when(platform.arch == "x86", "vscode-lua-%s-win32-ia32.vsix")
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "sumneko/vscode-lua",
+ asset_file = function(version)
+ local target = coalesce(
+ when(
+ platform.is_mac,
+ coalesce(
+ when(platform.arch == "x64", "vscode-lua-%s-darwin-x64.vsix"),
+ when(platform.arch == "arm64", "vscode-lua-%s-darwin-arm64.vsix")
+ )
+ ),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "x64", "vscode-lua-%s-linux-x64.vsix"),
+ when(platform.arch == "arm64", "vscode-lua-%s-linux-arm64.vsix")
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(
+ when(platform.arch == "x64", "vscode-lua-%s-win32-x64.vsix"),
+ when(platform.arch == "x86", "vscode-lua-%s-win32-ia32.vsix")
+ )
)
)
- )
- return target and target:format(version)
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ return target and target:format(version)
+ end,
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path {
diff --git a/lua/nvim-lsp-installer/servers/terraformls/init.lua b/lua/nvim-lsp-installer/servers/terraformls/init.lua
index 8bcb7f32..bf9e6cb5 100644
--- a/lua/nvim-lsp-installer/servers/terraformls/init.lua
+++ b/lua/nvim-lsp-installer/servers/terraformls/init.lua
@@ -2,9 +2,8 @@ local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local path = require "nvim-lsp-installer.path"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -14,34 +13,36 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/hashicorp/terraform-ls",
languages = { "terraform" },
- installer = {
- context.use_github_release_file("hashicorp/terraform-ls", function(version)
- return Data.coalesce(
- when(
- platform.is_mac,
- coalesce(
- when(platform.arch == "arm64", "terraform-ls_%s_darwin_arm64.zip"),
- when(platform.arch == "x64", "terraform-ls_%s_darwin_amd64.zip")
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "hashicorp/terraform-ls",
+ asset_file = function(version)
+ local target = coalesce(
+ when(
+ platform.is_mac,
+ coalesce(
+ when(platform.arch == "arm64", "terraform-ls_%s_darwin_arm64.zip"),
+ when(platform.arch == "x64", "terraform-ls_%s_darwin_amd64.zip")
+ )
+ ),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "arm64", "terraform-ls_%s_linux_arm64.zip"),
+ when(platform.arch == "arm", "terraform-ls_%s_linux_arm.zip"),
+ when(platform.arch == "x64", "terraform-ls_%s_linux_amd64.zip")
+ )
+ ),
+ when(
+ platform.is_win,
+ coalesce(when(platform.arch == "x64", "terraform-ls_%s_windows_amd64.zip"))
)
- ),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "arm64", "terraform-ls_%s_linux_arm64.zip"),
- when(platform.arch == "arm", "terraform-ls_%s_linux_arm.zip"),
- when(platform.arch == "x64", "terraform-ls_%s_linux_amd64.zip")
- )
- ),
- when(platform.is_win, coalesce(when(platform.arch == "x64", "terraform-ls_%s_windows_amd64.zip")))
- ):format(version:gsub("^v", ""))
- end),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file, "terraform-ls")
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ )
+ return target and target:format(version:gsub("^v", ""))
+ end,
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "terraform-ls" } },
diff --git a/lua/nvim-lsp-installer/servers/texlab/init.lua b/lua/nvim-lsp-installer/servers/texlab/init.lua
index 4b1e02c9..5adf0264 100644
--- a/lua/nvim-lsp-installer/servers/texlab/init.lua
+++ b/lua/nvim-lsp-installer/servers/texlab/init.lua
@@ -1,10 +1,8 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local platform = require "nvim-lsp-installer.platform"
-local installers = require "nvim-lsp-installer.installers"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -14,25 +12,27 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/latex-lsp/texlab",
languages = { "latex" },
- installer = {
- context.use_github_release_file(
- "latex-lsp/texlab",
- coalesce(
- when(platform.is_mac, "texlab-x86_64-macos.tar.gz"),
- when(platform.is_linux, "texlab-x86_64-linux.tar.gz"),
- when(platform.is_win, "texlab-x86_64-windows.zip")
- )
- ),
- context.capture(function(ctx)
- return installers.when {
- unix = std.untargz_remote(ctx.github_release_file),
- win = std.unzip_remote(ctx.github_release_file),
- }
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ local repo = "latex-lsp/texlab"
+ platform.when {
+ unix = function()
+ github.untargz_release_file({
+ repo = repo,
+ asset_file = coalesce(
+ when(platform.is_mac, "texlab-x86_64-macos.tar.gz"),
+ when(platform.is_linux and platform.arch == "x64", "texlab-x86_64-linux.tar.gz")
+ ),
+ }).with_receipt()
+ end,
+ win = function()
+ github.unzip_release_file({
+ repo = repo,
+ asset_file = coalesce(when(platform.arch == "x64", "texlab-x86_64-windows.zip")),
+ }).with_receipt()
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/tflint/init.lua b/lua/nvim-lsp-installer/servers/tflint/init.lua
index 125afa86..65a04dec 100644
--- a/lua/nvim-lsp-installer/servers/tflint/init.lua
+++ b/lua/nvim-lsp-installer/servers/tflint/init.lua
@@ -1,68 +1,61 @@
local server = require "nvim-lsp-installer.server"
local Data = require "nvim-lsp-installer.data"
+local a = require "nvim-lsp-installer.core.async"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
+local github = require "nvim-lsp-installer.core.managers.github"
+local spawn = require "nvim-lsp-installer.core.spawn"
local process = require "nvim-lsp-installer.process"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local os = coalesce(
- when(platform.is_mac, "darwin"),
- when(platform.is_linux, "linux"),
- when(platform.is_win, "windows")
- )
-
- local arch = coalesce(when(platform.arch == "x64", "amd64"), platform.arch)
-
- local target = ("tflint_%s_%s.zip"):format(os, arch)
-
return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "terraform" },
homepage = "https://github.com/terraform-linters/tflint",
- installer = {
- context.use_github_release_file("terraform-linters/tflint", target),
- context.capture(function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ installer = function()
+ github.unzip_release_file({
+ repo = "terraform-linters/tflint",
+ asset_file = coalesce(
+ when(platform.is_mac and platform.arch == "x64", "tflint_darwin_amd64.zip"),
+ when(platform.is_mac and platform.arch == "arm64", "tflint_darwin_arm64.zip"),
+ when(platform.is_linux and platform.arch == "x64", "tflint_linux_amd64.zip"),
+ when(platform.is_linux and platform.arch == "arm64", "tflint_linux_arm64.zip"),
+ when(platform.is_linux and platform.arch == "x86", "tflint_linux_386.zip"),
+ when(platform.is_win and platform.arch == "x64", "tflint_windows_amd64.zip")
+ ),
+ }).with_receipt()
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
},
commands = {
TFLintInit = {
- function()
- local process = require "nvim-lsp-installer.process"
+ a.scope(function()
local notify = require "nvim-lsp-installer.notify"
- local path = require "nvim-lsp-installer.path"
notify "Installing TFLint plugins…"
- process.spawn(
- "tflint",
- {
- args = { "--init" },
- cwd = path.cwd(),
- stdio_sink = process.simple_sink(),
- env = process.graft_env {
- PATH = process.extend_path { root_dir },
- },
- },
- vim.schedule_wrap(function(success)
- if success then
- notify "Successfully installed TFLint plugins."
- else
- notify "Failed to install TFLint plugins."
+ spawn.tflint({
+ "--init",
+ cwd = vim.loop.getcwd(),
+ with_paths = { root_dir },
+ })
+ :on_success(function()
+ if vim.in_fast_event() then
+ a.scheduler()
+ end
+ notify "Successfully installed TFLint plugins."
+ end)
+ :on_failure(function()
+ if vim.in_fast_event() then
+ a.scheduler()
end
+ notify "Failed to install TFLint plugins."
end)
- )
- end,
+ end),
description = "Runs tflint --init in the current working directory.",
},
},
diff --git a/lua/nvim-lsp-installer/servers/vala_ls/init.lua b/lua/nvim-lsp-installer/servers/vala_ls/init.lua
index b3e51431..1fca178b 100644
--- a/lua/nvim-lsp-installer/servers/vala_ls/init.lua
+++ b/lua/nvim-lsp-installer/servers/vala_ls/init.lua
@@ -1,8 +1,7 @@
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
-local installers = require "nvim-lsp-installer.installers"
+local std = require "nvim-lsp-installer.core.managers.std"
+local github = require "nvim-lsp-installer.core.managers.github"
local process = require "nvim-lsp-installer.process"
return function(name, root_dir)
@@ -11,40 +10,28 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://wiki.gnome.org/Projects/Vala",
languages = { "vala" },
- installer = {
- std.ensure_executables {
- { "meson", "meson was not found in path. Refer to https://mesonbuild.com/Getting-meson.html" },
- { "ninja", "ninja was not found in path. Refer to https://ninja-build.org/" },
- { "valac", "valac was not found in path. Refer to https://wiki.gnome.org/Projects/Vala" },
- },
- context.use_github_release_file("Prince781/vala-language-server", function(version)
- return ("vala-language-server-%s.tar.xz"):format(version)
- end),
- context.capture(function(ctx)
- return installers.pipe {
- std.untarxz_remote(ctx.github_release_file),
- std.rename(
- ("vala-language-server-%s"):format(ctx.requested_server_version),
- "vala-language-server"
- ),
- }
- end),
- function(_, callback, ctx)
- local c = process.chain {
- cwd = path.concat { ctx.install_dir, "vala-language-server" },
- stdio_sink = ctx.stdio_sink,
- }
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ std.ensure_executable("meson", { help_url = "https://mesonbuild.com/Getting-meson.html" })
+ std.ensure_executable("ninja", { help_url = "https://ninja-build.org/" })
+ std.ensure_executable("valac", { help_url = "https://wiki.gnome.org/Projects/Vala" })
- c.run("meson", { ("-Dprefix=%s"):format(ctx.install_dir), "build" })
- c.run("ninja", { "-C", "build", "install" })
+ local release_source = github.untarxz_release_file {
+ repo = "Prince781/vala-language-server",
+ asset_file = function(version)
+ return ("vala-language-server-%s.tar.xz"):format(version)
+ end,
+ }
+ release_source.with_receipt()
- c.spawn(callback)
- end,
- std.rmrf "vala-language-server",
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ local vala_dirname = ("vala-language-server-%s"):format(release_source.release)
+ ctx:chdir(vala_dirname, function()
+ ctx.spawn.meson { ("-Dprefix=%s"):format(ctx.cwd:get()), "build" }
+ ctx.spawn.ninja { "-C", "build", "install" }
+ end)
+ ctx.fs:rmrf(vala_dirname)
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "bin" } },
diff --git a/lua/nvim-lsp-installer/servers/verible/init.lua b/lua/nvim-lsp-installer/servers/verible/init.lua
index ea55531f..396fc6be 100644
--- a/lua/nvim-lsp-installer/servers/verible/init.lua
+++ b/lua/nvim-lsp-installer/servers/verible/init.lua
@@ -1,11 +1,9 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local installers = require "nvim-lsp-installer.installers"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
local path = require "nvim-lsp-installer.path"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
@@ -15,57 +13,52 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://chipsalliance.github.io/verible/",
languages = { "systemverilog", "verilog" },
- installer = {
- context.use_os_distribution(),
- context.capture(function(ctx)
- return context.use_github_release_file("chipsalliance/verible", function(version)
- if ctx.os_distribution.id == "ubuntu" then
- local target_file = when(
- platform.arch == "x64",
- coalesce(
- when(
- ctx.os_distribution.version.major == 16,
- "verible-%s-Ubuntu-16.04-xenial-x86_64.tar.gz"
- ),
- when(
- ctx.os_distribution.version.major == 18,
- "verible-%s-Ubuntu-18.04-bionic-x86_64.tar.gz"
- ),
- when(
- ctx.os_distribution.version.major == 20,
- "verible-%s-Ubuntu-20.04-focal-x86_64.tar.gz"
- ),
- when(
- ctx.os_distribution.version.major == 22,
- "verible-%s-Ubuntu-22.04-jammy-x86_64.tar.gz"
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local repo = "chipsalliance/verible"
+ platform.when {
+ linux = function()
+ local os_dist = platform.os_distribution()
+ local source = github.untarxz_release_file {
+ repo = repo,
+ asset_file = function(release)
+ if os_dist.id == "ubuntu" then
+ local target_file = when(
+ platform.arch == "x64",
+ coalesce(
+ when(
+ os_dist.version.major == 16,
+ "verible-%s-Ubuntu-16.04-xenial-x86_64.tar.gz"
+ ),
+ when(
+ os_dist.version.major == 18,
+ "verible-%s-Ubuntu-18.04-bionic-x86_64.tar.gz"
+ ),
+ when(os_dist.version.major == 20, "verible-%s-Ubuntu-20.04-focal-x86_64.tar.gz"),
+ when(os_dist.version.major == 22, "verible-%s-Ubuntu-22.04-jammy-x86_64.tar.gz")
+ )
)
- )
- )
- return target_file and target_file:format(version)
- else
- local target_file = coalesce(
- when(platform.is_win and platform.arch == "x64", "verible-%s-win64.zip")
- )
- return target_file and target_file:format(version)
- end
- end)
- end),
- context.capture(function(ctx)
- return installers.pipe {
- installers.when {
- unix = std.untargz_remote(ctx.github_release_file),
- win = std.unzip_remote(ctx.github_release_file),
- },
- std.rename(
- ("verible-%s%s"):format(ctx.requested_server_version, platform.is_win and "-win64" or ""),
- "verible"
- ),
- }
- end),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ return target_file and target_file:format(release)
+ end
+ end,
+ }
+ source.with_receipt()
+ ctx.fs:rename(("verible-%s"):format(source.release), "verible")
+ end,
+ win = function()
+ local source = github.unzip_release_file {
+ repo = repo,
+ asset_file = function(release)
+ local target_file = coalesce(when(platform.arch == "x64", "verible-%s-win64.zip"))
+ return target_file and target_file:format(release)
+ end,
+ }
+ source.with_receipt()
+ ctx.fs:rename(("verible-%s-win64"):format(source.release), "verible")
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path {
diff --git a/lua/nvim-lsp-installer/servers/zeta_note/init.lua b/lua/nvim-lsp-installer/servers/zeta_note/init.lua
index 01ef807a..2658772e 100644
--- a/lua/nvim-lsp-installer/servers/zeta_note/init.lua
+++ b/lua/nvim-lsp-installer/servers/zeta_note/init.lua
@@ -1,9 +1,9 @@
local server = require "nvim-lsp-installer.server"
local process = require "nvim-lsp-installer.process"
local platform = require "nvim-lsp-installer.platform"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local Data = require "nvim-lsp-installer.data"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
@@ -13,23 +13,20 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/artempyanykh/zeta-note",
languages = { "markdown" },
- installer = {
- context.use_github_release_file(
- "artempyanykh/zeta-note",
- coalesce(
+ async = true,
+ installer = function()
+ local source = github.release_file {
+ repo = "artempyanykh/zeta-note",
+ asset_file = coalesce(
when(platform.is_mac, "zeta-note-macos"),
when(platform.is_linux and platform.arch == "x64", "zeta-note-linux"),
when(platform.is_win and platform.arch == "x64", "zeta-note-windows.exe")
- )
- ),
- context.capture(function(ctx)
- return std.download_file(ctx.github_release_file, platform.is_win and "zeta-note.exe" or "zeta-note")
- end),
- std.chmod("+x", { "zeta-note" }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }
+ source.with_receipt()
+ std.download_file(source.download_url, platform.is_win and "zeta-note.exe" or "zeta-note")
+ std.chmod("+x", { "zeta-note" })
+ end,
default_options = {
cmd = { "zeta-note" },
cmd_env = {
diff --git a/lua/nvim-lsp-installer/servers/zk/init.lua b/lua/nvim-lsp-installer/servers/zk/init.lua
index 02a416bf..6c8825eb 100644
--- a/lua/nvim-lsp-installer/servers/zk/init.lua
+++ b/lua/nvim-lsp-installer/servers/zk/init.lua
@@ -1,9 +1,8 @@
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
-local std = require "nvim-lsp-installer.installers.std"
-local context = require "nvim-lsp-installer.installers.context"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
@@ -12,24 +11,27 @@ return function(name, root_dir)
root_dir = root_dir,
homepage = "https://github.com/mickael-menu/zk",
languages = { "markdown" },
- installer = {
- context.use_github_release_file(
- "mickael-menu/zk",
- coalesce(
- when(
- platform.is_mac,
- coalesce(
+ async = true,
+ installer = function()
+ local repo = "mickael-menu/zk"
+ platform.when {
+ mac = function()
+ github.unzip_release_file({
+ repo = repo,
+ asset_file = coalesce(
when(platform.arch == "arm64", function(version)
return ("zk-%s-macos-arm64.zip"):format(version)
end),
when(platform.arch == "x64", function(version)
return ("zk-%s-macos-x86_64.zip"):format(version)
end)
- )
- ),
- when(
- platform.is_linux,
- coalesce(
+ ),
+ }):with_receipt()
+ end,
+ linux = function()
+ github.untargz_release_file({
+ repo = repo,
+ asset_file = coalesce(
when(platform.arch == "arm64", function(version)
return ("zk-%s-linux-arm64.tar.gz"):format(version)
end),
@@ -39,22 +41,11 @@ return function(name, root_dir)
when(platform.arch == "x86", function(version)
return ("zk-%s-linux-i386.tar.gz"):format(version)
end)
- )
- )
- )
- ),
- context.capture(coalesce(
- when(platform.is_mac, function(ctx)
- return std.unzip_remote(ctx.github_release_file)
- end),
- when(platform.is_linux, function(ctx)
- return std.untargz_remote(ctx.github_release_file)
- end)
- )),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ ),
+ }).with_receipt()
+ end,
+ }
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },
diff --git a/lua/nvim-lsp-installer/servers/zls/init.lua b/lua/nvim-lsp-installer/servers/zls/init.lua
index 21d52239..c902f4aa 100644
--- a/lua/nvim-lsp-installer/servers/zls/init.lua
+++ b/lua/nvim-lsp-installer/servers/zls/init.lua
@@ -2,41 +2,39 @@ local path = require "nvim-lsp-installer.path"
local server = require "nvim-lsp-installer.server"
local platform = require "nvim-lsp-installer.platform"
local Data = require "nvim-lsp-installer.data"
-local context = require "nvim-lsp-installer.installers.context"
-local std = require "nvim-lsp-installer.installers.std"
local process = require "nvim-lsp-installer.process"
+local github = require "nvim-lsp-installer.core.managers.github"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- local archive_name = coalesce(
- when(platform.is_mac, "x86_64-macos.tar.xz"),
- when(
- platform.is_linux,
- coalesce(
- when(platform.arch == "x64", "x86_64-linux.tar.xz"),
- when(platform.arch == "x86", "i386-linux.tar.xz")
- )
- ),
- when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz")
- )
-
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/zigtools/zls",
languages = { "zig" },
- installer = {
- context.use_github_release_file("zigtools/zls", archive_name),
- context.capture(function(ctx)
- return std.untarxz_remote(ctx.github_release_file)
- end),
- std.rename("bin", "package"),
- std.chmod("+x", { path.concat { "package", "zls" } }),
- context.receipt(function(receipt, ctx)
- receipt:with_primary_source(receipt.github_release_file(ctx))
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local asset_file = coalesce(
+ when(platform.is_mac, "x86_64-macos.tar.xz"),
+ when(
+ platform.is_linux,
+ coalesce(
+ when(platform.arch == "x64", "x86_64-linux.tar.xz"),
+ when(platform.arch == "x86", "i386-linux.tar.xz")
+ )
+ ),
+ when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz")
+ )
+ github.untarxz_release_file({
+ repo = "zigtools/zls",
+ asset_file = asset_file,
+ }).with_receipt()
+ ctx.fs:rename("bin", "package")
+ std.chmod("+x", { path.concat { "package", "zls" } })
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { path.concat { root_dir, "package" } },
diff --git a/lua/nvim-lsp-installer/ui/init.lua b/lua/nvim-lsp-installer/ui/init.lua
index 4e522ce9..667bb35a 100644
--- a/lua/nvim-lsp-installer/ui/init.lua
+++ b/lua/nvim-lsp-installer/ui/init.lua
@@ -69,7 +69,8 @@ end
---@param condition boolean
---@param node INode | fun(): INode
-function M.When(condition, node)
+---@param default_val any
+function M.When(condition, node, default_val)
if condition then
if type(node) == "function" then
return node()
@@ -77,7 +78,7 @@ function M.When(condition, node)
return node
end
end
- return M.Node {}
+ return default_val or M.Node {}
end
---@param key string @The keymap to register to. Example: "<CR>".
diff --git a/lua/nvim-lsp-installer/ui/status-win/init.lua b/lua/nvim-lsp-installer/ui/status-win/init.lua
index 61969828..3236b3e9 100644
--- a/lua/nvim-lsp-installer/ui/status-win/init.lua
+++ b/lua/nvim-lsp-installer/ui/status-win/init.lua
@@ -201,10 +201,10 @@ end
---@param server ServerState
local function ServerMetadata(server)
return Ui.Node(Data.list_not_nil(
- Data.lazy(server.is_installed and server.deprecated, function()
+ Data.lazy_when(server.is_installed and server.deprecated, function()
return Ui.Node(Data.list_not_nil(
Ui.HlTextNode { server.deprecated.message, "Comment" },
- Data.lazy(server.deprecated.replace_with, function()
+ Data.lazy_when(server.deprecated.replace_with, function()
return Ui.Node {
Ui.HlTextNode {
{
@@ -219,7 +219,7 @@ local function ServerMetadata(server)
))
end),
Ui.Table(Data.list_not_nil(
- Data.lazy(server.is_installed, function()
+ Data.lazy_when(server.is_installed, function()
return {
{ "version", "LspInstallerMuted" },
server.installed_version_err and {
@@ -228,7 +228,7 @@ local function ServerMetadata(server)
} or { server.installed_version or "Loading...", "" },
}
end),
- Data.lazy(#server.metadata.outdated_packages > 0, function()
+ Data.lazy_when(#server.metadata.outdated_packages > 0, function()
return {
{ "latest version", "LspInstallerGreen" },
{
@@ -237,7 +237,7 @@ local function ServerMetadata(server)
},
}
end),
- Data.lazy(server.metadata.install_timestamp_seconds, function()
+ Data.lazy_when(server.metadata.install_timestamp_seconds, function()
return {
{ "installed", "LspInstallerMuted" },
{ format_time(server.metadata.install_timestamp_seconds), "" },