(neovim) another try of my own setup

This commit is contained in:
Bartek Stalewski 2025-07-24 03:26:03 +02:00
parent 50e0f23feb
commit 7225cf3967
Signed by: ftpd
SSH key fingerprint: SHA256:vGQiaNJcfUMLt3wF58+Zx15C6SpRDA9spUeggjVY8Yo
54 changed files with 677 additions and 586 deletions

View file

@ -0,0 +1,37 @@
-- don't auto comment new line
vim.api.nvim_create_autocmd("BufEnter", { command = [[set formatoptions-=cro]] })
-- resize neovim split when terminal is resized
vim.api.nvim_command("autocmd VimResized * wincmd =")
-- enable spell for text files
vim.api.nvim_create_autocmd("FileType", {
group = vim.api.nvim_create_augroup("spell", { clear = true }),
pattern = { "text", "plaintex", "typst", "gitcommit", "markdown" },
callback = function()
vim.opt_local.spell = true
end,
})
-- set some colors
vim.api.nvim_create_autocmd({ "BufReadPre" }, {
callback = function()
vim.api.nvim_set_hl(0, "ColorColumn", { bg = "#770000" })
vim.api.nvim_set_hl(0, "DiffChange", { bg = "NONE", fg = "#e7c547" })
vim.api.nvim_set_hl(0, "DiffText", { bg = "NONE", fg = "#ff8700" })
vim.api.nvim_set_hl(0, "Visual", { bg = "#0094d8", fg = "#ffffff" })
end,
})
-- fix dimmed elements in Snacks.picker
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
callback = function()
Snacks.util.set_hl({
PickerDir = { link = "Text" },
PickerPathHidden = { link = "Text" },
PickerPathIgnored = { link = "Comment" },
PickerGitStatusUntracked = { link = "Special" },
}, { prefix = "Snacks" })
end,
})

View file

@ -0,0 +1,110 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
local map = vim.keymap.set
local nomap = vim.keymap.del
nomap("n", "<leader><space>")
nomap("n", "<leader>,")
nomap("n", "<leader>.")
nomap("n", "<leader>?")
nomap("n", "<leader>K")
nomap("n", "<leader>l")
nomap("n", "<leader>L")
nomap("n", "<leader>S")
nomap("n", "<leader>`")
nomap("n", "<leader>bb")
nomap("n", "<leader>bD")
nomap("n", "<leader>bo")
nomap("n", "<leader>E")
nomap("n", "<leader>fb")
nomap("n", "<leader>fc")
nomap("n", "<leader>fF")
nomap("n", "<leader>fr")
nomap("n", "<leader>fB")
nomap("n", "<leader>fe")
nomap("n", "<leader>fE")
nomap("n", "<leader>fn")
nomap("n", "<leader>fp")
nomap("n", "<leader>fR")
nomap("n", "<leader>ft")
nomap("n", "<leader>fT")
nomap("n", "<leader>gY")
nomap("n", "<leader>gS")
nomap("n", "<leader>qq")
nomap("n", "<leader>xl")
nomap("n", "<leader>xq")
map("i", "<C-a>", "<esc>I")
map("i", "<C-e>", "<esc>A")
map("n", "<esc><cr>", "<esc><cmd>wq!<cr>", { desc = "Save and Exit", remap = true })
map("n", "<tab>", "<C-w>w", { desc = "Switch Pane", remap = true })
map("n", "+", ":vertical resize +5<CR>")
map("n", "_", ":vertical resize -5<CR>")
map("n", "=", ":resize +5<CR>")
map("n", "-", ":resize -5<CR>")
map("n", "<leader>-", "<C-W>s", { desc = "Split Horizontally", remap = true })
map("n", "<leader>/", "gcc", { desc = "Toggle Comments", remap = true })
map("n", "<leader>|", "<C-W>v", { desc = "Split Vertically", remap = true })
map("n", "<leader>b[", "<cmd>bprevious<CR>", { desc = "buffer previous", remap = true })
map("n", "<leader>b]", "<cmd>bnext<CR>", { desc = "buffer next", remap = true })
map("n", "<leader>bd", function()
Snacks.bufdelete()
end, { desc = "buffer delete", remap = true })
map("n", "<leader>bl", function()
Snacks.picker.buffers()
end, { desc = "buffer list", remap = true })
map("n", "<leader>bn", "<cmd>enew<CR>", { desc = "buffer create", remap = true })
map("n", "<leader>e", function()
Snacks.explorer()
end, { desc = "Explorer", remap = true })
map("n", "<leader>s", "<cmd>set hlsearch!<cr>", { desc = "toggle hlsearch", remap = true })
map("n", "<leader>ff", function()
Snacks.picker.files()
end, { desc = "files", remap = true })
map("n", "<leader>fg", function()
Snacks.picker.grep()
end, { desc = "grep", remap = true })
map("n", "<leader>hc", function()
Snacks.picker.command_history()
end, { desc = "commands", remap = true })
map("n", "<leader>hn", "<cmd>Noice<CR>", { desc = "notifications", remap = true })
map("n", "<leader>hs", function()
Snacks.picker.search_history()
end, { desc = "search", remap = true })
map("n", "<leader>n", function()
vim.cmd("set number!")
vim.cmd('execute "set signcolumn=" . (&signcolumn == "yes" ? "no" : "yes")')
if Snacks.indent.enabled then
Snacks.indent.disable()
else
Snacks.indent.enable()
end
end, { desc = "Toggle Decorations", remap = true })
map("n", "<leader>T", function()
Snacks.terminal()
end, { desc = "Terminal", remap = true })
map("n", "<leader>s", "<cmd>set hlsearch!<cr>", { desc = "Toggle hlsearch", remap = true })
map("n", "<leader>us", "<cmd>set spell!<cr>", { desc = "toggle spell", remap = true })
map("n", "<leader>uw", "<cmd>set wrap!<cr>", { desc = "toggle wrap", remap = true })
map("v", "<leader>/", "gc", { desc = "Toggle Comments", remap = true })

