Post

Which-Key Keymaps 정리

Which-Key Keymaps 정리

Which-Key Keymaps 정리

  • which-key는 등록된 keymap과 설정된 prefix 그룹을 탐지.
  • prefix 키 조합을 누르면 관련 명령어 그룹과 설명을 팝업으로 표시
키 조합그룹 / 설명비고
<leader><tab>Tabs탭 관련 명령어
<leader>cCode코드 관련 명령어
<leader>dDebug디버그 관련
<leader>dpProfiler성능 분석 관련
<leader>fFile / Find파일 열기 / 검색
<leader>gGitGit 명령어
<leader>ghHunksGit hunk 관련
<leader>qQuit / Session종료 및 세션 관련
<leader>sSearch검색 관련
<leader>uUIUI 관련 명령어
<leader>xDiagnostics / Quickfix진단 / 빠른 수정
[ Prev이전 항목 이동
] Next다음 항목 이동
gGoto이동 관련 (definition, references 등)
gsSurround텍스트 surround 관련
zFold코드 접기 / 펼치기
<leader>bBuffer버퍼 관련 (동적 확장)
<leader>wWindows창 관리 (<C-w> 기반)
gxOpen with system app단일 명령어 (url 위에서 하면 브라우저로 열기)
<leader>?Buffer Keymaps (which-key 메뉴 열기)현재 버퍼에서 메뉴 표시
<C-w><space>Window Hydra Mode창 관련 Hydra 모드 열기

설정 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  "folke/which-key.nvim",
  event = "VeryLazy",
  opts_extend = { "spec" },
  opts = {
    preset = "helix",
    defaults = {},
    spec = {
      {
        mode = { "n", "v" },
        { "<leader><tab>", group = "tabs" },
        { "<leader>c", group = "code" },
        { "<leader>d", group = "debug" },
        { "<leader>dp", group = "profiler" },
        { "<leader>f", group = "file/find" },
        { "<leader>g", group = "git" },
        { "<leader>gh", group = "hunks" },
        { "<leader>q", group = "quit/session" },
        { "<leader>s", group = "search" },
        { "<leader>u", group = "ui" },
        { "<leader>x", group = "diagnostics/quickfix" },
        { "[", group = "prev" },
        { "]", group = "next" },
        { "g", group = "goto" },
        { "gs", group = "surround" },
        { "z", group = "fold" },
        {
          "<leader>b",
          group = "buffer",
          expand = function()
            return require("which-key.extras").expand.buf()
          end,
        },
        {
          "<leader>w",
          group = "windows",
          proxy = "<c-w>",
          expand = function()
            return require("which-key.extras").expand.win()
          end,
        },
        -- better descriptions
        { "gx", desc = "Open with system app" },
      },
    },
  },
  keys = {
    {
      "<leader>?",
      function()
        require("which-key").show({ global = false })
      end,
      desc = "Buffer Keymaps (which-key)",
    },
    {
      "<c-w><space>",
      function()
        require("which-key").show({ keys = "<c-w>", loop = true })
      end,
      desc = "Window Hydra Mode (which-key)",
    },
  },
  config = function(_, opts)
    local wk = require("which-key")
    wk.setup(opts)
    if not vim.tbl_isempty(opts.defaults) then
      LazyVim.warn("which-key: opts.defaults is deprecated. Please use opts.spec instead.")
      wk.register(opts.defaults)
    end
  end,
}
This post is licensed under CC BY 4.0 by the author.