Something went wrong. Try again.
Dotfiles V2 with Chezmoi
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298-- Bootstrap lazy.nvimlocal 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) endendvim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before-- loading lazy.nvim so that mappings are correct.-- This is also a good place to setup other settings (vim.opt)vim.g.mapleader = " "vim.g.maplocalleader = ","
-- Setup lazy.nvimrequire("lazy").setup({ spec = { -- import your plugins { import = "plugins" }, }, -- automatically check for plugin updates checker = { enabled = true, notify = false },})
-- skip backwards compatibility routines and speed up loadingvim.g.skip_ts_context_commentstring_module = true
vim.g.markdown_fenced_languages = { "ts=typescript",}
-- VARIOUS AUTOCMDS HEREvim.api.nvim_create_autocmd({ "FileType" }, { pattern = { "qf", "help", "man", "lspinfo", "spectre_panel" }, callback = function() vim.cmd([[ nnoremap <silent> <buffer> q :close<CR> set nobuflisted ]]) end,})
vim.api.nvim_create_autocmd({ "FileType" }, { pattern = { "gitcommit", "markdown" }, callback = function() vim.opt_local.spell = true vim.opt_local.wrap = true end,})
vim.api.nvim_create_autocmd({ "VimResized" }, { callback = function() vim.cmd("tabdo wincmd =") end,})
vim.api.nvim_create_autocmd({ "CmdWinEnter" }, { callback = function() vim.cmd("quit") end,})
vim.api.nvim_create_autocmd({ "TextYankPost" }, { callback = function() vim.highlight.on_yank({ higroup = "Visual", timeout = 200 }) end,})
vim.api.nvim_create_user_command("CopyRelPath", function() local path = vim.fn.expand("%") vim.fn.setreg("+", path) vim.notify('Copied "' .. path .. '" to the clipboard!')end, {})
-- remember foldsvim.cmd([[augroup remember_folds autocmd! autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent! loadviewaugroup END]])
vim.api.nvim_create_autocmd({ "BufWritePost" }, { pattern = { "*.java" }, callback = function() vim.lsp.codelens.refresh() end,})
vim.api.nvim_create_autocmd({ "BufWritePre" }, { callback = function() vim.cmd("StripTrailingWhitespace") end,})
vim.api.nvim_create_autocmd({ "BufWritePre" }, { pattern = { "*.tf", "*.tfvars" }, callback = function() vim.lsp.buf.format() end,})
vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { pattern = "deployment.yaml", callback = function() vim.opt_local.filetype = "helm" end,})
---@type table<number, {token:lsp.ProgressToken, msg:string, done:boolean}[]>local progress = vim.defaulttable()vim.api.nvim_create_autocmd("LspProgress", { ---@param ev {data: {client_id: integer, params: lsp.ProgressParams}} callback = function(ev) local client = vim.lsp.get_client_by_id(ev.data.client_id) local value = ev.data.params.value --[[@as {percentage?: number, title?: string, message?: string, kind: "begin" | "report" | "end"}]] if not client or type(value) ~= "table" then return end local p = progress[client.id]
for i = 1, #p + 1 do if i == #p + 1 or p[i].token == ev.data.params.token then p[i] = { token = ev.data.params.token, msg = ("[%3d%%] %s%s"):format( value.kind == "end" and 100 or value.percentage or 100, value.title or "", value.message and (" **%s**"):format(value.message) or "" ), done = value.kind == "end", } break end end
local msg = {} ---@type string[] progress[client.id] = vim.tbl_filter(function(v) return table.insert(msg, v.msg) or not v.done end, p)
local spinner = { "⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏" } vim.notify(table.concat(msg, "\n"), "info", { id = "lsp_progress", title = client.name, opts = function(notif) notif.icon = #progress[client.id] == 0 and " " or spinner[math.floor(vim.uv.hrtime() / (1e6 * 80)) % #spinner + 1] end, }) end,})
-- KEYMAPS-- Shorten function namelocal keymap = vim.api.nvim_set_keymap-- Silent keymap optionlocal opts = { silent = true }
keymap("v", "<leader>y", '"+y', { noremap = true })
-- open oil keymap + autocmd to also open with previewkeymap("n", "-", "<CMD>Oil --float<CR>", opts)vim.api.nvim_create_autocmd("User", { pattern = "OilEnter", callback = vim.schedule_wrap(function(args) local oil = require("oil") if vim.api.nvim_get_current_buf() == args.data.buf and oil.get_cursor_entry() then oil.open_preview() end end),})
keymap("n", "<leader>c", ":bp<bar>sp<bar>bn<bar>bd<CR>", { noremap = true, silent = true })keymap("n", "<C-S>s", ":vert sb", { noremap = true, silent = true })
keymap("n", "<C-,>", ":30winc <<CR>", opts)keymap("n", "<C-.>", ":30winc ><CR>", opts)
keymap("t", "<C-\\><C-\\>", "<C-\\><C-n>", { noremap = true })
-- jump up and down then center-- keymap("n", "<C-d>", "<C-d>zz", opts)-- keymap("n", "<C-u>", "<C-u>zz", opts)
-- save filekeymap("n", "<C-s>", ":w<CR>", opts)keymap("i", "<C-s>", "<ESC>:w<CR>", opts)
keymap("n", "<leader>fml", "<cmd>CellularAutomaton make_it_rain<CR>", opts)
keymap("", "<Up>", "<Nop>", { noremap = true, silent = true })keymap("", "<Down>", "<Nop>", { noremap = true, silent = true })keymap("", "<Left>", "<Nop>", { noremap = true, silent = true })keymap("", "<Right>", "<Nop>", { noremap = true, silent = true })
-- jump back and forth between last two bufferskeymap("n", "<leader>j", ":b#<CR>", opts)
-- neotree togglekeymap("n", "<leader>n", ":Neotree toggle<CR>", opts)
-- Modes-- normal_mode = "n",-- insert_mode = "i",-- visual_mode = "v",-- visual_block_mode = "x",-- term_mode = "t",-- command_mode = "c",
-- Resize with arrowskeymap("n", "<C-Up>", ":resize -2<CR>", opts)keymap("n", "<C-Down>", ":resize +2<CR>", opts)keymap("n", "<C-Left>", ":vertical resize -2<CR>", opts)keymap("n", "<C-Right>", ":vertical resize +2<CR>", opts)
-- Clear highlightskeymap("n", "<leader>h", "<cmd>nohlsearch<CR>", opts)
-- Better pastekeymap("v", "p", '"_dP', opts)
-- Insert --keymap("i", "jk", "<ESC>", opts) -- Press jk fast to enterkeymap("v", "J", ":m '>+1<CR>gv=gv", opts) -- Shift visual selected line downkeymap("v", "K", ":m '<-2<CR>gv=gv", opts) -- Shift visual selected line up
-- Visual ---- Stay in indent modekeymap("v", "<", "<gv", opts)keymap("v", ">", ">gv", opts)
vim.o.jumpoptions = ""
-- OPTIONSvim.opt.clipboard = ""vim.opt.colorcolumn = "80,120"vim.opt.relativenumber = truevim.opt.shiftwidth = 4vim.opt.tabstop = 4vim.opt.title = false
vim.o.background = "dark"vim.o.exrc = true -- enable project local configvim.opt.backup = false -- creates a backup filevim.opt.cmdheight = 1 -- more space in the neovim command line for displaying messagesvim.opt.completeopt = { "menuone", "noselect" } -- mostly just for cmpvim.opt.conceallevel = 1 -- i hate anything being concealed, it's weird (set to 1 for obsidian.nvim)vim.opt.cursorline = true -- highlight the current linevim.opt.expandtab = true -- convert tabs to spacesvim.opt.fileencoding = "utf-8" -- the encoding written to a filevim.opt.fillchars.eob = " " -- show empty lines at the end of a buffer as ` ` {default `~`}vim.opt.formatoptions:remove({ "c", "r", "o" }) -- This is a sequence of letters which describes how automatic formatting is to be donevim.opt.hlsearch = true -- highlight all matches on previous search patternvim.opt.ignorecase = true -- ignore case in search patternsvim.opt.iskeyword:append("-") -- treats words with `-` as single wordsvim.opt.laststatus = 3 -- only the last window will always have a status linevim.opt.linebreak = truevim.opt.list = truevim.opt.listchars = { eol = "↲", tab = ">-",}vim.opt.mouse = "a" -- allow the mouse to be used in neovimvim.opt.number = true -- set numbered linesvim.opt.numberwidth = 4 -- minimal number of columns to use for the line number {default 4}vim.opt.pumheight = 10 -- pop up menu heightvim.opt.ruler = false -- hide the line and column number of the cursor positionvim.opt.scrolloff = 8 -- minimal number of screen lines to keep above and below the cursorvim.opt.shortmess:append("c") -- hide all the completion messages, e.g. "-- XXX completion (YYY)", "match 1 of 2", "The only match", "Pattern not found"vim.opt.showcmd = false -- hide (partial) command in the last line of the screen (for performance)vim.opt.showmode = false -- we don't need to see things like -- INSERT -- anymorevim.opt.showtabline = 0 -- always show tabsvim.opt.sidescrolloff = 8 -- minimal number of screen columns to keep to the left and right of the cursor if wrap is `false`vim.opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each timevim.opt.smartcase = true -- smart casevim.opt.smartindent = true -- make indenting smarter againvim.opt.splitbelow = true -- force all horizontal splits to go below current windowvim.opt.splitright = true -- force all vertical splits to go to the right of current windowvim.opt.swapfile = false -- creates a swapfilevim.opt.termguicolors = true -- set term gui colors (most terminals support this)vim.opt.timeoutlen = 500 -- time to wait for a mapped sequence to complete (in milliseconds)vim.opt.undofile = true -- enable persistent undovim.opt.updatetime = 200 -- faster completion (4000ms default)vim.opt.whichwrap:append("<,>,[,],h,l") -- keys allowed to move to the previous/next line when the beginning/end of line is reachedvim.opt.wrap = false -- display lines as one long linevim.opt.writebackup = false -- if a file is being edited by another program (or was written to file while editing with another program), it is not allowed to be edited