Created
May 16, 2026 15: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 | |
| if &background == 'light' | |
| " High-contrast syntax tweaks for white mode (No more light blue/yellow text) | |
| autocmd ColorScheme * highlight Comment ctermfg=244 cterm=italic " Deep slate gray comments | |
| autocmd ColorScheme * highlight Statement ctermfg=125 cterm=bold " Rich maroon for keywords (if, else, return) | |
| autocmd ColorScheme * highlight Type ctermfg=28 cterm=bold " Forest green for C types (int, char, struct) | |
| autocmd ColorScheme * highlight Constant ctermfg=22 " Olive green for numbers and macros | |
| autocmd ColorScheme * highlight String ctermfg=160 " Vivid crimson red for strings | |
| autocmd ColorScheme * highlight PreProc ctermfg=19 cterm=bold " Dark royal blue for preprocessor (#include, #define) | |
| autocmd ColorScheme * highlight Function ctermfg=20 " Midnight blue for function declarations | |
| autocmd ColorScheme * highlight Special ctermfg=90 " Dark purple for special characters (\n, %d) | |
| autocmd ColorScheme * highlight Identifier ctermfg=21 " Solid blue variables | |
| 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 = '⚠️' | |
| " CoC Tab Completion logic | |
| function! s:check_back_space() abort | |
| let col = col('.') - 1 | |
| return !col || getline('.')[col - 1] =~ '\s' | |
| endfunction | |
| inoremap <silent><expr> <Tab> | |
| \ pumvisible() ? "\<C-n>" : | |
| \ <SID>check_back_space() ? "\<Tab>" : | |
| \ coc#refresh() | |
| " 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment