Add gitlab.nvim plugins, update mappings

This commit is contained in:
Loïc Gremaud 2024-05-23 13:54:34 +02:00
parent d6f6f9e11d
commit 3f08c78c13
Signed by: Legrems
GPG Key ID: D4620E6DF3E0121D
6 changed files with 212 additions and 4 deletions

View File

@ -137,6 +137,41 @@ M.customstuffs = {
["<leader>ws"] = { ":WinShift swap<CR>", "Swap window, with selection" }, ["<leader>ws"] = { ":WinShift swap<CR>", "Swap window, with selection" },
["<leader>gg"] = { ":LazyGit<CR>", "Open lazygit" }, ["<leader>gg"] = { ":LazyGit<CR>", "Open lazygit" },
["gf"] = { ":call search('[A-Z]', 'W')<CR>", "Go to next uppercase" },
["fg"] = { ":call search('[A-Z]', 'bW')<CR>", "Go to last uppercase" },
["glb"] = { ":lua require('gitlab').choose_merge_request()<CR>", "Gitlab: Choose merge request" },
["glr"] = { ":lua require('gitlab').review()<CR>", "Gitlab: review" },
["gls"] = { ":lua require('gitlab').summary()<CR>", "Gitlab: summary" },
["glo"] = { ":lua require('gitlab').open_in_browser()<CR>", "Gitlab: open in browser" },
["glu"] = { ":lua require('gitlab').copy_mr_url()<CR>", "Gitlab: open in browser" },
["glO"] = { ":lua require('gitlab').create_mr()<CR>", "Gitlab: create MR" },
["glaa"] = { ":lua require('gitlab').add_assignee()<CR>", "Gitlab: add_assignee" },
-- vim.keymap.set("n", "glb", gitlab.choose_merge_request)
-- vim.keymap.set("n", "glr", gitlab.review)
-- vim.keymap.set("n", "gls", gitlab.summary)
-- vim.keymap.set("n", "glA", gitlab.approve)
-- vim.keymap.set("n", "glR", gitlab.revoke)
-- vim.keymap.set("n", "glc", gitlab.create_comment)
-- vim.keymap.set("v", "glc", gitlab.create_multiline_comment)
-- vim.keymap.set("v", "glC", gitlab.create_comment_suggestion)
-- vim.keymap.set("n", "glO", gitlab.create_mr)
-- vim.keymap.set("n", "glm", gitlab.move_to_discussion_tree_from_diagnostic)
-- vim.keymap.set("n", "gln", gitlab.create_note)
-- vim.keymap.set("n", "gld", gitlab.toggle_discussions)
-- vim.keymap.set("n", "glaa", gitlab.add_assignee)
-- vim.keymap.set("n", "glad", gitlab.delete_assignee)
-- vim.keymap.set("n", "glla", gitlab.add_label)
-- vim.keymap.set("n", "glld", gitlab.delete_label)
-- vim.keymap.set("n", "glra", gitlab.add_reviewer)
-- vim.keymap.set("n", "glrd", gitlab.delete_reviewer)
-- vim.keymap.set("n", "glp", gitlab.pipeline)
-- vim.keymap.set("n", "glM", gitlab.merge)
-- vim.keymap.set("n", "glu", gitlab.copy_mr_url)
-- vim.keymap.set("n", "glP", gitlab.publish_all_drafts)
}, },
v = { v = {
["n"] = { "nzz", "Next + auto center" }, ["n"] = { "nzz", "Next + auto center" },
@ -353,12 +388,17 @@ M.telescope = {
["<C-f>"] = { "<cmd> Telescope live_grep <CR>", "Live grep" }, ["<C-f>"] = { "<cmd> Telescope live_grep <CR>", "Live grep" },
["<C-b>"] = { "<cmd> Telescope buffers <CR>", "Find buffers" }, ["<C-b>"] = { "<cmd> Telescope buffers <CR>", "Find buffers" },
["<leader>ff"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text='<<<<<<< HEAD'}) <CR>", "Search for git conflicts" },
["<leader>fg<CR>"] = { "<cmd> lua require('telescope.builtin').live_grep({}) <CR>", "Live grep" },
["<leader>fg/"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text=vim.fn.getreg('/')}) <CR>", "Live grep with search term" }, ["<leader>fg/"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text=vim.fn.getreg('/')}) <CR>", "Live grep with search term" },
["<leader>fgw"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text=vim.fn.expand('<cword>')}) <CR>", "Live grep with current word" }, ["<leader>fgw"] = { "<cmd> lua require('telescope.builtin').live_grep({default_text=vim.fn.expand('<cword>')}) <CR>", "Live grep with current word" },
["<leader>gf<CR>"] = { "<cmd> lua require('telescope.builtin').find_files({}) <CR>", "Find files" },
["<leader>gf/"] = { "<cmd> lua require('telescope.builtin').find_files({default_text=vim.fn.getreg('/')}) <CR>", "Find files with search term" }, ["<leader>gf/"] = { "<cmd> lua require('telescope.builtin').find_files({default_text=vim.fn.getreg('/')}) <CR>", "Find files with search term" },
["<leader>gfw"] = { "<cmd> lua require('telescope.builtin').find_files({default_text=vim.fn.expand('<cword>')}) <CR>", "Find files with current word" }, ["<leader>gfw"] = { "<cmd> lua require('telescope.builtin').find_files({default_text=vim.fn.expand('<cword>')}) <CR>", "Find files with current word" },
["<leader>br<CR>"] = { ":execute '%s/' . input('Search term >') . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace pattern in current buffer" }, ["<leader>br<CR>"] = { ":execute '%s/' . input('Search term >') . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace pattern in current buffer" },
["<leader>br/"] = { ":execute '%s/' . input('Search term >', getreg('/')) . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace search term pattern in current buffer" }, ["<leader>br/"] = { ":execute '%s/' . input('Search term >', getreg('/')) . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace search term pattern in current buffer" },
["<leader>brw"] = { ":execute '%s/' . input('Search term >', expand('<cword>')) . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace current word pattern in current buffer" }, ["<leader>brw"] = { ":execute '%s/' . input('Search term >', expand('<cword>')) . '/' . input('Replace by >', '') . '/g | update' <CR>", "Replace current word pattern in current buffer" },

