Last active
June 13, 2025 07:42
-
-
Save internetimagery/c7515c497e5f37e0d5f09f2394c492f7 to your computer and use it in GitHub Desktop.
Current vimrc base
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
" Install vim-plug with following command | |
" curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
" Then ':PlugInstall' to install them | |
" Set leader to space. This is set up before plugins are loaded. | |
let mapleader = " " " map leader to Space | |
" Declare plugins | |
call plug#begin() | |
" Sensible Defaults | |
Plug 'tpope/vim-sensible' " Sensible defaults for various things | |
Plug 'roman/golden-ratio' " Resize split screen to fit active panel | |
Plug 'tpope/vim-commentary' " 'gc' to comment code 'gcc' comment line | |
Plug 'tpope/vim-unimpaired' " '[e' ']e' move lines up and down | |
Plug 'tpope/vim-repeat' " Allow custom tools to use '.' repeat function | |
Plug 'easymotion/vim-easymotion' " Jump to location '\\f' or '\\w' | |
Plug 'bronson/vim-visual-star-search' " Select text then can search with * | |
Plug 'vim-python/python-syntax' " Improved syntax highlighting | |
Plug 'wincent/terminus' " Minor quality of life improvements for terminal | |
" Linting + Autocomplete | |
Plug 'prabirshrestha/vim-lsp' " Run language servers | |
Plug 'mattn/vim-lsp-settings' " Install language servers easily. Do so via ':LspInstallServer <name>' for instance ':LspInstallServer ruff' | |
Plug 'ntpeters/vim-better-whitespace' " Show trailing whitespace so it can be removed | |
" Light Theme | |
Plug 'internetimagery/flatwhite-vim' | |
" Dark Theme | |
Plug 'sonph/onehalf', { 'rtp': 'vim' } | |
" Bottom Bar | |
Plug 'vim-airline/vim-airline' | |
" Git integration | |
Plug 'tpope/vim-fugitive' " Git integration | |
Plug 'tommcdo/vim-fugitive-blame-ext' " Add git blame message | |
Plug 'airblade/vim-gitgutter' " Show git additions/removals in the gutter | |
" AI autocomplete | |
" Requires running llama.cpp server. ie 'llama-server --fim-qwen-1.5b-default' | |
Plug 'ggml-org/llama.vim' | |
call plug#end() | |
" Theme | |
colorscheme flatwhite | |
"colorscheme onehalfdark | |
let g:airline_theme='onehalfdark' | |
if exists('+termguicolors') | |
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum" | |
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum" | |
set termguicolors | |
endif | |
" Keymaps | |
" Make Y consistent with C and D | |
map Y y$ | |
" Reselect visual block after indent/outdent. | |
vnoremap < <gv | |
vnoremap > >gv | |
" Keep search pattern at the center of the screen. | |
nnoremap <silent> n nzz | |
nnoremap <silent> N Nzz | |
nnoremap <silent> * *zz | |
nnoremap <silent> # #zz | |
nnoremap <silent> g* g*zz | |
" Allow Esc key to switch to normal mode in :terminal, and C+R for pasting list in regular insert mode | |
tnoremap <Esc> <C-w>N | |
tnoremap <C-r> <C-w><C-"> | |
" FileTypes | |
autocmd BufRead,BufNewFile wscript setfiletype python | |
let g:python_highlight_all = 1 " Ensure advanced python ast parsing is enabled | |
" GUI | |
set cursorline " Faint line showing cursor (y axis) | |
set cursorcolumn " Faint line showing cursor (x axis) | |
" Remove cursorline style when in insert, apply style when outside insert | |
:highlight CursorLine cterm=bold ctermbg=NONE gui=bold guibg=NONE | |
autocmd InsertEnter * highlight CursorLine cterm=NONE ctermbg=NONE gui=NONE guibg=NONE | |
autocmd InsertLeave * highlight CursorLine cterm=bold ctermbg=NONE gui=bold guibg=NONE | |
hi Visual term=reverse cterm=reverse " Highlight selection with reversed colours | |
set number relativenumber " Show line numbers and set relative to cursor when in normal mode | |
augroup numbertoggle | |
autocmd! | |
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber | |
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber | |
augroup END | |
set scrolloff=7 " keep 3 lines when scrolling | |
set showcmd " display incomplete commands | |
set showmode " display current modes | |
set showmatch " jump to matches when entering parentheses | |
set matchtime=2 " tenths of a second to show the matching parenthesis | |
set hlsearch " highlight searches | |
let g:netrw_banner = 0 " Remove top banner on directory views | |
let g:netrw_liststyle = 3 " Display folders in a tree view | |
let ghregex='\(^\|\s\s\)\zs\.\S\+' " Hide dotfiles by default, see... | |
let g:netrw_list_hide=ghregex " ...https://vi.stackexchange.com/a/18678 | |
let g:EasyMotion_smartcase = 1 " Use smartsearch casing with easymotion. ie v matches lower and upper, while V is only upper | |
" System | |
set hidden " Allow swapping of buffers with changes, without nagging. | |
set mouse=a " Enable mouse support | |
set nocompatible " Don't bother with vi compatibility | |
autocmd BufEnter * :checktime " Check if files need reloading when swapping buffer | |
set magic " For regular expressions turn magic on | |
set title " change the terminal's title | |
set nobackup " do not keep a backup file | |
set novisualbell noerrorbells " turn off visual bell | |
set visualbell t_vb= " turn off error beep/flash | |
set tm=500 | |
set ignorecase " ignore case when searching | |
set smartcase " Case sensitive is search includes uppercase letter | |
set path+=** " Include all files in search path (fuzzy search lite) | |
autocmd CursorHoldI * stopinsert " Drop out of insert mode after 4 seconds idle | |
:command W w " Remap W to w, so accidental capitals writes too | |
:command Q q " Remap Q to q, so accidental capitals can also close | |
set shiftwidth=4 smarttab " Use 4 spaces as tabs | |
set tabstop=8 softtabstop=0 " Size tabs differently so they stand out | |
set omnifunc=syntaxcomplete#Complete " Enable advanced contextural autocomplete. <C-X><C-O> | |
" Enable smart switching between constructs (eg html tags etc) (built in plugin) | |
runtime macros/matchit.vim | |
" Use ripgrep if it is available when running :grep | |
if executable("rg") | |
set grepprg=rg\ --vimgrep\ --smart-case\ --hidden | |
set grepformat=%f:%l:%c:%m | |
endif | |
" Improve :grep experience. https://gist.github.com/romainl/56f0c28ef953ffc157f36cc495947ab3#enlightenment | |
" Run grep command in background without poluting terminal with output under 'Grep' function | |
function! Grep(...) | |
return system(join([&grepprg] + [expandcmd(join(a:000, ' '))], ' ')) | |
endfunction | |
" Ensure autocomplete works | |
command! -nargs=+ -complete=file_in_path -bar Grep cgetexpr Grep(<f-args>) | |
command! -nargs=+ -complete=file_in_path -bar LGrep lgetexpr Grep(<f-args>) | |
" Open results window on search completion | |
augroup quickfix | |
autocmd! | |
autocmd QuickFixCmdPost cgetexpr bo cwindow " Open window in bottom panel | |
autocmd QuickFixCmdPost lgetexpr bo lwindow | |
augroup END | |
" Replace grep command with Grep function | |
cnoreabbrev <expr> grep (getcmdtype() ==# ':' && getcmdline() ==# 'grep') ? 'Grep' : 'grep' | |
cnoreabbrev <expr> gr (getcmdtype() ==# ':' && getcmdline() ==# 'gr') ? 'Grep' : 'grep' | |
" LSP settings | |
" Also :LspDocumentDiagnostics to show all errors, and those that go off screen | |
let g:lsp_diagnostics_echo_cursor = 1 " Ensure error messages are shown at the bottom when cursor is on the error | |
" :LspInstallServer pyright-langserver | |
let g:lsp_settings_filetype_python=['pyright-langserver'] | |
" Set up some simple keybinds and settings for when an LSP is running | |
function! s:on_lsp_buffer_enabled() abort | |
setlocal omnifunc=lsp#complete | |
setlocal signcolumn=yes | |
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif | |
nmap <buffer> gd <plug>(lsp-definition) | |
nmap <buffer> gt <plug>(lsp-type-definition) | |
nmap <buffer> gr <plug>(lsp-references) | |
nmap <buffer> K <plug>(lsp-hover) | |
endfunction | |
" Ensure LSP server is running when looking at supported filetypes | |
augroup lsp_install | |
au! | |
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() | |
augroup END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment