Skip to content

make path of server binary configurable #493

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/gitlab.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ you call this function with no values the defaults will be used:
port = nil, -- The port of the Go server, which runs in the background, if omitted or `nil` the port will be chosen automatically
log_path = vim.fn.stdpath("cache") .. "/gitlab.nvim.log", -- Log path for the Go server
config_path = nil, -- Custom path for `.gitlab.nvim` file, please read the "Connecting to Gitlab" section
bin = nil, -- Custom path to Go server binary, if not set the internal one is used. Only change if really needed
Copy link
Collaborator

@jakubbortlik jakubbortlik May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could give a specific example, so instead of "Only change if really needed" you could say something like:

Suggested change
bin = nil, -- Custom path to Go server binary, if not set the internal one is used. Only change if really needed
bin = nil, -- Custom path to Go server binary, if not set the internal one is used. Useful if the directory of the plugin is read-only.

But I'm also wondering, how you compile the server? Do you have to take the extra steps of cloning the repo to a different location? Wouldn't it be more user friendly to just customize the path where the server is supposed to be built, so that the user doesn't have to take any further steps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is part of a nix build, that complies the binary into another directory. The idea in nix is that the whole build/configuration is reproducable, therefore it marks a lot a direcories as read only and compliing some thing outside of the nix 'process' is not really desireable.
I am sure that there are more user friendly options to this issue but I did not see a good reason why the path should not be configurable. Plus it was an easy way to fix my problem.
In a lot of other plugins the path to a compliled executable is configurable as well.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine, I'm not familiar with nix, so what you write makes perfect sense. I'd just make the docstring a little more explicit.

@harrisoncramer will have to look at this and decide if he wants to merge it or not.

debug = {
request = false, -- Requests to/from Go server
response = false,
Expand Down
2 changes: 1 addition & 1 deletion lua/gitlab/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ local function setup(args)
if args == nil then
args = {}
end
server.build() -- Builds the Go binary if it doesn't exist
state.merge_settings(args) -- Merges user settings with default settings
server.build() -- Builds the Go binary if it doesn't exist
state.set_global_keymaps() -- Sets keymaps that are not bound to a specific buffer
require("gitlab.colors") -- Sets colors
reviewer.init()
Expand Down
7 changes: 6 additions & 1 deletion lua/gitlab/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,14 @@ end
M.build = function(override)
local file_path = u.current_file_path()
local parent_dir = vim.fn.fnamemodify(file_path, ":h:h:h:h")
state.settings.root_path = parent_dir

if state.settings.bin ~= nil then
u.notify(string.format("Skipping server installation, using: %s", state.settings.bin), vim.log.levels.INFO)
return true
end

local bin_name = u.is_windows() and "bin.exe" or "bin"
state.settings.root_path = parent_dir
state.settings.bin = parent_dir .. u.path_separator .. "cmd" .. u.path_separator .. bin_name

if not override then
Expand Down
1 change: 1 addition & 0 deletions lua/gitlab/state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ M.settings = {
auth_provider = M.default_auth_provider,
file_separator = u.path_separator,
port = nil, -- choose random port
bin = nil, -- use the plugins internal
debug = {
request = false,
response = false,
Expand Down