aboutsummaryrefslogtreecommitdiff
path: root/lua/cmake/init.lua
blob: 6d7843ca2b09a864742725da4fbce773f743e7c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
local config = require("cmake.config")
local commands = require("cmake.commands")
local autocmds = require("cmake.autocmds")
local utils = require("cmake.utils")
local constants = require("cmake.constants")

local uv = vim.uv

local M = {}

function M.setup(opts)
	opts = opts or {}
	config.setup(opts)
	if vim.fn.executable(config.cmake.cmake_path) then
		autocmds.setup()
		utils.file_exists(vim.fs.joinpath(uv.cwd(), constants.cmakelists), function(cmake_lists_exists)
			if cmake_lists_exists then
				--TODO: init autocommands needs to be related with project setup
				vim.schedule(function()
					autocmds.set_on_variants()
					commands.register_commands()
				end)
				require("cmake.project").setup()
			else
			end
		end)
	else
		vim.notify(
			"CMake: " .. config.cmake.cmake_path .. " is not executable. Plugin is unavailable",
			vim.log.levels.WARN
		)
	end
end

return M