(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)