" ~/.vimrc
" Vim configuration for Stormux

" Ensure vim directory structure exists
" mkdir -p ~/.vim/{backup,swap,views}

set nocompatible              " Use Vim settings (not Vi compatible)
filetype off                  " Required for some plugins

" Terminal and encoding
set term=linux                " Make arrow and other keys work
scriptencoding utf-8

" History and undo
set history=1000              " Store more history (default is 20)
set undoreload=10000          " Maximum lines to save for undo on buffer reload

" Backup and swap file configuration
set backup                    " Enable backups
set backupdir=$HOME/.vim/backup//
set directory=$HOME/.vim/swap//
set viewdir=$HOME/.vim/views//

" Search settings
set ignorecase                " Case insensitive search
set smartcase                 " Case sensitive when uppercase present
set gdefault                  " /g flag on :s substitutions by default

" Spell checking
set spell                     " Enable spell checking

" Display settings
set wrap                      " Wrap long lines
set linebreak                 " Break lines at word boundaries
set noruler                   " Disable ruler (for accessibility)
set laststatus=0              " Never show status line
set noshowcmd                 " Don't show commands in status

" Indentation settings
set shiftwidth=4              " Use indents of 4 spaces
set expandtab                 " Tabs are spaces, not tabs
set tabstop=4                 " An indentation every four columns
set softtabstop=4             " Let backspace delete indent

" Leader key
let mapleader = ','

" Remap semicolon to colon for easier commands
nnoremap ; :

" Yank from cursor to end of line (consistent with C and D)
nnoremap Y y$

" Em-dash insertion
inoremap ,- —

" Working directory shortcuts
cmap cwd lcd %:p:h
cmap cd. lcd %:p:h

" Write with sudo if you forgot to open with sudo
cmap w!! w !sudo tee % >/dev/null

" Disable automatic comment continuation
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o

" Load vim helper functions if they exist
if filereadable(expand("~/.vim/dates.vim"))
    source ~/.vim/dates.vim
endif

if filereadable(expand("~/.vim/emoji.vim"))
    source ~/.vim/emoji.vim
endif

" Enable filetype detection and indenting
filetype plugin indent on
