ui: redesign cheat sheet — vertical sidebar, one key per line, aligned

This commit is contained in:
m1ngsama 2026-04-22 14:41:09 +08:00
parent 51b10aa16d
commit fbb692846b

View file

@ -122,35 +122,88 @@ function! s:CheatSheet() abort
execute bufwinnr(l:name) . 'wincmd w | bd' execute bufwinnr(l:name) . 'wincmd w | bd'
return return
endif endif
execute 'botright new ' . l:name execute 'vertical botright new ' . l:name
vertical resize 42
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
setlocal nowrap nonumber norelativenumber signcolumn=no
setlocal winfixwidth
call setline(1, [ call setline(1, [
\ 'chopsticks — quick reference ,? toggle this sheet', \ ' chopsticks ,? close',
\ ' ─────────────────────────────',
\ '', \ '',
\ 'FILES Ctrl+p find | ,b buffers | ,rg grep | ,rG grep word', \ ' ── files ──────────────────',
\ ' ,e sidebar (cwd) | ,E sidebar (file dir) | ,, last file', \ ' Ctrl+p find file',
\ ' ,fh recent | ,fl lines | ,fc commands | ,fm marks', \ ' ,b buffers',
\ ' ,rg grep project',
\ ' ,rG grep word',
\ ' ,e sidebar (cwd)',
\ ' ,E sidebar (file dir)',
\ ' ,, last file',
\ ' ,fh recent files',
\ ' ,fl lines in buffer',
\ ' ,fc commands',
\ ' ,fm marks',
\ '', \ '',
\ 'CODE gd def | gy type | gi impl | gr refs | K docs', \ ' ── code ──────────────────',
\ ' ,rn rename | ,ca action | ,f format | ,o outline', \ ' gd definition',
\ ' [g ]g diagnostics | [e ]e ALE errors | ,cr run file', \ ' gy type definition',
\ ' gi implementation',
\ ' gr references',
\ ' K hover docs',
\ ' ,rn rename',
\ ' ,ca code action',
\ ' ,f format',
\ ' ,o outline',
\ ' ,cr run file',
\ ' [g ]g LSP diagnostics',
\ ' [e ]e ALE errors',
\ '', \ '',
\ 'EDIT gc comment | s+2ch jump | cs"'' surround | ,u undo tree', \ ' ── edit ──────────────────',
\ ' ,y clipboard yank | Alt+j/k move line | ,* replace word', \ ' gc comment',
\ ' ,F re-indent | ,W strip whitespace', \ ' s+2ch easymotion jump',
\ ' cs"'' surround',
\ ' ,u undo tree',
\ ' ,y clipboard yank',
\ ' Alt+j/k move line',
\ ' ,* replace word',
\ ' ,F re-indent file',
\ ' ,W strip whitespace',
\ '', \ '',
\ 'GIT ,gs status | ,gd diff | ,gb blame | ,gc commit', \ ' ── git ───────────────────',
\ ' ,gp push | ,gl pull | [x ]x conflict markers', \ ' ,gs status',
\ ' ,gd diff',
\ ' ,gb blame',
\ ' ,gc commit',
\ ' ,gp push',
\ ' ,gl pull',
\ ' [x ]x conflict markers',
\ '', \ '',
\ 'WINDOWS Ctrl+hjkl navigate | ,h ,l buffers | ,bd close buf', \ ' ── windows ───────────────',
\ ' ,z maximize | ,= ,- resize | ,tv ,th terminal', \ ' Ctrl+hjkl navigate splits',
\ ' ]q [q quickfix | ,qo ,qc open/close qf', \ ' ,h ,l prev / next buf',
\ ' ,bd close buffer',
\ ' ,z maximize toggle',
\ ' ,= ,- resize height',
\ ' ,tv ,th terminal v / h',
\ ' ]q [q next / prev qf',
\ ' ,qo ,qc open / close qf',
\ '', \ '',
\ 'TOGGLE F2 paste | F3 line# | F4 relative# | F6 invisible', \ ' ── toggle ────────────────',
\ ' ,ss spell | ,e sidebar', \ ' F2 paste mode',
\ ' F3 line numbers',
\ ' F4 relative numbers',
\ ' F6 invisible chars',
\ ' ,ss spell check',
\ '', \ '',
\ 'SURVIVAL ,w save | ,q quit | ,x save+quit | Ctrl+s save', \ ' ── survival ──────────────',
\ ' jk escape | :w!! sudo save | ,ev ,sv edit/reload vimrc', \ ' ,w save',
\ ' ,q quit',
\ ' ,x save + quit',
\ ' Ctrl+s save (any mode)',
\ ' jk exit insert',
\ ' :w!! sudo save',
\ ' ,ev edit vimrc',
\ ' ,sv reload vimrc',
\ ]) \ ])
setlocal nomodifiable readonly setlocal nomodifiable readonly
nnoremap <buffer> <silent> q :bd<CR> nnoremap <buffer> <silent> q :bd<CR>