Skip to content

Commit f3a063e

Browse files
committed
Added opencode with its default config, Added lazy=false to treesitter, Added helpful comments to init.lua
1 parent 28d74e7 commit f3a063e

File tree

7 files changed

+252
-178
lines changed

7 files changed

+252
-178
lines changed

init.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,20 @@ require("core.mappings") -- Mappings
2828
require("core.settings") -- Editor settings
2929

3030
require("plugins.plugins") -- Plugins
31+
32+
33+
-- For the new config: 12.02.2026
34+
-- I need to use `opts` instead of `config` for plugins(specs as folke likes to call it.) Check out: `https://lazy.folke.io/spec`
35+
--
36+
-- This is good:
37+
-- { "folke/todo-comments.nvim", opts = {} },
38+
--
39+
-- This is bad:
40+
-- {
41+
-- "folke/todo-comments.nvim",
42+
-- config = function()
43+
-- require("todo-comments").setup({})
44+
-- end,
45+
-- },
46+
--
47+
-- Always use `opts` instead of `config` whenever possible, `config` is almost never needed.

lazy-lock.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"nvim-treesitter-textobjects": { "branch": "master", "commit": "5ca4aaa6efdcc59be46b95a3e876300cfead05ef" },
4848
"nvim-ts-autotag": { "branch": "main", "commit": "c4ca798ab95b316a768d51eaaaee48f64a4a46bc" },
4949
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
50+
"opencode.nvim": { "branch": "main", "commit": "a13db1c0364319d3ebde65030005dea9f8a198cc" },
5051
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
5152
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
5253
"rainbow-delimiters.nvim": { "branch": "master", "commit": "d6b802552cbe7d643a3b6b31f419c248d1f1e220" },
@@ -59,7 +60,6 @@
5960
"snake.nvim": { "branch": "main", "commit": "c0bc2cfb0822f2aa8649baa0bf66910efc7b03f3" },
6061
"strudel.nvim": { "branch": "main", "commit": "a6b9752b0084a20c37786b54eef2095bb31daff7" },
6162
"styler.nvim": { "branch": "main", "commit": "d73d868541a2536a96d057c793d53c50e5f407bb" },
62-
"surrealdb.nvim": { "branch": "main", "commit": "80ae2beb7e1443902e89728dd876f1811f6839f3" },
6363
"tabout.nvim": { "branch": "master", "commit": "9a3499480a8e53dcaa665e2836f287e3b7764009" },
6464
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6fea601bd2b694c6f2ae08a6c6fab14930c60e2c" },
6565
"telescope.nvim": { "branch": "master", "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" },

lua/plugins/extras.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Build so much volume that there would be no option than to be successful.
5151
(It is what makes us human, you know🤗)
5252
😀😁😇😚🤪🤑🤗🤭🫣🤫🤔🫡🤐🤨😶‍🌫️🫥😏😮‍💨🫨😴😪🤒🤮🥵🤯🥸😎🥹😭😤🥱😡😂🥰
5353
54-
54+
Ain't nobody else that can do what you do the way you do.
5555
5656
5757

lua/plugins/opencode.lua

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
return {
2+
"nickjvandyke/opencode.nvim",
3+
dependencies = {
4+
-- Recommended for `ask()` and `select()`.
5+
-- Required for `snacks` provider.
6+
---@module 'snacks' <- Loads `snacks.nvim` types for configuration intellisense.
7+
{ "folke/snacks.nvim", opts = { input = {}, picker = {}, terminal = {} } },
8+
},
9+
config = function()
10+
---@type opencode.Opts
11+
vim.g.opencode_opts = {
12+
-- Your configuration, if any — see `lua/opencode/config.lua`, or "goto definition" on the type or field.
13+
}
14+
15+
-- Required for `opts.events.reload`.
16+
vim.o.autoread = true
17+
18+
-- Recommended/example keymaps.
19+
vim.keymap.set({ "n", "x" }, "<C-a>", function()
20+
require("opencode").ask("@this: ", { submit = true })
21+
end, { desc = "Ask opencode…" })
22+
23+
vim.keymap.set({ "n", "x" }, "<C-x>", function()
24+
require("opencode").select()
25+
end, { desc = "Execute opencode action…" })
26+
27+
vim.keymap.set({ "n", "t" }, "<C-.>", function()
28+
require("opencode").toggle()
29+
end, { desc = "Toggle opencode" })
30+
31+
vim.keymap.set({ "n", "x" }, "go", function()
32+
return require("opencode").operator("@this ")
33+
end, { desc = "Add range to opencode", expr = true })
34+
35+
vim.keymap.set("n", "goo", function()
36+
return require("opencode").operator("@this ") .. "_"
37+
end, { desc = "Add line to opencode", expr = true })
38+
39+
vim.keymap.set("n", "<S-C-u>", function()
40+
require("opencode").command("session.half.page.up")
41+
end, { desc = "Scroll opencode up" })
42+
43+
vim.keymap.set("n", "<S-C-d>", function()
44+
require("opencode").command("session.half.page.down")
45+
end, { desc = "Scroll opencode down" })
46+
47+
-- You may want these if you stick with the opinionated "<C-a>" and "<C-x>" above — otherwise consider "<leader>o…".
48+
vim.keymap.set("n", "+", "<C-a>", { desc = "Increment under cursor", noremap = true })
49+
vim.keymap.set("n", "-", "<C-x>", { desc = "Decrement under cursor", noremap = true })
50+
end,
51+
}

lua/plugins/plugins.lua

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
-- PLUGINS
1111

1212
return {
13-
require("plugins.ui"),
14-
require("plugins.colourscheme"),
15-
-- require("plugins.esp"),
16-
require("plugins.lsp"),
17-
require("plugins.completion"),
18-
require("plugins.snippets"),
19-
require("plugins.treesitter"),
20-
require("plugins.extras"),
21-
require("plugins.git"),
22-
require("plugins.telescope"),
23-
require("plugins.strudel"),
24-
-- require("plugins.keybinds"),
25-
-- require("plugins.surrealdb"),
26-
-- require("plugins.mcp"),
13+
require("plugins.ui"),
14+
require("plugins.colourscheme"),
15+
-- require("plugins.esp"),
16+
require("plugins.lsp"),
17+
require("plugins.completion"),
18+
require("plugins.snippets"),
19+
require("plugins.treesitter"),
20+
require("plugins.extras"),
21+
require("plugins.git"),
22+
require("plugins.telescope"),
23+
require("plugins.strudel"),
24+
-- require("plugins.keybinds"),
25+
-- require("plugins.surrealdb"),
26+
-- require("plugins.mcp"),
27+
require("plugins.opencode"),
2728
}

lua/plugins/treesitter.lua

Lines changed: 117 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -9,123 +9,128 @@
99
-- treesitter
1010

1111
return {
12-
"nvim-treesitter/nvim-treesitter",
13-
modules = {},
14-
build = ":TSUpdate",
15-
event = { "BufReadPost", "BufNewFile" },
16-
dependencies = {
17-
"nvim-treesitter/nvim-treesitter-textobjects",
18-
"nvim-treesitter/playground",
19-
},
20-
config = function()
21-
require("nvim-treesitter.configs").setup({
22-
ensure_installed = {
23-
"bash",
24-
"c",
25-
"cmake",
26-
"comment",
27-
"css",
28-
"diff",
29-
"dot",
30-
"hjson",
31-
"html",
32-
"http",
33-
"java",
34-
"javascript",
35-
"latex",
36-
"lua",
37-
"markdown",
38-
"markdown_inline",
39-
"php",
40-
"python",
41-
"query",
42-
"regex",
43-
"rust",
44-
"scss",
45-
"sql",
46-
"toml",
47-
"typescript",
48-
"vim",
49-
"vimdoc",
50-
"yaml",
51-
"scala",
52-
},
53-
sync_install = false,
54-
auto_install = true,
55-
ignore_install = {},
12+
"nvim-treesitter/nvim-treesitter",
13+
lazy = false,
14+
modules = {},
15+
build = ":TSUpdate",
16+
event = { "BufReadPost", "BufNewFile" },
17+
dependencies = {
18+
"nvim-treesitter/nvim-treesitter-textobjects",
19+
"nvim-treesitter/playground",
20+
},
21+
config = function()
22+
require("nvim-treesitter.configs").setup({
23+
ensure_installed = {
24+
"bash",
25+
"c",
26+
"cmake",
27+
"comment",
28+
"css",
29+
"diff",
30+
"dot",
31+
"hjson",
32+
"html",
33+
"http",
34+
"java",
35+
"javascript",
36+
"latex",
37+
"lua",
38+
"markdown",
39+
"markdown_inline",
40+
"php",
41+
"python",
42+
"query",
43+
"regex",
44+
"rust",
45+
"scss",
46+
"sql",
47+
"toml",
48+
"typescript",
49+
"vim",
50+
"vimdoc",
51+
"yaml",
52+
"scala",
53+
"dockerfile",
54+
"go",
55+
"typst",
56+
"zig",
57+
},
58+
sync_install = false,
59+
auto_install = true,
60+
ignore_install = {},
5661

57-
-- 🎨 Syntax highlighting
58-
highlight = {
59-
enable = true,
60-
disable = function(lang, buf)
61-
local max_filesize = 100 * 1024 -- 100 KB
62-
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
63-
if ok and stats and stats.size > max_filesize then
64-
return true
65-
end
66-
end,
67-
additional_vim_regex_highlighting = false,
68-
},
62+
-- 🎨 Syntax highlighting
63+
highlight = {
64+
enable = true,
65+
disable = function(lang, buf)
66+
local max_filesize = 100 * 1024 -- 100 KB
67+
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
68+
if ok and stats and stats.size > max_filesize then
69+
return true
70+
end
71+
end,
72+
additional_vim_regex_highlighting = false,
73+
},
6974

70-
-- 🧱 Smart indenting
71-
indent = {
72-
enable = true,
73-
},
75+
-- 🧱 Smart indenting
76+
indent = {
77+
enable = true,
78+
},
7479

75-
-- 🎯 Incremental selection
76-
incremental_selection = {
77-
enable = true,
78-
keymaps = {
79-
init_selection = "<C-space>",
80-
node_incremental = "<C-space>",
81-
node_decremental = "<BS>",
82-
scope_incremental = "<C-s>",
83-
},
84-
},
80+
-- 🎯 Incremental selection
81+
incremental_selection = {
82+
enable = true,
83+
keymaps = {
84+
init_selection = "<C-space>",
85+
node_incremental = "<C-space>",
86+
node_decremental = "<BS>",
87+
scope_incremental = "<C-s>",
88+
},
89+
},
8590

86-
-- 🧠 Textobjects (selection + movement)
87-
textobjects = {
88-
select = {
89-
enable = true,
90-
lookahead = true,
91-
keymaps = {
92-
["af"] = "@function.outer",
93-
["if"] = "@function.inner",
94-
["ac"] = "@class.outer",
95-
["ic"] = "@class.inner",
96-
},
97-
},
98-
move = {
99-
enable = true,
100-
set_jumps = true,
101-
goto_next_start = {
102-
["]f"] = "@function.outer",
103-
["]c"] = "@class.outer",
104-
},
105-
goto_previous_start = {
106-
["[f"] = "@function.outer",
107-
["[c"] = "@class.outer",
108-
},
109-
},
110-
},
111-
})
91+
-- 🧠 Textobjects (selection + movement)
92+
textobjects = {
93+
select = {
94+
enable = true,
95+
lookahead = true,
96+
keymaps = {
97+
["af"] = "@function.outer",
98+
["if"] = "@function.inner",
99+
["ac"] = "@class.outer",
100+
["ic"] = "@class.inner",
101+
},
102+
},
103+
move = {
104+
enable = true,
105+
set_jumps = true,
106+
goto_next_start = {
107+
["]f"] = "@function.outer",
108+
["]c"] = "@class.outer",
109+
},
110+
goto_previous_start = {
111+
["[f"] = "@function.outer",
112+
["[c"] = "@class.outer",
113+
},
114+
},
115+
},
116+
})
112117

113-
-- Optional: Enable smart folding
118+
-- Optional: Enable smart folding
114119

115-
vim.o.foldenable = false -- disable folding on startup
116-
vim.o.foldmethod = "expr"
117-
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
120+
vim.o.foldenable = false -- disable folding on startup
121+
vim.o.foldmethod = "expr"
122+
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
118123

119-
-- Keymap to toggle folding logic
120-
vim.keymap.set("n", "<leader>tf", function()
121-
if vim.o.foldmethod == "manual" then
122-
vim.o.foldmethod = "expr"
123-
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
124-
print("Folding enabled")
125-
else
126-
vim.o.foldmethod = "manual"
127-
print("Folding disabled")
128-
end
129-
end, { desc = "Toggle folding (Treesitter)" })
130-
end,
124+
-- Keymap to toggle folding logic
125+
vim.keymap.set("n", "<leader>tf", function()
126+
if vim.o.foldmethod == "manual" then
127+
vim.o.foldmethod = "expr"
128+
vim.o.foldexpr = "nvim_treesitter#foldexpr()"
129+
print("Folding enabled")
130+
else
131+
vim.o.foldmethod = "manual"
132+
print("Folding disabled")
133+
end
134+
end, { desc = "Toggle folding (Treesitter)" })
135+
end,
131136
}

0 commit comments

Comments
 (0)