" ========================================
" Basic Vim configuration for Debian/Ubuntu
" Maintainer: Your Name
" Date: 2025-09-23
" ========================================

" Bail out if running as evim
if v:progname =~? "evim"
  finish
endif

" Load Vim defaults
source $VIMRUNTIME/defaults.vim

" ----------------------------
" Swap, backup, and undo setup
" ----------------------------
" Directories for swap, backup, and undo files
let s:vim_dir = $HOME . '/.vim'
let &directory = s:vim_dir . '/swap//'
let &backupdir  = s:vim_dir . '/backup//'
let &undodir    = s:vim_dir . '/undo//'

" Create directories if they don't exist
if !isdirectory(s:vim_dir . '/swap')
    call mkdir(s:vim_dir . '/swap', 'p')
endif
if !isdirectory(s:vim_dir . '/backup')
    call mkdir(s:vim_dir . '/backup', 'p')
endif
if !isdirectory(s:vim_dir . '/undo')
    call mkdir(s:vim_dir . '/undo', 'p')
endif

" Enable swap, backup, and persistent undo
set swapfile
set backup
set undofile

" ----------------------------
" Visual & editing enhancements
" ----------------------------
" Line numbers and cursor line
set number

" Highlight search matches
set hlsearch
set incsearch

" Matching brackets/parentheses
set showmatch

" Tabs and indentation
set tabstop=4
set shiftwidth=4
set expandtab

" Syntax highlighting and colors
syntax on
set termguicolors
set background=dark

" Command history
set history=1000
set viminfo='1000,<1000,s100

" Search case handling
set ignorecase
set smartcase

" Enable mouse support
set mouse=a

" ---------------------------
"  Clipboard settings
" ---------------------------
" Use system clipboard
set clipboard=unnamedplus
nnoremap x "+x
nnoremap dd "_dd
nnoremap D "_D
nnoremap C "_C
" Paste clipboard below as new line
nnoremap <leader>p :put +<CR>
" Paste clipboard above as new line
nnoremap <leader>P :put! +<CR>




" ----------------------------
" Filetype-specific settings
" ----------------------------
augroup vimrcEx
  autocmd!
  " Text files: wrap at 78 characters
  autocmd FileType text setlocal textwidth=78
augroup END

" ----------------------------
" Optional plugins
" ----------------------------
" matchit: improves % for matching tags/brackets
if has('syntax') && has('eval')
  packadd! matchit
endif

" Done

