Files
dotfiles/vim/.config/vim/vimrc
2026-01-13 13:05:08 -05:00

184 lines
4.6 KiB
VimL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax on
set smarttab ts=2 sw=2
set softtabstop=2
set expandtab
set autoindent
" line length is 89
set textwidth=89
" Default: No wrap for code and config
set nowrap
" Wrap at word boundaries
" set linebreak
" Maintain indentation on wrapped lines
" set breakindent
" Optional: visual indicator for wrapped lines
set showbreak=↪\
" a group for wrapping by filetype
augroup filetype_wrapping
autocmd!
" Enable soft wrap for prose
autocmd FileType markdown,text,gitcommit setlocal wrap linebreak breakindent
" Maintain no wrap for code and structured data
autocmd FileType go,python,sh,yaml,json setlocal nowrap
augroup END
" Navigate visual lines instead of logical lines
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
set backspace=indent,eol,start
set background=dark
colorscheme theunixzoo
"colorscheme chill
"colorscheme plain-cterm
"colorscheme aomi-grayscale
"colorscheme solarized8
" disabled by default- enable this as needed to show hidden characters
" set list
" any trailing spaces are indicated by a ·
" tabs are indicated by an arrow followed by a space
" arrows could be: → »
set listchars=tab:→\ ,trail
"source /home/jswank/.config/nvim/colors-now
"set gfn=Droid\ Sans\ Mono\ 10
set gfn=Inconsolata\ 12
set guioptions-=T
"use semicolon as colon for commands
nmap ; :
filetype plugin on
filetype indent on
set ofu=syntaxcomplete#Complete#
" au FileType python setlocal tabstop=4 expandtab shiftwidth=4 softtabstop=4
au FileType markdown setlocal tabstop=4 expandtab shiftwidth=4 softtabstop=4 wrap
" typing idate inserts the current date
iab idate <c-r>=strftime("%Y-%m-%d")<cr>
" insert triple backticks for markdown code blocks with Ctrl-b
inoremap <C-b> ```<CR>```<Esc>O
" use \ toc to insert a table of contents for markdown from the current line to EOF
" nmap <leader>toc <cmd>.put =execute('.,$write !gh-md-toc --hide-header --hide-footer')<cr>
nmap <leader>toc :put =system('gh-md-toc --hide-header --hide-footer --indent=4', getline('.', '$'))<cr>
" use \ tf to format a buffer as tofu / terraform
nmap <leader>tf <cmd>% !tofu fmt -no-color -<cr>
" use \ jn to format a buffer as Jsonnet
nmap <leader>jn <cmd>% !jsonnetfmt -<cr>
" use \ js to format a buffer as JSON
nmap <leader>js <cmd>% !jq . -<cr>
set lazyredraw " redraw only when req'd
set wildmenu " visual auto-complete
set wildmode=longest:full,full
set wildignore=*.pyc,*.swp,.git/**
set showmatch " highlights matching parens
set cursorline " highlights the current line
" Search down into subfolders
set path+=**
" netrw config
let g:netrw_banner=0 " disable annoying banner
let g:netrw_browse_split=0 " open in prior window
let g:netrw_altv=1 " open splits to the right
let g:netrw_liststyle=3 " tree view
" let g:netrw_list_hide=',\(^\|\s\s\)\zs\.\S\+'
" NOW WE CAN:
" - :edit a folder to open a file browser
" - <CR>/v/t to open in an h-split/v-split/tab
" - check |netrw-browse-maps| for more mappings
" fzf.vim shortcuts
nnoremap <c-p> <cmd>Files<CR>
nnoremap <c-\> <cmd>Buffers<CR>
nnoremap <c-g> <cmd>Rg<CR>
"
" Github Copilot
"
" disable Copilot ny default
let g:copilot_enabled = 0
" map key to enable copilot
nmap <leader>cp :let g:copilot_enabled = 1<CR>
def ShowPalette()
vnew
setlocal buftype=nofile bufhidden=wipe noswapfile
# Iterate through all highlight groups
for group in getcompletion('', 'highlight')
# Skip cleared/empty groups
if hlexists(group)
append(line('$'), group)
# Use syntax keyword to apply the highlight group to its own name
exec 'syntax keyword ' .. group .. ' ' .. group
endif
endfor
enddef
command! ShowPalette call ShowPalette()
" format any yaml file
" autocmd BufWritePre *.yaml :%!yq -i %
"
" GO stuff
"
" format with goimports instead of gofmt
let g:go_fmt_command = "goimports"
" more syntax highlighting
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_interfaces = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" disable folding for markdown
let g:vim_markdown_folding_disabled = 1
" ancient stuff
"let g:hcl_fmt_autosave = 1
"let g:tf_fmt_autosave = 1
"let g:nomad_fmt_autosave = 1
"autocmd BufRead,BufNewFile *.go set makeprg=go\ build
"map <leader>gr <ESC>:!gorun %<CR>
"for javascript:
"use google closure to generate errors
":set makeprg=closure\ --js\ %
"javac style errors
":setl efm=%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#
"autocmd BufRead,BufNewFile *.js :call My_JS()
"function! My_JS()
" set makeprg=closure\ --js\ %
" setl efm=%A%f:%l:\ %m,%+Z%p^,%+C%.%#,%-G%.%#
"endfunction
"map <leader>hh :!tidy -q -i --show-errors 0<CR>