Skip to content

Commit b497c2c

Browse files
committed
improve docs
1 parent e2fc483 commit b497c2c

File tree

9 files changed

+134
-127
lines changed

9 files changed

+134
-127
lines changed

src/components/doc_comps/Sidebar.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ export const sidebar_Items = [
1515
label: ["Configure", "i-line-md:cog-filled"],
1616
items: [
1717
["Walkthrough", "config/walkthrough"],
18-
["Snippets", "config/snippets"],
1918
["Manage Plugins", "config/plugins"],
20-
["Syntax highlighting", "config/syntax"],
2119
["LSP Configuration", "config/lsp"],
2220
["Mappings", "config/mappings"],
2321
["UI Plugin", "config/nvchad_ui"],
24-
["Customize colors", "config/theming"],
22+
["Theming", "config/theming"],
23+
["Snippets", "config/snippets"],
2524
],
2625
},
2726

src/components/docpage/basic.tsx

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
const Basic = () => {
2+
return (
3+
<section grid="~ md:cols-2 gap3" un-children="3">
4+
<div grid="~ gap2" bg="red50 dark:dark3">
5+
<div
6+
grid="~ cols-3"
7+
items-center
8+
bg="red2 dark:dark4"
9+
p="3 y2"
10+
h-fit
11+
>
12+
<b />
13+
<span text="center lg" font="medium">
14+
NvChad
15+
</span>
16+
17+
<a href="https://github.com/NvChad/NvChad" ml="auto" target="_blank">
18+
<button bg="!slate6" text="white1" rounded="full">
19+
<div class="i-ri:link text-sm" />
20+
</button>
21+
</a>
22+
</div>
23+
24+
<ul>
25+
<li>This is the main repo for NvChad and its development.</li>
26+
27+
<li>It contains all the plugins, options, mappings, autocmds</li>
28+
29+
<li>
30+
All of its modules are in <code>/nvchad</code>
31+
</li>
32+
</ul>
33+
</div>
34+
35+
<div grid="~ gap2" bg="green50 dark:dark3">
36+
<div
37+
grid="~ cols-3"
38+
items-center
39+
bg="green2 dark:dark4"
40+
p="3 y2"
41+
h-fit
42+
>
43+
<b />
44+
<span text="center lg" font="medium">
45+
Starter
46+
</span>
47+
48+
<a href="https://github.com/NvChad/starter" ml="auto" target="_blank">
49+
<button bg="!slate6" text="white1" rounded="full">
50+
<div class="i-ri:link text-sm" />
51+
</button>
52+
</a>
53+
</div>
54+
55+
<ul>
56+
<li>Config which uses the NvChad repo as a plugin.</li>
57+
58+
<li>
59+
Users will be using the starter config as a base.
60+
</li>
61+
62+
<li>
63+
Imports nvchad modules, ex:
64+
<code>require("nvchad.options")</code>.
65+
</li>
66+
</ul>
67+
</div>
68+
</section>
69+
);
70+
};
71+
72+
export default Basic;

src/routes/docs/config/mappings.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@ The mapping configuration uses the nvim name shortcuts as:
2323
```lua
2424
local map = vim.keymap.set
2525

26-
map("i", "<C-k>", "<Up>", { desc = "Move up" })
26+
map("n", "<leader>ff", "<cmd> Telescope <cr>")
2727

2828
-- multiple modes
29-
map({ "i", "n" }, "<C-k>", "<Up>", { desc = "Move down" })
30-
31-
map("n", "<leader>ff", ":Telescope <cr>")
29+
map({ "i", "n" }, "<C-k>", "<Up>", { desc = "Move up" })
3230

3331
-- mapping with a lua function
3432
map("n", "<A-i>", function()
35-
require("nvchad.term").toggle({ pos = "sp", id ='abc' })
33+
-- do something
3634
end, { desc = "Terminal toggle floating" })
3735

38-
3936
-- Disable mappings
4037
local nomap = vim.keymap.del
4138

4239
nomap("i", "<C-k>")
4340
nomap("n", "<C-k>")
4441
```
42+
43+
<br/>
44+
45+
- Do know that lsp & gitsigns mappings wont be overrided by the above methods, because they dont load on startup & are lazy loaded. So put the lsp ones in `LspAttach` autocmd or right after your on_attach

src/routes/docs/config/plugins.mdx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ All NvChad default plugins will have `lazy = true` set. Therefore, if you want a
2525
local plugins = {
2626

2727
{ "elkowar/yuck.vim" , lazy = false }, -- load a plugin at startup
28+
{ "folke/which-key.nvim", enabled = false },
2829

2930
-- You can use any plugin specification from lazy.nvim
3031
{
3132
"Pocco81/TrueZen.nvim",
3233
cmd = { "TZAtaraxis", "TZMinimalist" },
3334
config = function()
34-
require "custom.configs.truezen" -- just an example path
35+
require "configs.truezen" -- just an example path
3536
end,
3637
},
3738

@@ -41,12 +42,7 @@ local plugins = {
4142
opts = {
4243
ensure_installed = {"html", "css", "bash"},
4344
},
44-
},
45-
46-
{
47-
"folke/which-key.nvim",
48-
enabled = false,
49-
},
45+
},
5046

