Discussion sign and diagnostics (#78)
This MR adds support for in-line comments in the review pane. This allows you to view comments (as diagnostics) directly in the Neovim buffers that you are reviewing. You can then jump to them directly in the discussion tree if you want to reply, edit, and so forth.
This commit is contained in:
69
README.md
69
README.md
@@ -20,10 +20,10 @@ https://github.com/harrisoncramer/gitlab.nvim/assets/32515581/50f44eaf-5f99-4cb3
|
||||
## Quick Start
|
||||
|
||||
1. Install Go
|
||||
3. Add configuration (see Installation section)
|
||||
4. Checkout your feature branch: `git checkout feature-branch`
|
||||
5. Open Neovim
|
||||
6. Run `:lua require("gitlab").review()` to open the reviewer pane
|
||||
2. Add configuration (see Installation section)
|
||||
3. Checkout your feature branch: `git checkout feature-branch`
|
||||
4. Open Neovim
|
||||
5. Run `:lua require("gitlab").review()` to open the reviewer pane
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -66,7 +66,7 @@ use {
|
||||
|
||||
## Project Configuration
|
||||
|
||||
This plugin requires an <a href="https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token">auth token</a> to connect to Gitlab. The token can be set in the root directory of the project in a `.gitlab.nvim` environment file, or can be set via a shell environment variable called `GITLAB_TOKEN` instead. If both are present, the `.gitlab.nvim` file will take precedence.
|
||||
This plugin requires an <a href="https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token">auth token</a> to connect to Gitlab. The token can be set in the root directory of the project in a `.gitlab.nvim` environment file, or can be set via a shell environment variable called `GITLAB_TOKEN` instead. If both are present, the `.gitlab.nvim` file will take precedence.
|
||||
|
||||
Optionally provide a GITLAB_URL environment variable (or gitlab_url value in the `.gitlab.nvim` file) to connect to a self-hosted Gitlab instance. This is optional, use ONLY for self-hosted instances.
|
||||
|
||||
@@ -112,6 +112,36 @@ require("gitlab").setup({
|
||||
resolved = '✓', -- Symbol to show next to resolved discussions
|
||||
unresolved = '✖', -- Symbol to show next to unresolved discussions
|
||||
},
|
||||
discussion_sign_and_diagnostic = {
|
||||
skip_resolved_discussion = false,
|
||||
skip_old_revision_discussion = true,
|
||||
},
|
||||
discussion_sign = {
|
||||
-- See :h sign_define for details about sign configuration.
|
||||
enabled = true,
|
||||
text = "💬",
|
||||
linehl = nil,
|
||||
texthl = nil,
|
||||
culhl = nil,
|
||||
numhl = nil,
|
||||
priority = 20, -- Priority of sign, the lower the number the higher the priority
|
||||
helper_signs = {
|
||||
-- For multiline comments the helper signs are used to indicate the whole context
|
||||
-- Priority of helper signs is lower than the main sign (-1).
|
||||
enabled = true,
|
||||
start = "↑",
|
||||
mid = "|",
|
||||
["end"] = "↓",
|
||||
},
|
||||
},
|
||||
discussion_diagnostic = {
|
||||
-- If you want to customize diagnostics for discussions you can make special config
|
||||
-- for namespace `gitlab_discussion`. See :h vim.diagnostic.config
|
||||
enabled = true,
|
||||
severity = vim.diagnostic.severity.INFO,
|
||||
code = nil, -- see :h diagnostic-structure
|
||||
display_opts = {}, -- see opts in vim.diagnostic.set
|
||||
},
|
||||
pipeline = {
|
||||
created = "",
|
||||
pending = "",
|
||||
@@ -145,7 +175,7 @@ Then open Neovim. To begin, try running the `summary` command or the `review` co
|
||||
|
||||
### Summary
|
||||
|
||||
The `summary` action will open the MR title and description.
|
||||
The `summary` action will open the MR title and description.
|
||||
|
||||
```lua
|
||||
require("gitlab").summary()
|
||||
@@ -188,6 +218,32 @@ If you'd like to create a note in an MR (like a comment, but not linked to a spe
|
||||
require("gitlab").create_note()
|
||||
```
|
||||
|
||||
### Discussions signs and diagnostics
|
||||
|
||||
By default when reviewing files you will see signs and diagnostics ( if enabled in configuration ). When cursor is on diagnostic line you can view discussion thread by using `vim.diagnostic.show`. You can also jump to discussion tree where you can reply, edit or delete discussion.
|
||||
|
||||
```lua
|
||||
require("gitlab").move_to_discussion_tree_from_diagnostic()
|
||||
```
|
||||
|
||||
The `discussion_sign` configuration controls the display of signs for discussions. The `enabled` option turns on/off the signs. `text` sets the sign text. `linehl`, `texthl`, `culhl`, and `numhl` customize the line highlighting, text highlighting, column highlighting, and number highlighting respectively. Keep in mind that these can be overridden by other configuration (for example diffview.nvim highlights). `priority` controls the sign priority order (when multiple signs are placed on the same line, the sign with highest priority is used). The `helper_signs` table configures additional signs for multiline discussions in order to show the whole context. `enabled` turns on/off the helper signs. `start`, `mid`, and `end` set the helper sign text.
|
||||
|
||||
The `discussion_diagnostic` configuration customizes the diagnostic display for discussions. The `enabled` option turns on/off the diagnostics. `severity` sets the diagnostic severity level and should be set to one of `vim.diagnostic.severity.ERROR`, `vim.diagnostic.severity.WARN`, or `vim.diagnostic.severity.INFO`, `vim.diagnostic.severity.HINT`. `code` specifies a diagnostic code. `display_opts` configures the diagnostic display options where you can configure values like (this is dirrectly used as opts in vim.diagnostic.set):
|
||||
|
||||
- `virtual_text` - Show virtual text for diagnostics.
|
||||
- `underline` - Underline text for diagnostics.
|
||||
|
||||
Diagnostics for discussions use the `gitlab_discussion` namespace. See `:h vim.diagnostic.config` and `:h diagnostic-structure` for more details.
|
||||
|
||||
Signs and diagnostics have common settings in `discussion_sign_and_diagnostics`. This allows customizing if discussions that are resolved or no longer relevant should still display visual indicators in the editor:
|
||||
|
||||
- `skip_resolved_discussion` - Whether to skip showing signs and diagnostics for resolved discussions. Default is `false`, meaning signs and diagnostics will be shown for resolved discussions.
|
||||
- `skip_old_revision_discussion` - Whether to skip showing signs and diagnostics for discussions on outdated diff revisions. Default is `true`, meaning signs and diagnostics won't be shown for discussions no longer relevant to the current diff.
|
||||
|
||||
#### Limitations
|
||||
|
||||
When checking multiline diagnostic the cursor must be on the "main" line of diagnostic -> where the `discussion_sign.text` is shown otherwise `vim.diagnostic.show` and `jump_to_discussion_tree_from_diagnostic` will not work.
|
||||
|
||||
### Uploading Files
|
||||
|
||||
To attach a file to an MR description, reply, comment, and so forth use the `settings.popup.perform_linewise_action` keybinding when the the popup is open. This will open a picker that will look in the directory you specify in the `settings.attachment_dir` folder (this must be an absolute path) for files.
|
||||
@@ -249,6 +305,7 @@ vim.keymap.set("n", "<leader>glR", gitlab.revoke)
|
||||
vim.keymap.set("n", "<leader>glc", gitlab.create_comment)
|
||||
vim.keymap.set("v", "<leader>glc", gitlab.create_multiline_comment)
|
||||
vim.keymap.set("v", "<leader>glC", gitlab.create_comment_suggestion)
|
||||
vim.keymap.set("n", "<leader>glm", gitlab.move_to_discussion_tree_from_diagnostic)
|
||||
vim.keymap.set("n", "<leader>gln", gitlab.create_note)
|
||||
vim.keymap.set("n", "<leader>gld", gitlab.toggle_discussions)
|
||||
vim.keymap.set("n", "<leader>glaa", gitlab.add_assignee)
|
||||
|
||||
Reference in New Issue
Block a user