Skip to content

Commit e45dde8

Browse files
chore(build): auto-generate docs
1 parent 978784b commit e45dde8

2 files changed

Lines changed: 23 additions & 24 deletions

File tree

docs/configuration/general.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ opt.fillchars = {
120120
diff = "",
121121
eob = " ",
122122
}
123-
opt.foldexpr = "v:lua.LazyVim.ui.foldexpr()" -- treesitter folds
123+
opt.foldexpr = "v:lua.LazyVim.treesitter.foldexpr()" -- treesitter folds
124124
opt.foldlevel = 99
125125
opt.foldmethod = "expr"
126126
opt.foldtext = ""
@@ -130,7 +130,7 @@ opt.grepformat = "%f:%l:%c:%m"
130130
opt.grepprg = "rg --vimgrep"
131131
opt.ignorecase = true -- Ignore case
132132
opt.inccommand = "nosplit" -- preview incremental substitute
133-
opt.indentexpr = "v:lua.LazyVim.ui.indentexpr()" -- treesitter indents
133+
opt.indentexpr = "v:lua.LazyVim.treesitter.indentexpr()" -- treesitter indents
134134
opt.jumpoptions = "view"
135135
opt.laststatus = 3 -- global statusline
136136
opt.linebreak = true -- Wrap lines at convenient points

docs/plugins/treesitter.md

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import TabItem from '@theme/TabItem';
1818

1919
```lua
2020
opts = {
21+
-- LazyVim config for treesitter
2122
ensure_installed = {
2223
"bash",
2324
"c",
@@ -69,7 +70,9 @@ opts = {
6970
event = { "LazyFile", "VeryLazy" },
7071
cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" },
7172
opts_extend = { "ensure_installed" },
73+
---@class lazyvim.TSConfig: TSConfig
7274
opts = {
75+
-- LazyVim config for treesitter
7376
ensure_installed = {
7477
"bash",
7578
"c",
@@ -97,43 +100,39 @@ opts = {
97100
"yaml",
98101
},
99102
},
100-
---@param plugin LazyPlugin
101-
---@param opts TSConfig
102-
config = function(plugin, opts)
103-
if vim.fn.executable("tree-sitter") == 0 then
104-
LazyVim.error({
103+
---@param opts lazyvim.TSConfig
104+
config = function(_, opts)
105+
local TS = require("nvim-treesitter")
106+
107+
-- some quick sanity checks
108+
if not TS.get_installed then
109+
return LazyVim.error("Please use `:Lazy` and update `nvim-treesitter`")
110+
elseif vim.fn.executable("tree-sitter") == 0 then
111+
return LazyVim.error({
105112
"**treesitter-main** requires the `tree-sitter` CLI executable to be installed.",
106113
"Run `:checkhealth nvim-treesitter` for more information.",
107114
})
108-
return
109-
end
110-
if type(opts.ensure_installed) ~= "table" then
111-
LazyVim.error("`nvim-treesitter` opts.ensure_installed must be a table")
115+
elseif type(opts.ensure_installed) ~= "table" then
116+
return LazyVim.error("`nvim-treesitter` opts.ensure_installed must be a table")
112117
end
113118

114-
local TS = require("nvim-treesitter")
115-
if not TS.get_installed then
116-
LazyVim.error("Please use `:Lazy` and update `nvim-treesitter`")
117-
return
118-
end
119+
-- setup treesitter
119120
TS.setup(opts)
120121

121-
local needed = LazyVim.dedup(opts.ensure_installed --[[@as string[] ]])
122-
LazyVim.ui.installed = TS.get_installed("parsers")
123-
122+
-- install missing parsers
124123
local install = vim.tbl_filter(function(lang)
125-
return not LazyVim.ui.have(lang)
126-
end, needed)
127-
124+
return not LazyVim.treesitter.have(lang)
125+
end, opts.ensure_installed or {})
128126
if #install > 0 then
129127
TS.install(install, { summary = true }):await(function()
130-
LazyVim.ui.installed = TS.get_installed("parsers")
128+
LazyVim.treesitter.get_installed(true) -- refresh the installed langs
131129
end)
132130
end
133131

132+
-- treesitter highlighting
134133
vim.api.nvim_create_autocmd("FileType", {
135134
callback = function(ev)
136-
if LazyVim.ui.have(ev.match) then
135+
if LazyVim.treesitter.have(ev.match) then
137136
pcall(vim.treesitter.start)
138137
end
139138
end,

0 commit comments

Comments
 (0)