nvim 0.12 wip

This commit is contained in:
2026-01-07 12:36:07 +01:00
parent 98707aa239
commit f28cd20207
5 changed files with 795 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
vim.pack.add({
{
src = "https://github.com/saghen/blink.cmp",
version = vim.version.range("^1"),
},
})
-- Lazy load on first insert mode entry (may not necessary)
local group = vim.api.nvim_create_augroup("BlinkCmpLazyLoad", { clear = true })
vim.api.nvim_create_autocmd("InsertEnter", {
pattern = "*",
group = group,
once = true,
callback = function()
require("blink.cmp").setup({
keymap = { preset = "super-tab" },
appearance = {
nerd_font_variant = "mono",
use_nvim_cmp_as_default = true,
},
completion = {
documentation = { auto_show = false },
},
sources = {
default = { "lsp", "path", "snippets", "buffer" },
},
fuzzy = { implementation = "prefer_rust_with_warning" },
})
end,
})

View File

@@ -0,0 +1,79 @@
vim.pack.add({ "https://github.com/stevearc/conform.nvim" })
require("conform").setup({
formatters_by_ft = {
lua = { "stylua" },
go = { "goimports", "gofmt" },
python = { "ruff_format", "black", stop_after_first = true },
json = { "biome", "prettier", stop_after_first = true },
markdown = { "prettier" },
javascript = { "biome", "prettier", stop_after_first = true },
typescript = { "biome", "prettier", stop_after_first = true },
javascriptreact = { "biome", "prettier", stop_after_first = true },
typescriptreact = { "biome", "prettier", stop_after_first = true },
css = { "prettier" },
html = { "prettier" },
toml = { "taplo" },
},
formatters = {
biome = { require_cwd = true },
},
default_format_opts = {
lsp_format = "fallback",
},
--[[ format_on_save = function(bufnr)
local ignore_filetypes = { "sql", "yaml", "yml" }
if vim.tbl_contains(ignore_filetypes, vim.bo[bufnr].filetype) then
return
end
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return
end
local bufname = vim.api.nvim_buf_get_name(bufnr)
if bufname:match("/node_modules/") then
return
end
return { timeout_ms = 500, lsp_format = "fallback" }
end,
]]
})
vim.api.nvim_create_user_command("FormatDisable", function(opts)
if opts.bang then
vim.b.disable_autoformat = true
else
vim.g.disable_autoformat = true
end
vim.notify("Autoformat disabled" .. (opts.bang and " (buffer)" or " (global)"), vim.log.levels.WARN)
end, { desc = "Disable autoformat-on-save", bang = true })
vim.api.nvim_create_user_command("FormatEnable", function()
vim.b.disable_autoformat = false
vim.g.disable_autoformat = false
vim.notify("Autoformat enabled", vim.log.levels.INFO)
end, { desc = "Re-enable autoformat-on-save" })
local auto_format = true
vim.keymap.set("n", "<leader>uf", function()
auto_format = not auto_format
if auto_format then
vim.cmd("FormatEnable")
else
vim.cmd("FormatDisable")
end
end, { desc = "Toggle Autoformat" })
vim.keymap.set({ "n", "v" }, "<leader>cn", "<cmd>ConformInfo<cr>", { desc = "Conform Info" })
vim.keymap.set({ "n", "v" }, "<leader>cf", function()
require("conform").format({ async = true }, function(err, did_edit)
if not err and did_edit then
vim.notify("Code formatted", vim.log.levels.INFO, { title = "Conform" })
end
end)
end, { desc = "Format buffer" })
vim.keymap.set({ "n", "v" }, "<leader>cF", function()
require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 })
end, { desc = "Format Injected Langs" })

View File

