mirror of
https://github.com/iofq/nvim.nix.git
synced 2026-01-23 08:55:16 -06:00
This commit is contained in:
parent
775af7d730
commit
3c5c3a6745
9 changed files with 42 additions and 156 deletions
|
|
@ -62,21 +62,6 @@ function M.file_history(filename)
|
|||
end
|
||||
end
|
||||
|
||||
local function confirm(picker, item)
|
||||
picker:close()
|
||||
local cmd = string.format('jj show --git -r %s', item.rev)
|
||||
local out = vim.fn.systemlist(cmd)
|
||||
|
||||
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, out)
|
||||
vim.bo[bufnr].bufhidden = 'wipe'
|
||||
vim.bo[bufnr].buftype = 'nofile'
|
||||
vim.bo[bufnr].filetype = 'diff'
|
||||
vim.keymap.set('n', 'q', vim.cmd.bdelete, { buffer = bufnr, noremap = true })
|
||||
|
||||
vim.api.nvim_set_current_buf(bufnr)
|
||||
end
|
||||
|
||||
local function get_history(f)
|
||||
local status_raw = vim.fn.system(
|
||||
'jj log --ignore-working-copy --no-graph'
|
||||
|
|
@ -100,7 +85,6 @@ function M.file_history(filename)
|
|||
title = 'jj file history for ' .. filename,
|
||||
items = get_history(filename),
|
||||
preview = preview,
|
||||
confirm = confirm,
|
||||
}
|
||||
end
|
||||
return M
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ cmd('FileType', {
|
|||
local ns = vim.api.nvim_create_namespace('nvim.difftool.hl')
|
||||
vim.api.nvim_buf_clear_namespace(event.buf, ns, 0, -1)
|
||||
for i, item in ipairs(qf) do
|
||||
local path = vim.fn.fnamemodify(item.user_data.right, ':.')
|
||||
local path = vim.fn.fnamemodify(item.user_data.right, ':t')
|
||||
local hl = 'Added'
|
||||
if
|
||||
exec('git diff --quiet -- %s', path) ~= 0
|
||||
|
|
@ -98,45 +98,6 @@ cmd('BufWinEnter', {
|
|||
vim.cmd(string.format('%dcopen', math.min(10, #items)))
|
||||
end)
|
||||
end
|
||||
|
||||
local function get_hunks(bufnr)
|
||||
local conf_start = vim.fn.search('^<<<<<<<', 'bc')
|
||||
local base_start = vim.fn.search('^|||||||', 'W')
|
||||
local base_end = vim.fn.search('^=======', 'W')
|
||||
local conf_end = vim.fn.search('^>>>>>>>', 'W')
|
||||
|
||||
local left = vim.api.nvim_buf_get_lines(bufnr, conf_start, base_start - 1, false)
|
||||
local right = vim.api.nvim_buf_get_lines(bufnr, base_end, conf_end - 1, false)
|
||||
|
||||
return {
|
||||
start = conf_start,
|
||||
stop = conf_end,
|
||||
left = left,
|
||||
right = right,
|
||||
}
|
||||
end
|
||||
|
||||
local function apply_hunk(hunks, first)
|
||||
local result = {}
|
||||
if first == -1 then -- left first
|
||||
vim.list_extend(result, hunks.left)
|
||||
vim.list_extend(result, hunks.right)
|
||||
else
|
||||
vim.list_extend(result, hunks.right)
|
||||
vim.list_extend(result, hunks.left)
|
||||
end
|
||||
|
||||
-- apply hunk in place
|
||||
vim.api.nvim_buf_set_lines(0, hunks.start - 1, hunks.stop, false, result)
|
||||
end
|
||||
|
||||
-- "combine" mappings ala vscode's merge editor
|
||||
vim.keymap.set('n', '<leader>dl', function()
|
||||
apply_hunk(get_hunks(event.buf), -1)
|
||||
end, { buffer = event.buf })
|
||||
vim.keymap.set('n', '<leader>dr', function()
|
||||
apply_hunk(get_hunks(event.buf), 1)
|
||||
end, { buffer = event.buf })
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,6 @@ vim.schedule(function()
|
|||
ai.setup {
|
||||
n_lines = 300,
|
||||
custom_textobjects = {
|
||||
i = require('mini.extra').gen_ai_spec.indent(),
|
||||
b = require('mini.extra').gen_ai_spec.buffer(),
|
||||
a = ai.gen_spec.treesitter { a = '@parameter.outer', i = '@parameter.inner' },
|
||||
f = ai.gen_spec.treesitter { a = '@function.outer', i = '@function.inner' },
|
||||
},
|
||||
|
|
@ -18,7 +16,9 @@ vim.schedule(function()
|
|||
|
||||
require('mini.git').setup()
|
||||
map('n', '<leader>gb', '<Cmd>Git blame -- %<CR>')
|
||||
map('n', '<leader>go', MiniGit.show_at_cursor)
|
||||
map('n', '<leader>go', function()
|
||||
return MiniGit.show_at_cursor()
|
||||
end)
|
||||
|
||||
local jump = require('mini.jump2d')
|
||||
jump.setup {
|
||||
|
|
|
|||
|
|
@ -3,7 +3,12 @@ local map = vim.keymap.set
|
|||
require('mini.basics').setup { mappings = { windows = true } }
|
||||
require('mini.icons').setup()
|
||||
|
||||
require('dart').setup {}
|
||||
require('dart').setup {
|
||||
tabline = {
|
||||
icons = false,
|
||||
label_marked_fg = 'cyan',
|
||||
},
|
||||
}
|
||||
|
||||
require('snacks').setup {
|
||||
bigfile = { enabled = true },
|
||||
|
|
@ -71,6 +76,7 @@ vim.schedule(function()
|
|||
json = { 'jq' },
|
||||
lua = { 'stylua' },
|
||||
python = { 'ruff' },
|
||||
nix = { 'nixfmt' },
|
||||
fish = { 'fish_indent' },
|
||||
['*'] = { 'trim_whitespace' },
|
||||
},
|
||||
|
|
@ -93,14 +99,11 @@ vim.schedule(function()
|
|||
|
||||
require('lint').linters_by_ft = {
|
||||
docker = { 'hadolint' },
|
||||
yaml = { 'yamllint' },
|
||||
sh = { 'shellcheck' },
|
||||
go = { 'golangcilint' },
|
||||
ruby = { 'rubocop' },
|
||||
fish = { 'fish' },
|
||||
bash = { 'bash' },
|
||||
nix = { 'nix' },
|
||||
php = { 'php' },
|
||||
}
|
||||
vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
|
||||
callback = function()
|
||||
|
|
@ -116,7 +119,7 @@ vim.schedule(function()
|
|||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'ripgrep', 'buffer' },
|
||||
providers = {
|
||||
lsp = { fallbacks = {}, async = true }, -- include buffer even when LSP is active
|
||||
lsp = { fallbacks = {} }, -- include buffer even when LSP is active
|
||||
path = { opts = { get_cwd = vim.fn.getcwd } }, -- use nvim pwd instead of current file pwd
|
||||
ripgrep = {
|
||||
module = 'blink-ripgrep',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue