From 653ac5b89bff5528cdca4e20314229294834f2ce Mon Sep 17 00:00:00 2001 From: AngeD Date: Mon, 12 Dec 2022 16:43:14 +0100 Subject: [PATCH 1/2] feat: custom p10k inspired kubectl PS1 --- .config/zsh/.zshrc | 2 +- .../zsh/custom/themes/simpletheme.zsh-theme | 39 +++++++++++++++---- .config/zsh/ohmyzsh | 2 +- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 599fd8b..1e96057 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -70,7 +70,7 @@ zstyle ':omz:update' mode disabled # disable automatic updates # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=(vi-mode colored-man-pages kube-ps1 timer git gitignore) +plugins=(vi-mode colored-man-pages git gitignore) . "$ZSH"/oh-my-zsh.sh diff --git a/.config/zsh/custom/themes/simpletheme.zsh-theme b/.config/zsh/custom/themes/simpletheme.zsh-theme index e9409b9..6da9595 100644 --- a/.config/zsh/custom/themes/simpletheme.zsh-theme +++ b/.config/zsh/custom/themes/simpletheme.zsh-theme @@ -1,13 +1,36 @@ -PROMPT=' -$(kube_ps1) -%(?::%{$fg_bold[red]%}%? )%{$fg_bold[cyan]%}%~%{$reset_color%} $(git_prompt_info)' +KUBE_PS1_KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" +KUBE_PS1_KUBECONFIGMD5= +KUBE_PS1_CTX= +KUBE_PS1_NS= + +_update_KUBE_PS1() { + local md5="$(md5sum $KUBE_PS1_KUBECONFIG)" + + [[ "$md5" == "$KUBE_PS1_KUBECONFIGMD5" ]] && return + + KUBE_PS1_KUBECONFIGMD5="$md5" + KUBE_PS1_CTX="$(kubectl config current-context)" + KUBE_PS1_NS="$(kubectl config view --minify -o jsonpath='{..namespace}')" +} + +precmd() { + _update_KUBE_PS1 + local ctx="$KUBE_PS1_CTX" + local ns="$KUBE_PS1_NS" + local symbol='\u2388 ' + local sep='/' + local bg='\e[45m' + local reset='\e[0m' + #local end=" $reset\e[35m\ue0b4" #  + #local end=" $reset\e[35m\ue0bc" #  + local end=" $reset\e[35m\ue0b0" #  + + echo "$bg$symbol$ctx$sep$ns$end$reset" +} + +PROMPT='%(?::%{$fg_bold[red]%}%? )%{$fg_bold[cyan]%}%~%{$reset_color%} $(git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}(%{$fg[red]%}" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} " ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗" ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" - -KUBE_PS1_PREFIX= -KUBE_PS1_SEPARATOR=' ' -KUBE_PS1_DIVIDER=/ -KUBE_PS1_SUFFIX= diff --git a/.config/zsh/ohmyzsh b/.config/zsh/ohmyzsh index f4dc8c5..29cf199 160000 --- a/.config/zsh/ohmyzsh +++ b/.config/zsh/ohmyzsh @@ -1 +1 @@ -Subproject commit f4dc8c5be365668810783ced01a86ff8f251bfd7 +Subproject commit 29cf199b5d84eb4897f2e0e421a344174568eb9f From 0af4b67ab6f956d49736ac0ec4ac5be03682c6d9 Mon Sep 17 00:00:00 2001 From: AngeD Date: Tue, 13 Dec 2022 11:04:59 +0100 Subject: [PATCH 2/2] feat: remove node / npm, fix zsh theme + color --- .config/nvim/init.lua | 1 + .config/nvim/lua/pack-easy-align.lua | 1 + .config/nvim/lua/pack-lspconfig.lua | 58 +++++++++---------- .config/nvim/pack/plugins/opt/black | 1 - .config/nvim/pack/plugins/opt/lspconfig | 2 +- .config/nvim/pack/plugins/opt/treesitter | 2 +- .config/zsh/.zsh_aliases | 2 +- .../zsh/custom/themes/simpletheme.zsh-theme | 9 ++- 8 files changed, 37 insertions(+), 39 deletions(-) delete mode 160000 .config/nvim/pack/plugins/opt/black diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 63384bf..ca5a606 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -14,6 +14,7 @@ vim.o.list = true vim.o.number = true vim.o.relativenumber = true vim.o.laststatus = 3 +vim.o.cmdheight = 0 vim.o.ignorecase = true vim.o.smartcase = true diff --git a/.config/nvim/lua/pack-easy-align.lua b/.config/nvim/lua/pack-easy-align.lua index e641358..3858c6e 100644 --- a/.config/nvim/lua/pack-easy-align.lua +++ b/.config/nvim/lua/pack-easy-align.lua @@ -1,3 +1,4 @@ vim.cmd("packadd easy-align") + vim.keymap.set("n", "ga", "(EasyAlign)") vim.keymap.set("x", "ga", "(EasyAlign)") diff --git a/.config/nvim/lua/pack-lspconfig.lua b/.config/nvim/lua/pack-lspconfig.lua index 2822a02..881ca9f 100644 --- a/.config/nvim/lua/pack-lspconfig.lua +++ b/.config/nvim/lua/pack-lspconfig.lua @@ -1,7 +1,33 @@ vim.cmd("packadd lspconfig") - lspconfig = require"lspconfig" +local servers = { + "jedi_language_server", +} + +local on_attach = function(client, bufnr) + -- Enable completion triggered by + vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") + + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap=true, silent=true, buffer=bufnr } + vim.keymap.set("n", "gD", vim.lsp.buf.declaration, 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", "gi", vim.lsp.buf.implementation, bufopts) + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + vim.keymap.set("n", "wl", function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, bufopts) + vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) + vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) + vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) +end + -- Mappings. -- See `:help vim.diagnostic.*` for documentation on any of the below functions local opts = { noremap=true, silent=true } @@ -10,34 +36,6 @@ vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts) vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) -local servers = { - "bashls", - "pyright", -} - for _, server in ipairs(servers) do - lspconfig[server].setup { - on_attach = function(client, bufnr) - -- Enable completion triggered by - vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc") - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local bufopts = { noremap=true, silent=true, buffer=bufnr } - vim.keymap.set("n", "gD", vim.lsp.buf.declaration, 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", "gi", vim.lsp.buf.implementation, bufopts) - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) - vim.keymap.set("n", "wl", function() - print(vim.inspect(vim.lsp.buf.list_workspace_folders())) - end, bufopts) - vim.keymap.set("n", "D", vim.lsp.buf.type_definition, bufopts) - vim.keymap.set("n", "rn", vim.lsp.buf.rename, bufopts) - vim.keymap.set("n", "ca", vim.lsp.buf.code_action, bufopts) - vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts) - end - } + lspconfig[server].setup {on_attach = on_attach} end diff --git a/.config/nvim/pack/plugins/opt/black b/.config/nvim/pack/plugins/opt/black deleted file mode 160000 index d4a8564..0000000 --- a/.config/nvim/pack/plugins/opt/black +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d4a85643a465f5fae2113d07d22d021d4af4795a diff --git a/.config/nvim/pack/plugins/opt/lspconfig b/.config/nvim/pack/plugins/opt/lspconfig index c720632..0c03849 160000 --- a/.config/nvim/pack/plugins/opt/lspconfig +++ b/.config/nvim/pack/plugins/opt/lspconfig @@ -1 +1 @@ -Subproject commit c7206327096bedf2e213788a60624a84b3b7552d +Subproject commit 0c038493b37e67bed287ff99722a9ced5cdfe617 diff --git a/.config/nvim/pack/plugins/opt/treesitter b/.config/nvim/pack/plugins/opt/treesitter index 0b00eb4..ae0317d 160000 --- a/.config/nvim/pack/plugins/opt/treesitter +++ b/.config/nvim/pack/plugins/opt/treesitter @@ -1 +1 @@ -Subproject commit 0b00eb4b826bde517e87a0993bdb8409435b2378 +Subproject commit ae0317d78a9f6fad78870d6645b60528e13ae6fa diff --git a/.config/zsh/.zsh_aliases b/.config/zsh/.zsh_aliases index aee716b..7dc2973 100644 --- a/.config/zsh/.zsh_aliases +++ b/.config/zsh/.zsh_aliases @@ -2,7 +2,7 @@ alias cls='clear && ls -lah' alias startgui='startx' alias tmp='cd $(mktemp -d)' -alias update="sudo apt-get update && sudo apt-get upgrade; sudo npm update -g; pip freeze | cut -f1 -d= | xargs pip install -U; config submodule update --remote --recursive --init" +alias update="sudo apt-get update && sudo apt-get upgrade; pip freeze | cut -f1 -d= | xargs pip install -U; config submodule update --remote --recursive --init" alias vi='$EDITOR' # conf diff --git a/.config/zsh/custom/themes/simpletheme.zsh-theme b/.config/zsh/custom/themes/simpletheme.zsh-theme index 1a4c186..8d4d6f4 100644 --- a/.config/zsh/custom/themes/simpletheme.zsh-theme +++ b/.config/zsh/custom/themes/simpletheme.zsh-theme @@ -1,4 +1,3 @@ -<<<<<<< HEAD KUBE_PS1_KUBECONFIG="${KUBECONFIG:-$HOME/.kube/config}" KUBE_PS1_KUBECONFIGMD5= KUBE_PS1_CTX= @@ -20,11 +19,11 @@ precmd() { local ns="$KUBE_PS1_NS" local symbol='\u2388 ' local sep='/' - local bg='\e[45m' + local bg='\e[44m' local reset='\e[0m' - #local end=" $reset\e[35m\ue0b4" #  - #local end=" $reset\e[35m\ue0bc" #  - local end=" $reset\e[35m\ue0b0" #  + #local end=" $reset\e[34m\ue0b4" #  + #local end=" $reset\e[34m\ue0bc" #  + local end=" $reset\e[34m\ue0b0" #  echo "$bg$symbol$ctx$sep$ns$end$reset" }