(Don't mind the cover image, I'm testing out stuff :P)
๐ Introduction
Do you don't like these default Neovim's Treesitter syntax?
I'm not explaining why it's better. Mainly because it's smarter. (wow, that didn't make sense)
alright' nuf' talkin' and let's start ๐ทโโ๏ธ configuring!
๐คจ Installing nvim-treesitter
If you've been following along your file structure should look like...
~/.config/nvim/
โโโ init.lua
โโโ lua/
โโโ core/
โ โโโ init.lua
โ โโโ options.lua
โโโ keymaps/
โโโ movement.lua
โโโ ...
โโโ plugins/
โโโ colorscheme.lua
โโโ ...
Now we're going to create a new configs
directory. (in the lua
directory) and in the configs directory, we're going to create sub directories for each "category" of a plugin's configuration. (e.g: UI related configurations in the configs.ui
directory, editor related configurations in the configs.editor
directory.)
So now our file structure should look like:
~/.config/nvim/
โโโ init.lua
โโโ lua/
โโโ core/
โ โโโ init.lua
โ โโโ options.lua
โโโ keymaps/
โโโ movement.lua
โโโ ...
โโโ plugins/
โโโ colorscheme.lua
โโโ treesitter.lua
โโโ ...
โโโ configs/ <- This!
โโโ ui/
โโโ editor/
โโโ ...
Alright. Now just create a new module in out plugins/
directory named treesitter.lua
(it could be anything)
And in it:
return {
"nvim-treesitter/nvim-treesitter.lua",
config = require("configs.editor.treesitter"),
event = "BufReadPost"
}
๐ทโโ๏ธ Configuring
And in our configs/editor
directory create a new treesitter.lua
module (again)
In it SLAM this in:
return function()
local status, treesitter = pcall(require, "nvim-treesitter.configs")
if not status then return end
treesitter.setup({
auto_install = true, -- Auto-install missing parsers. (once you open a file that requires it.)
highlight = {
enable = true -- Enable beautiful syntax highlighting!!!
}
})
end
Let's break this down. It pcalls
a require
statement that, wants a module called nvim-treesitter
more specifically, nvim-treesitter.configs
. It assigns it a local variable called treesitter
.
Then it setups nvim-treesitter
with some configuration.
Now quit Neovim (if you can) using :wqa
(Of course, if you can.)
And BAM, SUPER smart, beautiful syntax highlighting with the catppuccin colorscheme! Wait... Did you say "catppuccin"?
Alright kthxbye, imma get some catppuccin-mocha
. :wqa
Top comments (0)