From d5b48dbb319af1ac085e5026f263986b333a6790 Mon Sep 17 00:00:00 2001 From: traxys Date: Wed, 29 May 2024 10:26:45 +0200 Subject: [PATCH] work: Allow to insert reviewer with telescope --- hostconfig/thinkpad-nixos/telescope-team.lua | 42 ++++++++++++++++++++ hostconfig/thinkpad-nixos/work.nix | 9 +++++ 2 files changed, 51 insertions(+) create mode 100644 hostconfig/thinkpad-nixos/telescope-team.lua diff --git a/hostconfig/thinkpad-nixos/telescope-team.lua b/hostconfig/thinkpad-nixos/telescope-team.lua new file mode 100644 index 0000000..afaf5a9 --- /dev/null +++ b/hostconfig/thinkpad-nixos/telescope-team.lua @@ -0,0 +1,42 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local conf = require("telescope.config").values +local actions = require("telescope.actions") +local action_state = require("telescope.actions.state") + +local team_picker = function(opts) + opts = opts or {} + return pickers + .new(opts, { + prompt_title = "Team member", + finder = finders.new_table({ + results = { + [[Quentin Boyer ""]], + [[Mathieu Barbe ""]], + [[Philippe Dutrueux ""]], + [[Sylvain Goudeau ""]], + [[Jonathan EspiƩ--Caullet ""]], + [[Damien Bergamini ""]], + [[Pedro Martins Basso ""]], + [[Yoann Heitz ""]], + }, + }), + sorter = conf.generic_sorter(opts), + attach_mappings = function(prompt_bufnr, map) + actions.select_default:replace(function() + actions.close(prompt_bufnr) + local selection = action_state.get_selected_entry() + vim.api.nvim_put({ selection[1] }, "", false, true) + end) + return true + end, + }) + :find() +end + +return function() + local row, col = unpack(vim.api.nvim_win_get_cursor(0)) + local member = team_picker() + + vim.api.nvim_buf_set_text(0, row - 1, col, row - 1, col, { member }) +end diff --git a/hostconfig/thinkpad-nixos/work.nix b/hostconfig/thinkpad-nixos/work.nix index 09b9f0d..65cf04e 100644 --- a/hostconfig/thinkpad-nixos/work.nix +++ b/hostconfig/thinkpad-nixos/work.nix @@ -12,6 +12,15 @@ config = { workAddr = "quentin.boyer@***REMOVED***"; + extraNixvim = { + extraConfigLuaPre = '' + team_picker = dofile("${./telescope-team.lua}") + ''; + commands = { + Review = "lua team_picker()"; + }; + }; + home.packages = [ (pkgs.writeShellScriptBin "nwadminSendmail" '' #!/usr/bin/env sh