From cc5bbae6304f8f3fdb40d5fc6d27be1f6d1bb94b Mon Sep 17 00:00:00 2001 From: Moshe Avni Date: Sat, 28 Dec 2024 11:14:35 +0200 Subject: [PATCH] stuff --- nvim/.config/nvim/lua/plugins/conform.lua | 8 ++- .../nvim/lua/plugins/functionality.lua | 22 ++++--- zsh/.bin/mkgp.py | 62 ------------------- 3 files changed, 20 insertions(+), 72 deletions(-) delete mode 100755 zsh/.bin/mkgp.py diff --git a/nvim/.config/nvim/lua/plugins/conform.lua b/nvim/.config/nvim/lua/plugins/conform.lua index 7a05141c..b1ce396d 100644 --- a/nvim/.config/nvim/lua/plugins/conform.lua +++ b/nvim/.config/nvim/lua/plugins/conform.lua @@ -106,7 +106,13 @@ return { less = { 'prettierd' }, lua = { 'stylua' }, markdown = { 'cbfmt', 'injected', 'markdownlint' }, - python = { 'isort', 'black' }, + python = function(bufnr) + if require('conform').get_formatter_info('ruff_format', bufnr).available then + return { 'ruff_format' } + else + return { 'isort', 'black' } + end + end, scss = { 'prettierd' }, sh = { 'shfmt' }, svelte = { 'prettierd' }, diff --git a/nvim/.config/nvim/lua/plugins/functionality.lua b/nvim/.config/nvim/lua/plugins/functionality.lua index c20d7c51..44dfc36d 100644 --- a/nvim/.config/nvim/lua/plugins/functionality.lua +++ b/nvim/.config/nvim/lua/plugins/functionality.lua @@ -58,19 +58,23 @@ local M = { require('user.menu').add_actions('Diff', { ['Between 2 directories'] = function() local pretty_print = require('user.utils').pretty_print - vim.ui.input({ prompt = 'Directory A: ' }, function(a) - if not a or a == '' then - pretty_print 'Canceled.' - return - end - vim.ui.input({ prompt = 'Directory B: ' }, function(b) - if not b or b == '' then + vim.defer_fn(function() + vim.ui.input({ prompt = 'Directory A: ' }, function(a) + if not a or a == '' then pretty_print 'Canceled.' return end - vim.cmd('DirDiff ' .. a .. ' ' .. b) + vim.defer_fn(function() + vim.ui.input({ prompt = 'Directory B: ' }, function(b) + if not b or b == '' then + pretty_print 'Canceled.' + return + end + vim.cmd('DirDiff ' .. a .. ' ' .. b) + end) + end, 100) end) - end) + end, 100) end, }) end, diff --git a/zsh/.bin/mkgp.py b/zsh/.bin/mkgp.py deleted file mode 100755 index 464a501a..00000000 --- a/zsh/.bin/mkgp.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/local/bin/python3 -import iterm2 -import iterm2.util -from math import floor, ceil -import sys - - -def get_size(refsize, cursize, width=None, height=None): - """in percentage 0-100""" - new = iterm2.util.Size(cursize.width, cursize.height) - if width is not None: - new.width = floor(refsize.width * width / 100) - if height is not None: - new.height = floor(refsize.height * height / 100) - return new - - -def set_session_size(app, refsize, session, width=None, height=None): - """in percentage 0-100""" - session = app.get_session_by_id( - session.session_id - ) # to make sure to have as current as possible size - old = session.grid_size - new = get_size(refsize, old, width, height) - session.preferred_size = new - # print( - # f"set session size ({width}, {height}): width: {old.width} -> {new.width}, height: {old.height} -> {new.height}" - # ) - return app.get_session_by_id(session.session_id) - - -async def main(connection): - app = await iterm2.async_get_app(connection) - bottom = app.current_terminal_window.current_tab.current_session - _, tab = app.get_window_and_tab_for_session(bottom) - - bottom_grid_size = bottom.grid_size - top = await bottom.async_split_pane(vertical=False, before=True) - top_grid_size = top.grid_size - await bottom.async_activate() - await top.async_send_text( - text=f"""watch 'kubectl get pods --sort-by=.metadata.creationTimestamp -owide | grep {cmd_flags} "{search_term}"'\n""", - suppress_broadcast=False, - ) - set_session_size(app, bottom_grid_size, bottom, height=70) - set_session_size(app, top_grid_size, top, height=40) - tab = app.get_tab_by_id(tab.tab_id) - await tab.async_update_layout() - - -search_term = ".*" -cmd_flags = "" - -if len(sys.argv) == 2: - search_term = sys.argv[1] - -if len(sys.argv) == 3: - cmd_flags = sys.argv[1] - search_term = sys.argv[2] - -print(f"Searching for {search_term} pods") -iterm2.run_until_complete(main)