Skip to content

Deep dive

Deep dive with TJdeVries - NeoVim advent playlist from TJdeVries

:source %              # execute current buffer(file)
:lua                   # execute selection
:lua MyCoolFunction    # execute function

How NeoVim starts

06:45 start from scratch init.lua
09:35 run selected code

cat ~/.config/nvim/init.lua
cat ~/.config/nvim/lua/lazy-bootstrap.lua
cd ~/.local/share/nvim/

Our configuration starts with our init.lua.

~/.config/nvim-kickstart/init.lua
-- Set <space> as the leader key
-- See `:help mapleader`
--  NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.g.have_nerd_font = true
require("options")
require("keymaps")
-- [[ Install `lazy.nvim` plugin manager ]]
require("lazy-bootstrap")
require("lazy-plugins")
require("autocmds")

lazy.nvim (package management)

00:45 installation

require("config.lazy")
:echo nvim_list_runtime_paths()

The dots in require mening folders on disk. "config.lazy" means actualy the file lua/config/lazy.lua. All files must be within a main folder lua. And the lua folder must be within the runtimepath (rtp)

01:48 runtimepath (rtp)
03:30 lazy explained
13:00 how lazy configures (functions config and opts)

When a plugin is required, its getting loaded and setup(ops) is called. Also config() is called (loaded). It is better NOT to use the config function (see lazy.nvim website).

We do use a special version of the kickstart project which has seperatad files and lazy is loaded from the file ~/.config/nvim/lua/lazy-bootstrap.lua.

~/.config/nvim/lua/lazy-bootstrap.lua
-- [[ Install `lazy.nvim` plugin manager ]]
--    See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
   local lazyrepo = "https://github.com/folke/lazy.nvim.git"
   local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
   if vim.v.shell_error ~= 0 then
      error("Error cloning lazy.nvim:\n" .. out)
   end
end

Telescope

03:00 treesitter queries in neovim
04:00 treesitter plugin for loading queries
05:30 install plugin
09:24 :checkhealth treesitter
09:45 :Inspect
10:10 :InspectTree
11:45 change highligth color
12:40 open query editor

00:50 install telescope
01:38 :Telescope find_files
03:00 setting keymaps
05:15 :checkhealth telescope
05:50 install keymaps
06:00 install themes
07:50 default theme
09:05 Ctrl-/ show keymaps

make a query

(function_call) @fn