Update config
This commit is contained in:
		
							parent
							
								
									de76eeffc4
								
							
						
					
					
						commit
						9678e43efe
					
				
							
								
								
									
										4
									
								
								init.lua
								
								
								
								
							
							
						
						
									
										4
									
								
								init.lua
								
								
								
								
							| 
						 | 
				
			
			@ -1058,6 +1058,7 @@ require('lazy').setup({
 | 
			
		|||
  --
 | 
			
		||||
  --  Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
 | 
			
		||||
  { import = 'custom.plugins' },
 | 
			
		||||
 | 
			
		||||
  --
 | 
			
		||||
  -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
 | 
			
		||||
  -- Or use telescope!
 | 
			
		||||
| 
						 | 
				
			
			@ -1085,5 +1086,8 @@ require('lazy').setup({
 | 
			
		|||
  },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- Custom configuration
 | 
			
		||||
require 'custom.commands'
 | 
			
		||||
 | 
			
		||||
-- The line beneath this is called `modeline`. See `:help modeline`
 | 
			
		||||
-- vim: ts=2 sts=2 sw=2 et
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)()
 | 
			
		||||
| 
						 | 
				
			
			@ -2,11 +2,6 @@
 | 
			
		|||
--  I promise not to create any merge conflicts in this directory :)
 | 
			
		||||
--
 | 
			
		||||
-- See the kickstart.nvim README for more information
 | 
			
		||||
vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter' }, { command = 'checktime' })
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_create_user_command('DeleteOtherBuffers', function()
 | 
			
		||||
  require('snacks').bufdelete.other()
 | 
			
		||||
end, { desc = 'Delete Other Buffers' })
 | 
			
		||||
 | 
			
		||||
-- Resizing windows
 | 
			
		||||
vim.keymap.set('n', '<A-h>', '<C-w>5<', { desc = 'Decrease window width' })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,7 +16,6 @@ return {
 | 
			
		|||
    }
 | 
			
		||||
  end,
 | 
			
		||||
  keys = {
 | 
			
		||||
    -- { '=', '<cmd>Oil<cr>', mode = 'n', desc = 'Open Filesystem' },
 | 
			
		||||
    { '-', '<cmd>Oil --float<cr>', mode = 'n', desc = 'Open Floating Filesystem' },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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',
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +1,14 @@
 | 
			
		|||
vim.api.nvim_create_user_command('DeleteOtherBuffers', function()
 | 
			
		||||
  require('snacks').bufdelete.other()
 | 
			
		||||
end, { desc = 'Delete Other Buffers' })
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
  'folke/snacks.nvim',
 | 
			
		||||
  ---@diagnostic disable-next-line: undefined-doc-name
 | 
			
		||||
  ---@type snacks.Config
 | 
			
		||||
  opts = {
 | 
			
		||||
    lazygit = {
 | 
			
		||||
      -- your lazygit configuration comes here
 | 
			
		||||
      -- or leave it empty to use the default settings
 | 
			
		||||
      -- refer to the configuration section below
 | 
			
		||||
    },
 | 
			
		||||
    lazygit = {},
 | 
			
		||||
    gitbrowse = {},
 | 
			
		||||
  },
 | 
			
		||||
  keys = {
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			@ -33,5 +34,12 @@ return {
 | 
			
		|||
    },
 | 
			
		||||
    { '<leader>gb', '<cmd>Gitsigns blame<cr>', desc = 'Git blame' },
 | 
			
		||||
    { '<leader>gs', '<cmd>Telescope git_status<CR>', desc = 'Git Status' },
 | 
			
		||||
    {
 | 
			
		||||
      '<leader>go',
 | 
			
		||||
      function()
 | 
			
		||||
        Snacks.gitbrowse()
 | 
			
		||||
      end,
 | 
			
		||||
      desc = 'Git Browse',
 | 
			
		||||
    },
 | 
			
		||||
  },
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue