feat: new keymap

main
sudo pacman -Syu 2023-07-04 13:24:03 +07:00
parent 71ecec2bbb
commit c7924022ba
2 changed files with 92 additions and 52 deletions

View File

@ -50,11 +50,6 @@
All configs are in All configs are in
<a href="https://github.com/haunt98/dotfiles">my dotfiles</a>. <a href="https://github.com/haunt98/dotfiles">my dotfiles</a>.
</p> </p>
<p>Use both <code>\</code> and <code>;</code> as leader key:</p>
<div class="highlight highlight-source-lua">
<pre>vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>;<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;<span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>'<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;<span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })</pre>
</div>
<p>Search multiple words:</p> <p>Search multiple words:</p>
<div class="highlight highlight-source-viml"> <div class="highlight highlight-source-viml">
<pre>:/<span class="pl-cce">\v</span>word1|word2|word3</pre> <pre>:/<span class="pl-cce">\v</span>word1|word2|word3</pre>
@ -102,22 +97,43 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
</ul> </ul>
</li> </li>
</ul> </ul>
<p>Keymap for plugin (sync with dotfiles):</p> <p>Use both <code>\</code> and <code>;</code> as leader key:</p>
<div class="highlight highlight-source-lua"> <div class="highlight highlight-source-lua">
<pre>vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;f<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:FZF&lt;CR&gt;<span class="pl-pds">"</span></span>) <pre>vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>;<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;Leader&gt;<span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;rg<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:FZFRg&lt;CR&gt;<span class="pl-pds">"</span></span>) vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>'<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;Leader&gt;<span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;cm<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:FZFCommands&lt;CR&gt;<span class="pl-pds">"</span></span>) vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>q<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:q&lt;CR&gt;<span class="pl-pds">"</span></span>)</pre>
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;C-n&gt;<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:NvimTreeToggle&lt;CR&gt;<span class="pl-pds">"</span></span>)
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:NvimTreeFindFile&lt;CR&gt;<span class="pl-pds">"</span></span>)
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>&lt;leader&gt;tr<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:lua MiniTrailspace.trim()&lt;CR&gt;<span class="pl-pds">"</span></span>)</pre>
</div> </div>
<ul> <ul>
<li> <li>
<p><code>&lt;Leader&gt;</code> prefix: prefer global keymap</p>
</li>
<li>
<p>
<code>&lt;Space&gt;</code> prefix: prefer lsp keymap, for coding of
course :D
</p>
</li>
<li>
<p>
With
<a href="https://github.com/ibhagwan/fzf-lua">ibhagwan/fzf-lua</a>:
</p>
<ul>
<li><code>&lt;Leader&gt;f</code>: find files</li>
<li><code>&lt;Leader&gt;rg</code>: grep files</li>
<li><code>&lt;Space&gt;s</code>: find lsp symbols</li>
</ul>
</li>
<li>
<p>
With With
<a href="https://github.com/nvim-tree/nvim-tree.lua" <a href="https://github.com/nvim-tree/nvim-tree.lua"
>nvim-tree/nvim-tree.lua</a >nvim-tree/nvim-tree.lua</a
>, inside nvim-tree: >, inside nvim-tree:
</p>
<ul> <ul>
<li><code>&lt;C-n&gt;</code>: toggle</li>
<li><code>&lt;Leader&gt;n</code>: locate file</li>
<li><code>a</code>: create</li> <li><code>a</code>: create</li>
<li><code>d</code>: delete</li> <li><code>d</code>: delete</li>
<li><code>r</code>: rename</li> <li><code>r</code>: rename</li>
@ -128,19 +144,32 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
</ul> </ul>
</li> </li>
<li> <li>
<p>
With
<a href="https://github.com/hrsh7th/nvim-cmp">hrsh7th/nvim-cmp</a>:
</p>
<ul>
<li><code>&lt;C-Space&gt;</code>: trigger completion</li>
</ul>
</li>
<li>
<p>
With With
<a href="https://github.com/lewis6991/gitsigns.nvim" <a href="https://github.com/lewis6991/gitsigns.nvim"
>lewis6991/gitsigns.nvim</a >lewis6991/gitsigns.nvim</a
>: >:
</p>
<ul> <ul>
<li><code>]c</code>, <code>[c</code>: next/previous git change</li> <li><code>]c</code>, <code>[c</code>: next/previous git change</li>
</ul> </ul>
</li> </li>
<li> <li>
<p>
With With
<a href="https://github.com/echasnovski/mini.nvim" <a href="https://github.com/echasnovski/mini.nvim"
>echasnovski/mini.nvim</a >echasnovski/mini.nvim</a
> >
</p>
<ul> <ul>
<li> <li>
With mini-bracketed With mini-bracketed
@ -175,20 +204,28 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
<li><code>sr</code>: replace surround</li> <li><code>sr</code>: replace surround</li>
</ul> </ul>
</li> </li>
<li>
With mini-trailspace
<ul>
<li><code>&lt;Leader&gt;tr</code>: trim trailing whitespace</li>
</ul>
</li>
</ul> </ul>
</li> </li>
<li> <li>
<p>
With With
<a href="https://github.com/neovim/nvim-lspconfig" <a href="https://github.com/neovim/nvim-lspconfig"
>neovim/nvim-lspconfig</a >neovim/nvim-lspconfig</a
> >
</p>
<ul> <ul>
<li><code>gd</code>: go to definition</li> <li><code>&lt;Space&gt;gd</code>: go to definition</li>
<li><code>gr</code>: go to references</li> <li><code>&lt;Space&gt;k</code>: hover</li>
<li><code>K</code>: hover</li>
<li><code>&lt;F2&gt;</code>: rename</li> <li><code>&lt;F2&gt;</code>: rename</li>
<li><code>&lt;space&gt;f</code>: format</li> <li><code>&lt;Space&gt;ca</code>: code action</li>
<li><code>&lt;space&gt;ca</code>: code action</li> <li><code>&lt;Space&gt;gr</code>: go to references</li>
<li><code>&lt;Space&gt;f</code>: format</li>
</ul> </ul>
</li> </li>
</ul> </ul>

View File

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