View file

@ -0,0 +1,55 @@
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 = {
-- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins
{ import = "plugins" },
},
defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
-- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver
},
checker = {
enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update
}, -- automatically check for plugin updates
performance = {
rtp = {
-- disable some rtp plugins
disabled_plugins = {
"gzip",
-- "matchit",
-- "matchparen",
-- "netrwPlugin",
"tarPlugin",
"tohtml",
"tutor",
"zipPlugin",
},
},
},
rocks = {
enabled = false,
},
})

View file

@ -0,0 +1,44 @@
vim.filetype.add({
pattern = {
["helmfile.y.ml"] = "helm",
[".*.gotmpl"] = "helm",
},
})
vim.o.backup = false
vim.o.breakindent = true
vim.o.confirm = true
vim.o.cursorline = true
vim.o.expandtab = true
vim.o.gdefault = true
vim.o.hlsearch = true
vim.o.inccommand = "split"
vim.o.number = true
vim.o.relativenumber = false
vim.o.shiftround = true
vim.o.showcmd = false
vim.o.showmode = false
vim.o.smartcase = true
vim.o.smartindent = true
vim.o.splitbelow = true
vim.o.splitright = true
vim.o.termguicolors = true
vim.o.undofile = true
vim.o.wrap = true
vim.o.writebackup = false
vim.o.clipboard = ""
vim.o.conceallevel = 0
vim.o.fileencoding = "utf-8"
vim.o.foldcolumn = "0"
vim.o.mouse = ""
vim.o.shiftwidth = 2
vim.o.signcolumn = "yes"
vim.o.softtabstop = 2
vim.o.spelllang = "en_us,pl"
vim.o.statuscolumn = ""
vim.o.tabstop = 2
vim.o.updatetime = 100
vim.o.whichwrap = ""
vim.opt.shortmess:append({ W = true, I = true, c = true, C = true, S = false })