nvim: sync latest dotfiles
parent
e0eb2c5483
commit
25b5ff72f9
|
@ -156,12 +156,7 @@
|
|||
<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><Leader><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><Leader><span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })</pre>
|
||||
</div>
|
||||
<p>Misc keymap:</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>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>nzz<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>N<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Nzz<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<CR><span class="pl-pds">"</span></span>)</pre>
|
||||
</div>
|
||||
<p>Ground rules:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<p><code><Leader></code> prefix: prefer global keymap</p>
|
||||
|
@ -179,8 +174,21 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
|
|||
</p>
|
||||
<ul>
|
||||
<li><code><Leader>f</code>: find files</li>
|
||||
<li><code><Leader>l</code>: find lines</li>
|
||||
<li><code><Leader>rg</code>: grep files</li>
|
||||
<li><code><Space>s</code>: find lsp symbols</li>
|
||||
<li>
|
||||
With
|
||||
<a href="https://github.com/neovim/nvim-lspconfig"
|
||||
>neovim/nvim-lspconfig</a
|
||||
>
|
||||
helps:
|
||||
<ul>
|
||||
<li><code><Space>s</code>: find lsp symbols</li>
|
||||
<li><code><Space>d</code>: go to definition</li>
|
||||
<li><code><Space>r</code>: go to references</li>
|
||||
<li><code><Space>i</code>: go to implementation</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -281,12 +289,6 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
|
|||
<li><code>sr</code>: replace surround</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
With mini-trailspace
|
||||
<ul>
|
||||
<li><code><Leader>tr</code>: trim trailing whitespace</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -294,17 +296,13 @@ vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span clas
|
|||
With
|
||||
<a href="https://github.com/neovim/nvim-lspconfig"
|
||||
>neovim/nvim-lspconfig</a
|
||||
>
|
||||
>:
|
||||
</p>
|
||||
<ul>
|
||||
<li><code><Space>e</code>: float diagnostic</li>
|
||||
<li><code><Space>d</code>: go to definition</li>
|
||||
<li><code><Space>k</code>: hover</li>
|
||||
<li><code><F2></code>: rename</li>
|
||||
<li><code><Space>ca</code>: code action</li>
|
||||
<li><code><Space>r</code>: go to references</li>
|
||||
<li><code><Space>i</code>: go to implementation</li>
|
||||
<li><code><Space>f</code>: format</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
@ -47,34 +47,33 @@
|
|||
re-write to cache
|
||||
</li>
|
||||
</ul>
|
||||
<div class="highlight highlight-source-mermaid">
|
||||
<pre><span class="pl-k">sequenceDiagram</span>
|
||||
<span class="pl-k">participant</span> <span class="pl-ent">other</span>
|
||||
<span class="pl-k">participant</span> <span class="pl-ent">service</span>
|
||||
<span class="pl-k">participant</span> <span class="pl-ent">cache</span>
|
||||
<span class="pl-k">participant</span> <span class="pl-ent">db</span>
|
||||
<pre lang="mermaid"><code>sequenceDiagram
|
||||
participant other
|
||||
participant service
|
||||
participant cache
|
||||
participant db
|
||||
|
||||
<span class="pl-ent">other </span><span class="pl-k">->></span> <span class="pl-ent">service</span><span class="pl-k">:</span> <span class="pl-s">get data</span>
|
||||
<span class="pl-k">activate</span> <span class="pl-ent">service</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">->></span> <span class="pl-ent">cache</span><span class="pl-k">:</span> <span class="pl-s">get data</span>
|
||||
<span class="pl-k">alt</span> <span class="pl-s">exist in cache</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">-->></span> <span class="pl-ent">other</span><span class="pl-k">:</span> <span class="pl-s">return data</span>
|
||||
<span class="pl-k">else</span> <span class="pl-s">not exist in cache</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">->></span> <span class="pl-ent">db</span><span class="pl-k">:</span> <span class="pl-s">get data</span>
|
||||
<span class="pl-k">alt</span> <span class="pl-s">exist data in db</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">-->></span> <span class="pl-ent">other</span><span class="pl-k">:</span> <span class="pl-s">return data</span>
|
||||
<span class="pl-k">else</span> <span class="pl-s">not exist data in db</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">-->></span> <span class="pl-ent">other</span><span class="pl-k">:</span> <span class="pl-s">return error not found</span>
|
||||
<span class="pl-k">end</span>
|
||||
<span class="pl-k">end</span>
|
||||
<span class="pl-k">deactivate</span> <span class="pl-ent">service</span>
|
||||
other ->> service: get data
|
||||
activate service
|
||||
service ->> cache: get data
|
||||
alt exist in cache
|
||||
service -->> other: return data
|
||||
else not exist in cache
|
||||
service ->> db: get data
|
||||
alt exist data in db
|
||||
service -->> other: return data
|
||||
else not exist data in db
|
||||
service -->> other: return error not found
|
||||
end
|
||||
end
|
||||
deactivate service
|
||||
|
||||
<span class="pl-ent">other </span><span class="pl-k">->></span> <span class="pl-ent">service</span><span class="pl-k">:</span> <span class="pl-s">set data</span>
|
||||
<span class="pl-k">activate</span> <span class="pl-ent">service</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">->></span> <span class="pl-ent">db</span><span class="pl-k">:</span> <span class="pl-s">set data</span>
|
||||
<span class="pl-ent">service </span><span class="pl-k">->></span> <span class="pl-ent">cache</span><span class="pl-k">:</span> <span class="pl-s">set data</span>
|
||||
<span class="pl-k">deactivate</span> <span class="pl-ent">service</span></pre>
|
||||
</div>
|
||||
other ->> service: set data
|
||||
activate service
|
||||
service ->> db: set data
|
||||
service ->> cache: set data
|
||||
deactivate service
|
||||
</code></pre>
|
||||
<p>It's good for general cases, for example with CRUD action.</p>
|
||||
<p>
|
||||
The bad things happen when cache and database are not consistent. For
|
||||
|
|
|
@ -97,21 +97,21 @@ vim.keymap.set("n", ";", "<Leader>", { remap = true })
|
|||
vim.keymap.set("n", "'", "<Leader>", { remap = true })
|
||||
```
|
||||
|
||||
Misc keymap:
|
||||
|
||||
```lua
|
||||
vim.keymap.set("n", "n", "nzz")
|
||||
vim.keymap.set("n", "N", "Nzz")
|
||||
vim.keymap.set("n", "q", ":q<CR>")
|
||||
```
|
||||
Ground rules:
|
||||
|
||||
- `<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>l`: find lines
|
||||
- `<Leader>rg`: grep files
|
||||
- `<Space>s`: find lsp symbols
|
||||
- With [neovim/nvim-lspconfig](https://github.com/neovim/nvim-lspconfig)
|
||||
helps:
|
||||
- `<Space>s`: find lsp symbols
|
||||
- `<Space>d`: go to definition
|
||||
- `<Space>r`: go to references
|
||||
- `<Space>i`: go to implementation
|
||||
- With [nvim-tree/nvim-tree.lua](https://github.com/nvim-tree/nvim-tree.lua),
|
||||
inside nvim-tree:
|
||||
- `<C-n>`: toggle
|
||||
|
@ -143,17 +143,11 @@ vim.keymap.set("n", "q", ":q<CR>")
|
|||
- `sa`: add surround
|
||||
- `sd`: delete 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):
|
||||
- `<Space>e`: float diagnostic
|
||||
- `<Space>d`: go to definition
|
||||
- `<Space>k`: hover
|
||||
- `<F2>`: rename
|
||||
- `<Space>ca`: code action
|
||||
- `<Space>r`: go to references
|
||||
- `<Space>i`: go to implementation
|
||||
- `<Space>f`: format
|
||||
|
||||
## References / Thanks
|
||||
|
||||
|
|
Loading…
Reference in New Issue