@@ -0,0 +1,665 @@
vim.pack.add({
"https://github.com/lewis6991/gitsigns.nvim",
"https://github.com/sindrets/diffview.nvim",
})
require("gitsigns").setup({
signs = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged = {
add = { text = "" },
change = { text = "" },
delete = { text = "_" },
topdelete = { text = "" },
changedelete = { text = "~" },
untracked = { text = "" },
},
signs_staged_enable = true,
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
watch_gitdir = {
follow_files = true,
},
auto_attach = true,
attach_to_untracked = false,
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
current_line_blame_opts = {
virt_text = true,
virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 1000,
ignore_whitespace = false,
virt_text_priority = 100,
use_focus = true,
},
current_line_blame_formatter = "<author>, <author_time:%R> - <summary>",
sign_priority = 6,
update_debounce = 100,
status_formatter = nil, -- Use default
max_file_length = 40000, -- Disable if file is longer than this (in lines)
preview_config = {
-- Options passed to nvim_open_win
style = "minimal",
relative = "cursor",
row = 0,
col = 1,
},
on_attach = function(bufnr)
local gitsigns = require("gitsigns")
local function map(mode, l, r, opts)
opts = opts or {}
opts.buffer = bufnr
vim.keymap.set(mode, l, r, opts)
end
-- Navigation
map("n", "]c", function()
if vim.wo.diff then
vim.cmd.normal({ "]c", bang = true })
else
gitsigns.nav_hunk("next")
end
end)
map("n", "[c", function()
if vim.wo.diff then
vim.cmd.normal({ "[c", bang = true })
else
gitsigns.nav_hunk("prev")
end
end)
-- Actions
map("n", "<leader>hs", gitsigns.stage_hunk)
map("n", "<leader>hr", gitsigns.reset_hunk)
map("v", "<leader>hs", function()
gitsigns.stage_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
map("v", "<leader>hr", function()
gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") })
end)
map("n", "<leader>hS", gitsigns.stage_buffer)
map("n", "<leader>hR", gitsigns.reset_buffer)
map("n", "<leader>hp", gitsigns.preview_hunk)
map("n", "<leader>hi", gitsigns.preview_hunk_inline)
map("n", "<leader>hb", function()
gitsigns.blame_line({ full = true })
end)
map("n", "<leader>hd", gitsigns.diffthis)
map("n", "<leader>hD", function()
gitsigns.diffthis("~")
end)
map("n", "<leader>hQ", function()
gitsigns.setqflist("all")
end)
map("n", "<leader>hq", gitsigns.setqflist)
-- Toggles
map("n", "<leader>tb", gitsigns.toggle_current_line_blame)
map("n", "<leader>tw", gitsigns.toggle_word_diff)
-- Text object
map({ "o", "x" }, "ih", gitsigns.select_hunk)
end,
})
-- Lua
local actions = require("diffview.actions")
require("diffview").setup({
diff_binaries = false, -- Show diffs for binaries
enhanced_diff_hl = false, -- See |diffview-config-enhanced_diff_hl|
git_cmd = { "git" }, -- The git executable followed by default args.
hg_cmd = { "hg" }, -- The hg executable followed by default args.
use_icons = true, -- Requires nvim-web-devicons
show_help_hints = true, -- Show hints for how to open the help panel
watch_index = true, -- Update views and index buffers when the git index changes.
icons = { -- Only applies when use_icons is true.
folder_closed = "",
folder_open = "",
},
signs = {
fold_closed = "",
fold_open = "",
done = "",
},
view = {
-- Configure the layout and behavior of different types of views.
-- Available layouts:
-- 'diff1_plain'
-- |'diff2_horizontal'
-- |'diff2_vertical'
-- |'diff3_horizontal'
-- |'diff3_vertical'
-- |'diff3_mixed'
-- |'diff4_mixed'
-- For more info, see |diffview-config-view.x.layout|.
default = {
-- Config for changed files, and staged files in diff views.
layout = "diff2_horizontal",
disable_diagnostics = false, -- Temporarily disable diagnostics for diff buffers while in the view.
winbar_info = false, -- See |diffview-config-view.x.winbar_info|
},
merge_tool = {
-- Config for conflicted files in diff views during a merge or rebase.
layout = "diff3_horizontal",
disable_diagnostics = true, -- Temporarily disable diagnostics for diff buffers while in the view.
winbar_info = true, -- See |diffview-config-view.x.winbar_info|
},
file_history = {
-- Config for changed files in file history views.
layout = "diff2_horizontal",
disable_diagnostics = false, -- Temporarily disable diagnostics for diff buffers while in the view.
winbar_info = false, -- See |diffview-config-view.x.winbar_info|
},
},
file_panel = {
listing_style = "tree", -- One of 'list' or 'tree'
tree_options = { -- Only applies when listing_style is 'tree'
flatten_dirs = true, -- Flatten dirs that only contain one single dir
folder_statuses = "only_folded", -- One of 'never', 'only_folded' or 'always'.
},
win_config = { -- See |diffview-config-win_config|
position = "left",
width = 35,
win_opts = {},
},
},
file_history_panel = {
log_options = { -- See |diffview-config-log_options|
git = {
single_file = {
diff_merges = "combined",
},
multi_file = {
diff_merges = "first-parent",
},
},
hg = {
single_file = {},
multi_file = {},
},
},
win_config = { -- See |diffview-config-win_config|
position = "bottom",
height = 16,
win_opts = {},
},
},
commit_log_panel = {
win_config = {}, -- See |diffview-config-win_config|
},
default_args = { -- Default args prepended to the arg-list for the listed commands
DiffviewOpen = {},
DiffviewFileHistory = {},
},
hooks = {}, -- See |diffview-config-hooks|
keymaps = {
disable_defaults = false, -- Disable the default keymaps
view = {
-- The `view` bindings are active in the diff buffers, only when the current
-- tabpage is a Diffview.
{
"n",
"<tab>",
actions.select_next_entry,
{ desc = "Open the diff for the next file" },
},
{
"n",
"<s-tab>",
actions.select_prev_entry,
{ desc = "Open the diff for the previous file" },
},
{
"n",
"[F",
actions.select_first_entry,
{ desc = "Open the diff for the first file" },
},
{
"n",
"]F",
actions.select_last_entry,
{ desc = "Open the diff for the last file" },
},
{
"n",
"gf",
actions.goto_file_edit,
{ desc = "Open the file in the previous tabpage" },
},
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel." } },
{
"n",
"g<C-x>",
actions.cycle_layout,
{ desc = "Cycle through available layouts." },
},
{
"n",
"[x",
actions.prev_conflict,
{ desc = "In the merge-tool: jump to the previous conflict" },
},
{
"n",
"]x",
actions.next_conflict,
{ desc = "In the merge-tool: jump to the next conflict" },
},
{
"n",
"<leader>co",
actions.conflict_choose("ours"),
{ desc = "Choose the OURS version of a conflict" },
},
{
"n",
"<leader>ct",
actions.conflict_choose("theirs"),
{ desc = "Choose the THEIRS version of a conflict" },
},
{
"n",
"<leader>cb",
actions.conflict_choose("base"),
{ desc = "Choose the BASE version of a conflict" },
},
{
"n",
"<leader>ca",
actions.conflict_choose("all"),
{ desc = "Choose all the versions of a conflict" },
},
{ "n", "dx", actions.conflict_choose("none"), { desc = "Delete the conflict region" } },
{
"n",
"<leader>cO",
actions.conflict_choose_all("ours"),
{ desc = "Choose the OURS version of a conflict for the whole file" },
},
{
"n",
"<leader>cT",
actions.conflict_choose_all("theirs"),
{ desc = "Choose the THEIRS version of a conflict for the whole file" },
},
{
"n",
"<leader>cB",
actions.conflict_choose_all("base"),
{ desc = "Choose the BASE version of a conflict for the whole file" },
},
{
"n",
"<leader>cA",
actions.conflict_choose_all("all"),
{ desc = "Choose all the versions of a conflict for the whole file" },
},
{
"n",
"dX",
actions.conflict_choose_all("none"),
{ desc = "Delete the conflict region for the whole file" },
},
},
diff1 = {
-- Mappings in single window diff layouts
{ "n", "g?", actions.help({ "view", "diff1" }), { desc = "Open the help panel" } },
},
diff2 = {
-- Mappings in 2-way diff layouts
{ "n", "g?", actions.help({ "view", "diff2" }), { desc = "Open the help panel" } },
},
diff3 = {
-- Mappings in 3-way diff layouts
{
{ "n", "x" },
"2do",
actions.diffget("ours"),
{ desc = "Obtain the diff hunk from the OURS version of the file" },
},
{
{ "n", "x" },
"3do",
actions.diffget("theirs"),
{ desc = "Obtain the diff hunk from the THEIRS version of the file" },
},
{ "n", "g?", actions.help({ "view", "diff3" }), { desc = "Open the help panel" } },
},
diff4 = {
-- Mappings in 4-way diff layouts
{
{ "n", "x" },
"1do",
actions.diffget("base"),
{ desc = "Obtain the diff hunk from the BASE version of the file" },
},
{
{ "n", "x" },
"2do",
actions.diffget("ours"),
{ desc = "Obtain the diff hunk from the OURS version of the file" },
},
{
{ "n", "x" },
"3do",
actions.diffget("theirs"),
{ desc = "Obtain the diff hunk from the THEIRS version of the file" },
},
{ "n", "g?", actions.help({ "view", "diff4" }), { desc = "Open the help panel" } },
},
file_panel = {
{
"n",
"j",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"<down>",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"k",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<up>",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<cr>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"o",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"l",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"<2-LeftMouse>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"-",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry" },
},
{
"n",
"s",
actions.toggle_stage_entry,
{ desc = "Stage / unstage the selected entry" },
},
{ "n", "S", actions.stage_all, { desc = "Stage all entries" } },
{ "n", "U", actions.unstage_all, { desc = "Unstage all entries" } },
{
"n",
"X",
actions.restore_entry,
{ desc = "Restore entry to the state on the left side" },
},
{ "n", "L", actions.open_commit_log, { desc = "Open the commit log panel" } },
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{
"n",
"<tab>",
actions.select_next_entry,
{ desc = "Open the diff for the next file" },
},
{
"n",
"<s-tab>",
actions.select_prev_entry,
{ desc = "Open the diff for the previous file" },
},
{
"n",
"[F",
actions.select_first_entry,
{ desc = "Open the diff for the first file" },
},
{
"n",
"]F",
actions.select_last_entry,
{ desc = "Open the diff for the last file" },
},
{
"n",
"gf",
actions.goto_file_edit,
{ desc = "Open the file in the previous tabpage" },
},
{
"n",
"<C-w><C-f>",
actions.goto_file_split,
{ desc = "Open the file in a new split" },
},
{
"n",
"<C-w>gf",
actions.goto_file_tab,
{ desc = "Open the file in a new tabpage" },
},
{
"n",
"i",
actions.listing_style,
{ desc = "Toggle between 'list' and 'tree' views" },
},
{
"n",
"f",
actions.toggle_flatten_dirs,
{ desc = "Flatten empty subdirectories in tree listing style" },
},
{
"n",
"R",
actions.refresh_files,
{ desc = "Update stats and entries in the file list" },
},
{
"n",
"<leader>e",
actions.focus_files,
{ desc = "Bring focus to the file panel" },
},
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "[x", actions.prev_conflict, { desc = "Go to the previous conflict" } },
{ "n", "]x", actions.next_conflict, { desc = "Go to the next conflict" } },
{ "n", "g?", actions.help("file_panel"), { desc = "Open the help panel" } },
{
"n",
"<leader>cO",
actions.conflict_choose_all("ours"),
{ desc = "Choose the OURS version of a conflict for the whole file" },
},
{
"n",
"<leader>cT",
actions.conflict_choose_all("theirs"),
{ desc = "Choose the THEIRS version of a conflict for the whole file" },
},
{
"n",
"<leader>cB",
actions.conflict_choose_all("base"),
{ desc = "Choose the BASE version of a conflict for the whole file" },
},
{
"n",
"<leader>cA",
actions.conflict_choose_all("all"),
{ desc = "Choose all the versions of a conflict for the whole file" },
},
{
"n",
"dX",
actions.conflict_choose_all("none"),
{ desc = "Delete the conflict region for the whole file" },
},
},
file_history_panel = {
{ "n", "g!", actions.options, { desc = "Open the option panel" } },
{
"n",
"<C-A-d>",
actions.open_in_diffview,
{ desc = "Open the entry under the cursor in a diffview" },
},
{
"n",
"y",
actions.copy_hash,
{ desc = "Copy the commit hash of the entry under the cursor" },
},
{ "n", "L", actions.open_commit_log, { desc = "Show commit details" } },
{
"n",
"X",
actions.restore_entry,
{ desc = "Restore file to the state from the selected entry" },
},
{ "n", "zo", actions.open_fold, { desc = "Expand fold" } },
{ "n", "zc", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "h", actions.close_fold, { desc = "Collapse fold" } },
{ "n", "za", actions.toggle_fold, { desc = "Toggle fold" } },
{ "n", "zR", actions.open_all_folds, { desc = "Expand all folds" } },
{ "n", "zM", actions.close_all_folds, { desc = "Collapse all folds" } },
{
"n",
"j",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"<down>",
actions.next_entry,
{ desc = "Bring the cursor to the next file entry" },
},
{
"n",
"k",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<up>",
actions.prev_entry,
{ desc = "Bring the cursor to the previous file entry" },
},
{
"n",
"<cr>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"o",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"l",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{
"n",
"<2-LeftMouse>",
actions.select_entry,
{ desc = "Open the diff for the selected entry" },
},
{ "n", "<c-b>", actions.scroll_view(-0.25), { desc = "Scroll the view up" } },
{ "n", "<c-f>", actions.scroll_view(0.25), { desc = "Scroll the view down" } },
{ "n", "<tab>", actions.select_next_entry, { desc = "Open the diff for the next file" } },
{
"n",
"<s-tab>",
actions.select_prev_entry,
{ desc = "Open the diff for the previous file" },
},
{
"n",
"[F",
actions.select_first_entry,
{ desc = "Open the diff for the first file" },
},
{ "n", "]F", actions.select_last_entry, { desc = "Open the diff for the last file" } },
{
"n",
"gf",
actions.goto_file_edit,
{ desc = "Open the file in the previous tabpage" },
},
{ "n", "<C-w><C-f>", actions.goto_file_split, { desc = "Open the file in a new split" } },
{ "n", "<C-w>gf", actions.goto_file_tab, { desc = "Open the file in a new tabpage" } },
{ "n", "<leader>e", actions.focus_files, { desc = "Bring focus to the file panel" } },
{ "n", "<leader>b", actions.toggle_files, { desc = "Toggle the file panel" } },
{ "n", "g<C-x>", actions.cycle_layout, { desc = "Cycle available layouts" } },
{ "n", "g?", actions.help("file_history_panel"), { desc = "Open the help panel" } },
},
option_panel = {
{ "n", "<tab>", actions.select_entry, { desc = "Change the current option" } },
{ "n", "q", actions.close, { desc = "Close the panel" } },
{ "n", "g?", actions.help("option_panel"), { desc = "Open the help panel" } },
},
help_panel = {
{ "n", "q", actions.close, { desc = "Close help menu" } },
{ "n", "<esc>", actions.close, { desc = "Close help menu" } },
},
},
})

