From 7d43d9abd3a00320c9e36dcf3655a04c628a2337 Mon Sep 17 00:00:00 2001 From: ignuki Date: Sat, 29 Mar 2025 22:03:15 +0100 Subject: [PATCH] improve workflow with shell --- README.md | 1 + nvim/.config/nvim/lsp/bashls.lua | 5 +++ nvim/.config/nvim/lua/ink/lsp.lua | 5 +-- nvim/.config/nvim/lua/plugins/formatting.lua | 5 ++- nvim/.config/nvim/lua/plugins/linting.lua | 3 +- zsh/.zshenv | 10 ++--- zsh/.zshrc | 42 ++++++++++---------- 7 files changed, 39 insertions(+), 32 deletions(-) create mode 100644 nvim/.config/nvim/lsp/bashls.lua diff --git a/README.md b/README.md index 827bec7..aab718a 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ - prettier-plugin-go-template - rust-analyzer - shfmt +- shellcheck - bash-language-server - terraform - tflint diff --git a/nvim/.config/nvim/lsp/bashls.lua b/nvim/.config/nvim/lsp/bashls.lua new file mode 100644 index 0000000..a38d1b4 --- /dev/null +++ b/nvim/.config/nvim/lsp/bashls.lua @@ -0,0 +1,5 @@ +return { + cmd = { "bash-language-server" }, + filetypes = { "sh", "bash", "zsh" }, + settings = {}, +} diff --git a/nvim/.config/nvim/lua/ink/lsp.lua b/nvim/.config/nvim/lua/ink/lsp.lua index 19f3a40..f978c28 100644 --- a/nvim/.config/nvim/lua/ink/lsp.lua +++ b/nvim/.config/nvim/lua/ink/lsp.lua @@ -9,12 +9,9 @@ vim.lsp.config("*", { }, }) -vim.lsp.config("rust", { - filetypes = { "rust" }, -}) - vim.lsp.enable("luals") vim.lsp.enable("rust") +vim.lsp.enable("bashls") -- [[FOLDING SETUP -- Prefer LSP folding if client supports it diff --git a/nvim/.config/nvim/lua/plugins/formatting.lua b/nvim/.config/nvim/lua/plugins/formatting.lua index 3edaf98..9b75cc4 100644 --- a/nvim/.config/nvim/lua/plugins/formatting.lua +++ b/nvim/.config/nvim/lua/plugins/formatting.lua @@ -10,6 +10,7 @@ return { configs.setup({ ensure_installed = { "bash", + --"zsh", "c", "cmake", "dockerfile", @@ -95,6 +96,8 @@ return { terraform = { "terraform_fmt" }, -- brew install shfmt bash = { "shfmt" }, + zsh = { "shfmt" }, + sh = { "shfmt" }, -- brew install ruff python = { "ruff" }, }, @@ -103,7 +106,7 @@ return { prepend_args = { "--prose-wrap", "always" }, }, shfmt = { - prepend_args = { "-i", "4" }, + prepend_args = { "-i", "4", "-ci" }, }, ruff = { prepend_args = { "--extend-select", "I" }, diff --git a/nvim/.config/nvim/lua/plugins/linting.lua b/nvim/.config/nvim/lua/plugins/linting.lua index 2f03ae0..1622577 100644 --- a/nvim/.config/nvim/lua/plugins/linting.lua +++ b/nvim/.config/nvim/lua/plugins/linting.lua @@ -7,7 +7,8 @@ return { lint.linters_by_ft = { -- brew install luacheck lua = { "luacheck" }, - bash = { "bash" }, + bash = { "shellcheck" }, + sh = { "shellcheck" }, -- brew install tflint terraform = { "tflint" }, } diff --git a/zsh/.zshenv b/zsh/.zshenv index 022c00b..871c670 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -20,14 +20,14 @@ export SSH_ENV="$HOME/.ssh/agent-environment" export PATH=~/.local/bin:$PATH case "$(uname -s)" in - Linux* ) { + Linux*) { eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - };; - Darwin* ) { + } ;; + Darwin*) { eval "$(/opt/homebrew/bin/brew shellenv)" export PATH="/opt/homebrew/opt/make/libexec/gnubin:$PATH" - };; - * ) ;; + } ;; + *) ;; esac . "$HOME/.cargo/env" diff --git a/zsh/.zshrc b/zsh/.zshrc index 91745ba..3d68799 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,38 +1,38 @@ setopt INC_APPEND_HISTORY -setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. -setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history. -setopt HIST_FIND_NO_DUPS # Do not display a previously found event. -setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. -setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again. -setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. -unsetopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. -setopt SHARE_HISTORY # Share history between all sessions. +setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format. +setopt HIST_EXPIRE_DUPS_FIRST # Expire a duplicate event first when trimming history. +setopt HIST_FIND_NO_DUPS # Do not display a previously found event. +setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate. +setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again. +setopt HIST_IGNORE_SPACE # Do not record an event starting with a space. +unsetopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file. +setopt SHARE_HISTORY # Share history between all sessions. bindkey '^R' history-incremental-search-backward bindkey '^A' beginning-of-line bindkey '^E' end-of-line bindkey '^K' kill-line -setopt AUTO_PUSHD # Push the current directory visited on the stack. -setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. -setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. +setopt AUTO_PUSHD # Push the current directory visited on the stack. +setopt PUSHD_IGNORE_DUPS # Do not store duplicates in the stack. +setopt PUSHD_SILENT # Do not print the directory stack after pushd or popd. # install zsh-syntax-highlighting case "$(uname -s)" in - Linux* ) { + Linux*) { source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - };; - Darwin* ) { - source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - };; - * ) ;; + } ;; + Darwin*) { + source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" + } ;; + *) ;; esac bindkey "^[[1;5C" forward-word bindkey "^[[1;5D" backward-word -source $DOTFILES/zsh/completion.zsh -fpath=($DOTFILES/zsh/zsh-completions/src $fpath) +source "$DOTFILES/zsh/completion.zsh" +fpath=("$DOTFILES/zsh/zsh-completions/src" "$fpath") # make less more friendly for non-text input files, see lesspipe(1) [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" @@ -41,9 +41,9 @@ if [ -f ~/.zsh_aliases ]; then . ~/.zsh_aliases fi -function set_win_title(){ +function set_win_title() { echo -ne "\033]0; $(basename "$PWD") \007" } -starship_precmd_user_func="set_win_title" +export starship_precmd_user_func="set_win_title" eval "$(starship init zsh)"