From c7924022ba5369d16e4857059c6b289276ab57e6 Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Tue, 4 Jul 2023 13:24:03 +0700 Subject: [PATCH] feat: new keymap --- docs/2023-05-03-neovim.html | 103 ++++++++++++++++++++++++------------ posts/2023-05-03-neovim.md | 41 +++++++------- 2 files changed, 92 insertions(+), 52 deletions(-) diff --git a/docs/2023-05-03-neovim.html b/docs/2023-05-03-neovim.html index eec1f3c..3013dc4 100644 --- a/docs/2023-05-03-neovim.html +++ b/docs/2023-05-03-neovim.html @@ -50,11 +50,6 @@ All configs are in my dotfiles.

-

Use both \ and ; as leader key:

-
-
vim.keymap.set("n", ";", "<leader>", { remap = true })
-vim.keymap.set("n", "'", "<leader>", { remap = true })
-

Search multiple words:

:/\vword1|word2|word3
@@ -102,22 +97,43 @@ vim.keymap.set( -

Keymap for plugin (sync with dotfiles):

+

Use both \ and ; as leader key:

-
vim.keymap.set("n", "<leader>f", ":FZF<CR>")
-vim.keymap.set("n", "<leader>rg", ":FZFRg<CR>")
-vim.keymap.set("n", "<leader>cm", ":FZFCommands<CR>")
-vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
-vim.keymap.set("n", "<leader>n", ":NvimTreeFindFile<CR>")
-vim.keymap.set("n", "<leader>tr", ":lua MiniTrailspace.trim()<CR>")
+
vim.keymap.set("n", ";", "<Leader>", { remap = true })
+vim.keymap.set("n", "'", "<Leader>", { remap = true })
+vim.keymap.set("n", "q", ":q<CR>")
  • - With - nvim-tree/nvim-tree.lua, inside nvim-tree: +

    <Leader> prefix: prefer global keymap

    +
  • +
  • +

    + <Space> prefix: prefer lsp keymap, for coding of + course :D +

    +
  • +
  • +

    + With + ibhagwan/fzf-lua: +

      +
    • <Leader>f: find files
    • +
    • <Leader>rg: grep files
    • +
    • <Space>s: find lsp symbols
    • +
    +
  • +
  • +

    + With + nvim-tree/nvim-tree.lua, inside nvim-tree: +

    +
  • - With - neovim/nvim-lspconfig +

    + With + neovim/nvim-lspconfig +

      -
    • gd: go to definition
    • -
    • gr: go to references
    • -
    • K: hover
    • +
    • <Space>gd: go to definition
    • +
    • <Space>k: hover
    • <F2>: rename
    • -
    • <space>f: format
    • -
    • <space>ca: code action
    • +
    • <Space>ca: code action
    • +
    • <Space>gr: go to references
    • +
    • <Space>f: format
diff --git a/posts/2023-05-03-neovim.md b/posts/2023-05-03-neovim.md index eb19246..2e90680 100644 --- a/posts/2023-05-03-neovim.md +++ b/posts/2023-05-03-neovim.md @@ -4,13 +4,6 @@ All configs are in [my dotfiles](https://github.com/haunt98/dotfiles). -Use both `\` and `;` as leader key: - -```lua -vim.keymap.set("n", ";", "", { remap = true }) -vim.keymap.set("n", "'", "", { remap = true }) -``` - Search multiple words: ```vim @@ -46,18 +39,24 @@ Jump advance: - `CTRL-]`, `CTRL-T`: jump to tag/jump back from tag - Support jump to Go definition with [fatih/vim-go](https://github.com/fatih/vim-go). -Keymap for plugin (sync with dotfiles): +Use both `\` and `;` as leader key: ```lua -vim.keymap.set("n", "f", ":FZF") -vim.keymap.set("n", "rg", ":FZFRg") -vim.keymap.set("n", "cm", ":FZFCommands") -vim.keymap.set("n", "", ":NvimTreeToggle") -vim.keymap.set("n", "n", ":NvimTreeFindFile") -vim.keymap.set("n", "tr", ":lua MiniTrailspace.trim()") +vim.keymap.set("n", ";", "", { remap = true }) +vim.keymap.set("n", "'", "", { remap = true }) +vim.keymap.set("n", "q", ":q") ``` +- `` prefix: prefer global keymap +- `` prefix: prefer lsp keymap, for coding of course :D + +- With [ibhagwan/fzf-lua](https://github.com/ibhagwan/fzf-lua): + - `f`: find files + - `rg`: grep files + - `s`: find lsp symbols - With [nvim-tree/nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua), inside nvim-tree: + - ``: toggle + - `n`: locate file - `a`: create - `d`: delete - `r`: rename @@ -65,6 +64,8 @@ vim.keymap.set("n", "tr", ":lua MiniTrailspace.trim()") - `c`: copy - `p`: paste - `U`: toggle hidden +- With [hrsh7th/nvim-cmp](https://github.com/hrsh7th/nvim-cmp): + - ``: trigger completion - With [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim): - `]c`, `[c`: next/previous git change - With [echasnovski/mini.nvim](https://github.com/echasnovski/mini.nvim) @@ -79,13 +80,15 @@ vim.keymap.set("n", "tr", ":lua MiniTrailspace.trim()") - `sa`: add surround - `sd`: delete surround - `sr`: replace surround + - With mini-trailspace + - `tr`: trim trailing whitespace - With [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig) - - `gd`: go to definition - - `gr`: go to references - - `K`: hover + - `gd`: go to definition + - `k`: hover - ``: rename - - `f`: format - - `ca`: code action + - `ca`: code action + - `gr`: go to references + - `f`: format ## Reference