aboutsummaryrefslogtreecommitdiff
path: root/vim/.vim/vimrc
diff options
context:
space:
mode:
authoromagdy <omar.professional8777@gmail.com>2025-07-26 02:33:10 +0300
committeromagdy <omar.professional8777@gmail.com>2025-07-26 02:33:10 +0300
commit45bc42047321f6e51f32adb24ec5fc95333c6380 (patch)
tree5afef8257d24453be6d3bfa31caaff4fb24cdc3f /vim/.vim/vimrc
parentf098b4cc7b9026870de461d467a22c6be704085c (diff)
downloaddotfiles-45bc42047321f6e51f32adb24ec5fc95333c6380.tar.xz
dotfiles-45bc42047321f6e51f32adb24ec5fc95333c6380.zip
nvim: switched to blink.nvim + some other stuff I guess
Diffstat (limited to 'vim/.vim/vimrc')
-rw-r--r--vim/.vim/vimrc107
1 files changed, 96 insertions, 11 deletions
diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc
index a6f7ee3..bb271c4 100644
--- a/vim/.vim/vimrc
+++ b/vim/.vim/vimrc
@@ -1,10 +1,6 @@
" You want Vim, not vi. When Vim finds a vimrc, 'nocompatible' is set anyway.
-" We set it explicitely to make our position clear!
-
-set background=dark
-colorscheme rosepine
-
let g:disable_bg = 1
+let mapleader = " "
set nocompatible
@@ -28,6 +24,11 @@ set showmode " Show current mode in command-line.
set showcmd " Show already typed keys when more are expected.
set incsearch " Highlight while searching with / or ?.
+set ignorecase " Case-insensitive search...
+set smartcase " ...unless uppercase used
+set hlsearch " Highlight matches
+
+set backspace=indent,eol,start " Sane backspace behaviour
set ttyfast " Faster redrawing.
set lazyredraw " Only redraw when necessary.
@@ -38,16 +39,100 @@ set splitright " Open new windows right of the current window.
set wrapscan " Searches wrap around end-of-file.
set report =0 " Always report changed lines.
set synmaxcol =200 " Only highlight the first 200 columns.
+set clipboard=unnamedplus
+
+cnoreabbrev W! w!
+cnoreabbrev Q! q!
+cnoreabbrev W w
+cnoreabbrev Wq wq
+cnoreabbrev WQ wq
+cnoreabbrev wQ wq
+cnoreabbrev qw wq
+
+" Basic UI settings
+syntax on
+set background=dark
+colorscheme gruvbox
+
+" Recommended settings for better appearance
+set cursorline " Highlight current line
+set termguicolors " Enable true color support (if terminal supports it)
+
+
+function! GitBranch()
+ let l:git_dir = finddir('.git', expand('%:p:h') . ';')
+ if empty(l:git_dir)
+ return ''
+ endif
+ let l:branch = system('git -C ' . fnameescape(expand('%:p:h')) . ' rev-parse --abbrev-ref HEAD 2> /dev/null')
+ return substitute(l:branch, '\n', '', '')
+endfunction
+
+set laststatus=2
+set statusline=%f
+set statusline+=%h%m%r%w
+set statusline+=\ %{GitBranch()}
+set statusline+=\ [%{&ff}]
+set statusline+=\ [%{&fileencoding}]
+set statusline+=\ [%Y]
+set statusline+=\ %=
+set statusline+=Ln\ %l/%L
+set statusline+=\ Col\ %c
+set statusline+=\ [%p%%]
-set list " Show non-printable characters.
-if has('multi_byte') && &encoding ==# 'utf-8'
- let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±'
-else
- let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'
-endif
" The fish shell is not very compatible to other shells and unexpectedly
" breaks things that use 'shell'.
if &shell =~# 'fish$'
set shell=/bin/bash
endif
+
+function! CompileAndRun()
+ let l:filename = expand('%:p')
+ let l:output = expand('%:r')
+ if empty(l:filename) || empty(l:output)
+ echoerr "❌ File has not been saved. Save it before compiling."
+ return
+ endif
+
+ let l:current_winnr = winnr()
+
+ " Check if the compile output buffer already exists
+ let l:compile_bufnr = bufnr('__COMPILE_OUTPUT__')
+ let l:compile_winnr = bufwinnr(l:compile_bufnr)
+
+ if l:compile_winnr == -1
+ " Buffer doesn't exist in any window, create new vsplit
+ vsplit
+ enew
+ setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
+ " Give the buffer a name for easy identification
+ file __COMPILE_OUTPUT__
+ else
+ " Buffer exists in a window, switch to it
+ execute l:compile_winnr . 'wincmd w'
+ " Clear the buffer content
+ %delete _
+ endif
+
+ let l:compile_cmd = 'gcc -Wall ' . shellescape(l:filename) . ' -o ' . shellescape(l:output)
+ let l:result = system(l:compile_cmd)
+ if v:shell_error
+ call append(0, split(l:result, "\n"))
+ else
+ call append(0, ['✅ Compiled successfully.', '', '--- Running output: ---', ''])
+ let l:run_output = system('./' . l:output)
+ call append(line('$'), split(l:run_output, "\n"))
+ endif
+
+ " Remove the empty line at the top
+ if line('$') > 1 && getline(1) == ''
+ 1delete _
+ endif
+
+ execute l:current_winnr . 'wincmd w'
+endfunction
+
+
+command! Compile call CompileAndRun()
+nnoremap <leader>c :Compile<CR>