Member-only story
Neovim Tips for a Better Coding Experience
Overview
With the introduction of LSP (Language Server Protocol) support starting release 0.5, Neovim is gaining popularity among developers. Besides LSP, Neovim 0.5 adds support for tree-sitter, a tool that serves as a parsing library.
Parsing your code into a syntax tree allows for manipulating the structure of your code in a more intelligent way than is currently possible with regular expressions. This allows for improved and faster
- text objects and motions
- refactoring
- code navigation
- syntax highlighting
This article explores how we can leverage nvim-treesitter for a better coding experience.
This article can be read independently from the other related articles.
- Neovim Tips for a Better Coding Experience — Part 2
- 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 Text Objects and Motions
Using any plugin managers, install the following plugins.
E.g., Using packer.nvim
,
use {'nvim-treesitter/nvim-treesitter', run = ':TSUpdate'}
use {'nvim-treesitter/nvim-treesitter-textobjects'}
Run luafile %
and :PackerInstall
to install them.
For more information on Neovim configuration using Lua, you can check out this article. I assume you are already familiar with basic Neovim configuration using Lua.