Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .busted
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ return {
_all = {
pattern = "_spec",
lpath = "lua/?.lua;lua/?/init.lua",
ROOT = {"lua/gitlab"},
ROOT = { "tests/spec" },
},
default = {
verbose = true
verbose = true,
},
tests = {
verbose = true,
Expand Down
15 changes: 0 additions & 15 deletions .github/workflows/lua-tests.yaml

This file was deleted.

32 changes: 25 additions & 7 deletions .github/workflows/lua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
jobs:
lua_lint:
name: Lint Lua 💅
name: Lint Lua 💅
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -15,7 +15,7 @@ jobs:
with:
args: --globals vim --no-max-line-length -- .
lua_format:
name: Formatting Lua 💅
name: Formatting Lua 💅
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -27,11 +27,29 @@ jobs:
version: latest
args: --check .
lua_test:
name: Test Lua 🧪
needs: [lua_format,lua_lint]
name: Run tests 🧪
strategy:
matrix:
nvim_version: [stable, nightly]

runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Run Busted
uses: lunarmodules/[email protected]
uses: actions/checkout@v4
- name: Install neovim
uses: rhysd/action-setup-vim@v1
id: vim
with:
neovim: true
version: ${{ matrix.nvim_version }}
- name: Install luajit
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "luajit-2.1.0-beta3"
- name: Install luarocks
uses: leafo/gh-actions-luarocks@v4
- name: Run tests
shell: bash
run: |
chmod +x lua-test.sh
./lua-test.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ bin
/luarocks
/lua_modules
/.luarocks
*.rockspec
tests/plugins
!tests/plugins/.placeholder
luacov.*
3 changes: 3 additions & 0 deletions .luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include = {
"lua/gitlab/"
}
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ return {
"nvim-lua/plenary.nvim",
"sindrets/diffview.nvim",
"stevearc/dressing.nvim", -- Recommended but not required. Better UI for pickers.
"nvim-tree/nvim-web-devicons" -- Recommended but not required. Icons in discussion tree.
enabled = true,
},
build = function () require("gitlab.server").build(true) end, -- Builds the Go binary
Expand Down Expand Up @@ -104,7 +105,6 @@ gitlab_url=https://my-personal-gitlab-instance.com/

The plugin will look for the `.gitlab.nvim` file in the root of the current project by default. However, you may provide a custom path to the configuration file via the `config_path` option. This must be an absolute path to the directory that holds your `.gitlab.nvim` file.


## Configuring the Plugin

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:
Expand Down Expand Up @@ -135,6 +135,7 @@ require("gitlab").setup({
relative = "editor", -- Position of tree split relative to "editor" or "window"
resolved = '✓', -- Symbol to show next to resolved discussions
unresolved = '✖', -- Symbol to show next to unresolved discussions
tree_type = "simple", -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
},
info = { -- Show additional fields in the summary pane
enabled = true,
Expand Down Expand Up @@ -195,10 +196,13 @@ require("gitlab").setup({
},
colors = {
discussion_tree = {
username = 'Keyword', -- The highlight group used, for instance 'DiagnosticSignWarn'
date = 'Comment',
chevron = 'Comment',
}
username = "Keyword",
date = "Comment",
chevron = "DiffviewNonText",
directory = "Directory",
directory_icon = "DiffviewFolderSign",
file_name = "Normal",
}
}
})
```
Expand Down
13 changes: 13 additions & 0 deletions lua-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
#
# Process generated luacov stats file into coverage report for gitlab.nvim.
#
set -e

if ! [[ -f luacov.stats.out ]]; then
echo "You need to first run \`./lua-test.sh --coverage\`"
exit 1
fi

eval "$(luarocks path)"
luacov "$@"
59 changes: 59 additions & 0 deletions lua-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
#
# Setup and run tests for lua part of gitlab.nvim.
#
# In order to run tests you need to have `luarocks` and `git` installed. This script will check if
# environment is already setup, if not it will initialize current directory with `luarocks`,
# install `busted` framework and download plugin dependencies.
#
#
set -e

LUA_VERSION="5.1"
PLUGINS_FOLDER="tests/plugins"
PLUGINS=(
"https://github.com/MunifTanjim/nui.nvim"
"https://github.com/nvim-lua/plenary.nvim"
"https://github.com/sindrets/diffview.nvim"
)

if ! command -v luarocks > /dev/null 2>&1; then
echo "You need to have luarocks installed in order to run tests."
exit 1
fi

if ! command -v git > /dev/null 2>&1; then
echo "You need to have git installed in order to run tests."
exit 1
fi

if ! luarocks --lua-version=$LUA_VERSION which busted > /dev/null 2>&1; then
echo "Installing busted."
luarocks init
luarocks config --scope project lua_version "$LUA_VERSION"
luarocks install --lua-version="$LUA_VERSION" busted
fi

for arg in "$@"; do
if [[ $arg =~ "--coverage" ]] && ! luarocks --lua-version=$LUA_VERSION which luacov > /dev/null 2>&1; then
luarocks install --lua-version="$LUA_VERSION" luacov
# lcov reporter for luacov - lcov format is supported by `nvim-coverage`
luarocks install --lua-version="$LUA_VERSION" luacov-reporter-lcov
fi
done

for plugin in "${PLUGINS[@]}"; do
plugin_name=${plugin##*/}
plugin_folder="$PLUGINS_FOLDER/$plugin_name"

# Check if plugin was already downloaded
if [[ -d "$plugin_folder/.git" ]]; then
# We could also try to pull here but I am not sure if that wouldn't slow down tests too much.
continue
fi

git clone --depth 1 "$plugin" "$plugin_folder"

done

nvim -u NONE -U NONE -N -i NONE -l tests/init.lua "$@"
66 changes: 66 additions & 0 deletions lua/gitlab/actions/discussions/annotations.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---@meta diagnostics

---@class Author
---@field id integer
---@field username string
---@field email string
---@field name string
---@field state string
---@field avatar_url string
---@field web_url string

---@class LinePosition
---@field line_code string
---@field type string

---@class GitlabLineRange
---@field start LinePosition
---@field end LinePosition

---@class NotePosition
---@field base_sha string
---@field start_sha string
---@field head_sha string
---@field position_type string
---@field new_path string?
---@field new_line integer?
---@field old_path string?
---@field old_line integer?
---@field line_range GitlabLineRange?

---@class Note
---@field id integer
---@field type string
---@field body string
---@field attachment string
---@field title string
---@field file_name string
---@field author Author
---@field system boolean
---@field expires_at string?
---@field updated_at string?
---@field created_at string?
---@field noteable_id integer
---@field noteable_type string
---@field commit_id string
---@field position NotePosition
---@field resolvable boolean
---@field resolved boolean
---@field resolved_by Author
---@field resolved_at string?
---@field noteable_iid integer

---@class UnlinkedNote: Note
---@field position nil

---@class Discussion
---@field id string
---@field individual_note boolean
---@field notes Note[]

---@class UnlinkedDiscussion: Discussion
---@field notes UnlinkedNote[]

---@class DiscussionData
---@field discussions Discussion[]
---@field unlinked_discussions UnlinkedDiscussion[]
Loading