-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathannotations.lua
More file actions
397 lines (355 loc) · 19.1 KB
/
annotations.lua
File metadata and controls
397 lines (355 loc) · 19.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
---@meta diagnostics
---@alias BorderEnum "rounded" | "single" | "double" | "solid"
---@alias SeverityEnum "ERROR" | "WARN" | "INFO" | "HINT"
---@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
---@field url string?
---@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[]
---@class EmojiMap: table<string, Emoji>
---@class Emoji
---@field unicode string
---@field unicodeAlternates string[]
---@field name string
---@field shortname string
---@field category string
---@field aliases string[]
---@field aliasesASCII string[]
---@field keywords string[]
---@field moji string
---@class WinbarTable
---@field view_type string
---@field resolvable_discussions number
---@field resolved_discussions number
---@field non_resolvable_discussions number
---@field inline_draft_notes number
---@field unlinked_draft_notes number
---@field resolvable_notes number
---@field resolved_notes number
---@field non_resolvable_notes number
---@field help_keymap string
---@field ahead number|nil -- Number of commits local is ahead of remote
---@field behind number|nil -- Number of commits local is behind remote
---@field updated string
---
---@class SignTable
---@field name string
---@field group string
---@field priority number
---@field id number
---@field lnum number
---@field buffer number?
---
---@class DiagnosticTable
---@field message string
---@field col number
---@field severity number
---@field user_data table
---@field source string
---@field code string?
---@class LineRange
---@field start_line integer
---@field end_line integer
---@class DiffviewInfo
---@field modification_type string
---@field file_name string
---Relevant for renamed files only, the name of the file in the previous commit
---@field old_file_name string
---@field current_bufnr integer
---@field opposite_bufnr integer
---@field new_line_from_buf integer
---@field old_line_from_buf integer
---@field new_sha_focused boolean
---@field current_win_id integer
---@class LocationData
---@field old_line integer | nil
---@field new_line integer | nil
---@field line_range ReviewerRangeInfo|nil
---@class DraftNote
---@field note string
---@field id integer
---@field author_id integer
---@field merge_request_id integer
---@field resolve_discussion boolean
---@field discussion_id string -- This will always be ""
---@field commit_id string -- This will always be ""
---@field line_code string
---@field position NotePosition
---
---
--- Plugin Settings
---
---@class Settings
---@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
---@field debug? DebugSettings -- Which values to log
---@field attachment_dir? string, -- The local directory for files (see the "summary" section)
---@field reviewer_settings? ReviewerSettings -- Settings for the reviewer view
---@field connection_settings? ConnectionSettings -- Settings for the connection to Gitlab
---@field keymaps? Keymaps -- Keymaps for the plugin
---@field popup? PopupSettings -- Settings for the popup windows
---@field discussion_tree? DiscussionSettings -- Settings for the popup windows
---@field choose_merge_request? ChooseMergeRequestSettings -- Default settings when choosing a merge request
---@field info? InfoSettings -- Settings for the "info" or "summary" view
---@field mergeability_checks? MergeabilityChecksSettings -- Settings for the mergeability checks in the "summary" view
---@field discussion_signs? DiscussionSigns -- The settings for discussion signs/diagnostics
---@field pipeline? PipelineSettings -- The settings for the pipeline popup
---@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
---@field severity? SeverityEnum
---@field virtual_text? boolean -- Whether to show the comment text inline as floating virtual text
---@field use_diagnostic_signs? boolean -- Show diagnostic sign (depending on the `severity` setting) along with the comment icon
---@field priority? number -- Higher will override LSP warnings, etc
---@field icons? IconsOpts -- Customize the icons shown with comments or notes
---@class ColorSettings: table
---@field discussion_tree? DiscussionTreeColors -- Colors for elements in the discussion tree
---@class DiscussionTreeColors
--- @field username? string
--- @field mention? string
--- @field date? string
--- @field expander? string
--- @field directory? string
--- @field directory_icon? string
--- @field file_name? string
--- @field resolved? string
--- @field unresolved? string
--- @field draft? string
---@class CreateMrSettings: table
---@field target? string -- Default branch to target when creating an MR
---@field template_file? string -- Default MR template in .gitlab/merge_request_templates
---@field delete_branch? boolean -- Whether the source branch will be marked for deletion
---@field squash? boolean -- Whether the commits will be marked for squashing
---@field title_input? TitleInputSettings
---@field fork? ForkSettings
---@class ForkSettings: table
---@field enabled? boolean -- If making an MR from a fork
---@field forked_project_id? number -- The Gitlab ID of the project you are merging into. If nil, will be prompted.
---@class TitleInputSettings: table
---@field width? number
---@field border? BorderEnum
---@class PipelineSettings: table
---@field created? string -- What to show for this pipeline status, by default "",
---@field pending? string -- What to show for this pipeline status, by default "",
---@field preparing? string -- What to show for this pipeline status, by default "",
---@field scheduled? string -- What to show for this pipeline status, by default "",
---@field running? string -- What to show for this pipeline status, by default "",
---@field canceled? string -- What to show for this pipeline status, by default "↪",
---@field skipped? string -- What to show for this pipeline status, by default "↪",
---@field success? string -- What to show for this pipeline status, by default "✓",
---@field failed? string -- What to show for this pipeline status, by default "",
---@class IconsOpts: table
---@field comment? string -- The icon for comments, by default "→|",
---@field range? string -- The icon for lines in ranged comments, by default " |"
---@class ReviewerSettings: table
---@field diffview? SettingsDiffview -- Settings for diffview (the dependency)
---@class SettingsDiffview: table
---@field imply_local? boolean -- If true, will attempt to use --imply_local option when calling |:DiffviewOpen|
---@class ConnectionSettings: table
---@field insecure? boolean -- Like curl's --insecure option, ignore bad x509 certificates on connection
---@class DebugSettings: table
---@field go_request? boolean -- Log the requests to Gitlab sent by the Go server
---@field go_response? boolean -- Log the responses received from Gitlab to the Go server
---@field request? boolean -- Log the requests to the Go server
---@field response? boolean -- Log the responses from the Go server
---@class PopupSettings: table
---@field width? string -- The width of the popup, by default "40%"
---@field height? string The width of the popup, by default "60%"
---@field border? BorderEnum
---@field opacity? number -- From 0.0 (fully transparent) to 1.0 (fully opaque)
---@field comment? table -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 },
---@field edit? table -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 }
---@field note? table -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 }
---@field pipeline? table -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 }
---@field reply? table -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 }
---@field squash_message? string The default message when squashing a commit
---@field temp_registers? string[] -- List of registers for backing up popup content (see `:h gitlab.nvim.temp-registers`)
---@class ChooseMergeRequestSettings
---@field open_reviewer? boolean -- Open the reviewer window automatically after switching merge requests
---@class InfoSettings
---@field horizontal? boolean -- Display metadata to the left of the summary rather than underneath
---@field fields? ("author" | "created_at" | "updated_at" | "merge_status" | "draft" | "conflicts" | "assignees" | "reviewers" | "pipeline" | "branch" | "target_branch" | "delete_branch" | "squash" | "labels" | "web_url" | "mergeability_checks")[]
---@class MergeabilityChecksSettings
---@field statuses MergeabilityStatuses
---@field checks MergeabilityChecks
---@class MergeabilityStatuses
---@field SUCCESS string|false
---@field CHECKING string|false
---@field FAILED string|false
---@field WARNING string|false
---@field INACTIVE string|false
---@class MergeabilityChecks
---@field CI_MUST_PASS string|false
---@field COMMITS_STATUS string|false
---@field CONFLICT string|false
---@field DISCUSSIONS_NOT_RESOLVED string|false
---@field DRAFT_STATUS string|false
---@field JIRA_ASSOCIATION_MISSING string|false
---@field LOCKED_LFS_FILES string|false
---@field LOCKED_PATHS string|false
---@field MERGE_REQUEST_BLOCKED string|false
---@field MERGE_TIME string|false
---@field NEED_REBASE string|false
---@field NOT_APPROVED string|false
---@field NOT_OPEN string|false
---@field REQUESTED_CHANGES string|false
---@field SECURITY_POLICY_VIOLATIONS string|false
---@field STATUS_CHECKS_MUST_PASS string|false
---@field TITLE_REGEX string|false
---@class DiscussionSettings: table
---@field expanders? ExpanderOpts -- Customize the expander icons in the discussion tree
---@field auto_open? boolean -- Automatically open when the reviewer is opened
---@field default_view? string - Show "discussions" or "notes" by default
---@field blacklist? table<string> -- List of usernames to remove from tree (bots, CI, etc)
---@field keep_current_open? boolean -- If true, current discussion stays open even if it should otherwise be closed when toggling
---@field position? "top" | "right" | "bottom" | "left"
---@field size? string -- Size of split, default to "20%"
---@field relative? "editor" | "window" -- Relative position of tree split
---@field resolved? string -- Symbol to show next to resolved discussions
---@field unresolved? '-', -- Symbol to show next to unresolved discussions
---@field tree_type? string -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
---@field draft_mode? boolean -- Whether comments are posted as drafts as part of a review
---@field winbar? function -- Custom function to return winbar title, should return a string. Provided with WinbarTable (defined in annotations.lua)
---@class ExpanderOpts: table<string string>
---@field expanded? string -- Icon for expanded discussion thread
---@field collapsed? string -- Icon for collapsed discussion thread
---@field indentation? string -- Indentation Icon
---@class Keymaps
---@field help? string -- Open a help popup for local keymaps when a relevant view is focused (popup, discussion panel, etc)
---@field global? KeymapsGlobal -- Global keybindings which will apply everywhere in Neovim
---@field popup? KeymapsPopup -- Keymaps for the popups (creating a comment, reading the summary, etc)
---@field discussion_tree? KeymapsDiscussionTree -- Keymaps for the discussion tree pane
---@field reviewer? KeymapsReviewer -- Keymaps for the reviewer view
---@class KeymapTable: table<string, table<string, string | boolean>>
---@field disable_all? boolean -- Disable all built-in keymaps
---@class KeymapsPopup: KeymapTable
---@field next_field? string -- Cycle to the next field. Accepts |count|.
---@field prev_field? string -- Cycle to the previous field. Accepts |count|.
---@field perform_action? string -- Once in normal mode, does action (like saving comment or applying description edit, etc)
---@field perform_linewise_action? string -- Once in normal mode, does the linewise action (see logs for this job, etc)
---@field discard_changes? string -- Quit the popup discarding changes, the popup content isnot? saved to the `temp_registers` (see `:h gitlab.nvim.temp-registers`)
---
---@class KeymapsDiscussionTree: KeymapTable
---@field add_emoji? string -- Add an emoji to the note/comment
---@field delete_emoji? string -- Remove an emoji from a note/comment
---@field delete_comment? string -- Delete comment
---@field edit_comment? string -- Edit comment
---@field reply? string -- Reply to comment
---@field toggle_resolved? string -- Toggle the resolved? status of the whole discussion
---@field jump_to_file? string -- Jump to comment location in file
---@field jump_to_reviewer? string -- Jump to the comment location in the reviewer window
---@field open_in_browser? string -- Jump to the URL of the current note/discussion
---@field copy_node_url? string -- Copy the URL of the current node to clipboard
---@field switch_view? string -- Toggle between the notes and discussions views
---@field toggle_tree_type? string or "by_file_name"
---@field publish_draft? string -- Publish the currently focused note/comment
---@field toggle_draft_mode? string -- Toggle between draft mode (comments posted as drafts) and live mode (comments are posted immediately)
---@field toggle_node? string -- Open or close the discussion
---@field toggle_all_discussions? string -- Open or close? separately both resolved and unresolved discussions
---@field toggle_resolved_discussions? string -- Open or close all resolved discussions
---@field toggle_unresolved_discussions? string -- Open or close all unresolved discussions
---@field refresh_data? string -- Refresh the data in the view by hitting Gitlab's APIs again
---@field print_node? string -- Print the current node (for debugging)
---
---@class KeymapsReviewer: KeymapTable
---@field create_comment? string -- Create a comment for the lines that the following {motion} moves over. Repeat the key(s) for creating comment for the current line
---@field create_suggestion? string -- Creates suggestion for the lines that the following {motion} moves over. Repeat the key(s) for creating comment for the current line
---@field move_to_discussion_tree? string -- Jump to the comment in the discussion tree
---
---@class KeymapsGlobal: KeymapTable
---@field add_assignee? string -- Add an assignee to the merge request
---@field delete_assignee? string -- Delete an assignee from the merge request
---@field add_label? string -- Add a label from the merge request
---@field delete_label? string -- Remove a label from the merge request
---@field add_reviewer? string -- Add a reviewer to the merge request
---@field delete_reviewer? string -- Delete a reviewer from the merge request
---@field approve? string -- Approve MR
---@field revoke? string -- Revoke MR approval
---@field merge? string -- Merge the feature branch to the target branch and close MR
---@field create_mr? string -- Create a new MR for currently checked-out feature branch
---@field choose_merge_request? string -- Chose MR for review (if necessary check out the feature branch)
---@field start_review? string -- Start review for the currently checked-out branch
---@field summary? string -- Show the editable summary of the MR
---@field copy_mr_url? string -- Copy the URL of the MR to the system clipboard
---@field open_in_browser? string -- Openthe URL of the MR in the default Internet browser
---@field create_note? string -- Create a note (comment not linked toa specific line)
---@field pipeline? string -- Show the pipeline status
---@field toggle_discussions? string -- Toggle the discussions window
---@field toggle_draft_mode? string -- Toggle between draft mode (comments posted as drafts) and live mode (comments are posted immediately)
---@field publish_all_drafts? string -- Publish all draft comments/notes
---@class Settings: KeymapTable
---@field next_field? string -- Cycle to the next field. Accepts |count|.
---@field prev_field? string -- Cycle to the previous field. Accepts |count|.
---@field perform_action? string -- Once in normal mode, does action (like saving comment or applying description edit, etc)
---@field perform_linewise_action? string -- Once in normal mode, does the linewise action (see logs for this job, etc)
---@field discard_changes? string -- Quit the popup discarding changes, the popup content is not? saved to the `temp_registers` (see `:h gitlab.nvim.temp-registers`)
---@class List The base class for all list objects
---@field new function -- Creates a new List from a table
---@field map function -- Mutates a given list
---@field filter function -- Filters a given list
---@field partition function -- Partitions a given list into two lists
---@field reduce function -- Applies a function to reduce the list to a single value
---@field sort function -- Sorts the list in place based on a comparator function
---@field find function -- Returns the first element that satisfies the callback
---@field slice function -- Returns a portion of the list between start and end indices
---@field includes function -- Returns true if any of the elements can satisfy the callback
---@field values function -- Returns an iterator over the list's values