From 42004fddfdf6541eb9f0f1cba2bb306c60c13457 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Mon, 22 Apr 2024 12:01:27 -0400 Subject: [PATCH] update home manager & add gh pr check lualine --- home.nix | 15 +++++++-- nvim/config/lua/lualine-config.lua | 44 ++++++++++++++++++++++++++- nvim/config/lua/toggleterm-config.lua | 9 ++++++ 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/home.nix b/home.nix index e72925a..33f7da2 100644 --- a/home.nix +++ b/home.nix @@ -27,12 +27,10 @@ in home.packages = with pkgs; [ (nerdfonts.override { fonts = [ "Meslo" ]; }) android-tools - awscli2 bashInteractive + gitAndTools.gh google-cloud-sdk - htop imagemagick - k9s kubectl mosh neofetch @@ -43,8 +41,19 @@ in kitty ] ++ optionals isLinux [ ]; + # GitHub CLI + programs.gh = { + enable = true; + settings = { + git_protocol = "ssh"; + }; + }; + # Misc Programs + programs.awscli.enable = true; + programs.htop.enable = true; programs.jq.enable = true; + programs.k9s.enable = true; programs.pandoc.enable = true; # Enable Flakes & Commands diff --git a/nvim/config/lua/lualine-config.lua b/nvim/config/lua/lualine-config.lua index c4b57f6..6e809dd 100644 --- a/nvim/config/lua/lualine-config.lua +++ b/nvim/config/lua/lualine-config.lua @@ -1,7 +1,49 @@ +-- Cached variable +local cached_pr_status = "" + +-- Read process output +local function read_output(err, data) + if err then return end + if not data then return end + cached_pr_status = data +end + +-- Spawn process +local function execute_command() + local stdout = vim.loop.new_pipe(false) + + local spawn_opts = { + detached = true, + stdio = {nil, stdout, nil}, + args = {"-c", "gh pr checks | awk '{ print $2 }'"} + } + + vim.loop.spawn("bash", spawn_opts, + function() stdout:read_start(read_output) end) +end + +-- Spawn & schedule process +execute_command() +vim.fn.timer_start(300000, execute_command) + +-- Return status from cache +function pr_status() + --    + --    + -- + -- PENDING COLOR - #d29922 + -- PASS COLOR - #3fb950 + -- FAIL COLOR - #f85149 + return cached_pr_status:gsub("\n", ""):gsub("fail", " "):gsub("pass", + " ") + :gsub("pending", " "):sub(1, -2) +end + require('lualine').setup({ options = { theme = "gruvbox_dark" -- theme = "nord" -- theme = "OceanicNext", - } + }, + sections = {lualine_c = {{pr_status}}} }) diff --git a/nvim/config/lua/toggleterm-config.lua b/nvim/config/lua/toggleterm-config.lua index 91bc05e..c705c1d 100644 --- a/nvim/config/lua/toggleterm-config.lua +++ b/nvim/config/lua/toggleterm-config.lua @@ -1,5 +1,14 @@ require("toggleterm").setup({open_mapping = [[]]}) +-- Get PR status on terminal load +-- require("toggleterm").setup({ +-- open_mapping = [[]], +-- on_create = function(term) +-- vim.cmd("startinsert") +-- term:send("gh pr checks") +-- end +-- }) + -- Duplicate C-w & Esc Behavior function _G.set_terminal_keymaps() local opts = {buffer = 0}