init commit

This commit is contained in:
gib
2025-11-07 17:00:48 -06:00
commit df4e95bfea
37 changed files with 2114 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
local augroup = vim.api.nvim_create_augroup
local gib_group = augroup('Gib', {})
local autocmd = vim.api.nvim_create_autocmd
local yank_group = augroup('HighlightYank', {})
function R(name)
require("plenary.reload").reload_module(name)
end
autocmd('TextYankPost', {
group = yank_group,
pattern = '*',
callback = function()
vim.highlight.on_yank({
higroup = 'IncSearch',
timeout = 40,
})
end,
})
autocmd({"BufWritePre"}, {
group = gib_group,
pattern = "*",
command = [[%s/\s\+$//e]],
})
autocmd({'BufWritePost'}, {
pattern = 'init.lua',
command = 'source <afile>',
})
autocmd('LspAttach', {
group = gib_group,
callback = function(e)
local opts = { buffer = e.buf }
vim.keymap.set('n', '<leader>kf', function() vim.lsp.buf.format() end, opts)
vim.keymap.set("n", "<leader>gd", function() vim.lsp.buf.definition() end, opts)
vim.keymap.set("n", "<leader>kw", function() vim.lsp.buf.workspace_symbol() end, opts)
vim.keymap.set("n", "<leader>kd", function() vim.diagnostic.open_float() end, opts)
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
vim.keymap.set("n", "<leader>re", function() vim.lsp.buf.references() end, opts)
vim.keymap.set("n", "<leader>rn", function() vim.lsp.buf.rename() end, opts)
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
end
})
+4
View File
@@ -0,0 +1,4 @@
require'config.options'
require'config.keymaps'
require'config.lazy'
require'config.autocmd'
+41
View File
@@ -0,0 +1,41 @@
vim.g.mapleader = ' '
vim.g.maplocalleader = "\\"
vim.keymap.set('n', '<leader><leader>s', ':update<CR> :source<CR>')
vim.keymap.set('n', '<leader><leader>x', ':!chmod +x %<CR>', { silent = true })
vim.keymap.set({'n', 'v', 'x'}, '<leader>h', '<C-w>h')
vim.keymap.set({'n', 'v', 'x'}, '<leader>j', '<C-w>j')
vim.keymap.set({'n', 'v', 'x'}, '<leader>k', '<C-w>k')
vim.keymap.set({'n', 'v', 'x'}, '<leader>l', '<C-w>l')
vim.keymap.set('n', '<leader>w', ':write<CR>')
vim.keymap.set('n', '<leader>q', ':quit<CR>')
-- Move the selected lines up or down one line and reselect
vim.keymap.set('v', 'J', ':m \'>+1<CR>gv=gv')
vim.keymap.set('v', 'K', ':m \'<-2<CR>gv=gv')
-- Join the current line with the line below and reposition the cursor
vim.keymap.set('n', 'J', 'mzJ`z')
-- Scroll down or up and reposition the cursor
vim.keymap.set('n', '<C-d>', '<C-d>zz')
vim.keymap.set('n', '<C-u>', '<C-u>zz')
-- Search forward and reposition the cursor
vim.keymap.set('n', 'n', 'nzzzv')
-- Search backward and reposition the cursor
vim.keymap.set('n', 'N', 'Nzzzv')
-- Paste the selection from the system clipboard
vim.keymap.set({'n', 'v', 'x'}, '<leader>p', [["+p]])
vim.keymap.set({'n', 'v', 'x'}, '<leader>P', [["+P]])
-- Move selected text to the black hole register & replace with copied text.
vim.keymap.set('x', '<leader>v', [["_dP]])
-- Yank (copy) the selection to the system clipboard
vim.keymap.set({'n', 'v'}, '<leader>y', [["+y]])
-- Yank (copy) the entire buffer to the system clipboard
vim.keymap.set('n', '<leader>yy', [["+Y]])
-- Yank all the text in the file to the system clipboard
vim.keymap.set('n', '<leader>YY', ':%y+<CR>')
-- Delete the selection without yanking (copying) it
vim.keymap.set({'n', 'v'}, '<leader>d', [["_d]])
-- Delete the line without yanking (copying) it
vim.keymap.set('n', '<leader>dd', [["_dd]])
-- Map Q in Normal mode to do nothing (nop)
vim.keymap.set('n', 'Q', '<nop>')
-- Perform a search and replace operation using the word under the cursor
vim.keymap.set('n', '<leader>sr', [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
+28
View File
@@ -0,0 +1,28 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--branch=stable",
lazyrepo,
lazypath
})
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
require'lazy'.setup({
spec = { { import = 'plugins' } },
install = { colorscheme = { 'tokyonight-moon' } },
checker = { enabled = false },
})
+21
View File
@@ -0,0 +1,21 @@
vim.o.number = true
vim.o.relativenumber = true
vim.o.winborder = 'rounded'
vim.o.tabstop = 2
vim.o.softtabstop = 2
vim.o.shiftwidth = 2
vim.o.expandtab = true
vim.o.smartindent = true
vim.o.swapfile = false
vim.o.undodir = os.getenv('HOME') .. '/.vim/undodir'
vim.o.undofile = true
vim.o.hlsearch = true
vim.o.incsearch = true
vim.o.termguicolors = true
vim.o.scrolloff = 4
vim.o.signcolumn = 'yes'
vim.o.updatetime = 50
vim.opt.isfname:append('@-@')
vim.cmd([[set list]])
vim.cmd([[set listchars=trail:⋅,nbsp:⋅,tab:\ \ ]])
vim.cmd(':hi statusline guibg=NONE')