Last active
July 11, 2026 23:52
-
-
Save prime-hacker/75932388ac9247be90c4b3bb2f320ebc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " =============================================================================== | |
| " MAC-ADAPTED & CLEANED VIMRC CONFIGURATION | |
| " =============================================================================== | |
| " NEEDED FOR THIS FILE TO WORK IN MACOS: | |
| " 1. Install dependencies: brew install fzf node | |
| " 2. Install vim-plug: curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ | |
| " https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
| " 3. Run :PlugInstall within Vim | |
| " ========================================== | |
| " 1. PLUGINS RUNTIME (via vim-plug) | |
| " ========================================== | |
| call plug#begin('~/.vim/plugged') | |
| Plug 'sheerun/vim-polyglot' | |
| Plug 'dense-analysis/ale' | |
| Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
| Plug 'junegunn/fzf.vim' | |
| Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
| Plug 'ludovicchabant/vim-gutentags' | |
| Plug 'preservim/nerdtree' | |
| call plug#end() | |
| " ========================================== | |
| " 2. CORE VIM BEHAVIOR & SECURITY | |
| " ========================================== | |
| set nocompatible | |
| filetype off | |
| filetype plugin indent on | |
| syntax on | |
| set history=500 | |
| set modelines=0 | |
| set encoding=utf-8 | |
| set hidden " Allow hidden buffers | |
| " Auto-read outside changes | |
| set autoread | |
| au FocusGained,BufEnter * checktime | |
| " Return to last edit position when opening files | |
| au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif | |
| " ========================================== | |
| " 3. USER INTERFACE & RENDERING (macOS Adaptive) | |
| " ========================================== | |
| set number " Show line numbers | |
| set ruler " Show file stats | |
| set cmdheight=1 | |
| set foldcolumn=1 " Add extra margin to the left | |
| set ttyfast " Fast rendering | |
| set lazyredraw " Don't redraw while executing macros | |
| set scrolloff=7 " Set 7 lines to the cursor when moving vertically | |
| " Audio/Visual Bells | |
| set noerrorbells | |
| set novisualbell | |
| set t_vb= | |
| set tm=500 | |
| " Color Configuration (Dynamic macOS Terminal Inheritance) | |
| set t_Co=256 | |
| " 1. Force background transparency so the native terminal theme shows through | |
| autocmd ColorScheme * highlight Normal ctermbg=NONE guibg=NONE | |
| autocmd ColorScheme * highlight NonText ctermbg=NONE guibg=NONE | |
| autocmd ColorScheme * highlight LineNr ctermbg=NONE guibg=NONE | |
| autocmd ColorScheme * highlight SignColumn ctermbg=NONE guibg=NONE | |
| " 2. Dynamic light/dark profile initialization (Registered permanently at boot) | |
| " --- Light Mode Interceptors --- | |
| autocmd ColorScheme * if &background == 'light' | highlight Comment ctermfg=244 cterm=italic | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Statement ctermfg=125 cterm=bold | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Type ctermfg=28 cterm=bold | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Constant ctermfg=22 | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight String ctermfg=160 | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight PreProc ctermfg=19 cterm=bold | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Function ctermfg=20 | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Special ctermfg=90 | endif | |
| autocmd ColorScheme * if &background == 'light' | highlight Identifier ctermfg=21 | endif | |
| " --- Dark Mode Interceptors --- | |
| autocmd ColorScheme * if &background == 'dark' | highlight Comment ctermfg=247 cterm=italic | endif | |
| autocmd ColorScheme * if &background == 'dark' | highlight PreProc ctermfg=51 cterm=bold | endif | |
| autocmd ColorScheme * if &background == 'dark' | highlight Function ctermfg=117 cterm=bold | endif | |
| autocmd ColorScheme * if &background == 'dark' | highlight Identifier ctermfg=85 | endif | |
| " Enable default scheme processing | |
| colorscheme default | |
| " ========================================== | |
| " 4. WHITESPACE, TABS, AND FORMATTING | |
| " ========================================== | |
| set wrap " Wrap lines | |
| set textwidth=79 | |
| set formatoptions=tcqrn1 | |
| set tabstop=2 | |
| set shiftwidth=2 | |
| set softtabstop=2 | |
| set expandtab " Use spaces instead of tabs | |
| set noshiftround | |
| set ai " Auto indent | |
| set si " Smart indent | |
| " Visualize tabs and newlines | |
| set listchars=tab:▸\ ,eol:¬ | |
| " To enable by default, uncomment: set list | |
| " Delete trailing white space on save automatically | |
| fun! CleanExtraSpaces() | |
| let save_cursor = getpos(".") | |
| let old_query = getreg('/') | |
| silent! %s/\s\+$//e | |
| call setpos('.', save_cursor) | |
| call setreg('/', old_query) | |
| endfun | |
| if has("autocmd") | |
| autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces() | |
| " Saves markdown files automatically whenever text is changed | |
| autocmd TextChanged,TextChangedI *.md silent write | |
| endif | |
| " ========================================== | |
| " 5. SEARCHING AND MATCHING | |
| " ========================================== | |
| set hlsearch " Highlight search results | |
| set incsearch " Incremental browser-like search | |
| set ignorecase " Ignore case when searching | |
| set smartcase " Smart case parsing | |
| set showmatch " Show matching bracket | |
| set matchpairs+=<:> " Use % to jump between HTML/XML pairs | |
| runtime! macros/matchit.vim | |
| " ========================================== | |
| " 6. KEYBINDINGS & MAPPINGS | |
| " ========================================== | |
| let mapleader = "," " Set defined leader key to comma | |
| " Fast saving and Sudo writing for macOS | |
| nmap <leader>w :w!<cr> | |
| command! W execute 'w !sudo tee % > /dev/null' | edit! | |
| " Clear search highlight | |
| map <leader><space> :let @/=''<cr> | |
| " Move up/down visual editor lines instead of physical lines | |
| nnoremap j gj | |
| nnoremap k gk | |
| " Toggle visual tab symbols | |
| map <leader>l :set list!<CR> | |
| " Remap help key to handle fullscreen toggles | |
| inoremap <F1> <ESC>:set invfullscreen<CR>a | |
| nnoremap <F1> :set invfullscreen<CR> | |
| vnoremap <F1> :set invfullscreen<CR> | |
| " Formatting Paragraph | |
| map <leader>q gqip | |
| " FZF Keybindings | |
| nnoremap <C-p> :Files<CR> | |
| nnoremap <Leader>b :Buffers<CR> | |
| nnoremap <Leader>h :History<CR> | |
| nnoremap <Leader>t :BTags<CR> | |
| nnoremap <Leader>T :Tags<CR> | |
| " Tab Navigation Mappings | |
| nnoremap th :tabnext<CR> | |
| nnoremap tl :tabprev<CR> | |
| nnoremap tn :tabnew<CR> | |
| nnoremap td :tabclose<CR> | |
| " Spell Checking Mappings | |
| map <leader>ss :setlocal spell!<cr> | |
| map <leader>sn ]s | |
| map <leader>sp [s | |
| map <leader>sa zg | |
| map <leader>s? z= | |
| " Surround Selection Mappings (Visual Mode) | |
| vnoremap $1 <esc>`>a)<esc>`<i(<esc> | |
| vnoremap $2 <esc>`>a]<esc>`<i[<esc> | |
| vnoremap $3 <esc>`>a}<esc>`<i{<esc> | |
| vnoremap $$ <esc>`>a"<esc>`<i"<esc> | |
| vnoremap $q <esc>`>a'<esc>`<i'<esc> | |
| vnoremap $e <esc>`>a`<esc>`<i`<esc> | |
| " Auto-pair shortcuts (Insert Mode) | |
| inoremap $1 ()<esc>i | |
| inoremap $2 []<esc>i | |
| inoremap $3 {}<esc>i | |
| inoremap $4 {<esc>o}<esc>O | |
| inoremap $q ''<esc>i | |
| inoremap $e ""<esc>i | |
| " ========================================== | |
| " 7. PLUGIN CONFIGURATIONS (ALE & COC) | |
| " ========================================== | |
| let g:ale_sign_error = '❌' | |
| let g:ale_sign_warning = '⚠️' | |
| " Modernized CoC Tab Completion engine (Fixes E117 Error) | |
| function! CheckBackspace() abort | |
| let col = col('.') - 1 | |
| return !col || getline('.')[col - 1] =~# '\s' | |
| endfunction | |
| inoremap <silent><expr> <TAB> | |
| \ coc#pum#visible() ? coc#pum#next(1) : | |
| \ CheckBackspace() ? "\<TAB>" : | |
| \ coc#refresh() | |
| inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" | |
| " CoC Code Navigation bindings | |
| nmap <silent> gd <Plug>(coc-definition) | |
| nmap <silent> gy <Plug>(coc-type-definition) | |
| nmap <silent> gi <Plug>(coc-implementation) | |
| nmap <silent> gr <Plug>(coc-references) | |
| " Highlight symbol under cursor on hold | |
| autocmd CursorHold * silent call CocActionAsync('highlight') | |
| " ========================================== | |
| " 8. HELPER UTILITIES & BUFFER MANAGEMENT | |
| " ========================================== | |
| command! Bclose call <SID>BufcloseCloseIt() | |
| function! <SID>BufcloseCloseIt() | |
| let l:currentBufNum = bufnr("%") | |
| let l:alternateBufNum = bufnr("#") | |
| if buflisted(l:alternateBufNum) | |
| buffer # | |
| else | |
| bnext | |
| endif | |
| if bufnr("%") == l:currentBufNum | |
| new | |
| endif | |
| if buflisted(l:currentBufNum) | |
| execute("bdelete! ".l:currentBufNum) | |
| endif | |
| endfunction | |
| " AUTOMATIC STARTUP DETECTION: Check macOS System Theme on Boot | |
| if has("macunix") | |
| let s:macos_theme = system('defaults read -g AppleInterfaceStyle 2>/dev/null | tr -d "\n "') | |
| if s:macos_theme ==# 'Dark' | |
| set background=dark | |
| else | |
| set background=light | |
| endif | |
| else | |
| echom "DEBUG: Failed macunix condition entirely!" | |
| endif | |
| " =============================================================================== | |
| " FORCEFUL C FUNCTION OVERRIDE (Place at the very bottom of your .vimrc) | |
| " =============================================================================== | |
| function! FixCFunctions() | |
| if &background == 'dark' | |
| highlight Function ctermfg=117 cterm=bold " Bright sky blue | |
| highlight cFunction ctermfg=117 cterm=bold | |
| highlight cCustomFunc ctermfg=117 cterm=bold " Catch-all for polyglot/treesitter | |
| else | |
| highlight Function ctermfg=20 cterm=none " Midnight blue for light mode | |
| highlight cFunction ctermfg=20 cterm=none | |
| highlight cCustomFunc ctermfg=20 cterm=none | |
| endif | |
| endfunction | |
| augroup FixSyntaxColors | |
| autocmd! | |
| " Fire whenever a file's syntax engine finishes initialization | |
| autocmd Syntax c,cpp call FixCFunctions() | |
| " Fire when live-toggling the background option profile | |
| autocmd OptionSet background call FixCFunctions() | |
| augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment