Migrate to vim.pack
This commit is contained in:
@@ -0,0 +1,74 @@
|
|||||||
|
# Neovim Config
|
||||||
|
|
||||||
|
Plugin management uses Neovim's native `vim.pack` (0.12+). No lazy.nvim.
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
- `init.lua` — entry point: `require("config")` then `require("plugins")`
|
||||||
|
- `lua/config/*.lua` — core settings (options, keymaps, LSP, autocmds)
|
||||||
|
- `lua/plugins/init.lua` — loads every plugin module in order, hosts `PackChanged` build hooks
|
||||||
|
- `lua/plugins/<name>.lua` — one self-contained module per plugin
|
||||||
|
- `nvim-pack-lock.json` — lock file, auto-updated by `vim.pack`, commit it
|
||||||
|
|
||||||
|
## Plugin module structure
|
||||||
|
|
||||||
|
Each `lua/plugins/<name>.lua` is self-contained: it declares its own `vim.pack.add` specs (including shared deps like `nvim-lua/plenary.nvim`, `nvim-tree/nvim-web-devicons`, `MunifTanjim/nui.nvim` — repeated adds are idempotent), then runs setup/config code directly. All plugins load eagerly at startup; there is no lazy loading.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://github.com/owner/repo.nvim" },
|
||||||
|
})
|
||||||
|
|
||||||
|
require("repo").setup({ ... })
|
||||||
|
```
|
||||||
|
|
||||||
|
## Adding a new plugin
|
||||||
|
|
||||||
|
1. Create `lua/plugins/<name>.lua` with a `vim.pack.add` spec and its config
|
||||||
|
2. Add `require("plugins.<name>")` to `lua/plugins/init.lua` (theme first if it affects colorscheme/highlights)
|
||||||
|
3. Restart nvim — the plugin is cloned automatically on first startup
|
||||||
|
|
||||||
|
## Spec conventions
|
||||||
|
|
||||||
|
- `version` — pin to a semver release: `version = vim.version.range("^1")`; use a branch name string (e.g. `version = "main"`) only when the plugin requires it (nvim-treesitter and its textobjects do)
|
||||||
|
- `name` — set only when the repo name is undesirable (e.g. `catppuccin/nvim` is installed as `catppuccin`)
|
||||||
|
- Shared deps listed explicitly in every module that needs them
|
||||||
|
|
||||||
|
## Build steps
|
||||||
|
|
||||||
|
There is no `build` field. Post-install/update steps run from the `PackChanged` autocmd in `lua/plugins/init.lua`, keyed by plugin name. It must stay registered before the first `vim.pack.add` call, so keep new hooks in that file:
|
||||||
|
|
||||||
|
```lua
|
||||||
|
-- in the PackChanged callback in lua/plugins/init.lua
|
||||||
|
if name == "my-plugin" and (kind == "install" or kind == "update") then
|
||||||
|
vim.system({ "make" }, { cwd = path })
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Current hooks: `make` for telescope-fzf-native, parser `update` for nvim-treesitter.
|
||||||
|
|
||||||
|
## Useful commands
|
||||||
|
|
||||||
|
`vim.pack` has no `:Pack*` user commands — everything goes through `:lua`. Plugin names are the installed directory names (e.g. `telescope-fzf-native.nvim`).
|
||||||
|
|
||||||
|
- `:lua vim.pack.update()` — fetch and update all plugins to their pinned version (or latest branch), updating `nvim-pack-lock.json`
|
||||||
|
- `:lua vim.pack.update({ "gitsigns.nvim" })` — update a single plugin
|
||||||
|
- `:lua vim.pack.update(nil, { offline = true })` — update using cached refs, no network fetch
|
||||||
|
- `:lua vim.pack.update(nil, { target = "lockfile" })` — restore all plugins to the revisions in `nvim-pack-lock.json` (rollback)
|
||||||
|
- `:lua vim.pack.get()` — list all installed plugins with spec, path, revision, active status
|
||||||
|
- `:lua vim.pack.add({ { src = "https://github.com/owner/repo.nvim" } })` — install/register a plugin on the fly (restart required to persist in config)
|
||||||
|
- `:lua vim.pack.del("name")` — delete a plugin directory and its lock entry
|
||||||
|
|
||||||
|
## Updating / removing
|
||||||
|
|
||||||
|
- Update everything: `:lua vim.pack.update()` (see commands above for variants)
|
||||||
|
- Remove a plugin: delete its entry from `vim.pack.add` calls and its `lua/plugins/<name>.lua` + require in `lua/plugins/init.lua`, then run `:lua vim.pack.del("name")` to delete the directory and lock entry
|
||||||
|
|
||||||
|
## Pitfalls
|
||||||
|
|
||||||
|
- First startup installs missing plugins and asks for confirmation — expected behavior, not an error
|
||||||
|
- The first `vim.pack.add` call in a session triggers installs, so `PackChanged` hooks must be registered in `lua/plugins/init.lua` before the requires
|
||||||
|
- Only install actual Neovim plugins via `vim.pack` — CLI tools (e.g. `fd`, `ripgrep`) must not be added
|
||||||
|
- Plugins already on disk are not re-checked against their spec on startup; run `vim.pack.update()` to sync revisions
|
||||||
@@ -2,19 +2,4 @@ vim.g.mapleader = " "
|
|||||||
vim.g.maplocalleader = " "
|
vim.g.maplocalleader = " "
|
||||||
|
|
||||||
require("config")
|
require("config")
|
||||||
|
require("plugins")
|
||||||
-- Bootstrap lazy.nvim
|
|
||||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
|
||||||
if not vim.loop.fs_stat(lazypath) then
|
|
||||||
vim.fn.system({
|
|
||||||
"git", "clone", "--filter=blob:none",
|
|
||||||
"https://github.com/folke/lazy.nvim.git",
|
|
||||||
"--branch=stable",
|
|
||||||
lazypath,
|
|
||||||
})
|
|
||||||
end
|
|
||||||
vim.opt.rtp:prepend(lazypath)
|
|
||||||
|
|
||||||
require("lazy").setup("plugins", {
|
|
||||||
change_detection = { notify = false },
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"saghen/blink.cmp",
|
{ src = "https://github.com/saghen/blink.cmp", version = vim.version.range("^1") },
|
||||||
version = "^1",
|
})
|
||||||
event = "InsertEnter", -- Lazy's native equivalent of the manual InsertEnter augroup
|
|
||||||
config = function()
|
require("blink.cmp").setup({
|
||||||
require("blink.cmp").setup({
|
|
||||||
keymap = { preset = "super-tab" },
|
keymap = { preset = "super-tab" },
|
||||||
appearance = {
|
appearance = {
|
||||||
nerd_font_variant = "mono",
|
nerd_font_variant = "mono",
|
||||||
@@ -16,6 +15,4 @@ return {
|
|||||||
default = { "lsp", "path", "snippets", "buffer" },
|
default = { "lsp", "path", "snippets", "buffer" },
|
||||||
},
|
},
|
||||||
fuzzy = { implementation = "prefer_rust_with_warning" },
|
fuzzy = { implementation = "prefer_rust_with_warning" },
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"stevearc/conform.nvim",
|
{ src = "https://github.com/stevearc/conform.nvim" },
|
||||||
config = function()
|
})
|
||||||
require("conform").setup({
|
|
||||||
|
require("conform").setup({
|
||||||
formatters_by_ft = {
|
formatters_by_ft = {
|
||||||
lua = { "stylua" },
|
lua = { "stylua" },
|
||||||
go = { "goimports", "gofmt" },
|
go = { "goimports", "gofmt" },
|
||||||
@@ -22,46 +23,44 @@ return {
|
|||||||
default_format_opts = {
|
default_format_opts = {
|
||||||
lsp_format = "fallback",
|
lsp_format = "fallback",
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("FormatDisable", function(opts)
|
vim.api.nvim_create_user_command("FormatDisable", function(opts)
|
||||||
if opts.bang then
|
if opts.bang then
|
||||||
vim.b.disable_autoformat = true
|
vim.b.disable_autoformat = true
|
||||||
else
|
else
|
||||||
vim.g.disable_autoformat = true
|
vim.g.disable_autoformat = true
|
||||||
end
|
end
|
||||||
vim.notify("Autoformat disabled" .. (opts.bang and " (buffer)" or " (global)"), vim.log.levels.WARN)
|
vim.notify("Autoformat disabled" .. (opts.bang and " (buffer)" or " (global)"), vim.log.levels.WARN)
|
||||||
end, { desc = "Disable autoformat-on-save", bang = true })
|
end, { desc = "Disable autoformat-on-save", bang = true })
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("FormatEnable", function()
|
vim.api.nvim_create_user_command("FormatEnable", function()
|
||||||
vim.b.disable_autoformat = false
|
vim.b.disable_autoformat = false
|
||||||
vim.g.disable_autoformat = false
|
vim.g.disable_autoformat = false
|
||||||
vim.notify("Autoformat enabled", vim.log.levels.INFO)
|
vim.notify("Autoformat enabled", vim.log.levels.INFO)
|
||||||
end, { desc = "Re-enable autoformat-on-save" })
|
end, { desc = "Re-enable autoformat-on-save" })
|
||||||
|
|
||||||
local auto_format = true
|
local auto_format = true
|
||||||
|
|
||||||
vim.keymap.set("n", "<leader>uf", function()
|
vim.keymap.set("n", "<leader>uf", function()
|
||||||
auto_format = not auto_format
|
auto_format = not auto_format
|
||||||
if auto_format then
|
if auto_format then
|
||||||
vim.cmd("FormatEnable")
|
vim.cmd("FormatEnable")
|
||||||
else
|
else
|
||||||
vim.cmd("FormatDisable")
|
vim.cmd("FormatDisable")
|
||||||
end
|
end
|
||||||
end, { desc = "Toggle Autoformat" })
|
end, { desc = "Toggle Autoformat" })
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cn", "<cmd>ConformInfo<cr>", { desc = "Conform Info" })
|
vim.keymap.set({ "n", "v" }, "<leader>cn", "<cmd>ConformInfo<cr>", { desc = "Conform Info" })
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
|
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
|
||||||
require("conform").format({ async = true }, function(err, did_edit)
|
require("conform").format({ async = true }, function(err, did_edit)
|
||||||
if not err and did_edit then
|
if not err and did_edit then
|
||||||
vim.notify("Code formatted", vim.log.levels.INFO, { title = "Conform" })
|
vim.notify("Code formatted", vim.log.levels.INFO, { title = "Conform" })
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end, { desc = "Format buffer" })
|
end, { desc = "Format buffer" })
|
||||||
|
|
||||||
vim.keymap.set({ "n", "v" }, "<leader>cF", function()
|
vim.keymap.set({ "n", "v" }, "<leader>cF", function()
|
||||||
require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 })
|
require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 })
|
||||||
end, { desc = "Format Injected Langs" })
|
end, { desc = "Format Injected Langs" })
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
{
|
{ src = "https://github.com/lewis6991/gitsigns.nvim" },
|
||||||
"lewis6991/gitsigns.nvim",
|
{ src = "https://github.com/sindrets/diffview.nvim" },
|
||||||
config = function()
|
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||||
require("gitsigns").setup({
|
})
|
||||||
|
|
||||||
|
require("gitsigns").setup({
|
||||||
signs = {
|
signs = {
|
||||||
add = { text = "┃" },
|
add = { text = "┃" },
|
||||||
change = { text = "┃" },
|
change = { text = "┃" },
|
||||||
@@ -88,16 +90,11 @@ return {
|
|||||||
-- Text object
|
-- Text object
|
||||||
map({ "o", "x" }, "ih", gitsigns.select_hunk)
|
map({ "o", "x" }, "ih", gitsigns.select_hunk)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"sindrets/diffview.nvim",
|
|
||||||
dependencies = { "nvim-lua/plenary.nvim" },
|
|
||||||
config = function()
|
|
||||||
local actions = require("diffview.actions")
|
|
||||||
|
|
||||||
require("diffview").setup({
|
local actions = require("diffview.actions")
|
||||||
|
|
||||||
|
require("diffview").setup({
|
||||||
diff_binaries = false,
|
diff_binaries = false,
|
||||||
enhanced_diff_hl = false,
|
enhanced_diff_hl = false,
|
||||||
git_cmd = { "git" },
|
git_cmd = { "git" },
|
||||||
@@ -283,7 +280,4 @@ return {
|
|||||||
{ "n", "<esc>", actions.close, { desc = "Close help menu" } },
|
{ "n", "<esc>", actions.close, { desc = "Close help menu" } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
-- PackChanged hooks must be registered before the first vim.pack.add() call,
|
||||||
|
-- otherwise installs triggered during the initial startup would miss them.
|
||||||
|
vim.api.nvim_create_autocmd("PackChanged", {
|
||||||
|
callback = function(ev)
|
||||||
|
local name, kind, path = ev.data.spec.name, ev.data.kind, ev.data.path
|
||||||
|
if name == "telescope-fzf-native.nvim" and (kind == "install" or kind == "update") then
|
||||||
|
vim.system({ "make" }, { cwd = path })
|
||||||
|
elseif name == "nvim-treesitter" and (kind == "install" or kind == "update") then
|
||||||
|
if not ev.data.active then
|
||||||
|
vim.cmd.packadd("nvim-treesitter")
|
||||||
|
end
|
||||||
|
pcall(require("nvim-treesitter").update)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
require("plugins.theme")
|
||||||
|
require("plugins.treesitter")
|
||||||
|
require("plugins.blink")
|
||||||
|
require("plugins.whichkey")
|
||||||
|
require("plugins.lualine")
|
||||||
|
require("plugins.telescope")
|
||||||
|
require("plugins.neotree")
|
||||||
|
require("plugins.conform")
|
||||||
|
require("plugins.git")
|
||||||
|
require("plugins.markdown")
|
||||||
|
require("plugins.log-highlight")
|
||||||
|
require("plugins.zig")
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"fei6409/log-highlight.nvim",
|
{ src = "https://github.com/fei6409/log-highlight.nvim" },
|
||||||
}
|
})
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"nvim-lualine/lualine.nvim",
|
{ src = "https://github.com/nvim-lualine/lualine.nvim" },
|
||||||
dependencies = { "nvim-tree/nvim-web-devicons" },
|
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||||
config = function()
|
})
|
||||||
require("lualine").setup({
|
|
||||||
|
require("lualine").setup({
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
theme = "auto",
|
theme = "auto",
|
||||||
@@ -48,6 +49,4 @@ return {
|
|||||||
winbar = {},
|
winbar = {},
|
||||||
inactive_winbar = {},
|
inactive_winbar = {},
|
||||||
extensions = {},
|
extensions = {},
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"MeanderingProgrammer/render-markdown.nvim",
|
{ src = "https://github.com/MeanderingProgrammer/render-markdown.nvim" },
|
||||||
dependencies = {
|
{ src = "https://github.com/nvim-treesitter/nvim-treesitter" },
|
||||||
"nvim-treesitter/nvim-treesitter",
|
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||||
"nvim-tree/nvim-web-devicons",
|
})
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"nvim-neo-tree/neo-tree.nvim",
|
{ src = "https://github.com/nvim-neo-tree/neo-tree.nvim", version = vim.version.range("3.*") },
|
||||||
version = "3.*",
|
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||||
dependencies = {
|
{ src = "https://github.com/MunifTanjim/nui.nvim" },
|
||||||
"nvim-lua/plenary.nvim",
|
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||||
"MunifTanjim/nui.nvim",
|
})
|
||||||
"nvim-tree/nvim-web-devicons",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"nvim-telescope/telescope.nvim",
|
{ src = "https://github.com/nvim-telescope/telescope.nvim" },
|
||||||
dependencies = {
|
{ src = "https://github.com/nvim-lua/plenary.nvim" },
|
||||||
"nvim-lua/plenary.nvim",
|
{ src = "https://github.com/nvim-tree/nvim-web-devicons" },
|
||||||
"nvim-tree/nvim-web-devicons",
|
{ src = "https://github.com/nvim-telescope/telescope-fzf-native.nvim" },
|
||||||
{
|
})
|
||||||
"nvim-telescope/telescope-fzf-native.nvim",
|
|
||||||
build = "make",
|
local builtin = require("telescope.builtin")
|
||||||
},
|
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
|
||||||
},
|
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
|
||||||
config = function()
|
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
|
||||||
local builtin = require("telescope.builtin")
|
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
|
||||||
vim.keymap.set("n", "<leader>ff", builtin.find_files, { desc = "Telescope find files" })
|
|
||||||
vim.keymap.set("n", "<leader>fg", builtin.live_grep, { desc = "Telescope live grep" })
|
|
||||||
vim.keymap.set("n", "<leader>fb", builtin.buffers, { desc = "Telescope buffers" })
|
|
||||||
vim.keymap.set("n", "<leader>fh", builtin.help_tags, { desc = "Telescope help tags" })
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"catppuccin/nvim",
|
{ src = "https://github.com/catppuccin/nvim", name = "catppuccin" },
|
||||||
name = "catppuccin",
|
})
|
||||||
priority = 1000, -- Load before other plugins so colorscheme is set first
|
|
||||||
config = function()
|
vim.cmd("colorscheme catppuccin")
|
||||||
vim.cmd("colorscheme catppuccin")
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
{
|
{ src = "https://github.com/nvim-treesitter/nvim-treesitter", version = "main" },
|
||||||
"nvim-treesitter/nvim-treesitter",
|
{ src = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects", version = "main" },
|
||||||
branch = "main",
|
})
|
||||||
build = ":TSUpdate",
|
|
||||||
config = function()
|
require("nvim-treesitter").setup({})
|
||||||
require("nvim-treesitter").setup({})
|
require("nvim-treesitter").install({
|
||||||
require("nvim-treesitter").install({
|
|
||||||
"bash", "blade", "c", "comment", "css", "diff", "dockerfile",
|
"bash", "blade", "c", "comment", "css", "diff", "dockerfile",
|
||||||
"fish", "gitcommit", "gitignore", "go", "gomod", "gosum", "gowork",
|
"fish", "gitcommit", "gitignore", "go", "gomod", "gosum", "gowork",
|
||||||
"html", "ini", "javascript", "jsdoc", "json", "lua", "luadoc",
|
"html", "ini", "javascript", "jsdoc", "json", "lua", "luadoc",
|
||||||
@@ -13,12 +12,12 @@ return {
|
|||||||
"proto", "python", "query", "regex", "rust", "scss", "sql",
|
"proto", "python", "query", "regex", "rust", "scss", "sql",
|
||||||
"terraform", "toml", "tsx", "typescript", "vim", "vimdoc",
|
"terraform", "toml", "tsx", "typescript", "vim", "vimdoc",
|
||||||
"xml", "yaml", "zig",
|
"xml", "yaml", "zig",
|
||||||
})
|
})
|
||||||
|
|
||||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||||
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("FileType", {
|
||||||
pattern = { "*" },
|
pattern = { "*" },
|
||||||
callback = function()
|
callback = function()
|
||||||
local filetype = vim.bo.filetype
|
local filetype = vim.bo.filetype
|
||||||
@@ -26,15 +25,9 @@ return {
|
|||||||
pcall(vim.treesitter.start)
|
pcall(vim.treesitter.start)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
},
|
require("nvim-treesitter-textobjects").setup({
|
||||||
{
|
|
||||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
|
||||||
branch = "main",
|
|
||||||
dependencies = { "nvim-treesitter/nvim-treesitter" },
|
|
||||||
config = function()
|
|
||||||
require("nvim-treesitter-textobjects").setup({
|
|
||||||
select = {
|
select = {
|
||||||
enable = true,
|
enable = true,
|
||||||
lookahead = true,
|
lookahead = true,
|
||||||
@@ -49,11 +42,11 @@ return {
|
|||||||
enable = true,
|
enable = true,
|
||||||
set_jumps = true,
|
set_jumps = true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- SELECT keymaps
|
-- SELECT keymaps
|
||||||
local sel = require("nvim-treesitter-textobjects.select")
|
local sel = require("nvim-treesitter-textobjects.select")
|
||||||
for _, map in ipairs({
|
for _, map in ipairs({
|
||||||
{ { "x", "o" }, "af", "@function.outer" },
|
{ { "x", "o" }, "af", "@function.outer" },
|
||||||
{ { "x", "o" }, "if", "@function.inner" },
|
{ { "x", "o" }, "if", "@function.inner" },
|
||||||
{ { "x", "o" }, "ac", "@class.outer" },
|
{ { "x", "o" }, "ac", "@class.outer" },
|
||||||
@@ -62,15 +55,15 @@ return {
|
|||||||
{ { "x", "o" }, "ia", "@parameter.inner" },
|
{ { "x", "o" }, "ia", "@parameter.inner" },
|
||||||
{ { "x", "o" }, "ad", "@comment.outer" },
|
{ { "x", "o" }, "ad", "@comment.outer" },
|
||||||
{ { "x", "o" }, "as", "@statement.outer" },
|
{ { "x", "o" }, "as", "@statement.outer" },
|
||||||
}) do
|
}) do
|
||||||
vim.keymap.set(map[1], map[2], function()
|
vim.keymap.set(map[1], map[2], function()
|
||||||
sel.select_textobject(map[3], "textobjects")
|
sel.select_textobject(map[3], "textobjects")
|
||||||
end, { desc = "Select " .. map[3] })
|
end, { desc = "Select " .. map[3] })
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MOVE keymaps
|
-- MOVE keymaps
|
||||||
local mv = require("nvim-treesitter-textobjects.move")
|
local mv = require("nvim-treesitter-textobjects.move")
|
||||||
for _, map in ipairs({
|
for _, map in ipairs({
|
||||||
{ { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" },
|
{ { "n", "x", "o" }, "]m", mv.goto_next_start, "@function.outer" },
|
||||||
{ { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" },
|
{ { "n", "x", "o" }, "[m", mv.goto_previous_start, "@function.outer" },
|
||||||
{ { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" },
|
{ { "n", "x", "o" }, "]]", mv.goto_next_start, "@class.outer" },
|
||||||
@@ -79,13 +72,10 @@ return {
|
|||||||
{ { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" },
|
{ { "n", "x", "o" }, "[M", mv.goto_previous_end, "@function.outer" },
|
||||||
{ { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
|
{ { "n", "x", "o" }, "]o", mv.goto_next_start, { "@loop.inner", "@loop.outer" } },
|
||||||
{ { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
|
{ { "n", "x", "o" }, "[o", mv.goto_previous_start, { "@loop.inner", "@loop.outer" } },
|
||||||
}) do
|
}) do
|
||||||
local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
|
local modes, lhs, fn, query = map[1], map[2], map[3], map[4]
|
||||||
local qstr = (type(query) == "table") and table.concat(query, ",") or query
|
local qstr = (type(query) == "table") and table.concat(query, ",") or query
|
||||||
vim.keymap.set(modes, lhs, function()
|
vim.keymap.set(modes, lhs, function()
|
||||||
fn(query, "textobjects")
|
fn(query, "textobjects")
|
||||||
end, { desc = "Move to " .. qstr })
|
end, { desc = "Move to " .. qstr })
|
||||||
end
|
end
|
||||||
end,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
return {
|
vim.pack.add({
|
||||||
"folke/which-key.nvim",
|
{ src = "https://github.com/folke/which-key.nvim" },
|
||||||
event = "VeryLazy",
|
})
|
||||||
config = function()
|
|
||||||
local wk = require("which-key")
|
local wk = require("which-key")
|
||||||
wk.setup({
|
wk.setup({
|
||||||
preset = "helix",
|
preset = "helix",
|
||||||
})
|
})
|
||||||
wk.add({
|
wk.add({
|
||||||
{ "<leader><tab>", group = "tabs" },
|
{ "<leader><tab>", group = "tabs" },
|
||||||
{ "<leader>c", group = "code" },
|
{ "<leader>c", group = "code" },
|
||||||
{ "<leader>d", group = "debug" },
|
{ "<leader>d", group = "debug" },
|
||||||
@@ -91,6 +91,4 @@ return {
|
|||||||
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" },
|
{ "<leader>q", "<cmd>q<cr>", desc = "Quit" },
|
||||||
{ "<leader>w", "<cmd>w<cr>", desc = "Write" },
|
{ "<leader>w", "<cmd>w<cr>", desc = "Write" },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
vim.pack.add({
|
||||||
|
{ src = "https://codeberg.org/ziglang/zig.vim" },
|
||||||
|
})
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
{
|
||||||
|
"plugins": {
|
||||||
|
"blink.cmp": {
|
||||||
|
"rev": "78336bc89ee5365633bcf754d93df01678b5c08f",
|
||||||
|
"src": "https://github.com/saghen/blink.cmp",
|
||||||
|
"version": "1.0.0 - 2.0.0"
|
||||||
|
},
|
||||||
|
"catppuccin": {
|
||||||
|
"rev": "79e2049a0fdf7ec840f8463fe1d962c94493196b",
|
||||||
|
"src": "https://github.com/catppuccin/nvim"
|
||||||
|
},
|
||||||
|
"conform.nvim": {
|
||||||
|
"rev": "619363c30309d29ffa631e67c8183f2a72caa373",
|
||||||
|
"src": "https://github.com/stevearc/conform.nvim"
|
||||||
|
},
|
||||||
|
"diffview.nvim": {
|
||||||
|
"rev": "4516612fe98ff56ae0415a259ff6361a89419b0a",
|
||||||
|
"src": "https://github.com/sindrets/diffview.nvim"
|
||||||
|
},
|
||||||
|
"gitsigns.nvim": {
|
||||||
|
"rev": "31d6fb2d618bca1482b9f274751ead5f03461408",
|
||||||
|
"src": "https://github.com/lewis6991/gitsigns.nvim"
|
||||||
|
},
|
||||||
|
"log-highlight.nvim": {
|
||||||
|
"rev": "b2e00cfd41ca94338265a595f3f3f423d9f9322e",
|
||||||
|
"src": "https://github.com/fei6409/log-highlight.nvim"
|
||||||
|
},
|
||||||
|
"lualine.nvim": {
|
||||||
|
"rev": "221ce6b2d999187044529f49da6554a92f740a96",
|
||||||
|
"src": "https://github.com/nvim-lualine/lualine.nvim"
|
||||||
|
},
|
||||||
|
"neo-tree.nvim": {
|
||||||
|
"rev": "83e7a2982fd12b9c3d35bc39dd5877cd91a02a61",
|
||||||
|
"src": "https://github.com/nvim-neo-tree/neo-tree.nvim",
|
||||||
|
"version": "3.0.0 - 4.0.0"
|
||||||
|
},
|
||||||
|
"nui.nvim": {
|
||||||
|
"rev": "de740991c12411b663994b2860f1a4fd0937c130",
|
||||||
|
"src": "https://github.com/MunifTanjim/nui.nvim"
|
||||||
|
},
|
||||||
|
"nvim-treesitter": {
|
||||||
|
"rev": "7b6cc8949f9999c5ed91436cbe24aa5f99c42025",
|
||||||
|
"src": "https://github.com/nvim-treesitter/nvim-treesitter"
|
||||||
|
},
|
||||||
|
"nvim-treesitter-textobjects": {
|
||||||
|
"rev": "898ee307df58f854d11cd7edd06472574d48014e",
|
||||||
|
"src": "https://github.com/nvim-treesitter/nvim-treesitter-textobjects",
|
||||||
|
"version": "'main'"
|
||||||
|
},
|
||||||
|
"nvim-web-devicons": {
|
||||||
|
"rev": "2ae6958df7ced50baac5035cec0c15799eedfbf7",
|
||||||
|
"src": "https://github.com/nvim-tree/nvim-web-devicons"
|
||||||
|
},
|
||||||
|
"plenary.nvim": {
|
||||||
|
"rev": "74b06c6c75e4eeb3108ec01852001636d85a932b",
|
||||||
|
"src": "https://github.com/nvim-lua/plenary.nvim"
|
||||||
|
},
|
||||||
|
"render-markdown.nvim": {
|
||||||
|
"rev": "f422cb5c6855f150e2ddcfaf44e7157b98b34f6a",
|
||||||
|
"src": "https://github.com/MeanderingProgrammer/render-markdown.nvim"
|
||||||
|
},
|
||||||
|
"telescope-fzf-native.nvim": {
|
||||||
|
"rev": "b25b749b9db64d375d782094e2b9dce53ad53a40",
|
||||||
|
"src": "https://github.com/nvim-telescope/telescope-fzf-native.nvim"
|
||||||
|
},
|
||||||
|
"telescope.nvim": {
|
||||||
|
"rev": "427b576c16792edad01a92b89721d923c19ad60f",
|
||||||
|
"src": "https://github.com/nvim-telescope/telescope.nvim"
|
||||||
|
},
|
||||||
|
"which-key.nvim": {
|
||||||
|
"rev": "3aab2147e74890957785941f0c1ad87d0a44c15a",
|
||||||
|
"src": "https://github.com/folke/which-key.nvim"
|
||||||
|
},
|
||||||
|
"zig.vim": {
|
||||||
|
"rev": "61109e5166f2bdb7578493a0220a92c43627fc82",
|
||||||
|
"src": "https://codeberg.org/ziglang/zig.vim"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user