From 00741211ab96725d50f7c0f20ad5ee2c1421388a Mon Sep 17 00:00:00 2001 From: Hau Nguyen Date: Sat, 10 Jun 2023 10:50:39 +0700 Subject: [PATCH] feat: more neovim workflow --- docs/2023-05-03-neovim.html | 115 +++++++++++++++++++++++++++++++++++- posts/2023-05-03-neovim.md | 63 +++++++++++++++++++- 2 files changed, 175 insertions(+), 3 deletions(-) diff --git a/docs/2023-05-03-neovim.html b/docs/2023-05-03-neovim.html index f3368ac..c63ca97 100644 --- a/docs/2023-05-03-neovim.html +++ b/docs/2023-05-03-neovim.html @@ -50,10 +50,121 @@ >My neovim workflow +

+ All configs are in + my dotfiles. +

+

Use both \ and ; as leader key.

Search multiple words:

-
-
:/\vword1|word2|word3
+
+
:/\vword1|word2|word3
+

Replace word:

+
+
:%s/word1/word2/g
+
+

Jump basic:

+ +

Jump advance:

+ +

Keymap for plugin (sync with dotfiles):

+
+
vim.keymap.set("n", "<leader>f", ":FZF<CR>")
+vim.keymap.set("n", "<leader>rg", ":Rg<CR>")
+vim.keymap.set("n", "<C-n>", ":NvimTreeToggle<CR>")
+vim.keymap.set("n", "<leader>n", ":NvimTreeFindFile<CR>")
+vim.keymap.set("n", "<leader>z", ":ZenMode<CR>")
+vim.keymap.set("n", "<leader>tr", ":lua MiniTrailspace.trim()<CR>")
+vim.keymap.set("n", "<F2>", ":GoRename<CR>")
+vim.keymap.set("n", "<leader>gf", ":GoFillStruct<CR>:w<CR>")
+vim.keymap.set("n", "<leader>gat", ":GoAlternate<CR>")
+vim.keymap.set("n", "<leader>gt", ":GoTest<CR>")
+vim.keymap.set("n", "<leader>gr", ":GoReferrers<CR>")
+vim.keymap.set("n", "<leader>gcv", ":GoCoverage<CR>")
+vim.keymap.set("n", "<leader>gdd", ":GoDeclsDir<CR>")
+
+ +

+ Reference +

+
Feel free to ask me via diff --git a/posts/2023-05-03-neovim.md b/posts/2023-05-03-neovim.md index 1e0a64f..fa92541 100644 --- a/posts/2023-05-03-neovim.md +++ b/posts/2023-05-03-neovim.md @@ -1,7 +1,68 @@ # My neovim workflow +All configs are in [my dotfiles](https://github.com/haunt98/dotfiles). + +Use both `\` and `;` as leader key. + Search multiple words: -```txt +```vim :/\vword1|word2|word3 ``` + +Replace word: + +```vim +:%s/word1/word2/g +``` + +Jump basic: + +- `gg`: first line +- `G`: last line +- `0`: first character of line +- `$`: last character of line +- `w`, `b`: word forward/backward + +Jump advance: + +- `CTRL-O`, `CTRL-I`: cursor position backward/forward +- : jump forward cursor position +- `(`, `)`: sentence backward/forward +- `{`, `}`: paragraph backward/forward +- `H`: top of screen +- `M`: middle of screen +- `L`: bottom of screen +- `CTRL-]`, `CTRL-T`: jump to tag/jump back from tag + - Support jump to golang definition with [fatih/vim-go](https://github.com/fatih/vim-go). + +Keymap for plugin (sync with dotfiles): + +```lua +vim.keymap.set("n", "f", ":FZF") +vim.keymap.set("n", "rg", ":Rg") +vim.keymap.set("n", "", ":NvimTreeToggle") +vim.keymap.set("n", "n", ":NvimTreeFindFile") +vim.keymap.set("n", "z", ":ZenMode") +vim.keymap.set("n", "tr", ":lua MiniTrailspace.trim()") +vim.keymap.set("n", "", ":GoRename") +vim.keymap.set("n", "gf", ":GoFillStruct:w") +vim.keymap.set("n", "gat", ":GoAlternate") +vim.keymap.set("n", "gt", ":GoTest") +vim.keymap.set("n", "gr", ":GoReferrers") +vim.keymap.set("n", "gcv", ":GoCoverage") +vim.keymap.set("n", "gdd", ":GoDeclsDir") +``` + +- With [echasnovski/mini.nvim mini-comment](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-comment.md) + - `gcc`: comment/uncomment current line + - `gc`: comment/uncomment selected lines +- With [echasnovski/mini.nvim mini-bracketed](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-bracketed.md) + - `[b`, `]b`: buffer backward/forward + - `[T`, `]T`, `[t`, `]t`: tree-sitter backward/forward + - Support more languages with [nvim-treesitter/nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) + +## Reference + +- [neovim Motion](https://neovim.io/doc/user/motion.html) +- [neovim Tagsrch](http://neovim.io/doc/user/tagsrch.html)