[nvim] feat: switch to lazy.nvim

!!! BREAKING: packer.nvim is not used anymore

to get telescope-fzf-native.nvim working, run  `:Lazy build
telescope-fzf-native.nvim`
This commit is contained in:
David JULIEN 2023-01-29 01:09:12 +01:00
parent 173e84c089
commit 19af34b75d
Signed by: swytch
GPG Key ID: 498590A3AA82A06F
12 changed files with 431 additions and 546 deletions

View File

@ -6,6 +6,7 @@
require("globals") -- ./lua/globals.lua
require("utils") -- ./lua/utils.lua
require("settings") -- ./lua/settings.lua
require("plugin.packer") -- ./lua/plugin/packer.lua
require("maps") -- ./lua/maps.lua
require("statusline") -- ./lua/statusline.lua
require("plugin")
require("lazy").setup("plugin")

View File

@ -61,8 +61,8 @@ vim.keymap.set("n", "<leader><enter>",
-- packer
vim.keymap.set("n", "<leader>u",
function() require("packer").sync() end,
{ desc = "Sync packer config and update plugins" }
function() require("lazy").sync() end,
{ desc = "Open up Lazy.nvim" }
)
-- telescope

View File

@ -1,95 +0,0 @@
-- Author : swytch
-- Created : Saturday Sept. 11, 2021 22:12:33 CET
-- License : GPLv3
-- Description : cmp plugin config file
local cmp = require("cmp")
local luasnip = require("luasnip")
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
sub(col, col):match('%s') == nil
end
-- Custom item icons
local icons = { }
cmp.setup {
completion = {
autocomplete = true
},
sources = {
{ name = "path" },
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "calc" },
{ name = "spell" },
{ name = "treesitter" },
},
formatting = {
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[lsp]",
nvim_lua = "[nvim]",
luasnip = "[snip]",
path = "[path]",
buffer = "[buff]",
calc = "[calc]",
spell = "[spel]",
treesitter = "[tree]",
})[entry.source.name]
return vim_item
end,
},
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
},
view = {
entries = {name = 'custom', selection_order = 'near_cursor' }
},
}

View File

@ -0,0 +1,17 @@
-- Author : swytch
-- Created : Sunday Jan. 29, 2023 00:50:17 CET
-- License : GPLv3
-- Description : colorscheme config file
local utils = require("utils")
local file = os.getenv("XDG_STATE_HOME") .. "/nvim_colorscheme"
local colorscheme = utils.lines_from(file)[0]
return {
{
dir = "~/.local/src/astronomy.nvim",
opts = {
variant = colorscheme,
}
},
}

View File

@ -1,57 +1,21 @@
-- Author : swytch
-- Created : Tuesday Oct. 12, 2021 19:07:36 CET
-- Created : Sunday Jan. 29, 2023 00:20:31 CET
-- License : GPLv3
-- Description : Comment plugin config file
-- Description : Mini.comment plugin config file
require("Comment").setup {
---Add a space b/w comment and the line
---@type boolean
padding = true,
return {
"echasnovski/mini.comment",
version = "*",
opts = {
mappings = {
comment = "<leader>c",
---Lines to be ignored while comment/uncomment.
---Could be a regex string or a function that returns a regex string.
---Example: Use '^$' to ignore empty lines
---@type string|function
ignore = nil,
comment_line = "<leader><Space>",
---Whether to create basic (operator-pending) and extra mappings for NORMAL/VISUAL mode
---@type table
mappings = {
---operator-pending mapping
---Includes `gcc`, `gcb`, `gc[count]{motion}` and `gb[count]{motion}`
basic = true,
---extra mapping
---Includes `gco`, `gcO`, `gcA`
extra = true,
---extended mapping
---Includes `g>`, `g<`, `g>[count]{motion}` and `g<[count]{motion}`
extended = false,
text_object = "gc",
},
},
---LHS of line and block comment toggle mapping in NORMAL/VISUAL mode
---@type table
toggler = {
---line-comment toggle
line = "<leader><Space>",
---block-comment toggle
block = "<leader>bb",
},
---LHS of line and block comment operator-mode mapping in NORMAL/VISUAL mode
---@type table
opleader = {
---line-comment opfunc mapping
line = "<leader>c",
---block-comment opfunc mapping
block = "<leader>b",
},
---Pre-hook, called before commenting the line
---@type function|nil
pre_hook = nil,
---Post-hook, called after commenting is done
---@type function|nil
post_hook = nil,
config = function(_, opts)
require("mini.comment").setup(opts)
end,
}

View File

@ -0,0 +1,151 @@
-- Author : swytch
-- Created : Sunday Jan. 29, 00:03:53 CET
-- License : GPLv3
-- Description : completion plugin config file
return {
{
"L3MON4D3/LuaSnip",
opts = function()
local types = require("luasnip.util.types")
return {
history = true,
-- Update more often, :h events for more info.
updateevents = "TextChanged,TextChangedI",
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "", "LuaSnipChoice" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.functionNode] = {
active = {
virt_text = { { "", "LuaSnipFunction" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.insertNode] = {
active = {
virt_text = { { "", "LuaSnipInsert" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
},
-- treesitter-hl has 100, use something higher (default is 200).
ext_base_prio = 200,
-- minimal increase in priority.
ext_prio_increase = 1,
enable_autosnippets = true,
}
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = {
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-calc",
"ray-x/cmp-treesitter",
"f3fora/cmp-spell",
},
opts = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local has_words_before = function()
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and
vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:
sub(col, col):match('%s') == nil
end
return {
completion = {
autocomplete = true
},
sources = {
{ name = "path" },
{ name = "luasnip" },
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "nvim_lua" },
{ name = "calc" },
{ name = "spell" },
{ name = "treesitter" },
},
formatting = {
format = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[lsp]",
nvim_lua = "[nvim]",
luasnip = "[snip]",
path = "[path]",
buffer = "[buff]",
calc = "[calc]",
spell = "[spel]",
treesitter = "[tree]",
})[entry.source.name]
return vim_item
end,
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = {
["<C-d>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.close(),
["<CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}),
["<Tab>"] = cmp.mapping(function(fallback)
if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<C-n>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<C-p>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, { "i", "s" }),
},
view = {
entries = { name = 'custom', selection_order = 'near_cursor' }
},
}
end,
}
}

View File

@ -0,0 +1,20 @@
-- Author : swytch
-- Created : Friday Mar 12, 2021 22:28:34 CET
-- License : GPLv3
-- Description : neovim packer config file
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", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
return {}

View File

@ -4,59 +4,7 @@
-- Description : neovim global lsp config file
local lspconfig = require("lspconfig")
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")
local globals = require("globals")
local signs = {
Error = globals.sign_error,
Warn = globals.sign_warn,
Hint = globals.sign_hint,
Info = globals.sign_info,
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, {
text = icon,
texthl = hl,
numhl = hl
})
end
vim.diagnostic.config({
update_in_insert = true
})
local on_attach = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<leader>ln", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<leader>wa",
vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<leader>wr",
vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<leader>wl", function()
vim.inspect(vim.lsp.buf.list_workspace_folders())
end, opts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>so",
require("telescope.builtin").lsp_document_symbols, opts)
end
-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
_G.lsp_root_dir = vim.fn.stdpath("data") .. "/mason/bin"
local servers = {
"clangd",
@ -65,31 +13,98 @@ local servers = {
"texlab",
}
mason.setup({
ui = {
icons = {
server_installed = "",
server_pending = "o",
server_uninstalled = ""
return {
{
"neovim/nvim-lspconfig",
dependencies = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function()
vim.diagnostic.config({
underline = true,
update_in_insert = false,
severity_sort = true,
})
local lspconfig = require("lspconfig")
local globals = require("globals")
local signs = {
Error = globals.sign_error,
Warn = globals.sign_warn,
Hint = globals.sign_hint,
Info = globals.sign_info,
}
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, {
text = icon,
texthl = hl,
numhl = hl
})
end
local on_attach = function(_, bufnr)
local opts = { buffer = bufnr }
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
vim.keymap.set("n", "<leader>ln", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "<leader>lp", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "<leader>lf", vim.lsp.buf.format, opts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
vim.keymap.set("n", "<leader>wa",
vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set("n", "<leader>wr",
vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set("n", "<leader>wl", function()
vim.inspect(vim.lsp.buf.list_workspace_folders())
end, opts)
vim.keymap.set("n", "<leader>D", vim.lsp.buf.type_definition, opts)
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts)
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>so",
require("telescope.builtin").lsp_document_symbols, opts)
end
-- nvim-cmp supports additional completion capabilities
local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities)
for _, server in ipairs(servers) do
local opts = {
on_attach = on_attach,
capabilities = capabilities,
}
local plugin = string.format("plugin.lsp.%s", server)
require(plugin).setup(opts)
lspconfig[server].setup(opts)
end
require("mason-lspconfig").setup({ ensure_installed = servers })
end
},
{
"williamboman/mason.nvim",
cmd = "Mason",
-- opts = { ensure_installed = servers },
opts = {
ui = {
icons = {
server_installed = "",
server_pending = "o",
server_uninstalled = ""
}
}
}
}
})
_G.lsp_root_dir = vim.fn.stdpath("data") .. "/mason/bin"
mason_lspconfig.setup({
ensure_installed = servers,
})
for _, server in ipairs(servers) do
local opts = {
on_attach = on_attach,
capabilities = capabilities,
}
local plugin = string.format("plugin.lsp.%s", server)
require(plugin).setup(opts)
lspconfig[server].setup(opts)
end
},
}

View File

@ -1,84 +0,0 @@
-- Author : swytch
-- Created : Friday Nov. 19, 2021 23:27:24 CET
-- License : GPLv3
-- Description : luasnip config file
local ls = require("luasnip")
-- some shorthands...
local s = ls.snippet
local sn = ls.snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local l = require("luasnip.extras").lambda
local r = require("luasnip.extras").rep
local p = require("luasnip.extras").partial
local m = require("luasnip.extras").match
local n = require("luasnip.extras").nonempty
local dl = require("luasnip.extras").dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local types = require("luasnip.util.types")
local conds = require("luasnip.extras.expand_conditions")
-- Every unspecified option will be set to the default.
ls.config.set_config({
history = true,
-- Update more often, :h events for more info.
updateevents = "TextChanged,TextChangedI",
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = { { "", "LuaSnipChoice" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.functionNode] = {
active = {
virt_text = { { "", "LuaSnipFunction" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
[types.insertNode] = {
active = {
virt_text = { { "", "LuaSnipInsert" } },
},
inactive = {
virt_text = { { "", "LuaSnipInactive" } },
},
},
},
-- treesitter-hl has 100, use something higher (default is 200).
ext_base_prio = 200,
-- minimal increase in priority.
ext_prio_increase = 1,
enable_autosnippets = true,
})
-- Make sure to not pass an invalid command, as io.popen() may write over nvim-text.
local function bash(_, _, command)
local file = io.popen(command, "r")
local res = {}
for line in file:lines() do
table.insert(res, line)
end
return res
end
-- Returns a snippet_node wrapped around an insert_node whose initial
-- text value is set to the current date in the desired format.
local function date_input(fmt)
local format = fmt or "%Y-%m-%d"
return sn(nil, i(1, os.date(format)))
end
-- in a lua file: search lua-, then c-, then all-snippets.
ls.filetype_extend("lua", { "c" })
-- in a cpp file: search c-snippets, then all-snippets only (no cpp-snippets!!).
ls.filetype_set("cpp", { "c" })

View File

@ -1,125 +0,0 @@
-- Author : swytch
-- Created : Friday Mar 12, 2021 22:28:34 CET
-- License : GPLv3
-- Description : neovim packer config file
local install_path = vim.fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
print("Cloning packer...")
PACKER_BOOTSTRAP = vim.fn.system({
"git",
"clone",
"--depth",
"1",
"https://github.com/wbthomason/packer.nvim",
install_path,
})
vim.cmd([[packadd packer.nvim]])
print("Done.")
end
local packer = require("packer")
packer.init({
display = {
working_sym = '', -- The symbol for a plugin being installed/updated
error_sym = '', -- The symbol for a plugin with an error in installation/updating
done_sym = '', -- The symbol for a plugin which has completed installation/updating
removed_sym = '- ', -- The symbol for an unused plugin which was removed
moved_sym = '', -- The symbol for a plugin which was moved (e.g. from opt to start)
header_sym = '', -- The symbol for the header line in packer's display
open_fn = function()
return require('packer.util').float({ border = "single" })
end, -- Display in a floating window
},
})
local use = packer.use
return require("packer").startup(function()
-- packer manages itself
use "wbthomason/packer.nvim"
-- colorscheme
use {
"~/.local/src/astronomy.nvim",
config = function() require("colorscheme") end
}
-- tree-sitter
use {
"nvim-treesitter/nvim-treesitter",
run = ":TSUpdate",
config = function() require("plugin.treesitter") end
}
use { -- Additional text objects via treesitter
'nvim-treesitter/nvim-treesitter-textobjects',
after = 'nvim-treesitter',
}
-- telescope
use {
"nvim-telescope/telescope.nvim",
requires = {
{
"nvim-lua/plenary.nvim",
},
{
"nvim-telescope/telescope-fzf-native.nvim",
run = "make"
},
{
"nvim-telescope/telescope-file-browser.nvim",
}
},
config = function()
require("telescope")
require("telescope").load_extension("fzf")
require("telescope").load_extension("file_browser")
end
}
-- LSP
use {
"neovim/nvim-lspconfig",
requires = {
"williamboman/mason.nvim",
"williamboman/mason-lspconfig.nvim",
},
config = function() require("plugin.lsp") end
}
-- auto completion
use {
"hrsh7th/nvim-cmp",
requires = {
{
"L3MON4D3/LuaSnip",
config = function()
require("plugin.luasnip") end
},
"saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-nvim-lua",
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"hrsh7th/cmp-calc",
"ray-x/cmp-treesitter",
"f3fora/cmp-spell",
},
config = function() require("plugin.cmp") end
}
-- commenting, simplified
use {
"numToStr/Comment.nvim",
config = function() require("plugin.comment") end
}
-- automatically setup the config after cloning
if PACKER_BOOTSTRAP then
require("packer").sync()
end
end)

View File

@ -1,22 +1,32 @@
-- Author : swytch
-- Created : Monday Dec. 26, 2022 18:39:16 CET
-- License : GPLv3
-- Description : treesitter config file
-- Description : telescope config file
require("telescope").setup {
extensions = {
file_browser = {
theme = "ivy",
-- disables netrw and use telescope-file-browser in its place
hijack_netrw = true,
mappings = {
["i"] = {
-- your custom insert mode mappings
},
["n"] = {
-- your custom normal mode mappings
},
return {
"nvim-telescope/telescope.nvim",
dependencies = {
{
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope-file-browser.nvim",
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
lazy = false,
},
},
}
},
opts = {
extensions = {
file_browser = {
theme = "ivy",
hijack_netrw = true,
}
}
},
config = function(_, opts)
require("telescope").setup(opts)
require("telescope").load_extension("fzf")
require("telescope").load_extension("file_browser")
end
}

View File

@ -3,113 +3,124 @@
-- License : GPLv3
-- Description : treesitter config file
require("nvim-treesitter.configs").setup {
ensure_installed = { "c", "lua", "rust", "bash", "vim" },
highlight = {
enable = true,
return {
"nvim-treesitter/nvim-treesitter",
dependencies = {
-- Additional text objects via treesitter
"nvim-treesitter/nvim-treesitter-textobjects",
},
indent = {
enable = true,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<C-Space>",
node_incremental = "<C-Space>",
scope_incremental = "<Tab>",
node_decremental = "<BS>",
},
},
textobjects = {
select = {
build = ":TSUpdate",
opts = {
ensure_installed = { "c", "lua", "rust", "bash", "vim" },
highlight = {
enable = true,
},
indent = {
enable = true,
},
incremental_selection = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- use the capture groups defined in textobjects.scm
["ap"] = {
query = "@parameter.outer",
desc = "Select parameter region"
},
["ip"] = {
query = "@parameter.inner",
desc = "Select inner part of a parameter region"
},
["af"] = {
query = "@function.outer",
desc = "Select a function block"
},
["if"] = {
query = "@function.inner",
desc = "Select inner part of a function"
},
["ac"] = {
query = "@class.outer",
desc = "Select a class block"
},
["ic"] = {
query = "@class.inner",
desc = "Select inner part of a class"
},
init_selection = "<C-Space>",
node_incremental = "<C-Space>",
scope_incremental = "<Tab>",
node_decremental = "<BS>",
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = {
query = "@function.outer",
desc = "Jump to next function",
},
["])"] = {
query = "@class.outer",
desc = "Jump to next class",
textobjects = {
select = {
enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = {
-- use the capture groups defined in textobjects.scm
["ap"] = {
query = "@parameter.outer",
desc = "Select parameter region"
},
["ip"] = {
query = "@parameter.inner",
desc = "Select inner part of a parameter region"
},
["af"] = {
query = "@function.outer",
desc = "Select a function block"
},
["if"] = {
query = "@function.inner",
desc = "Select inner part of a function"
},
["ac"] = {
query = "@class.outer",
desc = "Select a class block"
},
["ic"] = {
query = "@class.inner",
desc = "Select inner part of a class"
},
},
},
goto_next_end = {
["]M"] = {
query = "@function.outer",
desc = "Jump after next function",
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
["]m"] = {
query = "@function.outer",
desc = "Jump to next function",
},
["])"] = {
query = "@class.outer",
desc = "Jump to next class",
},
},
["]]"] = {
query = "@class.outer",
desc = "Jump after next class",
goto_next_end = {
["]M"] = {
query = "@function.outer",
desc = "Jump after next function",
},
["]]"] = {
query = "@class.outer",
desc = "Jump after next class",
},
},
goto_previous_start = {
["[m"] = {
query = "@function.outer",
desc = "Jump to previous function",
},
["[)"] = {
query = "@class.outer",
desc = "Jump to previous class",
},
},
goto_previous_end = {
["[M"] = {
query = "@function.outer",
desc = "Jump after previous function",
},
["[]"] = {
query = "@class.outer",
desc = "Jump after previous class",
},
},
},
goto_previous_start = {
["[m"] = {
query = "@function.outer",
desc = "Jump to previous function",
swap = {
enable = true,
swap_next = {
["<leader>a"] = {
query = "@parameter.inner",
desc = "Swap with next parameter",
},
},
["[)"] = {
query = "@class.outer",
desc = "Jump to previous class",
},
},
goto_previous_end = {
["[M"] = {
query = "@function.outer",
desc = "Jump after previous function",
},
["[]"] = {
query = "@class.outer",
desc = "Jump after previous class",
},
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = {
query = "@parameter.inner",
desc = "Swap with next parameter",
},
},
swap_previous = {
["<leader>A"] = {
query = "@parameter.inner",
desc = "Swap with previous parameter",
swap_previous = {
["<leader>A"] = {
query = "@parameter.inner",
desc = "Swap with previous parameter",
},
},
},
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end
}