Move LSP navigation to native-first mappings (#26)

This commit is contained in:
m1ngsama 2026-05-13 13:18:08 +08:00 committed by GitHub
parent 5544b74545
commit 2f7d488c8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 37 additions and 18 deletions

View file

@ -57,8 +57,8 @@ Ctrl+p fuzzy find file (git-aware)
## Write code ## Write code
``` ```
gd go to definition ,dd go to definition
K hover docs ,dk hover docs
,rn rename symbol ,rn rename symbol
,ca code action ,ca code action
,f format ,f format

View file

@ -96,8 +96,8 @@ active profile and only shows keys for enabled features.
Leader: `,` Leader: `,`
``` ```
Ctrl+p fuzzy find file gd go to definition Ctrl+p fuzzy find file ,dd go to definition
,rg ripgrep project K hover docs ,rg ripgrep project ,dk hover docs
,e toggle file sidebar ,cr run current file ,e toggle file sidebar ,cr run current file
,gs git status ,f format ,gs git status ,f format
,w save ,q quit ,w save ,q quit
@ -113,7 +113,7 @@ jk exit insert mode ,? cheat sheet
### Code ### Code
`gd` def | `gy` type | `gi` impl | `gr` refs | `K` docs | `[g` `]g` diagnostics | `[e` `]e` ALE errors | `,rn` rename | `,ca` action | `,o` outline | `,cr` run `,dd` def | `,dt` type | `,di` impl | `,dr` refs | `,dk` docs | `,dp` `,dn` diagnostics | `[e` `]e` ALE errors | `,rn` rename | `,ca` action | `,o` outline | `,cr` run
### Edit ### Edit

View file

@ -63,14 +63,14 @@ function! s:on_lsp_buffer_enabled() abort
setlocal signcolumn=yes setlocal signcolumn=yes
endif endif
nmap <buffer> gd <plug>(lsp-definition) nmap <buffer> <leader>dd <plug>(lsp-definition)
nmap <buffer> gy <plug>(lsp-type-definition) nmap <buffer> <leader>dt <plug>(lsp-type-definition)
nmap <buffer> gi <plug>(lsp-implementation) nmap <buffer> <leader>di <plug>(lsp-implementation)
nmap <buffer> gr <plug>(lsp-references) nmap <buffer> <leader>dr <plug>(lsp-references)
nmap <buffer> [g <plug>(lsp-previous-diagnostic) nmap <buffer> <leader>dp <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic) nmap <buffer> <leader>dn <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover) nmap <buffer> <leader>dk <plug>(lsp-hover)
nmap <buffer> <leader>rn <plug>(lsp-rename) nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> <leader>ca <plug>(lsp-code-action) nmap <buffer> <leader>ca <plug>(lsp-code-action)

View file

@ -343,16 +343,16 @@ function! s:CheatSheet() abort
if l:has_lsp if l:has_lsp
call extend(l:lines, [ call extend(l:lines, [
\ ' gd definition', \ ' ,dd definition',
\ ' gy type definition', \ ' ,dt type definition',
\ ' gi implementation', \ ' ,di implementation',
\ ' gr references', \ ' ,dr references',
\ ' K hover docs', \ ' ,dk hover docs',
\ ' ,rn rename', \ ' ,rn rename',
\ ' ,ca code action', \ ' ,ca code action',
\ ' ,f format', \ ' ,f format',
\ ' ,o outline', \ ' ,o outline',
\ ' [g ]g LSP diagnostics', \ ' ,dp ,dn LSP diagnostics',
\ ' :LspInstallServer setup LSP', \ ' :LspInstallServer setup LSP',
\ ' :ChopsticksStatus check LSP setup', \ ' :ChopsticksStatus check LSP setup',
\ ]) \ ])

View file

@ -237,6 +237,18 @@ check_vim() {
-c 'qa!' 2>&1 -c 'qa!' 2>&1
grep -Fq 'vim-lsp not installed; run :PlugInstall' "$TMP_ROOT/status-missing-plugin.txt" grep -Fq 'vim-lsp not installed; run :PlugInstall' "$TMP_ROOT/status-missing-plugin.txt"
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'doautocmd User lsp_buffer_enabled' \
-c 'if maparg("gd", "n") !=# "" || maparg("K", "n") !=# "" || maparg("gi", "n") !=# "" || maparg("gr", "n") !=# "" | cquit | endif' \
-c 'if maparg(",dd", "n") !~# "lsp-definition" | cquit | endif' \
-c 'if maparg(",dt", "n") !~# "lsp-type-definition" | cquit | endif' \
-c 'if maparg(",di", "n") !~# "lsp-implementation" | cquit | endif' \
-c 'if maparg(",dr", "n") !~# "lsp-references" | cquit | endif' \
-c 'if maparg(",dk", "n") !~# "lsp-hover" | cquit | endif' \
-c 'if maparg(",dp", "n") !~# "lsp-previous-diagnostic" | cquit | endif' \
-c 'if maparg(",dn", "n") !~# "lsp-next-diagnostic" | cquit | endif' \
-c 'qa!' 2>&1
XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \ XDG_CONFIG_HOME="$EMPTY_XDG" vim -u .vimrc -i NONE -es -N \
-c 'normal ,?' \ -c 'normal ,?' \
-c "redir! > $TMP_ROOT/cheat-default.txt" \ -c "redir! > $TMP_ROOT/cheat-default.txt" \
@ -244,6 +256,13 @@ check_vim() {
-c 'redir END' \ -c 'redir END' \
-c 'qa!' 2>&1 -c 'qa!' 2>&1
grep -Fq ':ChopsticksStatus check LSP setup' "$TMP_ROOT/cheat-default.txt" grep -Fq ':ChopsticksStatus check LSP setup' "$TMP_ROOT/cheat-default.txt"
grep -Fq ',dd definition' "$TMP_ROOT/cheat-default.txt"
grep -Fq ',dk hover docs' "$TMP_ROOT/cheat-default.txt"
grep -Fq ',dp ,dn LSP diagnostics' "$TMP_ROOT/cheat-default.txt"
if grep -Eq 'gd definition|K hover docs|\\[g \\]g LSP diagnostics' "$TMP_ROOT/cheat-default.txt"; then
cat "$TMP_ROOT/cheat-default.txt"
exit 1
fi
vim -u NONE -i NONE -es -N \ vim -u NONE -i NONE -es -N \
-c 'let g:chopsticks_profile = "minimal"' \ -c 'let g:chopsticks_profile = "minimal"' \