View File

@ -0,0 +1,138 @@
local M = {
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 = {
go_request = false,
go_response = false,
},
attachment_dir = nil, -- The local directory for files (see the "summary" section)
reviewer_settings = {
diffview = {
imply_local = false, -- If true, will attempt to use --imply_local option when calling |:DiffviewOpen|
},
},
connection_settings = {
insecure = false, -- Like curl's --insecure option, ignore bad x509 certificates on connection
},
help = "g?", -- Opens a help popup for local keymaps when a relevant view is focused (popup, discussion panel, etc)
popup = { -- The popup for comment creation, editing, and replying
keymaps = {
next_field = "<Tab>", -- Cycle to the next field. Accepts count.
prev_field = "<S-Tab>", -- Cycle to the previous field. Accepts count.
},
perform_action = "<leader>s", -- Once in normal mode, does action (like saving comment or editing description, etc)
perform_linewise_action = "<leader>l", -- Once in normal mode, does the linewise action (see logs for this job, etc)
width = "50%",
height = "80%",
border = "rounded", -- One of "
opacity = 1.0, -- From 0.0 (fully transparent) to 1.0 (fully opaque)
comment = nil, -- Individual popup overrides, e.g. { width = "60%", height = "80%", border = "single", opacity = 0.85 },
edit = nil,
note = nil,
pipeline = nil,
reply = nil,
squash_message = nil,
temp_registers = {}, -- List of registers for backing up popup content (see `:h gitlab.nvim.temp-registers`)
},
discussion_tree = { -- The discussion tree that holds all comments
auto_open = true, -- Automatically open when the reviewer is opened
switch_view = "S", -- Toggles between the notes and discussions views
default_view = "discussions", -- Show "discussions" or "notes" by default
blacklist = {}, -- List of usernames to remove from tree (bots, CI, etc)
jump_to_file = "o", -- Jump to comment location in file
jump_to_reviewer = "m", -- Jump to the location in the reviewer window
edit_comment = "e", -- Edit comment
delete_comment = "dd", -- Delete comment
reply = "r", -- Reply to comment
toggle_node = "t", -- Opens or closes the discussion
add_emoji = "Ea", -- Add an emoji to the note/comment
-- add_emoji = "Ed", -- Remove an emoji from a note/comment
toggle_all_discussions = "T", -- Open or close separately both resolved and unresolved discussions
toggle_resolved_discussions = "R", -- Open or close all resolved discussions
toggle_unresolved_discussions = "U", -- Open or close all unresolved discussions
keep_current_open = false, -- If true, current discussion stays open even if it should otherwise be closed when toggling
publish_draft = "P", -- Publishes the currently focused note/comment
toggle_resolved = "p", -- Toggles the resolved status of the whole discussion
position = "left", -- "top", "right", "bottom" or "left"
open_in_browser = "b", -- Jump to the URL of the current note/discussion
copy_node_url = "u", -- Copy the URL of the current node to clipboard
size = "30%", -- Size of split
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 = "by_file_name", -- Type of discussion tree - "simple" means just list of discussions, "by_file_name" means file tree with discussions under file
toggle_tree_type = "i", -- Toggle type of discussion tree - "simple", or "by_file_name"
draft_mode = false, -- Whether comments are posted as drafts as part of a review
toggle_draft_mode = "D", -- Toggle between draft mode (comments posted as drafts) and live mode (comments are posted immediately)
winbar = nil, -- Custom function to return winbar title, should return a string. Provided with WinbarTable (defined in annotations.lua)
-- If using lualine, please add "gitlab" to disabled file types, otherwise you will not see the winbar.
},
choose_merge_request = {
open_reviewer = true, -- Open the reviewer window automatically after switching merge requests
},
info = { -- Show additional fields in the summary view
enabled = true,
horizontal = false, -- Display metadata to the left of the summary rather than underneath
fields = { -- The fields listed here will be displayed, in whatever order you choose
"author",
"created_at",
"updated_at",
"merge_status",
"draft",
"conflicts",
"assignees",
"reviewers",
"pipeline",
"branch",
"target_branch",
"delete_branch",
"squash",
"labels",
},
},
discussion_signs = {
enabled = true, -- Show diagnostics for gitlab comments in the reviewer
skip_resolved_discussion = false, -- Show diagnostics for resolved discussions
severity = vim.diagnostic.severity.INFO, -- ERROR, WARN, INFO, or HINT
virtual_text = false, -- Whether to show the comment text inline as floating virtual text
priority = 100, -- Higher will override LSP warnings, etc
icons = {
comment = "→|",
range = " |",
},
},
pipeline = {
created = "",
pending = "",
preparing = "",
scheduled = "",
running = "",
canceled = "",
skipped = "",
success = "",
failed = "",
},
create_mr = {
target = "master", -- Default branch to target when creating an MR
template_file = nil, -- Default MR template in .gitlab/merge_request_templates
delete_branch = false, -- Whether the source branch will be marked for deletion
squash = false, -- Whether the commits will be marked for squashing
title_input = { -- Default settings for MR title input window
width = 40,
border = "rounded",
},
},
colors = {
discussion_tree = {
username = "Keyword",
date = "Comment",
chevron = "DiffviewNonText",
directory = "Directory",
directory_icon = "DiffviewFolderSign",
file_name = "Normal",
}
}
}
return M