5147
-- If your opts uses a function call ex: require*, then make opts spec a function
5248
-- should return the modified default config as well

src/routes/docs/config/syntax.mdx

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,21 @@
1+
import Basics from "~/components/docpage/basic";
2+
13
export const meta = {
24
title: "NvChad Walkthrough",
35
desc: "Walkthrough guide for NvChad"
46
}
57

6-
# How does NvChad work?
7-
8-
## Understanding the basics
9-
10-
Before getting into the topic, first you should understand the `vim.tbl_deep_extend` function which is used for merging tables and their values recursively.
11-
12-
- The function `vim.tbl_deep_extend` is normally used to merge 2 tables, and its syntax looks like this:
13-
14-
```lua
15-
-- table 1
16-
local person = {
17-
name = "joe",
18-
age = 19,
19-
skills = {"python", "html"},
20-
}
21-
22-
-- table 2
23-
local someone = {
24-
name = "siduck",
25-
skills = {"js", "lua"},
26-
}
27-
28-
-- "force" will overwrite equal values from the someone table over the person table
29-
local result = vim.tbl_deep_extend("force", person, someone)
30-
31-
-- result :
32-
{
33-
name = "siduck",
34-
age = 19,
35-
skills = {"js", "lua"},
36-
}
8+
## How does NvChad work?
379

38-
-- The list tables wont merge cuz they dont have keys
39-
```
10+
> NvChad's starter repo is the actual config and it uses the main NvChad repo as a plugin
4011
41-
## Main Config Structure
42-
43-
- [NvChad/NvChad](https://github.com/NvChad/NvChad) repo, this contains plugins, options, mappings, autocmds.
44-
- [NvChad/starter](https://github.com/NvChad/starter) - This is a minimal config which shows how to use the nvchad repo as a plugin.
45-
- Users will be using the starter config or can create their own
46-
47-
config structure of the main nvchad repo :
48-
```lua
49-
├── lua/
50-
│ ├── nvchad/
51-
│ │ ├── autocmds.lua
52-
│ │ ├── mappings.lua
53-
│ │ └── options.lua
54-
│ ├── plugins/
55-
│ │ ├── init.lua
56-
│ │ └── ui.lua
57-
│ └── configs/
58-
│ ├── cmp.lua
59-
│ └── more..
60-
└── nvconfig.lua
61-
```
62-
<br/>
63-
- example module import, `require "nvchad.options"`
64-
- nvconfig.lua is the list of all options for both ui/base46 repo!
12+
<Basics/>
6513

6614
## Chadrc.lua
6715

68-
- This file is meant to have structure of [nvconfig.lua](https://github.com/NvChad/NvChad/blob/v2.5/lua/nvconfig.lua), check the nvconfig.lua for knowing all supported options.
69-
- So nvconfig returns a table of config and then merges chadrc's table.
70-
- And you put this file in your `/lua` folder
16+
- This file is used to configure ui & base46 plugin
17+
- Its meant to have structure of [nvconfig.lua](https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua)
18+
- It should be in your config's `/lua` folder
7119

7220
## Themes
7321

@@ -81,3 +29,4 @@ If you want to know all the keymaps, you can run the following commands:
8129

8230
- `NvCheatsheet`
8331
- `Telescope keymaps`
32+

src/routes/docs/faq.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ nomap("n", "<tab>")
5050
5151
- You might be using a terminal that doesn't support true color. This problem is very common for those who use the default MacOS terminal, opt to use [iterm2](https://iterm2.com/) instead.
5252
53+
54+
## Syntax highlighting not working
55+
56+
- Make sure you have installed the treesitter parser for the language i.e `TSInstall lua`.
57+
5358
## CursorLine not showing
5459
5560
- We set it to only number by default, to have cursorline highlight shown, add :

src/routes/docs/quickstart/learn-lua.mdx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,36 @@ require("path")
258258

259259
-- both do the same thing
260260
```
261+
262+
## vim.tbl_deep_extend
263+
264+
This is a neovim function which is used for merging tables and their values recursively. Most plugins use it for merging config tables.
265+
266+
```lua
267+
-- table 1
268+
local person = {
269+
name = "joe",
270+
age = 19,
271+
skills = {"python", "html"},
272+
}
273+
274+
-- table 2
275+
local someone = {
276+
name = "siduck",
277+
skills = {"js", "lua"},
278+
}
279+
280+
-- "force" will overwrite equal values from the someone table over the person table
281+
local result = vim.tbl_deep_extend("force", person, someone)
282+
283+
-- result :
284+
{
285+
name = "siduck",
286+
age = 19,
287+
skills = {"js", "lua"},
288+
}
289+
290+
-- The list tables wont merge cuz they dont have keys
291+
```
292+
<br/>
293+
- check :h vim.tbl_deep_extend for more info

src/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ export const assign_heading_ids = () => {
3838

3939
headingElements?.forEach((item) => {
4040
item.id = item.innerText.replaceAll(/[ .&]/g, "_").toLowerCase();
41-
headings.push([item.localName.toLowerCase(), item.innerText]);
41+
42+
if (item.className != "nosidebar")
43+
headings.push([item.localName.toLowerCase(), item.innerText]);
4244
});
4345

4446
setHeadings(headings);

0 commit comments

Comments
 (0)