Update config
parent
de76eeffc4
commit
9678e43efe
@ -0,0 +1,2 @@
|
||||
-- Update file on focus if it was changed
|
||||
vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' }, { command = 'checktime' })
|
@ -0,0 +1,3 @@
|
||||
require 'custom.commands.files'
|
||||
require 'custom.commands.quickfix'
|
||||
require 'custom.commands.shadafile'
|
@ -0,0 +1,51 @@
|
||||
-- Shortcuts for quickfix
|
||||
|
||||
local function clamp(target, a, b)
|
||||
if target <= a then
|
||||
return a
|
||||
end
|
||||
if target >= b then
|
||||
return b
|
||||
end
|
||||
return target
|
||||
end
|
||||
|
||||
local function clamp_linecount(target)
|
||||
local count = vim.api.nvim_buf_line_count(0)
|
||||
return clamp(target, 1, count)
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('BufWinEnter', {
|
||||
callback = function(ev)
|
||||
if vim.bo[ev.buf].buftype ~= 'quickfix' then
|
||||
return
|
||||
end
|
||||
|
||||
vim.keymap.set('n', 'dd', function()
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
|
||||
local entries = vim.fn.getqflist()
|
||||
local rm_index = cursor[1]
|
||||
table.remove(entries, rm_index)
|
||||
vim.fn.setqflist(entries)
|
||||
|
||||
vim.api.nvim_win_set_cursor(0, { clamp_linecount(cursor[1]), cursor[2] })
|
||||
end, { buffer = ev.buf })
|
||||
|
||||
vim.keymap.set('v', 'd', function()
|
||||
local cursor = vim.api.nvim_win_get_cursor(0)
|
||||
|
||||
local from, to = vim.fn.line 'v', vim.fn.line '.'
|
||||
local qf = {}
|
||||
for i, v in ipairs(vim.fn.getqflist()) do
|
||||
if i < from or i > to then
|
||||
table.insert(qf, v)
|
||||
end
|
||||
end
|
||||
vim.fn.setqflist(qf)
|
||||
vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<esc>', true, true, true), 'nv', false)
|
||||
|
||||
vim.api.nvim_win_set_cursor(0, { clamp_linecount(from), cursor[2] })
|
||||
end, { buffer = ev.buf })
|
||||
end,
|
||||
})
|
@ -0,0 +1,26 @@
|
||||
-- This code configures Neovim's ShaDa file (short for Shared data) to be stored separately for each project.
|
||||
-- The benefit of this approach is that each project gets its own independent ShaDa file, which means:
|
||||
-- - Project-specific histories don't mix
|
||||
-- - Marks and registers are isolated per project
|
||||
-- - Buffer lists are maintained separately
|
||||
-- - Less chance of conflicts between different projects
|
||||
--
|
||||
-- For example, if you're working on two different projects:
|
||||
-- - Project A: `/home/user/projectA` -> Gets its own ShaDa file
|
||||
-- - Project B: `/home/user/projectB` -> Gets its own ShaDa file
|
||||
--
|
||||
-- This keeps the project-specific data cleanly separated instead of having all projects share the same ShaDa file.
|
||||
|
||||
vim.opt.shadafile = (function()
|
||||
local data = vim.fn.stdpath 'data'
|
||||
|
||||
local cwd = vim.fn.getcwd()
|
||||
cwd = vim.fs.root(cwd, '.git') or cwd
|
||||
|
||||
local cwd_b64 = vim.base64.encode(cwd)
|
||||
|
||||
local file = vim.fs.joinpath(data, 'project_shada', cwd_b64)
|
||||
vim.fn.mkdir(vim.fs.dirname(file), 'p')
|
||||
|
||||
return file
|
||||
end)()
|
@ -0,0 +1,29 @@
|
||||
return {
|
||||
'rgroli/other.nvim',
|
||||
lazy = false,
|
||||
config = function()
|
||||
require('other-nvim').setup {
|
||||
mappings = {
|
||||
'golang',
|
||||
{ pattern = '/app/(.*)/(.*).rb', target = { { context = 'test', target = '/spec/%1/%2_spec.rb' } } },
|
||||
{ pattern = '(.+)/spec/(.*)/(.*)_spec.rb', target = { { target = '%1/app/%2/%3.rb' } } },
|
||||
},
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'<leader>to',
|
||||
function()
|
||||
require('other-nvim').open()
|
||||
end,
|
||||
mode = 'n',
|
||||
},
|
||||
{
|
||||
'<leader>tO',
|
||||
function()
|
||||
require('other-nvim').openVSplit()
|
||||
end,
|
||||
mode = 'n',
|
||||
},
|
||||
},
|
||||
}
|
Loading…
Reference in New Issue