autocommit

This commit is contained in:
realfresh 2024-12-25 13:55:30 +08:00
parent 86e62b526a
commit 0a47d77133
2 changed files with 132 additions and 7 deletions

View File

@ -34,7 +34,7 @@ What is Kickstart?
If you don't know anything about Lua, I recommend taking some time to read through If you don't know anything about Lua, I recommend taking some time to read through
a guide. One possible example which will only take 10-15 minutes: a guide. One possible example which will only take 10-15 minutes:
- https://learnxinyminutes.com/docs/lua/ - https://learnxinyminutes.com/docs/lua/ini
After understanding a bit more about Lua, you can use `:help lua-guide` as a After understanding a bit more about Lua, you can use `:help lua-guide` as a
reference for how Neovim integrates Lua. reference for how Neovim integrates Lua.
@ -91,7 +91,7 @@ vim.g.mapleader = ' '
vim.g.maplocalleader = ' ' vim.g.maplocalleader = ' '
-- Set to true if you have a Nerd Font installed and selected in the terminal -- Set to true if you have a Nerd Font installed and selected in the terminal
vim.g.have_nerd_font = false vim.g.have_nerd_font = true
-- [[ Setting options ]] -- [[ Setting options ]]
-- See `:help vim.opt` -- See `:help vim.opt`
@ -155,7 +155,7 @@ vim.opt.inccommand = 'split'
vim.opt.cursorline = true vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor. -- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10 vim.opt.scrolloff = 20
-- [[ Basic Keymaps ]] -- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()` -- See `:help vim.keymap.set()`
@ -204,6 +204,20 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end, end,
}) })
-- WARN: My Configuration
-- vim.opt.fillchars = { fold = ' ' }
-- vim.opt.foldmethod = 'indent'
-- vim.opt.foldenable = false
-- vim.opt.foldlevel = 99
-- g.markdown_folding = 1 -- enable markdown folding
vim.keymap.set('n', '<space><space>x', '<cmd>source %<CR>')
vim.keymap.set('n', '<space>x', ':.lua<CR>')
vim.keymap.set('v', '<space>x', ':lua<CR>')
-- WARN: My Configuration
-- [[ Install `lazy.nvim` plugin manager ]] -- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
@ -247,12 +261,84 @@ require('lazy').setup({
'lewis6991/gitsigns.nvim', 'lewis6991/gitsigns.nvim',
opts = { opts = {
signs = { signs = {
add = { text = '+' }, add = { text = '' },
change = { text = '~' }, change = { text = '' },
delete = { text = '_' }, delete = { text = '_' },
topdelete = { text = '' }, topdelete = { text = '' },
changedelete = { text = '~' }, changedelete = { text = '~' },
untracked = { text = '' },
}, },
signs_staged = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
untracked = { text = '' },
},
signs_staged_enable = true,
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)
-- Keybinds
map('n', '<leader>hp', gitsigns.preview_hunk)
vim.cmd [[
highlight GitSignsAdd guifg=green guibg=NONE
highlight GitSignsChange guifg=darkyellow guibg=NONE
highlight GitSignsDelete guifg=red guibg=NONE
]]
--[[
-- 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>hu', gitsigns.undo_stage_hunk)
map('n', '<leader>hR', gitsigns.reset_buffer)
map('n', '<leader>hb', function()
gitsigns.blame_line { full = true }
end)
map('n', '<leader>tb', gitsigns.toggle_current_line_blame)
map('n', '<leader>hd', gitsigns.diffthis)
map('n', '<leader>hD', function()
gitsigns.diffthis '~'
end)
map('n', '<leader>td', gitsigns.toggle_deleted)
-- Text object
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>')
--]]
end,
}, },
}, },
@ -937,7 +1023,7 @@ require('lazy').setup({
-- This is the easiest way to modularize your config. -- This is the easiest way to modularize your config.
-- --
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- { import = 'custom.plugins' }, { import = 'custom.plugins' },
-- --
-- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec`
-- Or use telescope! -- Or use telescope!

View File

@ -2,4 +2,43 @@
-- I promise not to create any merge conflicts in this directory :) -- I promise not to create any merge conflicts in this directory :)
-- --
-- See the kickstart.nvim README for more information -- See the kickstart.nvim README for more information
return {} return {
-- Add this section for nvim-ufo and its dependencies
{
'kevinhwang91/nvim-ufo',
dependencies = {
'kevinhwang91/promise-async',
'nvim-treesitter/nvim-treesitter',
},
config = function()
-- Enable fold column
vim.o.foldcolumn = '1'
-- Set fold level to 99 (effectively expanding all folds)
vim.o.foldlevel = 99
-- Start with all folds expanded
vim.o.foldlevelstart = 99
-- Use nvim-ufo provider
vim.o.foldenable = true
-- Using ufo provider need remap `zR` and `zM`
vim.keymap.set('n', 'zR', require('ufo').openAllFolds)
vim.keymap.set('n', 'zM', require('ufo').closeAllFolds)
vim.keymap.set('n', 'zm', require('ufo').closeFoldsWith) -- closeAllFolds == closeFoldsWith(0)
vim.keymap.set('n', 'K', function()
local winid = require('ufo').peekFoldedLinesUnderCursor()
if not winid then
-- choose one of coc.nvim and nvim lsp
vim.fn.CocActionAsync 'definitionHover' -- coc.nvim
vim.lsp.buf.hover()
end
end)
-- Configure UFO
require('ufo').setup {
provider_selector = function(bufnr, filetype, buftype)
return { 'treesitter', 'indent' }
end,
}
end,
},
}