From 8a9f8dfc88bb6aa4132fe7824095005b944ec72a Mon Sep 17 00:00:00 2001 From: "Harrison (Harry) Cramer" <32515581+harrisoncramer@users.noreply.github.com> Date: Sat, 18 Nov 2023 16:31:06 -0500 Subject: [PATCH] Fix: Allows you to open up gitlab.nvim even in nested directories (#107) This MR is a #patch fix that ensures you can provide a `.gitlab.nvim` file at the root of the git project and open up the reviewer at any level of the project. --- lua/gitlab/actions/pipeline.lua | 1 + lua/gitlab/state.lua | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lua/gitlab/actions/pipeline.lua b/lua/gitlab/actions/pipeline.lua index 6ccce65..86b3577 100644 --- a/lua/gitlab/actions/pipeline.lua +++ b/lua/gitlab/actions/pipeline.lua @@ -141,6 +141,7 @@ M.see_logs = function() bufnr = vim.api.nvim_get_current_buf() vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, lines) + -- TODO: Fix for Windows local job_file_path = string.format("/tmp/gitlab.nvim.job-%d", j.id) vim.cmd("w! " .. job_file_path) vim.cmd.bd() diff --git a/lua/gitlab/state.lua b/lua/gitlab/state.lua index 3ded1b2..2560773 100644 --- a/lua/gitlab/state.lua +++ b/lua/gitlab/state.lua @@ -115,6 +115,8 @@ M.merge_settings = function(args) ) end + M.settings.file_separator = (u.is_windows() and "\\" or "/") + return true end @@ -130,7 +132,15 @@ M.setPluginConfiguration = function() if M.initialized then return true end - local config_file_path = vim.fn.getcwd() .. "/.gitlab.nvim" + + local base_path = vim.fn.trim(vim.fn.system({ "git", "rev-parse", "--show-toplevel" })) + if vim.v.shell_error ~= 0 then + u.notify(string.format("Could not get base directory: %s", base_path), vim.log.levels.ERROR) + return false + end + + local config_file_path = base_path .. M.settings.file_separator .. ".gitlab.nvim" + local config_file_content = u.read_file(config_file_path) local file_properties = {}