From 36d5021ba3d8ce5e3bf82ac40a2a7b27400f6f5a Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Fri, 1 Nov 2019 23:37:15 -0400 Subject: [PATCH] Revert "Promoting vim/ to https://github.com/akarle/dotvim" This reverts commit a1468f779ece74e01e4d501ed238904d95d23022. Mono repo was the right call all along... --- README.md | 5 ----- vim/ftplugin/c.vim | 4 ++++ vim/ftplugin/html.vim | 3 +++ vim/ftplugin/javascript.vim | 3 +++ vim/ftplugin/markdown.vim | 11 +++++++++++ vim/ftplugin/python.vim | 10 ++++++++++ vim/ftplugin/tex.vim | 14 ++++++++++++++ vim/ftplugin/vim.vim | 21 +++++++++++++++++++++ vim/gvimrc | 12 ++++++++++++ vim/swp/.gitkeep | 0 vim/syntax/python.vim | 3 +++ vim/undo/.gitkeep | 0 vim/vimrc | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 281 insertions(+), 5 deletions(-) create mode 100644 vim/ftplugin/c.vim create mode 100644 vim/ftplugin/html.vim create mode 100644 vim/ftplugin/javascript.vim create mode 100644 vim/ftplugin/markdown.vim create mode 100644 vim/ftplugin/python.vim create mode 100644 vim/ftplugin/tex.vim create mode 100644 vim/ftplugin/vim.vim create mode 100644 vim/gvimrc create mode 100644 vim/swp/.gitkeep create mode 100644 vim/syntax/python.vim create mode 100644 vim/undo/.gitkeep create mode 100644 vim/vimrc diff --git a/README.md b/README.md index d2906d4..e76fe05 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,6 @@ My dotfiles. -I found that most of my customization was going to Vim, so I promoted it to its -own repo, [dotvim](https://github.com/akarle/dotvim). - -Note that the install will still download it! - ## Install For a full-featured install, with interactive use (bash required) and options to diff --git a/vim/ftplugin/c.vim b/vim/ftplugin/c.vim new file mode 100644 index 0000000..652c632 --- /dev/null +++ b/vim/ftplugin/c.vim @@ -0,0 +1,4 @@ +" for neovim development! +if exists( "g:loaded_youcompleteme" ) + nnoremap :YcmCompleter GoTo +endif diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim new file mode 100644 index 0000000..12be0ea --- /dev/null +++ b/vim/ftplugin/html.vim @@ -0,0 +1,3 @@ +" 2 spaces +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/vim/ftplugin/javascript.vim b/vim/ftplugin/javascript.vim new file mode 100644 index 0000000..bff51f2 --- /dev/null +++ b/vim/ftplugin/javascript.vim @@ -0,0 +1,3 @@ +" 2 space +setlocal softtabstop=2 +setlocal shiftwidth=2 diff --git a/vim/ftplugin/markdown.vim b/vim/ftplugin/markdown.vim new file mode 100644 index 0000000..a210b8b --- /dev/null +++ b/vim/ftplugin/markdown.vim @@ -0,0 +1,11 @@ +" wrap at word breaks +setlocal linebreak + +" have broken lines indent! +setlocal breakindent + +" spell check +setlocal spell spelllang=en_us + +" Break at 80 +setlocal textwidth=80 diff --git a/vim/ftplugin/python.vim b/vim/ftplugin/python.vim new file mode 100644 index 0000000..da21201 --- /dev/null +++ b/vim/ftplugin/python.vim @@ -0,0 +1,10 @@ +" set fold method to be indent based +" USAGE: +" KEY: no longer use zf#j or zf/ to create folds +" instead: +" zc -- close a fold by indent (at cursor until end indent) +" zo -- open a closed fold +setlocal foldmethod=indent + +" Set the local :make command to run flake8 +setlocal makeprg=flake8\ % diff --git a/vim/ftplugin/tex.vim b/vim/ftplugin/tex.vim new file mode 100644 index 0000000..c681ff3 --- /dev/null +++ b/vim/ftplugin/tex.vim @@ -0,0 +1,14 @@ +" ignore the wrapped lines +noremap k gk +noremap j gj + +" spell check! +setlocal spell spelllang=en_us + +" soft word wrap should not break words +" NOTE: don't use listchars with this feature +setlocal linebreak +setlocal breakindent + +" Break at 80 +setlocal textwidth=80 diff --git a/vim/ftplugin/vim.vim b/vim/ftplugin/vim.vim new file mode 100644 index 0000000..6b0001e --- /dev/null +++ b/vim/ftplugin/vim.vim @@ -0,0 +1,21 @@ +" Custom folding by expression to fold markers and functions + +let b:viml_fold_markers = split(&foldmarker, ',') + +function! VimLFoldByFunctionAndMarker(lnum) abort + let l = getline(a:lnum) + if l =~ '^function' + return 'a1' + elseif l =~ '^endfunction' + return 's1' + elseif l =~ b:viml_fold_markers[0] + return 'a1' + elseif l =~ b:viml_fold_markers[1] + return 's1' + else + return '=' + endif +endfunction + +setlocal foldmethod=expr +setlocal foldexpr=VimLFoldByFunctionAndMarker(v:lnum) diff --git a/vim/gvimrc b/vim/gvimrc new file mode 100644 index 0000000..fb1b513 --- /dev/null +++ b/vim/gvimrc @@ -0,0 +1,12 @@ +" Disable visual bells +set noerrorbells visualbell t_vb= +autocmd GUIEnter * set visualbell t_vb= + +" Pretty printing +set printoptions=left:1in,right:1in,paper:letter +set printfont=Consolas:h11 + +" Minimal UI +set guioptions= " Don't show guioptions (toolbar, scrollbar,..) +set guifont=Consolas:h11 " Font that doesn't hurt my eyes +set guicursor=a:blinkon0 " Don't blink the cursor (not my thang) diff --git a/vim/swp/.gitkeep b/vim/swp/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/vim/swp/.gitkeep diff --git a/vim/syntax/python.vim b/vim/syntax/python.vim new file mode 100644 index 0000000..18539d9 --- /dev/null +++ b/vim/syntax/python.vim @@ -0,0 +1,3 @@ +" Highlight the self keyword +syn keyword pythonSelf self +highlight link pythonSelf GruvboxBlue diff --git a/vim/undo/.gitkeep b/vim/undo/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/vim/undo/.gitkeep diff --git a/vim/vimrc b/vim/vimrc new file mode 100644 index 0000000..548e517 --- /dev/null +++ b/vim/vimrc @@ -0,0 +1,200 @@ +" .vimrc by Alex Karle +" Hosted at https://github.com/akarle/dotfiles +" +" Inspired by tips all over the interwebs + +" GENERAL EDITOR SETTINGS {{{ +" Try to be platform agnostic: +if has('win64') || has('win32') + let s:vimdir = expand($HOME . '/vimfiles') +else + let s:vimdir = expand($HOME . '/.vim') +endif + +" Add all the plugins to the path +if filereadable(s:vimdir . "/autoload/pathogen.vim") + execute pathogen#infect() +endif + +" Space related +set softtabstop=4 " is 4 spaces (when expandtab set) +set shiftwidth=4 " >> will indent 4 spaces +set expandtab " Needed to replace with spaces +set autoindent " Indent carries over on new line +set smarttab " Use shiftwidth for and + +" Search related +set hlsearch " Highlight searches +set incsearch " Incrementally search + +" Faster grepping! (use ripgrep if available for :grep and :FZF) +if executable('rg') + set grepprg=rg\ --vimgrep\ --no-heading + set grepformat=%f:%l:%c:%m,%f:%l:%m + let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --glob "!.git/*"' +endif + +" Key related behavior +set backspace=indent,eol,start " Backspace should function as expected +set foldopen-=block " {}, (), [] commands don't open folds +set ttimeout " Tell how to interpret key codes (used below) +set ttimeoutlen=30 " Low keycode timeout to avoid delay + +" Other +set modelines=0 " Disable modelines for security +set encoding=utf-8 " Encoding +set history=1000 " Remember last 1000 :commands +set scrolloff=5 " Scroll at 5 rows from top/bot of screen +filetype plugin indent on " Enable filetype specific plugins/indent + +" Persistent undo +if has('persistent_undo') && isdirectory(s:vimdir . '/undo') + exe 'set undodir='.s:vimdir.'/undo/' + set undofile " Do indeed create said files + set undolevels=1000 " Max # changes that can be undone + set undoreload=10000 " Saves undofile on reload (:e) if < 10k LOC +endif + +" Use ~/.vim/swp if avail (else .) for backup and swp files respectively +exe 'set backupdir='.s:vimdir.'/swp,.' +exe 'set directory='.s:vimdir.'/swp,.' +" }}} + +" PLUGIN RELATED SETTINGS {{{ +" Set pdf viewer to skim for vimtex +let g:vimtex_view_method='skim' + +" Don't use powerline font in airline (not neces. installed) +let g:airline_powerline_fonts = 0 +" }}} + +" THEME AND APPEARANCE {{{ +syntax on " Syntax highlighting on +set number " Line numbers on +set wildmenu " Visual completion for command mode +set showcmd " Show the command being typed +set laststatus=2 " Always show the statusbar +set noequalalways " Don't resize split on open/close event + +" Whitespace chars to display with :set list +set listchars=space:·,tab:>–,trail:~,eol:¬ + +" COLORSCHEME +" if can use truecolor, do +if (has("termguicolors") || has('gui_running')) && + \ filereadable(s:vimdir . "/bundle/gruvbox/colors/gruvbox.vim") + let g:gruvbox_italic = 1 + set termguicolors + colorscheme gruvbox + + " See :h xterm-true-color for tmux+termguicolors + if &term =~# '^tmux' + let &t_8f = "\[38;2;%lu;%lu;%lum" + let &t_8b = "\[48;2;%lu;%lu;%lum" + endif +else + colorscheme elflord +endif + +set background=dark " seems to need to be after gruvbox + +" Allow cursor to change shape: https://stackoverflow.com/questions/6488683 +let &t_SI = "\e[6 q" +let &t_EI = "\e[2 q" + +" auto commands (grouped so that re-sourcing vimrc doesn't cause duplicates!) +if has('autocmd') + augroup MyCustomAucmds + " removes all autocmds from this group (needed when re-sourcing) + autocmd! + + " Set cursor line when in insert mode (to indicate insert mode) + autocmd InsertEnter,InsertLeave * set cul! + augroup END " goes back to default augroup +endif +" }}} + +" FUNCTIONS {{{ +" A function to execute a command and return to the old position +" CREDIT: http://vimcasts.org/episodes/tidying-whitespace/ +function! CMDPreserve(command) abort + " Preparation: save last search, and cursor position. + let _s=@/ + let l = line(".") + let c = col(".") + " Do the business: + execute a:command + " Clean up: restore previous search history, and cursor position + let @/=_s + call cursor(l, c) +endfunction + +function! ToggleColorColumn() abort + if &colorcolumn == "" + set colorcolumn=80 + else + set colorcolumn="" + endif +endfunction +" }}} + +" KEY MAPPINGS {{{ +" set leader to be spacebar +let mapleader = " " + +"Map ctrl-i/j/k/h to switch between splits +nnoremap j +nnoremap k +nnoremap h +nnoremap l + +if has('terminal') || has('nvim') + tnoremap + tnoremap +endif + +"Map ctrl-p to toggle paste mode +nnoremap :set paste! + +" Elim Whitespace (through regexp) +nnoremap :call CMDPreserve("%s/\\s\\+$//e") +" save session +" nnoremap s :mksession! + +" edit in current buffer dir +nnoremap e :e %:h/ +nnoremap v :vsp %:h/ +nnoremap s :sp %:h/ + +" quick toggle for light/dark background +nnoremap L :set background=light +nnoremap D :set background=dark + +" toggle color column (to ensure short lines) +nnoremap C ToggleColorColumn() + +" easier tab switching (good for use w terminal wher gt doesn't work) +nnoremap t :tabnext + +" call fzf! +nnoremap f :FZF + +" 2 space / 4 space toggle +nnoremap 2 :setlocal softtabstop=2 shiftwidth=2 +nnoremap 4 :setlocal softtabstop=4 shiftwidth=4 + +" Faster file navigation +nnoremap :cprev +nnoremap :cnext +nnoremap :prev +nnoremap :next + +" Clear that highlight! +nnoremap :nohlsearch + +" Get greppin quick! --> search word under cursor (escape # for VimL autoload) +nnoremap g :exe "grep " . substitute(expand(''), '#', '\\#', 'g') + +" Toggle whitespace +nnoremap w :set list! +" }}} -- libgit2 0.28.4