mirror of
https://oauth2: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@github.com/m1ngsama/chopsticks.git
synced 2026-05-10 19:10:59 +08:00
fix: usability and design improvements across .vimrc, install.sh, README
.vimrc:
- Remove global eventignore+=FileType corruption in large file handler
- Add t_8f/t_8b for tmux true color support
- Fix vnoremap J/K shadowing built-in J (join); use Alt+j/k in visual mode
- Replace map with nnoremap for buffer/tab/spell/misc mappings (prevents
visual/operator-pending mode contamination)
- Change BufEnter to FileType for formatoptions (fires less frequently)
- Remove duplicate whitespace trim (ALE already handles it via fix_on_save)
- Guard <leader>so to only source vim files
- Guard <leader>cp/<leader>cf with has('clipboard')
- Add completeopt=popup for floating completion docs (Vim 8.1.1517+)
- Change Startify header from "MINGSAMA" to "chopsticks"
- Make Startify bookmarks conditional (only show shell rc files that exist)
- EasyMotion <Leader>j/k: map → nmap (prevent visual mode leak)
- Move-line: nnoremap instead of nmap for normal mode variant
install.sh:
- Add --help flag
- Support NO_COLOR and non-TTY output (no ANSI codes when redirected)
- Include $BASH_COMMAND in ERR trap for better debugging
- Use mktemp for secure temp files instead of predictable /tmp paths
- Warn user when pip falls back to --break-system-packages
README:
- Add missing mappings: jk, F2-F6, gV, //, ,ev, ,sv, ,cp, ,cf, ,*, ,F, ,W, ,ms, ,ss
- Note that some language servers require Node.js even though vim-lsp doesn't
- Clarify Alt+j/k works in both normal and visual mode
This commit is contained in:
parent
0ba2e84e0c
commit
233ceabf53
3 changed files with 113 additions and 68 deletions
104
.vimrc
104
.vimrc
|
|
@ -160,6 +160,9 @@ call plug#end()
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
|
|
||||||
if g:has_true_color && has('termguicolors') && !g:is_tty
|
if g:has_true_color && has('termguicolors') && !g:is_tty
|
||||||
|
" Required for true color inside tmux
|
||||||
|
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
|
||||||
|
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
|
||||||
set termguicolors
|
set termguicolors
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -216,20 +219,20 @@ nmap <leader>q :q<cr>
|
||||||
nmap <leader>x :x<cr>
|
nmap <leader>x :x<cr>
|
||||||
|
|
||||||
" Clear search highlight
|
" Clear search highlight
|
||||||
map <silent> <leader><cr> :noh<cr>
|
nnoremap <silent> <leader><cr> :noh<cr>
|
||||||
|
|
||||||
" Buffer navigation
|
" Buffer navigation
|
||||||
map <leader>bd :Bclose<cr>
|
nnoremap <leader>bd :Bclose<cr>
|
||||||
map <leader>ba :bufdo bd<cr>
|
nnoremap <leader>ba :bufdo bd<cr>
|
||||||
map <leader>l :bnext<cr>
|
nnoremap <leader>l :bnext<cr>
|
||||||
map <leader>h :bprevious<cr>
|
nnoremap <leader>h :bprevious<cr>
|
||||||
|
|
||||||
" Tab management
|
" Tab management
|
||||||
map <leader>tn :tabnew<cr>
|
nnoremap <leader>tn :tabnew<cr>
|
||||||
map <leader>to :tabonly<cr>
|
nnoremap <leader>to :tabonly<cr>
|
||||||
map <leader>tc :tabclose<cr>
|
nnoremap <leader>tc :tabclose<cr>
|
||||||
map <leader>tm :tabmove
|
nnoremap <leader>tm :tabmove
|
||||||
map <leader>t<leader> :tabnext<cr>
|
nnoremap <leader>t<leader> :tabnext<cr>
|
||||||
|
|
||||||
let g:lasttab = 1
|
let g:lasttab = 1
|
||||||
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
nmap <Leader>tl :exe "tabn ".g:lasttab<CR>
|
||||||
|
|
@ -238,8 +241,8 @@ augroup ChopstickTabHistory
|
||||||
autocmd TabLeave * let g:lasttab = tabpagenr()
|
autocmd TabLeave * let g:lasttab = tabpagenr()
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
map <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
|
nnoremap <leader>te :tabedit <C-r>=expand("%:p:h")<cr>/
|
||||||
map <leader>cd :lcd %:p:h<cr>:pwd<cr>
|
nnoremap <leader>cd :lcd %:p:h<cr>:pwd<cr>
|
||||||
|
|
||||||
" File browser (netrw — built-in, no plugins)
|
" File browser (netrw — built-in, no plugins)
|
||||||
nnoremap <leader>e :Explore<CR>
|
nnoremap <leader>e :Explore<CR>
|
||||||
|
|
@ -255,18 +258,18 @@ nnoremap gV `[v`]
|
||||||
cnoremap <C-p> <Up>
|
cnoremap <C-p> <Up>
|
||||||
cnoremap <C-n> <Down>
|
cnoremap <C-n> <Down>
|
||||||
|
|
||||||
" Move lines
|
" Move lines (Alt+j / Alt+k in both normal and visual mode)
|
||||||
nmap <M-j> mz:m+<cr>`z
|
nnoremap <M-j> :m .+1<CR>==
|
||||||
nmap <M-k> mz:m-2<cr>`z
|
nnoremap <M-k> :m .-2<CR>==
|
||||||
vnoremap J :m '>+1<CR>gv=gv
|
vnoremap <M-j> :m '>+1<CR>gv=gv
|
||||||
vnoremap K :m '<-2<CR>gv=gv
|
vnoremap <M-k> :m '<-2<CR>gv=gv
|
||||||
|
|
||||||
" Spell checking
|
" Spell checking
|
||||||
map <leader>ss :setlocal spell!<cr>
|
nnoremap <leader>ss :setlocal spell!<cr>
|
||||||
map <leader>sn ]s
|
nnoremap <leader>sn ]s
|
||||||
map <leader>sp [s
|
nnoremap <leader>sp [s
|
||||||
map <leader>sa zg
|
nnoremap <leader>sa zg
|
||||||
map <leader>s? z=
|
nnoremap <leader>s? z=
|
||||||
|
|
||||||
" Toggle modes
|
" Toggle modes
|
||||||
set pastetoggle=<F2>
|
set pastetoggle=<F2>
|
||||||
|
|
@ -506,7 +509,11 @@ let g:lsp_signs_warning = {'text': '!'}
|
||||||
let g:lsp_signs_information = {'text': 'i'}
|
let g:lsp_signs_information = {'text': 'i'}
|
||||||
let g:lsp_signs_hint = {'text': '>'}
|
let g:lsp_signs_hint = {'text': '>'}
|
||||||
|
|
||||||
set completeopt=menuone,noinsert,noselect
|
if has('patch-8.1.1517')
|
||||||
|
set completeopt=menuone,noinsert,noselect,popup
|
||||||
|
else
|
||||||
|
set completeopt=menuone,noinsert,noselect
|
||||||
|
endif
|
||||||
set pumheight=15
|
set pumheight=15
|
||||||
let g:asyncomplete_auto_popup = 1
|
let g:asyncomplete_auto_popup = 1
|
||||||
let g:asyncomplete_auto_completeopt = 1
|
let g:asyncomplete_auto_completeopt = 1
|
||||||
|
|
@ -587,9 +594,9 @@ let g:EasyMotion_smartcase = 1
|
||||||
" s + two chars: jump anywhere on screen
|
" s + two chars: jump anywhere on screen
|
||||||
nmap s <Plug>(easymotion-overwin-f2)
|
nmap s <Plug>(easymotion-overwin-f2)
|
||||||
|
|
||||||
" J/K: line motions
|
" Line motions
|
||||||
map <Leader>j <Plug>(easymotion-j)
|
nmap <Leader>j <Plug>(easymotion-j)
|
||||||
map <Leader>k <Plug>(easymotion-k)
|
nmap <Leader>k <Plug>(easymotion-k)
|
||||||
|
|
||||||
" ============================================================================
|
" ============================================================================
|
||||||
" => UndoTree
|
" => UndoTree
|
||||||
|
|
@ -620,12 +627,12 @@ endif
|
||||||
|
|
||||||
if exists('g:plugs["vim-startify"]')
|
if exists('g:plugs["vim-startify"]')
|
||||||
let g:startify_custom_header = [
|
let g:startify_custom_header = [
|
||||||
\ ' ███╗ ███╗ ██╗███╗ ██╗ ██████╗ ███████╗ █████╗ ███╗ ███╗ █████╗ ',
|
\ ' ██████╗██╗ ██╗ ██████╗ ██████╗ ███████╗████████╗██╗ ██████╗██╗ ██╗███████╗',
|
||||||
\ ' ████╗ ████║███║████╗ ██║██╔════╝ ██╔════╝██╔══██╗████╗ ████║██╔══██╗ ',
|
\ ' ██╔════╝██║ ██║██╔═══██╗██╔══██╗██╔════╝╚══██╔══╝██║██╔════╝██║ ██╔╝██╔════╝',
|
||||||
\ ' ██╔████╔██║╚██║██╔██╗ ██║██║ ███╗███████╗███████║██╔████╔██║███████║ ',
|
\ ' ██║ ███████║██║ ██║██████╔╝███████╗ ██║ ██║██║ █████╔╝ ███████╗',
|
||||||
\ ' ██║╚██╔╝██║ ██║██║╚██╗██║██║ ██║╚════██║██╔══██║██║╚██╔╝██║██╔══██║ ',
|
\ ' ██║ ██╔══██║██║ ██║██╔═══╝ ╚════██║ ██║ ██║██║ ██╔═██╗ ╚════██║',
|
||||||
\ ' ██║ ╚═╝ ██║ ██║██║ ╚████║╚██████╔╝███████║██║ ██║██║ ╚═╝ ██║██║ ██║ ',
|
\ ' ╚██████╗██║ ██║╚██████╔╝██║ ███████║ ██║ ██║╚██████╗██║ ██╗███████║',
|
||||||
\ ' ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝',
|
\ ' ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝',
|
||||||
\ '',
|
\ '',
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
|
|
@ -636,11 +643,16 @@ if exists('g:plugs["vim-startify"]')
|
||||||
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
\ { 'type': 'bookmarks', 'header': [' Bookmarks'] },
|
||||||
\ ]
|
\ ]
|
||||||
|
|
||||||
let g:startify_bookmarks = [
|
let g:startify_bookmarks = [{'v': '~/.vimrc'}]
|
||||||
\ {'v': '~/.vimrc'},
|
if filereadable(expand('~/.zshrc'))
|
||||||
\ {'z': '~/.zshrc'},
|
call add(g:startify_bookmarks, {'z': '~/.zshrc'})
|
||||||
\ {'b': '~/.bashrc'},
|
endif
|
||||||
\ ]
|
if filereadable(expand('~/.bashrc'))
|
||||||
|
call add(g:startify_bookmarks, {'b': '~/.bashrc'})
|
||||||
|
endif
|
||||||
|
if filereadable(expand('~/.config/fish/config.fish'))
|
||||||
|
call add(g:startify_bookmarks, {'f': '~/.config/fish/config.fish'})
|
||||||
|
endif
|
||||||
|
|
||||||
let g:startify_session_persistence = 1
|
let g:startify_session_persistence = 1
|
||||||
let g:startify_session_autoload = 1
|
let g:startify_session_autoload = 1
|
||||||
|
|
@ -797,7 +809,7 @@ endfunc
|
||||||
" Suppress comment continuation on Enter / o / O
|
" Suppress comment continuation on Enter / o / O
|
||||||
augroup ChopstickFormatOptions
|
augroup ChopstickFormatOptions
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufEnter * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
|
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Auto-disable paste mode on leaving insert
|
" Auto-disable paste mode on leaving insert
|
||||||
|
|
@ -806,13 +818,6 @@ augroup ChopstickPaste
|
||||||
autocmd InsertLeave * set nopaste
|
autocmd InsertLeave * set nopaste
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
" Strip trailing whitespace on save (real files only)
|
|
||||||
augroup ChopstickCleanup
|
|
||||||
autocmd!
|
|
||||||
autocmd BufWritePre *
|
|
||||||
\ if empty(&buftype) && !empty(expand('<afile>')) | call CleanExtraSpaces() | endif
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
augroup ChopstickFiletype
|
augroup ChopstickFiletype
|
||||||
autocmd!
|
autocmd!
|
||||||
|
|
||||||
|
|
@ -907,7 +912,7 @@ nnoremap <leader><leader> <c-^>
|
||||||
nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
|
nnoremap <leader>W :%s/\s\+$//<CR>:let @/=''<CR>
|
||||||
|
|
||||||
" Source helpers
|
" Source helpers
|
||||||
nnoremap <leader>so :source %<CR>
|
nnoremap <leader>so :if &filetype ==# 'vim' <Bar> source % <Bar> echo "Sourced " . expand('%') <Bar> else <Bar> echo "Not a vim file" <Bar> endif<CR>
|
||||||
nnoremap <leader>ev :edit $MYVIMRC<CR>
|
nnoremap <leader>ev :edit $MYVIMRC<CR>
|
||||||
nnoremap <leader>sv :source $MYVIMRC<CR>:echo "vimrc reloaded"<CR>
|
nnoremap <leader>sv :source $MYVIMRC<CR>:echo "vimrc reloaded"<CR>
|
||||||
|
|
||||||
|
|
@ -915,8 +920,10 @@ nnoremap <leader>sv :source $MYVIMRC<CR>:echo "vimrc reloaded"<CR>
|
||||||
nnoremap <leader>* :%s/\<<C-r><C-w>\>//g<Left><Left>
|
nnoremap <leader>* :%s/\<<C-r><C-w>\>//g<Left><Left>
|
||||||
|
|
||||||
" Copy path / filename to clipboard
|
" Copy path / filename to clipboard
|
||||||
nnoremap <leader>cp :let @+ = expand("%:p")<CR>:echo "Copied: " . expand("%:p")<CR>
|
if has('clipboard')
|
||||||
nnoremap <leader>cf :let @+ = expand("%:t")<CR>:echo "Copied: " . expand("%:t")<CR>
|
nnoremap <leader>cp :let @+ = expand("%:p")<CR>:echo "Copied: " . expand("%:p")<CR>
|
||||||
|
nnoremap <leader>cf :let @+ = expand("%:t")<CR>:echo "Copied: " . expand("%:t")<CR>
|
||||||
|
endif
|
||||||
|
|
||||||
" Scratch markdown buffer
|
" Scratch markdown buffer
|
||||||
nnoremap <leader>ms :e ~/buffer.md<cr>
|
nnoremap <leader>ms :e ~/buffer.md<cr>
|
||||||
|
|
@ -981,7 +988,6 @@ augroup END
|
||||||
function! LargeFileSettings()
|
function! LargeFileSettings()
|
||||||
setlocal bufhidden=unload
|
setlocal bufhidden=unload
|
||||||
setlocal undolevels=-1
|
setlocal undolevels=-1
|
||||||
setlocal eventignore+=FileType
|
|
||||||
setlocal noswapfile
|
setlocal noswapfile
|
||||||
setlocal syntax=
|
setlocal syntax=
|
||||||
let b:ale_enabled = 0
|
let b:ale_enabled = 0
|
||||||
|
|
|
||||||
22
README.md
22
README.md
|
|
@ -124,6 +124,10 @@ Supported languages and their servers:
|
||||||
| Markdown | marksman |
|
| Markdown | marksman |
|
||||||
| SQL | sqls |
|
| SQL | sqls |
|
||||||
|
|
||||||
|
**Note:** While vim-lsp itself needs no Node.js, some language servers (TypeScript,
|
||||||
|
HTML, CSS, JSON, YAML) are npm packages that require Node.js to run. Python (pylsp),
|
||||||
|
Go (gopls), and Rust (rust-analyzer) language servers do not need Node.js.
|
||||||
|
|
||||||
**Markdown LSP** requires `marksman` as a standalone binary:
|
**Markdown LSP** requires `marksman` as a standalone binary:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
@ -203,8 +207,14 @@ Press `,?` at any time to open the built-in cheat sheet.
|
||||||
| `Space` | Toggle code fold |
|
| `Space` | Toggle code fold |
|
||||||
| `Y` | Yank to end of line |
|
| `Y` | Yank to end of line |
|
||||||
| `Ctrl+d` / `Ctrl+u` | Half-page scroll, cursor centred |
|
| `Ctrl+d` / `Ctrl+u` | Half-page scroll, cursor centred |
|
||||||
| `Alt+j` / `Alt+k` | Move line down / up |
|
| `Alt+j` / `Alt+k` | Move line down / up (normal and visual) |
|
||||||
| `,u` | Undo tree (visual branch history) |
|
| `,u` | Undo tree (visual branch history) |
|
||||||
|
| `F2` | Toggle paste mode |
|
||||||
|
| `F3` / `F4` | Toggle line numbers / relative numbers |
|
||||||
|
| `F5` | Toggle undo tree |
|
||||||
|
| `F6` | Toggle invisible characters |
|
||||||
|
| `gV` | Reselect last paste |
|
||||||
|
| `//` | Search visual selection |
|
||||||
|
|
||||||
### Survival
|
### Survival
|
||||||
|
|
||||||
|
|
@ -212,7 +222,8 @@ Press `,?` at any time to open the built-in cheat sheet.
|
||||||
|-----|--------|
|
|-----|--------|
|
||||||
| `jk` | Exit insert mode |
|
| `jk` | Exit insert mode |
|
||||||
| `Esc` | Exit insert / visual mode |
|
| `Esc` | Exit insert / visual mode |
|
||||||
| `Ctrl+s` | Save |
|
| `jk` | Exit insert mode |
|
||||||
|
| `Ctrl+s` | Save (any mode) |
|
||||||
| `,w` | Save |
|
| `,w` | Save |
|
||||||
| `,x` | Save and quit |
|
| `,x` | Save and quit |
|
||||||
| `,q` | Quit |
|
| `,q` | Quit |
|
||||||
|
|
@ -227,6 +238,13 @@ Press `,?` at any time to open the built-in cheat sheet.
|
||||||
| `Esc Esc` | Exit terminal mode |
|
| `Esc Esc` | Exit terminal mode |
|
||||||
| `,tn` / `,tc` | New tab / close tab |
|
| `,tn` / `,tc` | New tab / close tab |
|
||||||
| `,tl` | Toggle to last tab |
|
| `,tl` | Toggle to last tab |
|
||||||
|
| `,ev` / `,sv` | Edit / reload `~/.vimrc` |
|
||||||
|
| `,cp` / `,cf` | Copy file path / filename to clipboard |
|
||||||
|
| `,*` | Search and replace word under cursor |
|
||||||
|
| `,F` | Re-indent entire file |
|
||||||
|
| `,W` | Strip trailing whitespace |
|
||||||
|
| `,ms` | Open scratch markdown buffer |
|
||||||
|
| `,ss` | Toggle spell checking |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
55
install.sh
55
install.sh
|
|
@ -1,23 +1,41 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# install.sh - chopsticks vim configuration installer
|
# install.sh - chopsticks vim configuration installer
|
||||||
# Usage: cd /path/to/chopsticks && ./install.sh [--yes]
|
# Usage: cd /path/to/chopsticks && ./install.sh [--yes] [--help]
|
||||||
#
|
#
|
||||||
# --yes non-interactive: install all optional components automatically
|
# --yes non-interactive: install all optional components automatically
|
||||||
|
# --help show this help and exit
|
||||||
|
|
||||||
set -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
AUTO_YES=0
|
AUTO_YES=0
|
||||||
[[ "${1:-}" == "--yes" ]] && AUTO_YES=1
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--yes) AUTO_YES=1 ;;
|
||||||
|
--help|-h)
|
||||||
|
echo "Usage: ./install.sh [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --yes Non-interactive mode: select all defaults automatically"
|
||||||
|
echo " --help Show this help and exit"
|
||||||
|
echo ""
|
||||||
|
echo "Supported platforms: macOS (brew), Debian/Ubuntu (apt), Arch (pacman), Fedora (dnf)"
|
||||||
|
exit 0 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
# ── Colours ───────────────────────────────────────────────────────────────────
|
# ── Colours (respect NO_COLOR and non-TTY) ───────────────────────────────────
|
||||||
GREEN='\033[0;32m'
|
if [[ -t 1 ]] && [[ -z "${NO_COLOR:-}" ]]; then
|
||||||
YELLOW='\033[1;33m'
|
GREEN='\033[0;32m'
|
||||||
RED='\033[0;31m'
|
YELLOW='\033[1;33m'
|
||||||
BOLD='\033[1m'
|
RED='\033[0;31m'
|
||||||
CYAN='\033[0;36m'
|
BOLD='\033[1m'
|
||||||
DIM='\033[2m'
|
CYAN='\033[0;36m'
|
||||||
NC='\033[0m'
|
DIM='\033[2m'
|
||||||
|
NC='\033[0m'
|
||||||
|
else
|
||||||
|
GREEN='' YELLOW='' RED='' BOLD='' CYAN='' DIM='' NC=''
|
||||||
|
fi
|
||||||
|
|
||||||
ok() { echo -e "${GREEN}[OK]${NC} $1"; }
|
ok() { echo -e "${GREEN}[OK]${NC} $1"; }
|
||||||
warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
warn() { echo -e "${YELLOW}[!]${NC} $1"; }
|
||||||
|
|
@ -50,13 +68,14 @@ ask() {
|
||||||
|
|
||||||
# ── Error trap ────────────────────────────────────────────────────────────────
|
# ── Error trap ────────────────────────────────────────────────────────────────
|
||||||
on_error() {
|
on_error() {
|
||||||
echo -e "\n${RED}[FATAL]${NC} Unexpected error at line ${BASH_LINENO[0]}." >&2
|
echo -e "\n${RED}[FATAL]${NC} Command '${BASH_COMMAND}' failed at line ${BASH_LINENO[0]}." >&2
|
||||||
echo " To get a full debug log:" >&2
|
echo " To get a full debug log:" >&2
|
||||||
echo " ./install.sh 2>&1 | tee /tmp/chopsticks-install.log" >&2
|
echo " ./install.sh 2>&1 | tee /tmp/chopsticks-install.log" >&2
|
||||||
echo " Report issues: https://github.com/m1ngsama/chopsticks/issues" >&2
|
echo " Report issues: https://github.com/m1ngsama/chopsticks/issues" >&2
|
||||||
}
|
}
|
||||||
trap on_error ERR
|
trap on_error ERR
|
||||||
trap 'rm -f /tmp/chopsticks-hadolint /tmp/chopsticks-marksman 2>/dev/null' EXIT
|
_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/chopsticks-XXXXXX")
|
||||||
|
trap 'rm -rf "$_TMPDIR" 2>/dev/null' EXIT
|
||||||
|
|
||||||
# ── Safe download helper ──────────────────────────────────────────────────────
|
# ── Safe download helper ──────────────────────────────────────────────────────
|
||||||
safe_download() {
|
safe_download() {
|
||||||
|
|
@ -604,7 +623,7 @@ elif [[ $HAS_APT -eq 1 ]]; then
|
||||||
else
|
else
|
||||||
_do_binary_apt "hadolint" hadolint "$_I_HADOLINT" \
|
_do_binary_apt "hadolint" hadolint "$_I_HADOLINT" \
|
||||||
"https://github.com/hadolint/hadolint/releases/download/${HVER}/hadolint-Linux-${HARCH}" \
|
"https://github.com/hadolint/hadolint/releases/download/${HVER}/hadolint-Linux-${HARCH}" \
|
||||||
/tmp/chopsticks-hadolint
|
"$_TMPDIR/hadolint"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
skip "hadolint"; SKIPPED+=("hadolint")
|
skip "hadolint"; SKIPPED+=("hadolint")
|
||||||
|
|
@ -621,7 +640,7 @@ elif [[ $HAS_APT -eq 1 ]]; then
|
||||||
else
|
else
|
||||||
_do_binary_apt "marksman" marksman "$_I_MARKSMAN" \
|
_do_binary_apt "marksman" marksman "$_I_MARKSMAN" \
|
||||||
"https://github.com/artempyanykh/marksman/releases/download/${MVER}/marksman-linux-${MARCH}" \
|
"https://github.com/artempyanykh/marksman/releases/download/${MVER}/marksman-linux-${MARCH}" \
|
||||||
/tmp/chopsticks-marksman
|
"$_TMPDIR/marksman"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
skip "marksman"; SKIPPED+=("marksman")
|
skip "marksman"; SKIPPED+=("marksman")
|
||||||
|
|
@ -714,8 +733,10 @@ else
|
||||||
if command -v "$check" >/dev/null 2>&1; then
|
if command -v "$check" >/dev/null 2>&1; then
|
||||||
ok "$pkg (already installed)"; return
|
ok "$pkg (already installed)"; return
|
||||||
fi
|
fi
|
||||||
if pip3 install --quiet "$pkg" 2>/dev/null || \
|
if pip3 install --quiet "$pkg" 2>/dev/null; then
|
||||||
pip3 install --quiet --break-system-packages "$pkg" 2>/dev/null; then
|
ok "$pkg"; INSTALLED+=("$pkg")
|
||||||
|
elif pip3 install --quiet --break-system-packages "$pkg" 2>/dev/null; then
|
||||||
|
warn "$pkg installed with --break-system-packages (consider using a virtualenv)"
|
||||||
ok "$pkg"; INSTALLED+=("$pkg")
|
ok "$pkg"; INSTALLED+=("$pkg")
|
||||||
else
|
else
|
||||||
fail "$pkg"; FAILED+=("$pkg")
|
fail "$pkg"; FAILED+=("$pkg")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue