Neovim Tips for a Better Coding Experience — Part 2
Overview
I walked through with you the tips and tricks using tree-sitter
in my previous article. This article continues to explore how we can improve our coding experience using Neovim.
This article can be read independently from the other related articles.
- Neovim Tips for a Better Coding Experience
- Neovim Plugins for a Better Coding Experience — Part 3
- Neovim Plugins for a Better Coding Experience — Part 4
- Neovim Plugins for a Better Coding Experience — Part 5
Better Select
nvim-treehopper is a plugin using tree-sitter
that provides region selection using hints on the abstract syntax tree of a document. This is intended to be used for pending operator mappings.
Using packer.nvim
, I install and configure the plugin.
use {
"mfussenegger/nvim-treehopper",
config = function()
vim.cmd [[omap <silent> m :<C-U>lua require('tsht').nodes()<CR>]]
vim.cmd [[vnoremap <silent> m :lua require('tsht').nodes()<CR>]]
end,
}
Run luafile %
and :PackerInstall
to install them.
Now I can select the correct code block easily in Visual mode or use the Vim operators.
E.g., Using Visual mode or Vim operator, type “m” and you can select either the class or the function.
Better TODO
todo-comment. nvim is a Lua plugin to highlight and search for todo comments like TODO
, HACK
, BUG
, or keywords you defined in your codebase.
You can list the TODO in the quick-fix list, or using Trouble or Telescope.
use {
"folke/todo-comments.nvim",
requires = "nvim-lua/plenary.nvim",
config = function() require("todo-comments").setup {} end
}