aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/ccls/common.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer/servers/ccls/common.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/ccls/common.lua41
1 files changed, 41 insertions, 0 deletions
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