View File

@@ -2,4 +2,7 @@ require("plugins.whichkey")
require("plugins.treesitter") require("plugins.treesitter")
require("plugins.neotree") require("plugins.neotree")
require("plugins.telescope") require("plugins.telescope")
require("plugins.blink")
require("plugins.conform")
require("plugins.git")
require("plugins.theme") require("plugins.theme")

View File

@@ -1,9 +1,26 @@
{ {
"plugins": { "plugins": {
"blink.cmp": {
"rev": "b19413d",
"src": "https://github.com/saghen/blink.cmp",
"version": "1.0.0 - 2.0.0"
},
"conform.nvim": {
"rev": "8314f4c",
"src": "https://github.com/stevearc/conform.nvim"
},
"diffview.nvim": {
"rev": "4516612",
"src": "https://github.com/sindrets/diffview.nvim"
},
"fd": { "fd": {
"rev": "5f95a78", "rev": "5f95a78",
"src": "https://github.com/sharkdp/fd" "src": "https://github.com/sharkdp/fd"
}, },
"gitsigns.nvim": {
"rev": "dfac404",
"src": "https://github.com/lewis6991/gitsigns.nvim"
},
"neo-tree.nvim": { "neo-tree.nvim": {
"rev": "f3df514", "rev": "f3df514",
"src": "https://github.com/nvim-neo-tree/neo-tree.nvim", "src": "https://github.com/nvim-neo-tree/neo-tree.nvim",