Compare commits
8 commits
be0cc6b971
...
c6735f3912
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | c6735f3912 | ||
Bruno BELANYI | 3438290e32 | ||
Bruno BELANYI | 82f49f1389 | ||
Bruno BELANYI | 5918a0b9e6 | ||
Bruno BELANYI | a7c542784c | ||
Bruno BELANYI | 280829b54f | ||
Bruno BELANYI | 5ffe2653c0 | ||
Bruno BELANYI | 5592a120a4 |
|
@ -1,15 +0,0 @@
|
|||
local wk = require("which-key")
|
||||
local telescope_builtin = require("telescope.builtin")
|
||||
|
||||
local keys = {
|
||||
f = {
|
||||
name = "Fuzzy finder",
|
||||
b = { telescope_builtin.buffers, "Open buffers" },
|
||||
f = { telescope_builtin.git_files, "Git tracked files" },
|
||||
F = { telescope_builtin.find_files, "Files" },
|
||||
g = { telescope_builtin.live_grep, "Grep string" },
|
||||
G = { telescope_builtin.grep_string, "Grep string under cursor" },
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys, { prefix = "<leader>" })
|
|
@ -1,30 +0,0 @@
|
|||
local wk = require("which-key")
|
||||
|
||||
local motions = {
|
||||
["]m"] = "Next method start",
|
||||
["]M"] = "Next method end",
|
||||
["]S"] = "Next statement start",
|
||||
["]]"] = "Next class start",
|
||||
["]["] = "Next class end",
|
||||
["[m"] = "Previous method start",
|
||||
["[M"] = "Previous method end",
|
||||
["[S"] = "Previous statement start",
|
||||
["[["] = "Previous class start",
|
||||
["[]"] = "Previous class end",
|
||||
}
|
||||
|
||||
local objects = {
|
||||
["aa"] = "a parameter",
|
||||
["ia"] = "inner parameter",
|
||||
["ab"] = "a block",
|
||||
["ib"] = "inner block",
|
||||
["ac"] = "a class",
|
||||
["ic"] = "inner class",
|
||||
["af"] = "a function",
|
||||
["if"] = "inner function",
|
||||
["ak"] = "a comment",
|
||||
["aS"] = "a statement",
|
||||
}
|
||||
|
||||
wk.register(motions, { mode = "n" })
|
||||
wk.register(objects, { mode = "o" })
|
|
@ -7,17 +7,28 @@ local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true
|
|||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "if &nu | setlocal rnu | endif",
|
||||
callback = function()
|
||||
if vim.opt.number:get() then
|
||||
vim.opt.relativenumber = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "if &nu | setlocal nornu | endif",
|
||||
callback = function()
|
||||
if vim.opt.number:get() then
|
||||
vim.opt.relativenumber = false
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Never show the sign column in a terminal buffer
|
||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||
pattern = "*",
|
||||
group = numbertoggle,
|
||||
command = "setlocal nonu nornu",
|
||||
callback = function()
|
||||
vim.opt.number = false
|
||||
vim.opt.relativenumber = false
|
||||
end,
|
||||
})
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local gitsigns = require("gitsigns")
|
||||
local utils = require("ambroisie.utils")
|
||||
local wk = require("which-key")
|
||||
|
||||
--- Transform `f` into a function which acts on the current visual selection
|
||||
|
@ -11,16 +12,14 @@ local function make_visual(f)
|
|||
end
|
||||
|
||||
local function nav_hunk(dir)
|
||||
return function()
|
||||
if vim.wo.diff then
|
||||
local map = {
|
||||
prev = "[c",
|
||||
next = "]c",
|
||||
}
|
||||
vim.cmd.normal({ map[dir], bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk(dir)
|
||||
end
|
||||
if vim.wo.diff then
|
||||
local map = {
|
||||
prev = "[c",
|
||||
next = "]c",
|
||||
}
|
||||
vim.cmd.normal({ map[dir], bang = true })
|
||||
else
|
||||
gitsigns.nav_hunk(dir)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -29,12 +28,14 @@ gitsigns.setup({
|
|||
-- Show the blame quickly
|
||||
delay = 100,
|
||||
},
|
||||
-- Work-around for https://github.com/lewis6991/gitsigns.nvim/issues/929
|
||||
signs_staged_enable = false,
|
||||
})
|
||||
|
||||
local keys = {
|
||||
-- Navigation
|
||||
["[c"] = { nav_hunk("prev"), "Previous hunk/diff" },
|
||||
["]c"] = { nav_hunk("next"), "Next hunk/diff" },
|
||||
["[c"] = { utils.partial(nav_hunk, "prev"), "Previous hunk/diff" },
|
||||
["]c"] = { utils.partial(nav_hunk, "next"), "Next hunk/diff" },
|
||||
|
||||
-- Commands
|
||||
["<leader>g"] = {
|
||||
|
@ -42,8 +43,7 @@ local keys = {
|
|||
-- Actions
|
||||
b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" },
|
||||
d = { gitsigns.diffthis, "Diff buffer" },
|
||||
-- stylua: ignore
|
||||
D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" },
|
||||
D = { utils.partial(gitsigns.diffthis, "~"), "Diff buffer against last commit" },
|
||||
g = { "<cmd>Git<CR>", "Git status" },
|
||||
h = { gitsigns.toggle_deleted, "Show deleted hunks" },
|
||||
L = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" },
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
local telescope = require("telescope")
|
||||
local telescope_builtin = require("telescope.builtin")
|
||||
local wk = require("which-key")
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
|
@ -22,3 +24,16 @@ telescope.setup({
|
|||
|
||||
telescope.load_extension("fzf")
|
||||
telescope.load_extension("lsp_handlers")
|
||||
|
||||
local keys = {
|
||||
f = {
|
||||
name = "Fuzzy finder",
|
||||
b = { telescope_builtin.buffers, "Open buffers" },
|
||||
f = { telescope_builtin.git_files, "Git tracked files" },
|
||||
F = { telescope_builtin.find_files, "Files" },
|
||||
g = { telescope_builtin.live_grep, "Grep string" },
|
||||
G = { telescope_builtin.grep_string, "Grep string under cursor" },
|
||||
},
|
||||
}
|
||||
|
||||
wk.register(keys, { prefix = "<leader>" })
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
local ts_config = require("nvim-treesitter.configs")
|
||||
|
||||
ts_config.setup({
|
||||
highlight = {
|
||||
enable = true,
|
||||
|
@ -14,16 +15,16 @@ ts_config.setup({
|
|||
-- Jump to matching text objects
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
["aa"] = "@parameter.outer",
|
||||
["ia"] = "@parameter.inner",
|
||||
["ab"] = "@block.outer",
|
||||
["ib"] = "@block.inner",
|
||||
["ac"] = "@class.outer",
|
||||
["ic"] = "@class.inner",
|
||||
["af"] = "@function.outer",
|
||||
["if"] = "@function.inner",
|
||||
["ak"] = "@comment.outer",
|
||||
["aS"] = "@statement.outer",
|
||||
["aa"] = { query = "@parameter.outer", desc = "a parameter" },
|
||||
["ia"] = { query = "@parameter.inner", desc = "inner parameter" },
|
||||
["ab"] = { query = "@block.outer", desc = "a block" },
|
||||
["ib"] = { query = "@block.inner", desc = "inner block" },
|
||||
["ac"] = { query = "@class.outer", desc = "a class" },
|
||||
["ic"] = { query = "@class.inner", desc = "inner class" },
|
||||
["af"] = { query = "@function.outer", desc = "a function" },
|
||||
["if"] = { query = "@function.inner", desc = "inner function" },
|
||||
["ak"] = { query = "@comment.outer", desc = "a comment" },
|
||||
["aS"] = { query = "@statement.outer", desc = "a statement" },
|
||||
},
|
||||
},
|
||||
move = {
|
||||
|
@ -31,22 +32,22 @@ ts_config.setup({
|
|||
-- Add to jump list
|
||||
set_jumps = true,
|
||||
goto_next_start = {
|
||||
["]m"] = "@function.outer",
|
||||
["]S"] = "@statement.outer",
|
||||
["]]"] = "@class.outer",
|
||||
["]m"] = { query = "@function.outer", desc = "Next method start" },
|
||||
["]S"] = { query = "@statement.outer", desc = "Next statement start" },
|
||||
["]]"] = { query = "@class.outer", desc = "Next class start" },
|
||||
},
|
||||
goto_next_end = {
|
||||
["]M"] = "@function.outer",
|
||||
["]["] = "@class.outer",
|
||||
["]M"] = { query = "@function.outer", desc = "Next method end" },
|
||||
["]["] = { query = "@class.outer", desc = "Next class end" },
|
||||
},
|
||||
goto_previous_start = {
|
||||
["[m"] = "@function.outer",
|
||||
["[S"] = "@statement.outer",
|
||||
["[["] = "@class.outer",
|
||||
["[m"] = { query = "@function.outer", desc = "Previous method start" },
|
||||
["[S"] = { query = "@statement.outer", desc = "Previous statement start" },
|
||||
["[["] = { query = "@class.outer", desc = "Previous class start" },
|
||||
},
|
||||
goto_previous_end = {
|
||||
["[M"] = "@function.outer",
|
||||
["[]"] = "@class.outer",
|
||||
["[M"] = { query = "@function.outer", desc = "Previous method end" },
|
||||
["[]"] = { query = "@class.outer", desc = "Previous class end" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -4,17 +4,23 @@ local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true })
|
|||
vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=yes",
|
||||
callback = function()
|
||||
vim.opt.signcolumn = "yes"
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=yes",
|
||||
callback = function()
|
||||
vim.opt.signcolumn = "no"
|
||||
end,
|
||||
})
|
||||
|
||||
-- Never show the sign column in a terminal buffer
|
||||
vim.api.nvim_create_autocmd({ "TermOpen" }, {
|
||||
pattern = "*",
|
||||
group = signtoggle,
|
||||
command = "setlocal signcolumn=no",
|
||||
callback = function()
|
||||
vim.opt.signcolumn = "no"
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue