🔧 Overhaul for performance

This commit is contained in:
z3rOR0ne 2025-03-29 12:48:37 -07:00
parent 9e1b046074
commit 6365ecfe66
37 changed files with 487 additions and 345 deletions

View file

@ -0,0 +1,176 @@
vim.g.mapleader = " "
vim.keymap.set("n", "<leader>pv", vim.cmd.Ex)
vim.keymap.set("n", "J", "mzJ`z")
-- remap for vim-smoothie
vim.cmd([[nnoremap <C-D> <cmd>call smoothie#do("\<C-D>zz")<CR>]])
vim.cmd([[nnoremap <C-U> <cmd>call smoothie#do("\<C-U>zz")<CR>]])
vim.cmd([[nnoremap gg <cmd>call smoothie#do("gg")<CR>]])
vim.cmd([[nnoremap <S-g> <cmd>call smoothie#do("\<S-g>zz")<CR>]])
-- recenter on next/previous search
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
--Toggle NERDCommenter with Ctrl + c
vim.keymap.set("n", "<C-c>", "<Plug>NERDCommenterToggle")
vim.keymap.set("n", "Q", "<nop>")
-- reformats
--vim.keymap.set("n", "<leader>f", vim.lsp.buf.format)
-- global search and replace
vim.keymap.set("n", "<S-s>", ":%s///gI<Left><Left><Left><Left>")
-- single line search and replace
vim.keymap.set("n", "<S-y>", ":.,.s///g<Left><Left><Left>")
-- toggle english spellcheck
vim.keymap.set("n", "<F11>", ":set spell!<cr>", { silent = true })
-- make current file executable
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
-- Vimium Like Keybindings
vim.keymap.set("n", "<S-t>", "<c-w>:tabnew<CR>", {})
-- tab keybindings
vim.keymap.set("n", "<A-left>", "<c-w>:tabprevious<CR>", {})
vim.keymap.set("n", "<A-right>", "<c-w>:tabnext<CR>", {})
-- Use ctrl- [hl] to select the active split!
vim.keymap.set("n", "<C-h>", "<c-w>:wincmd h<CR>", {})
vim.keymap.set("n", "<C-l>", "<c-w>:wincmd l<CR>", {})
-- remap Nvim_Tree toggle to leader+'
vim.keymap.set("n", "<leader>'", "<c-w>:NvimTreeToggle<CR>", {})
-- Use ctrl - [hl] to select the active split
vim.keymap.set("n", "<C-h>", "<c-w>:wincmd h<CR>", {})
vim.keymap.set("n", "<C-l>", "<c-w>:wincmd l<CR>", {})
-- nv creates new vertical split
vim.keymap.set("n", "nv", ":vnew", { silent = true })
-- shift + p invokes Lazy sync
vim.keymap.set("n", "<S-p>", "<c-w>:Lazy sync<CR>", {})
-- control + t enable transparency
vim.keymap.set("n", "<leader>t", "<c-w>:lua ColorMyPencils()<CR>", {})
-- open :Mason using msn
vim.keymap.set("n", "msn", ":Mason", { silent = true })
-- toggle relative line number with shift + x
vim.keymap.set("n", "<S-x>", ":set relativenumber! number<cr>", {})
-- toggle multi-corsor with control + j/k
vim.cmd([[nmap <C-j> <C-Down>]])
vim.cmd([[nmap <C-k> <C-Up>]])
-- enable gitblame with ctrl + g
vim.keymap.set("n", "<C-g>", "<c-w>:GitBlameToggle<CR>", { silent = true })
-- shift + m brings up markdown previewer
vim.keymap.set("n", "<S-m>", "<c-w>:MarkdownPreview<CR>", {})
-- invoke neoformat with nf
vim.keymap.set("n", "nf", ":Neoformat<cr>", { silent = true })
-- format C and C++ Code with cp
vim.keymap.set("n", "cp", ":ClangFormat<cr>", { silent = true })
-- open fzf with ctrl + p
vim.cmd([[nnoremap fzf :silent :FZFExplore]])
vim.keymap.set("n", "<leader>f", ":FZFExplore<CR>")
-- vim.keymap.set("n", "<C-p>", "<c-w>:FZFExplore<CR>", {})
-- CtrlP: similar to fzf, but with a more simple interface
vim.keymap.set("n", "<C-p>", "<c-w>:CtrlPMixed<cr>")
-- open ripgrep
vim.cmd([[nnoremap rg :silent :Rg]])
vim.keymap.set("n", "<leader>r", ":silent :Rg")
-- restart lsp
vim.cmd([[nnoremap lsp :silent :LspRestart]])
--toggle autocompletion
vim.cmd([[nnoremap cmp :silent lua SetAutoCmp(Mode)]])
-- SudaWrite
-- vim.cmd([[nnoremap sw :SudaWrite]])
vim.keymap.set("n", "<leader>sw", ":SudaWrite")
-- appends backslash to end of specified number of lines (min 2)
-- usage: 4<leader>b will append a backslash to the end of 4 lines
-- note: useful for grabbing code snippets for chatting with codellama in terminal
vim.cmd([[nnoremap <leader>b :.,+<C-R>=v:count1<CR>norm A\<Esc>]])
--toggle undotree
vim.keymap.set("n", "<leader>u", ":UndotreeToggle<cr>")
-- runs npm tests without having to leave vim
-- vim.keymap.set("n", "<leader>t", ":w|!npm test<cr>")
-- opens go to definition in new tab if not in current file
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts)
-- toggles floating error messages
vim.keymap.set("n", "<space>e", "<cmd>vim.diagnostic.open_float()<CR>", opts)
vim.keymap.set("n", "gD", function()
local org_path = vim.api.nvim_buf_get_name(0)
-- Go to definition:
vim.api.nvim_command("normal gd")
-- Wait LSP server response
vim.wait(100, function() end)
local new_path = vim.api.nvim_buf_get_name(0)
if not (org_path == new_path) then
-- Create a new tab for the original file
vim.api.nvim_command("0tabnew %")
-- Restore the cursor position
vim.api.nvim_command("b " .. org_path)
vim.api.nvim_command('normal! `"')
-- Switch to the original tab
vim.api.nvim_command("normal! gt")
end
end, bufopts)
-- dap Keybindings
-- vim.keymap.set("n", "<leader>dbp", ":lua require'dap'.toggle_breakpoint()")
-- vim.keymap.set("n", "<leader>dco", ":lua require'dap'.continue()")
-- vim.keymap.set("n", "<leader>dov", ":lua require'dap'.step_over()")
-- vim.keymap.set("n", "<leader>dso", ":lua require'dap'.step_out()")
-- vim.keymap.set("n", "<leader>dsi", ":lua require'dap'.step_into()")
-- vim.keymap.set("n", "<leader>dcl", ":lua require'dap'.close()")
-- vim.keymap.set("n", "<leader>dui", ":lua require('dapui').toggle()")
--
-- codeium remappings
vim.keymap.set("i", "<A-tab>", function()
return vim.fn["codeium#Accept"]()
end, { expr = true })
vim.keymap.set("i", "<C-right>", function()
return vim.fn["codeium#CycleCompletions"](1)
end, { expr = true })
vim.keymap.set("i", "<C-left>", function()
return vim.fn["codeium#CycleCompletions"](-2)
end, { expr = true })
vim.keymap.set("i", "<C-x>", function()
return vim.fn["codeium#Clear"]()
end, { expr = true })
--toggle codeium on/off
function Toggle_codeium()
vim.g.codeium_enabled = not vim.g.codeium_enabled
end
vim.keymap.set("n", "<leader>c", ":lua Toggle_codeium()<cr>", { noremap = true, silent = true })
-- move single line or highlighted lines of text up cursor (alt + j/k)
vim.keymap.set("n", "<A-k>", "<c-w>:m .-2<CR>==")
vim.keymap.set("n", "<A-j>", "<c-w>:m .+1<CR>==")
vim.keymap.set("v", "<A-j>", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "<A-k>", ":m '<-2<CR>gv=gv")

View file

@ -0,0 +1,148 @@
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("config.keymaps")
require("config.options")
require("lazy").setup({
spec = {
{ import = "plugins" },
{ "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", event = "BufReadPost" },
{ "nvim-treesitter/playground" },
{
"shaunsingh/nord.nvim",
config = function()
vim.cmd("colorscheme nord")
end,
},
{ "preservim/nerdcommenter", event = "VeryLazy" },
{ "kyazdani42/nvim-web-devicons", opt = true, event = "VeryLazy" },
{ "psliwka/vim-smoothie", event = "VeryLazy" },
{ "mg979/vim-visual-multi" },
{ "airblade/vim-gitgutter", event = "BufReadPre" },
{ "kkoomen/vim-doge", build = ":call doge#install()" },
{ "simeji/winresizer" },
{ "rhysd/vim-clang-format" },
{ "sangdol/mintabline.vim" },
{ "nvim-lua/plenary.nvim" },
{ "tpope/vim-fugitive" },
{ "tpope/vim-surround", keys = { "cs", "ds", "ys" } },
{ "lambdalisue/suda.vim" },
{ "junegunn/fzf" },
{ "junegunn/fzf.vim" },
{ "junegunn/gv.vim" },
{ "kien/ctrlp.vim" },
{ "mbbill/undotree", cmd = { "UndotreeToggle" } },
{ "williamboman/mason.nvim", event = "VeryLazy" },
{ "williamboman/mason-lspconfig.nvim", event = "VeryLazy" },
{ "neovim/nvim-lspconfig", event = { "BufReadPre", "BufNewFile" } },
{
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = "cd app && npm install && git restore .",
-- or if you use yarn: (I have not checked this, I use npm)
-- build = "cd app && yarn install && git restore .",
init = function()
vim.g.mkdp_filetypes = { "markdown" }
end,
ft = { "markdown" },
},
-- Autocompletion/Snippets
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-vsnip" },
{ "VonHeikemen/lsp-zero.nvim" },
-- codeium AI
{ "Exafunction/codeium.vim" },
-- golang
{ "ray-x/go.nvim" },
{ "ray-x/guihua.lua" },
-- rustlang
{ "rust-lang/rust.vim" },
-- code snippet screenshots
-- capture code snippets using :Silicon,
-- in Visual mode highlight then enter command
{
"michaelrommel/nvim-silicon",
config = function()
require("silicon").setup({
command = "silicon",
font = "mononoki NF=34",
theme = "Nord",
no_round_corner = true,
no_line_number = true,
no_window_controls = true,
background = "#20201e",
})
end,
},
},
defaults = {
lazy = false,
version = false,
},
checker = {
enabled = true,
concurrency = 1,
frequency = 86400,
notify = false,
},
ui = {
border = "rounded",
size = {
width = 0.8,
height = 0.8,
},
},
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
},
},
},
})

View file

@ -0,0 +1,175 @@
-- fat cursor no matter what
vim.opt.guicursor = ""
--
vim.opt.nu = true
vim.opt.relativenumber = true
vim.opt.softtabstop = 0
vim.opt.shiftwidth = 4
-- vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.opt.smartindent = true
vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.opt.undofile = true
vim.opt.hlsearch = false
vim.opt.incsearch = true
vim.opt.termguicolors = true
vim.opt.scrolloff = 18
vim.opt.signcolumn = "yes"
-- vim.opt.isfname:append("@-@")
vim.opt.updatetime = 50
vim.opt.mouse = "a"
vim.opt.autoindent = true
vim.opt.smarttab = true
vim.opt.ignorecase = true
vim.opt.cindent = true
vim.opt.tabstop = 4
vim.opt.cursorcolumn = true
-- Disable folds
-- vim.g.nofoldenable = true
-- Fix Splitting
vim.opt.splitbelow = true
vim.opt.splitright = true
vim.opt.cursorcolumn = true
-- Removes trailing spaces
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})
-- Marks end of line, space, and trailing space characters
vim.opt.listchars:append({ eol = "", trail = "·", space = "·" })
vim.opt.list = true
-- return quotation marks to json files
vim.cmd([[autocmd Filetype json let g:indentLine_setConceal = 0]])
-- vertically center document when entering Insert mode (breaks shift+A)
-- vim.cmd([[autocmd InsertEnter * norm zz]])
-- enable clipboard
vim.cmd([[set clipboard+=unnamedplus]])
-- disable intro screen
vim.cmd([[set shortmess+=I]])
-- enable folds
vim.cmd([[set foldmethod=manual]])
-- enable hard/soft wrap
-- vim.cmd([[set wrap linebreak textwidth=80]])
-- vim.opt.textwidth = 80
-- vim.opt.wrap = true
-- vim.opt.linebreak = true
vim.cmd([[au BufRead,BufNewFile *.md setlocal textwidth=80]])
-- max tab characters
vim.cmd([[let g:mintabline_tab_max_chars=10]])
-- Search pattern across repository files using fzf
vim.cmd([[
function! FzfExplore(...)
let inpath = substitute(a:1, "'", '', 'g')
if inpath == "" || matchend(inpath, '/') == strlen(inpath)
execute "cd" getcwd() . '/' . inpath
let cwpath = getcwd() . '/'
call fzf#run(fzf#wrap(fzf#vim#with_preview({'source': 'ls -1ap', 'dir': cwpath, 'sink': 'FZFExplore', 'options': ['--prompt', cwpath]})))
else
let file = getcwd() . '/' . inpath
execute "e" file
endif
endfunction]])
vim.cmd([[command! -nargs=* FZFExplore call FzfExplore(shellescape(<q-args>))]])
-- CtrlP will ignore .git and node_modules directories
vim.cmd([[set wildignore+=*/node_modules/*,*/.git/*]])
vim.cmd([[let g:ctrlp_custom_ignore = '\v[\/]\.(git|node_modules)']])
-- fzf is on bottom of screen
-- vim.cmd([[let g:fzf_layout = { 'down': '~30%' }]])
--lastplace ignores fzf
--vim.cmd([[let g:lastplace_ignore_buftype = "quickfix, nofile, help, FZF"]])
-- jump to last place visited in file
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local mark = vim.api.nvim_buf_get_mark(0, '"')
local lcount = vim.api.nvim_buf_line_count(0)
if mark[1] > 0 and mark[1] <= lcount then
pcall(vim.api.nvim_win_set_cursor, 0, mark)
end
end,
})
-- Automatically closes Nvim tree if last window open
vim.cmd([[autocmd BufEnter * ++nested if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]])
-- turns off LSP semantic tokens by default
-- vim.api.nvim_create_autocmd("LspAttach", {
-- callback = function(args)
-- local client = vim.lsp.get_client_by_id(args.data.client_id)
-- client.server_capabilities.semanticTokensProvider = nil
-- end,
-- })
-- set folds to be remembered on save
vim.cmd([[
augroup remember_folds
autocmd!
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent! loadview
augroup END
]])
-- configure diagnostic lsp err msgs
-- vim.diagnostic.config({
-- underline = true,
-- signs = true,
-- virtual_text = true,
-- float = {
-- show_header = true,
-- source = "always",
-- border = "border",
-- focusable = false,
-- },
-- update_in_insert = false, -- default to false
-- severity_sort = false, -- default to false
-- })
-- codeium disable default keybindings
vim.g.codeium_disable_bindings = 1
-- codeium enable(1)/disable(0) by default
vim.g.codeium_enabled = 0
-- Markdown Previewer settings
vim.g.mkdp_browser = "librewolf"
vim.g.mkdp_theme = "dark"
-- Create Default Mappings for NerdCommenter
vim.g.NERDCreateDefaultMappings = 1
-- Add spaces after NerdCommenter delimiters by default
vim.g.NERDSpaceDelims = 1
-- Enable Comments with Italics
-- vim.cmd[[highlight Comment cterm=italic gui=italic]]
vim.g.rainbow_active = 1
-- UndoTree Settings
vim.g.undotree_DiffAutoOpen = 0
vim.g.undotree_SetFocusWhenToggle = 1
-- Vim Smoothie Settings
vim.g.smoothie_experimental_mappings = 1