Skip to content
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
30 changes: 30 additions & 0 deletions .github/workflows/update-gomod2nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Update gomod2nix

on:
push:
branches:
- develop
paths:
- go.mod
- go.sum

jobs:
update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v27
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Generate gomod2nix.toml
run: nix run github:nix-community/gomod2nix -- generate

- name: Commit updated gomod2nix.toml
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update gomod2nix.toml"
file_pattern: gomod2nix.toml
7 changes: 5 additions & 2 deletions doc/gitlab.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ Here is the default setup function. All of these values are optional, and if
you call this function with no values the defaults will be used:
>lua
require("gitlab").setup({
port = nil, -- The port of the Go server, which runs in the background, if omitted or `nil` the port will be chosen automatically
server = {
binary = nil, -- The path to the server binary. If omitted or nil, the server will be built
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
debug = {
Expand Down Expand Up @@ -711,7 +714,7 @@ by a |motion|.
Either the operator or the motion can be preceded by a count, so that `3sj` is
equivalent to `s3j`, and they both create a comment for the current line and
three more lines downwards. Similarly, both `2s`|ap| and `s2`|ap| create a suggestion
for two "outer" paragraphs.
for two "outer" paragraphs.

The operators force |linewise| visual selection, so they work correctly even
if the motion itself works |characterwise| (e.g., |i(| for selecting the inner
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
flake-utils.url = "github:numtide/flake-utils";
gomod2nix = {
url = "github:nix-community/gomod2nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, flake-utils, nixpkgs, gomod2nix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ gomod2nix.overlays.default ];
};
gitlab-nvim-server = pkgs.buildGoApplication {
pname = "gitlab.nvim-server";
version = "git";
src = ./.;
modules = ./gomod2nix.toml;
subPackages = [ "cmd" ];
postInstall = ''
cp -r ${./cmd/config} $out/bin/config
mv $out/bin/cmd $out/bin/gitlab.nvim
'';
};
gitlab-nvim = pkgs.vimUtils.buildVimPlugin {
name = "gitlab.nvim";
src = ./.;
doCheck = false;
};
in
{
formatter = pkgs.nixpkgs-fmt;
packages.gitlab-nvim-server = gitlab-nvim-server;
packages.gitlab-nvim = gitlab-nvim;
packages.default = gitlab-nvim;
devShells.default = pkgs.mkShell {
packages = with pkgs; [
git
go
go-tools
gomod2nix
golangci-lint
luajitPackages.busted
luajitPackages.luacheck
luajitPackages.luarocks
neovim
stylua
];
};
}
);
}
66 changes: 66 additions & 0 deletions gomod2nix.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
schema = 3

[mod]
[mod.'github.com/gabriel-vasile/mimetype']
version = 'v1.4.3'
hash = 'sha256-EDmlRi3av27dq/ISVTglv08z4yZzMQ/SxL1c46EJro0='

[mod.'github.com/go-playground/locales']
version = 'v0.14.1'
hash = 'sha256-BMJGAexq96waZn60DJXZfByRHb8zA/JP/i6f/YrW9oQ='

[mod.'github.com/go-playground/universal-translator']
version = 'v0.18.1'
hash = 'sha256-2/B2qP51zfiY+k8G0w0D03KXUc7XpWj6wKY7NjNP/9E='

[mod.'github.com/go-playground/validator/v10']
version = 'v10.22.1'
hash = 'sha256-EsgeltH0ow6saxLvTFVtIyHVqWI3Fiu1AE2Qmnsmowg='

[mod.'github.com/google/go-cmp']
version = 'v0.7.0'
hash = 'sha256-JbxZFBFGCh/Rj5XZ1vG94V2x7c18L8XKB0N9ZD5F2rM='

[mod.'github.com/google/go-querystring']
version = 'v1.2.0'
hash = 'sha256-F/Ve4oDaEqho8RryvdGSRR22/DbYHWZQa6M60n6oSYM='

[mod.'github.com/hashicorp/go-cleanhttp']
version = 'v0.5.2'
hash = 'sha256-N9GOKYo7tK6XQUFhvhImtL7PZW/mr4C4Manx/yPVvcQ='

[mod.'github.com/hashicorp/go-retryablehttp']
version = 'v0.7.8'
hash = 'sha256-4LZwKaFBbpKi9lSq5y6lOlYHU6WMnQdGNMxTd33rN80='

[mod.'github.com/leodido/go-urn']
version = 'v1.4.0'
hash = 'sha256-Q6kplWkY37Tzy6GOme3Wut40jFK4Izun+ij/BJvcEu0='

[mod.'gitlab.com/gitlab-org/api/client-go']
version = 'v1.17.0'
hash = 'sha256-PdVbuFXCp/TphltAkpJG3YNXhtqHnhhyel9KLUX/xz0='

[mod.'golang.org/x/crypto']
version = 'v0.19.0'
hash = 'sha256-Vi6vY/eWNlYQ9l3Y+gA+X2+h2CmzEOrBRVFO/cnrPWc='

[mod.'golang.org/x/net']
version = 'v0.21.0'
hash = 'sha256-LfiqMpPtqvW/eLkfx6Ebr5ksqKbQli6uq06c/+XrBsw='

[mod.'golang.org/x/oauth2']
version = 'v0.34.0'
hash = 'sha256-5eqpGGxJ7FJsPmfRek6roeGmkWHBMJaWYXyz8gXJsS4='

[mod.'golang.org/x/sys']
version = 'v0.39.0'
hash = 'sha256-dxTBu/JAWUkPbjFIXXRFdhQWyn+YyEpIC+tWqGo0Y6U='

[mod.'golang.org/x/text']
version = 'v0.32.0'
hash = 'sha256-9PXtWBKKY9rG4AgjSP4N+I1DhepXhy8SF/vWSIDIoWs='

[mod.'golang.org/x/time']
version = 'v0.14.0'
hash = 'sha256-fVjpq0ieUHVEOTSElDVleMWvfdcqojZchqdUXiC7NnY='
2 changes: 1 addition & 1 deletion lua-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ done

# Run tests
echo "Running tests with Neovim..."
nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@"
LC_TIME=en_US.UTF-8 nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@"
6 changes: 5 additions & 1 deletion lua/gitlab/annotations.lua
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
--- Plugin Settings
---
---@class Settings
---@field port? number -- The port of the Go server, which runs in the background, if omitted or `nil` the port will be chosen automatically
---@field server ServerSettings
---@field remote_branch "origin" | string -- The remote, "origin" by default
---@field log_path? string -- Log path for the Go server
---@field string? any -- Custom path for `.gitlab.nvim` file, please read the "Connecting to Gitlab" section
Expand All @@ -167,6 +167,10 @@
---@field create_mr? CreateMrSettings -- The settings when creating an MR
---@field colors? ColorSettings --- Colors settings for the plugin

---@class ServerSettings
---@field port? number -- The port of the Go server, which runs in the background, if omitted or `nil` the port will be chosen automatically
---@field binary? string -- The path to the server binary. If omitted or nil, the server will be built

---@class DiscussionSigns: table
---@field enabled? boolean -- Show diagnostics for gitlab comments in the reviewer
---@field skip_resolved_discussion? boolean -- Show diagnostics for resolved discussions
Expand Down
2 changes: 1 addition & 1 deletion lua/gitlab/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ local function setup(args)
return
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
3 changes: 2 additions & 1 deletion lua/gitlab/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ local M = {}

M.run_job = function(endpoint, method, body, callback, on_error_callback)
local state = require("gitlab.state")
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s", state.settings.port) .. endpoint }
local port = state.settings.server and state.settings.server.port
local args = { "-s", "-X", (method or "POST"), string.format("localhost:%s%s", port, endpoint) }

if body ~= nil then
local encoded_body = vim.json.encode(body)
Expand Down
Loading