View File

@ -1,7 +1,7 @@
local options = { local options = {
ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim ensure_installed = { "lua-language-server" }, -- not an option from mason.nvim
PATH = "skip", PATH = "prepand",
ui = { ui = {
icons = { icons = {

View File

@ -18,7 +18,7 @@ local on_attach = function(client, bufnr)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts) vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts) -- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts) vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts) vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wl', function() vim.keymap.set('n', '<space>wl', function()

View File

@ -158,10 +158,20 @@ local options = {
mappings = { mappings = {
i = { i = {
["<CR>"] = custom_actions.multi_selection_open, ["<CR>"] = custom_actions.multi_selection_open,
["<C-V>"] = custom_actions.multi_selection_vsplit, ["<C-v>"] = custom_actions.multi_selection_vsplit,
["<C-X>"] = custom_actions.multi_selection_split, ["<C-X>"] = custom_actions.multi_selection_split,
["<C-T>"] = custom_actions.multi_selection_tab, ["<C-T>"] = custom_actions.multi_selection_tab,
["<C-SPACE>"] = actions.send_selected_to_qflist, ["<C-Space>"] = actions.smart_send_to_qflist,
["<C-L>"] = actions.smart_send_to_loclist,
},
n = i,
}
},
live_grep = {
mappings = {
i = {
["<C-Space>"] = actions.smart_send_to_qflist,
["<C-L>"] = actions.smart_send_to_loclist,
}, },
n = i, n = i,
} }

View File

@ -20,6 +20,26 @@ local default_plugins = {
{"preservim/tagbar", lazy=false}, {"preservim/tagbar", lazy=false},
{"ludovicchabant/vim-gutentags", lazy=false}, {"ludovicchabant/vim-gutentags", lazy=false},
{"emaniacs/vim-rest-console", lazy=false}, {"emaniacs/vim-rest-console", lazy=false},
{"harrisoncramer/gitlab.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"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,
lazy = false,
build = function()
require("gitlab.server").build(true)
end, -- Builds the Go binary
opts = function()
return require "plugins.configs.gitlab"
end,
config = function(_, opts)
require("gitlab").setup(opts)
end,
},
{ {
"sindrets/diffview.nvim", "sindrets/diffview.nvim",
lazy=false, lazy=false,