aboutsummaryrefslogtreecommitdiff
path: root/lua/cmake-explorer/project_uauaua.lua
diff options
context:
space:
mode:
authorDaniil Rozanov <daniilrozzanov@gmail.com>2024-04-24 03:34:52 +0300
committerDaniil Rozanov <daniilrozzanov@gmail.com>2024-04-24 03:34:52 +0300
commitf9b36bf730fda5488be87b91fd03a6f7cbf64e73 (patch)
treed8a7da573111d40c0e51c9e9954a3bb1977dd39c /lua/cmake-explorer/project_uauaua.lua
parent672f0d32e322b79661b5d7959887adaa9e41ad98 (diff)
refactor: full rewrite
Diffstat (limited to 'lua/cmake-explorer/project_uauaua.lua')
-rw-r--r--lua/cmake-explorer/project_uauaua.lua113
1 files changed, 0 insertions, 113 deletions
diff --git a/lua/cmake-explorer/project_uauaua.lua b/lua/cmake-explorer/project_uauaua.lua
deleted file mode 100644
index b54abd6..0000000
--- a/lua/cmake-explorer/project_uauaua.lua
+++ /dev/null
@@ -1,113 +0,0 @@
-local config = require("cmake-explorer.config")
-local capabilities = require("cmake-explorer.capabilities")
-local FileApi = require("cmake-explorer.file_api")
-local Path = require("plenary.path")
-local Scandir = require("plenary.scandir")
-local utils = require("cmake-explorer.utils")
-local notif = require("cmake-explorer.notification")
-
-local Project = {}
-
-Project.__index = Project
-
-function Project:new(o)
- o = o or {}
-
- local path
- if type(o) == "string" then
- path = o
- elseif type(o) == "table" and o.path then
- path = o.path
- else
- return
- end
-
- if not Path:new(path, "CMakeLists.txt"):exists() then
- return
- end
-
- local obj = {
- path = path,
- fileapis = {},
- last_generate = nil,
- }
- notif.notify("PATH " .. obj.path)
- setmetatable(
- obj.fileapis,
- utils.make_maplike_list(function(v)
- return v.path
- end)
- )
- setmetatable(obj, Project)
- return obj
-end
-
-function Project:scan_build_dirs()
- local builds_root = utils.is_eq(
- Path:new(config.build_dir):is_absolute(),
- true,
- Path:new(config.build_dir),
- Path:new(self.path, config.build_dir)
- )
- local candidates =
- Scandir.scan_dir(builds_root:absolute(), { hidden = false, only_dirs = true, depth = 0, silent = true })
- for _, v in ipairs(candidates) do
- local fa = FileApi:new(v)
- if fa and fa:exists() and fa:read_reply() then
- self.fileapis[fa.path] = fa
- end
- end
-end
-
-function Project:symlink_compile_commands(path)
- local src = Path:new(path, "compile_commands.json")
- if src:exists() then
- vim.cmd(
- 'silent exec "!'
- .. config.cmake_cmd
- .. " -E create_symlink "
- .. src:normalize()
- .. " "
- .. Path:new(self.path, "compile_commands.json"):normalize()
- .. '"'
- )
- end
-end
-
-function Project:configure(params)
- params = params or {}
- local args = utils.generate_args(params, self.path)
- local build_dir = utils.build_path(params, self.path)
- if not args then
- return
- end
- if not self.fileapis[build_dir] then
- local fa = FileApi:new(build_dir)
- if not fa then
- notif.notify("Cannot fileapi object", vim.log.levels.ERROR)
- return
- end
- if not fa:create() then
- return
- end
- self.fileapis[build_dir] = fa
- end
-
- local job_args = {
- cmd = config.cmake_cmd,
- args = args,
- cwd = self.path,
- after_success = function()
- self.last_generate = job_args
- self.fileapis[build_dir]:read_reply()
- self:symlink_compile_commands(build_dir)
- end,
- }
- return job_args
-end
-
-function Project:configure_last()
- return self.last_generate
-end
-
-return Project