if &compatible set nocompatible endif map :source $MYVIMRC " Plugins -------------------------------------------------------------------{{{ if has('nvim') && has('win32') lua require('plugins') endif call plug#begin() " if !has('nvim') " Plug 'dense-analysis/ale' " asynchronous linting engine " endif Plug 'tpope/vim-fugitive' " integration with the git cli Plug 'tpope/vim-surround' " edits surrounding quotes and parens and the like Plug 'tpope/vim-rails' " rails project management stuff Plug 'tpope/vim-repeat' " fixes the . key for ...something Plug 'scrooloose/nerdtree' " better file navigation Plug 'mhinz/vim-signify' Plug 'slim-template/vim-slim' " what in the 2008 is this Plug 'kchmck/vim-coffee-script' " lol coffee script Plug 'fatih/vim-go' " all-in-one Go tools Plug 'fatih/vim-hclfmt' " nicely formats hcl files Plug 'nanotech/jellybeans.vim' " the best colorscheme Plug 'ervandew/supertab' " makes tab better apparently Plug 'scrooloose/nerdcommenter' " no idea if I'm even using this Plug 'ctrlpvim/ctrlp.vim' " don't actually know how to use this honestly Plug 'itchyny/lightline.vim' " fancy status line Plug 'heavenshell/vim-jsdoc' " js docs? Plug 'hashivim/vim-terraform' " hclfmt but for terraform Plug 'b4b4r07/vim-hcl' " hcl syntax stuff? Plug 'Glench/Vim-Jinja2-Syntax' " jinja2 syntax stuff Plug 'rust-lang/rust.vim' " bare minimum rust syntax stuff Plug 'ziglang/zig.vim' Plug 'elubow/cql-vim' Plug 'tikhomirov/vim-glsl' Plug 'jparise/vim-graphql' call plug#end() " enable the filetype plugin filetype plugin indent on " ---------------------------------------------------------------------------}}} " Character Encoding --------------------------------------------------------{{{ " sets the character encoding used inside of vim itself. does not change how " files are written to disk. set encoding=utf-8 if has("multi_byte") " termencoding specifies what character encoding the keyboard produces and " the display will understand if &termencoding == "" let &termencoding = &encoding endif endif " ---------------------------------------------------------------------------}}} " Whitespace ----------------------------------------------------------------{{{ " allow backspacing over line breaks set backspace=indent,eol,start " copy indent from current line when starting a new line set autoindent " automatically add an indent after block-opening symbols like { set smartindent " display tab as 4 characters wide instead of 8 set tabstop=4 " use 4 spaces when creating a new indentation level with autoindentation set shiftwidth=4 " tab key inserts spaces set expandtab " no matter how many times I read the help text on this I still don't " understand what it does, but I've had it in here for years so I'm just " leaving it. set smarttab " set whitespace characters if has("multi_byte") set listchars=tab:▸\ ,trail:·,precedes:←,extends:→ let &showbreak='↪ ' else set listchars=tab:>-,trail:.,precedes:#,extends:# endif " ---------------------------------------------------------------------------}}} " Search --------------------------------------------------------------------{{{ " perform searches incrementally set incsearch " perform case-insensitive searches set ignorecase " if a search term includes upper case letters, use a cast-sensitive search set smartcase " highlights the last searched pattern set hlsearch " press escape twice to clear highlight search nnoremap :nohlsearch " press ctrl+L to clear highlight search nnoremap :nohlsearch nnoremap :nohlsearch " ---------------------------------------------------------------------------}}} " Backup --------------------------------------------------------------------{{{ set nobackup set nowritebackup set noswapfile " ---------------------------------------------------------------------------}}} " Wild Menu -----------------------------------------------------------------{{{ " enable the wild menu. set wildmenu " list matches set wildmode=list:full set wildignore=.svn,CVS,.git " ignore verson control files set wildignore+=*.o,*.a,*.so " ignore compiled binaries set wildignore+=*.jpg,*.png,*.gif " ignore images set wildignore+=*.pdf " ignore pdf documents set wildignore+=*.pyc,*.pyo " ignore compiled Python files " ---------------------------------------------------------------------------}}} " Mouse ---------------------------------------------------------------------{{{ " enable the mouse if has('mouse') set mouse=a endif " hide the mouse when typing set mousehide " open up directories with a single click instead of needing to double-click let g:NERDTreeMouseMode = 2 " mouse is always on in nvim anyway if !has('nvim') " this fixes the WSL mouse not working beyond column 95 but I have no idea why set ttymouse=sgr endif " ---------------------------------------------------------------------------}}} " Colorscheme ---------------------------------------------------------------{{{ if &t_Co > 2 || has("gui_running") " enable syntax highlighting syntax on " enable 256-color mode set t_Co=256 " background-color erasing corrections to tell vim to fill the background " from our colorscheme instead of from the terminal default if (&term =~ '^xterm') set t_ut= | set ttyscroll=1 endif " this should not do anything but it does. set termguicolors " jellybeans disables italics by default for some reason let g:jellybeans_use_term_italics = 1 let g:jellybeans_overrides = { \ 'background': { 'ctermbg': 'none', '256ctermbg': 'none' }, \} if has('termguicolors') && &termguicolors let g:jellybeans_overrides['background']['guibg'] = 'none' endif try colorscheme jellybeans catch silent! colorscheme habamax endtry endif " ---------------------------------------------------------------------------}}} " Autocmd Hooks -------------------------------------------------------------{{{ if has("autocmd") " Put these in an autocmd group, so that we can delete them easily. augroup vimrcEx autocmd! " Add filetype recognition for some lesser-known file types autocmd BufNewFile,BufRead *.zig set filetype=zig autocmd BufNewFile,BufRead *.txt set filetype=text autocmd BufNewFile,BufRead *.gd set filetype=gdscript3 " on some machines md files are thought to be modula2 autocmd BufNewFile,BufRead *.md set filetype=markdown autocmd BufNewFile,BufRead *.tf set filetype=terraform " add Coloring for ChucK source autocmd BufNewFile,BufRead *.ck set filetype=ck " When editing a file, always jump to the last known cursor position. " Don't do it when the position is invalid or when inside an event handler " (happens when dropping a file on gvim). " Also don't do it when the mark is in the first line, that is the default " position when opening a file. autocmd BufReadPost * \ if line("'\"") > 1 && line("'\"") <= line("$") | \ exe "normal! g`\"" | \ endif if !has('nvim') autocmd FileType html set omnifunc=htmlcomplete#CompleteTags autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags autocmd FileType php set omnifunc=phpcomplete#CompletePHP autocmd FileType python set omnifunc=ale#completion#OmniFunc autocmd FileType css set omnifunc=csscomplete#CompleteCSS autocmd FileType rust set omnifunc=ale#completion#OmniFunc endif " causes VIM to enter the directory of the file being edited to simplify " finding related files. " autocmd BufEnter * silent! lcd %:p:h autocmd FileType go :iabbrev iff if {} autocmd FileType javascript :iabbrev iff if autocmd FileType javascript :iabbrev fun function augroup END else endif " ---------------------------------------------------------------------------}}} " Status Line ---------------------------------------------------------------{{{ " always show the status line set laststatus=2 " don't display the current mode in the message line, we moved it to the " status line. set noshowmode " don't show the readonly marker in help files, it's pointless. function! LightlineReadonly() return &readonly && &filetype !=# 'help' ? 'RO' : '' endfunction let g:lightline = { \ 'colorscheme': 'jellybeans', \ 'active': { \ 'left': [ \ ['mode', 'paste'], \ ['gitbranch'], \ ['llreadonly', 'filename', 'modified'] \ ], \ 'right': [ \ ['lineinfo'], \ ['filetype'] \ ] \ }, \ 'component_function': { \ 'gitbranch': 'FugitiveHead', \ 'llreadonly': 'LightlineReadonly' \ } \ } " }}} " Normal|Visual|Operator-Pending Mode {{{ " ctrl-k to go to the next tab noremap :tabnext " ctrl-j to go to the previous tab noremap :tabprevious " ctrl-n to open a new tab with the current file noremap :tabnew % noremap :tab term noremap :tab term tnoremap :bnext tnoremap :bnext " move by visual lines when moving instead of physical lines noremap k gk noremap j gj noremap 0 g0 noremap $ g$ " ---------------------------------------------------------------------------}}} " Normal Mode ---------------------------------------------------------------{{{ " toggle line numbering with n nnoremap n :set number! " line numbers should be hidden by default set nonumber " Shortcut to show invisible characters nnoremap l :set list! " leader pe (prefs edit) to edit your vimrc nnoremap pe :vsplit $MYVIMRC " leader ps (prefs source) to source your vimrc nnoremap ps :source $MYVIMRC " leader ci inverts comment states on a line by line basis noremap ci NERDComInvertComment " ---------------------------------------------------------------------------}}} " Buffers -------------------------------------------------------------------{{{ " " nmap " ---------------------------------------------------------------------------}}} " Git -----------------------------------------------------------------------{{{ let g:signify_disable_by_default = 1 " toggle the signify sign column on and off nmap vs :SignifyToggle " toggle line-level highlighting in signify nmap vl :SignifyToggleHighlight " diff the current file with signify nmap vd :SignifyDiff nmap vc :Git commit nmap vp :Git push nmap va :Git add % " fart nmap vj (signify-next-hunk) nmap vk (signify-prev-hunk) omap ic (signify-motion-inner-pending) xmap ic (signify-motion-inner-visual) omap ac (signify-motion-outer-pending) xmap ac (signify-motion-outer-visual) " nmap :Git " nmap :Git pull --rebase " nmap :Git push " ---------------------------------------------------------------------------}}} " Insert Mode ---------------------------------------------------------------{{{ " Ctrl-U deletes from the current position to the start of the line. inoremap u iabbrev @@ @jordanorelli " ---------------------------------------------------------------------------}}} " Command Mode --------------------------------------------------------------{{{ " new command mode command: w!! " allows you to sudo write the file you're currently editing without closing " (and thus losing) your changes. cnoremap w!! w !sudo tee % >/dev/null " command mode abbreviation :vhelp to open help text in a vertical split " instead of a horizontal split. cabbrev vhelp vertical help " prevents editing a file named "~", which I literally never want. cabbrev ~ $HOME " ---------------------------------------------------------------------------}}} " Terminal Mode -------------------------------------------------------------{{{ " ctrl-k to go to the next tab tnoremap :tabnext " ctrl-j to go to the previous tab tnoremap :tabprevious " ctrl-n-n to create a new tab with an empty buffer tnoremap :tabnew tnoremap :tabnew " ctrl-shift-n creates a new tab with a terminal tnoremap :tab term tnoremap :tab term nnoremap :bnext! tnoremap :bnext! nnoremap :term ++curwin nnoremap :belo term let g:terminal_ansi_colors = [ \ '#929292', \ '#e27373', \ '#94b979', \ '#ffba7b', \ '#97bedc', \ '#e1c0fa', \ '#00988e', \ '#dedede', \ '#bdbdbd', \ '#ffa1a1', \ '#bddeab', \ '#ffdca0', \ '#b1d8f6', \ '#fbdaff', \ '#1ab2a8', \ '#ffffff' \ ] if !has('nvim') autocmd TerminalOpen * set nonu endif highlight Terminal guibg='#0c0c0c' highlight Terminal guifg='#cccccc' function! ExitNormalMode() unmap call feedkeys("a") endfunction function! EnterNormalMode() if &buftype == 'terminal' && mode('') == 't' call feedkeys("\N") call feedkeys("\") map :call ExitNormalMode() endif endfunction tmap :call EnterNormalMode() " ---------------------------------------------------------------------------}}} " Operator-Pending Mode -----------------------------------------------------{{{ " new text object: "next paren". means the next open paren on the current " line. onoremap in( :normal! f(ci( " new text object: "last paren". means the previous open paren on the current " line. (using p would shadow the paragraph object) onoremap il( :normal! F)vi( " ---------------------------------------------------------------------------}}} " Supertab ------------------------------------------------------------------{{{ " use omnicomplete by default " let g:SuperTabDefaultCompletionType = "" let g:SuperTabDefaultCompletionType = "" let g:SuperTabClosePreviewOnPopupClose = 1 " close doc window after finishing an autocomplete " let g:SuperTabClosePreviewOnPopupClose = 1 " ---------------------------------------------------------------------------}}} " YouCompleteMe -------------------------------------------------------------{{{ " " I've stopped using this because the install process was too crazy " " let g:ycm_keep_logfiles = 1 " let g:ycm_log_level = 'debug' " let g:ycm_language_server = " \ [ " \ { " \ 'name': 'zig', " \ 'cmdline': [ 'zls', '--debug-log' ], " \ 'filetypes': [ 'zig' ], " \ } " \ ] " ---------------------------------------------------------------------------}}} " lsp -----------------------------------------------------------------------{{{ " this is not portable at all and I hate it and dunno how to fix it yet " call LspAddServer([#{name: 'pyright', " \ filetype: 'python', " \ path: '/Users/jordan.orelli/.nix-profile/bin/pyright-langserver', " \ args: ['--stdio'], " \ workspaceConfig: #{ " \ python: #{ " \ pythonPath: '/usr/local/bin/python3' " \ }} " \ }]) " ---------------------------------------------------------------------------}}} " ALE -----------------------------------------------------------------------{{{ if !has('nvim') let g:ale_linters = {'rust': ['analyzer']} let g:ale_fixers = {'rust': ['rustfmt', 'trim_whitespace', 'remove_trailing_lines']} let g:ale_rust_cargo_use_clippy = 1 let g:ale_completion_enabled = 1 set completeopt=menu,menuone,preview,noselect,noinsert endif " ---------------------------------------------------------------------------}}} " CtrlP ---------------------------------------------------------------------{{{ let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_user_command = [ \ '.git', \ 'cd %s && git ls-files -co --exclude-standard' \ ] " ---------------------------------------------------------------------------}}} " NERDTree ------------------------------------------------------------------{{{ if has("multi_byte") let g:NERDTreeDirArrowExpandable = '▸' let g:NERDTreeDirArrowCollapsible = '▾' else let g:NERDTreeDirArrowExpandable = '+' let g:NERDTreeDirArrowCollapsible = '-' endif " enable dir tree arrows let g:NERDTreeDirArrows = 1 " ---------------------------------------------------------------------------}}} " terraform -----------------------------------------------------------------{{{ let g:terraform_align=1 let g:terraform_fmt_on_save=1 " ---------------------------------------------------------------------------}}} " Commenting ----------------------------------------------------------------{{{ " left-align comment markers by default let g:NERDDefaultAlign='left' " insert a space after comment markers let g:NERDSpaceDelims=1 " ---------------------------------------------------------------------------}}} " Misc ----------------------------------------------------------------------{{{ " keep 50 lines of command line history set history=50 " show commands as you type them (mostly for leader-based stuff) set showcmd " wrap long lines set wrap " force line wrapping to only happen at word boundaries set linebreak " wait 200ms after typing for updates (default is 4000) set updatetime=200 " set current working directory on file enter set autochdir " match angle brackets set matchpairs+=<:> " use visual bell instead of beeping set visualbell " you know what, just disable the error bells entirely set noerrorbells " highlight the cursor line only in the current window augroup CursorLine au! au VimEnter,WinEnter,BufWinEnter * setlocal cursorline au WinLeave * setlocal nocursorline augroup END " integrate the wsl clipboard for yanking to the system clipboard let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point if executable(s:clip) augroup WSLYank autocmd! autocmd TextYankPost * if v:event.operator ==# 'y' | call system(s:clip, @0) | endif augroup END endif " ---------------------------------------------------------------------------}}} " Neovim Stuff --------------------------------------------------------------{{{ if has('nvim') set guifont=Cascadia\ Mono:h12 endif " ---------------------------------------------------------------------------}}}