feat: debloat

This commit is contained in:
2024-10-31 17:53:54 +01:00
parent 28a349bb6f
commit 93b501048d
12 changed files with 124 additions and 268 deletions
-4
View File
@@ -1,4 +0,0 @@
-- Tell neovim to prefer tmux as clipboard over xsel/xclip.
if vim.fn.getenv("TMUX") ~= vim.NIL then
vim.fn.setenv("DISPLAY", vim.NIL)
end
+1 -5
View File
@@ -1,5 +1,5 @@
vim.g.mapleader = " "
vim.g.vimsyn_embed = "1"
vim.g.vimsyn_embed = "lpP"
vim.g.netrw_banner = 0
vim.g.netrw_liststyle = 1
vim.g.netrw_list_hide = '\\.venv/,\\.git/'
@@ -11,7 +11,3 @@ vim.g.netrw_sort_options = 'i'
vim.g.netrw_sort_sequence = '[\\/]\\s*,*'
vim.g.netrw_special_syntax = 1
vim.g.netrw_timefmt = '%d-%m-%Y %H:%M'
vim.cmd.language("en_US.UTF-8")
-- Bundled plugins config
vim.g.zig_fmt_autosave = 0
+16 -33
View File
@@ -1,44 +1,27 @@
--- Tab mappings ---
-- Tab mappings ---
vim.keymap.set("n", "tn", vim.cmd.tabnew)
vim.keymap.set("n", "tq", vim.cmd.tabclose)
-- switch tabs with Ctrl+PgUp/Ctrl+PgDwn (default vim mapping)
--- Buffer mappings ---
-- Center cursorline
vim.keymap.set("n", "<leader><leader>", "zz")
-- Save buffer
vim.keymap.set("n", "<C-s>", function ()
vim.cmd.write({ mods = { silent = true, }, })
end)
-- Cycle buffers
vim.keymap.set("n", "<C-End>", vim.cmd.bnext)
vim.keymap.set("n", "<C-Home>", vim.cmd.bprev)
--- Navigation ---
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
-- nnoremap <expr> j v:count ? 'j' : 'gj'
-- nnoremap <expr> k v:count ? 'k' : 'gk'
--- General mappings ---
-- yank/put using named register
vim.keymap.set({ "n", "x", }, "<leader>y", '"+y')
-- Clipboard
if vim.env.TMUX and vim.fn.executable('tmux') then
vim.keymap.set(
{ "n", "x" },
"<leader>y",
"\"+y:call system('tmux load-buffer -w -', @+)<CR>"
)
else
vim.keymap.set({ "n", "x", }, "<leader>y", '"+y')
end
vim.keymap.set({ "n", "x", }, "<leader>p", '"+p')
vim.keymap.set({ "n", "x", }, "<leader>P", '"+P')
vim.keymap.set({ "n", "x", }, "<leader>+", function ()
vim.fn.setreg("+", vim.fn.getreg('"'))
end)
vim.keymap.set({ "n", "x", }, "<leader>+", ":call setreg('+', @\")<CR>")
-- Allow exiting insert mode in terminal by hitting <ESC>
vim.keymap.set("t", "<Esc>", "<C-\\><C-n>")
-- Use :diffput/get instead of normal one to allow staging visual selection
vim.keymap.set("n", "<leader>dp", vim.cmd.diffput)
vim.keymap.set("x", "<leader>dp", ":diffput<CR>")
vim.keymap.set("n", "<leader>do", vim.cmd.diffget)
vim.keymap.set("x", "<leader>do", ":diffget<CR>")
vim.keymap.set({"n", "x"}, "<leader>dp", ":diffput<CR>")
vim.keymap.set({"n", "x"}, "<leader>do", ":diffget<CR>")
vim.keymap.set({ "n", "i", }, "<C-e>",
function ()
if vim.fn.pumvisible() ~= 0 then
@@ -56,6 +39,8 @@ vim.keymap.set({ "n", "i", }, "<C-e>",
{ expr = true, }
)
vim.keymap.set("n", "<C-w>q", ":bp \\| bd#<CR>")
-- Allow (de)indenting without deselecting
vim.keymap.set({"x"}, "<", "<gv")
vim.keymap.set({"x"}, ">", ">gv")
@@ -73,7 +58,6 @@ vim.keymap.set('i', '<C-f>', '<Right>')
vim.keymap.set('i', '<C-b>', '<Left>')
vim.keymap.set('i', '<C-a>', '<C-o>^')
vim.keymap.set('i', '<C-e>', '<C-o>$')
vim.keymap.set('i', '<C-k>', '<C-o>C')
vim.keymap.set('i', '<C-d>', '<C-o>x')
vim.keymap.set('i', '<M-f>', '<C-o>w')
vim.keymap.set('i', '<M-b>', '<C-o>b')
@@ -85,7 +69,6 @@ vim.keymap.set('c', '<C-f>', '<Right>')
vim.keymap.set('c', '<C-b>', '<Left>')
vim.keymap.set('c', '<C-a>', '<Home>')
vim.keymap.set('c', '<C-e>', '<End>')
-- vim.keymap.set('c', '<C-k>', '???')
vim.keymap.set('c', '<C-d>', '<Delete>')
vim.keymap.set('c', '<C-n>', '<Down>')
vim.keymap.set('c', '<C-p>', '<Up>')
+61 -11
View File
@@ -15,7 +15,6 @@ vim.opt.fillchars = {
}
vim.opt.splitbelow = true
vim.opt.splitright = true
-- set tabline=%!MyTabLine()
vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.expandtab = true
@@ -25,7 +24,6 @@ vim.opt.smarttab = false
vim.opt.foldlevelstart = 99
vim.opt.foldmethod = "indent"
vim.opt.foldignore = ""
vim.opt.guifont = "JetBrains Mono:11"
vim.opt.completeopt:append({
"menu",
"menuone",
@@ -34,8 +32,7 @@ vim.opt.completeopt:append({
"noselect",
})
-- set nowrap
vim.opt.matchpairs:append({ "<:>", "':'", "\":\"", })
vim.opt.fileencoding = "utf-8"
vim.opt.matchpairs:append({ "<:>", })
-- Only relevant with wrap enabled (default)
vim.opt.linebreak = true
vim.opt.breakindent = true
@@ -46,12 +43,6 @@ vim.opt.visualbell = true
vim.opt.errorbells = false
-- Persistent undo even after you close a file and re-open it
vim.opt.undofile = true
-- Insert mode key word completion setting, see :h 'compelete'
-- and https://medium.com/usevim/set-complete-e76b9f196f0f#:~:text=When%20in%20Insert%20mode%2C%20you,%2D%2D%20CTRL%2DN%20goes%20backwards.
-- kspell is only relevant if ':set spell' is toggled on, e.g. when editing
-- documents
vim.opt.complete = ".,kspell"
vim.opt.spelllang = "en"
-- Align indent to next multiple value of shiftwidth.
-- E.g., only insert as many spaces necessary for reaching the next shiftwidth
vim.opt.shiftround = true
@@ -73,7 +64,6 @@ vim.opt.diffopt:append("internal")
-- These make diffs easier to read, please see the following:
-- https://vimways.org/2018/the-power-of-diff/
vim.opt.diffopt:append({ "indent-heuristic", "algorithm:histogram", })
vim.cmd.filetype("plugin on")
vim.opt.hlsearch = true
vim.opt.laststatus = 3
vim.opt.textwidth = 0
@@ -82,3 +72,63 @@ vim.opt.shortmess:append("a")
vim.opt.autoread = true
-- vim.opt.cmdheight = 0 -- To hide cmdline when not used. Disabled due to
-- causing "Press ENTER to continue" messages for small messages.
vim.opt.jumpoptions = {'stack', 'view', 'clean'}
vim.opt.updatetime = 100
function _G._status_line_git()
local status = vim.b.gitsigns_status_dict
if not status then
return ''
end
local parts = {}
if status.added > 0 then
table.insert(parts, string.format("%%#GitSignsAdd#+%d%%*", status.added))
end
if status.changed > 0 then
table.insert(parts, string.format('%%#GitSignsChange#~%d%%*', status.changed))
end
if status.removed > 0 then
table.insert(parts, string.format('%%#GitSignsDelete#-%d%%*', status.removed))
end
return table.concat(parts, " ")
end
function _G._status_line_diagnostics()
local diag = vim.diagnostic.count(0)
local err = diag[vim.diagnostic.severity.ERROR] or 0
local warn = diag[vim.diagnostic.severity.WARN] or 0
local hint = diag[vim.diagnostic.severity.HINT] or 0
local info = diag[vim.diagnostic.severity.INFO] or 0
local parts = {}
if err > 0 then
table.insert(parts, string.format("%%#DiagnosticError#E%d%%*", err))
end
if warn > 0 then
table.insert(parts, string.format('%%#DiagnosticWarn#W%d%%*', warn))
end
if hint > 0 then
table.insert(parts, string.format('%%#DiagnosticHint#H%d%%*', hint))
end
if info > 0 then
table.insert(parts, string.format('%%#DiagnosticInfo#I%d%%*', info))
end
return table.concat(parts, " ")
end
vim.opt.statusline = " %f%4( %m%) %{%v:lua._status_line_git()%} %="
.. " %{%v:lua._status_line_diagnostics()%} "
.. " %{&filetype} %-6.6{&fileencoding}"
.. " %-4.4{&fileformat} %4.4(%p%%%)%5.5l:%-3.3v"
vim.cmd("syntax on")
vim.cmd("filetype plugin indent on")
-42
View File
@@ -1,42 +0,0 @@
local module_name = "core.user_commands"
local utils = require("utils")
vim.api.nvim_create_user_command("Update", function(_)
local lazy = utils.try_require("lazy")
if lazy then
lazy.update()
end
local treesitter_install = utils.try_require("nvim-treesitter.install")
if treesitter_install then
treesitter_install.update({ with_sync = true })("all")
end
local mason_update_all = utils.try_require("mason-update-all")
if mason_update_all then
mason_update_all.update_all()
end
end, {
desc = "Update lazy plugins, treesitter parsers and mason language servers",
force = false,
})
vim.api.nvim_create_user_command("Cmake", function(ctx)
local args = ctx.fargs
if vim.tbl_isempty(args) then
args = { "--build", "build" }
end
local mp = vim.o.makeprg
vim.o.makeprg = "cmake"
local ok, res = pcall(vim.cmd.make, { args = args, bang = ctx.bang })
vim.o.makeprg = mp
if not ok then
utils.err(res)
end
end, {
desc = "Like :make, but for CMake",
force = false,
nargs = "*",
})
-9
View File
@@ -1,9 +0,0 @@
-- https://github.com/famiu/bufdelete.nvim
---@type LazyPluginSpec
return {
"famiu/bufdelete.nvim",
keys = {
{ "<C-w>q", vim.cmd.Bwipeout, { remap = false, silent = true }, mode = "n" },
},
}
-40
View File
@@ -1,40 +0,0 @@
-- https://github.com/cbochs/grapple.nvim
---@type LazyPluginSpec
return {
"cbochs/grapple.nvim",
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
local grapple = require("grapple")
grapple.setup()
vim.keymap.set("n", "<leader>'", grapple.toggle_tags)
vim.keymap.set("n", "<leader>mm", function()
if grapple.exists() then
grapple.untag()
return
end
for i = 1, 9 do
local opts = { name = "m" .. i }
if not grapple.exists(opts) then
grapple.tag(opts)
return
end
end
grapple.tag({ name = "m0" })
end)
for i = 1, 9 do
local opts = { name = "m" .. i }
vim.keymap.set("n", "<leader>m" .. i, function()
grapple.tag(opts)
end)
vim.keymap.set("n", "<leader>" .. i, function()
grapple.select(opts)
end)
end
end,
}
-8
View File
@@ -1,8 +0,0 @@
-- https://github.com/lvimuser/lsp-inlayhints.nvim
---@type LazyPluginSpec
return {
"lvimuser/lsp-inlayhints.nvim",
branch = "anticonceal",
config = true,
}
-41
View File
@@ -1,41 +0,0 @@
-- https://github.com/nvim-lualine/lualine.nvim
---@type LazyPluginSpec
return {
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
config = function()
local custom_moonfly = require("lualine.themes.moonfly")
custom_moonfly.normal.c.bg = require("moonfly").palette.bg
require("lualine").setup({
options = {
icons_enabled = false,
theme = custom_moonfly,
component_separators = { left = "", right = "" },
section_separators = { left = "", right = "" },
always_divide_middle = true,
globalstatus = true,
},
sections = {
lualine_a = {},
lualine_b = {},
lualine_c = {
{ "filename", path = 1 },
{ "diff" },
{ "diagnostics", sources = { "nvim_diagnostic" } },
{ require("grapple").statusline, cond = require("grapple").exists },
},
lualine_x = {
"bo:filetype",
"encoding",
"bo:fileformat",
"progress",
"location",
},
lualine_y = {},
lualine_z = {},
},
})
end,
}
-14
View File
@@ -1,14 +0,0 @@
-- https://github.com/simeji/winresizer
---@type LazyPluginSpec
return {
"simeji/winresizer",
keys = {
{ "<C-W>r", vim.cmd.WinResizerStartResize, mode = "n" },
},
init = function()
vim.g.winresizer_vert_resize = "5"
vim.g.winresizer_horiz_resize = "5"
vim.g.winresizer_start_key = ""
end,
}
-9
View File
@@ -1,9 +0,0 @@
-- https://github.com/sindrets/winshift.nvim
---@type LazyPluginSpec
return {
"sindrets/winshift.nvim",
keys = {
{ "<C-W>m", vim.cmd.WinShift, mode = "n" },
},
}