1
0
forked from extern/nix-config

Clean up vim config

In this commit I remove a lot of the things I no longer use in vim. I
also enable lazy loading of some plugins and add lightline for the
status bar.
This commit is contained in:
Donovan Glover 2018-10-13 19:42:56 -04:00
parent f26f5acedc
commit cdc96ed5ab
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
4 changed files with 74 additions and 189 deletions

View File

@ -19,7 +19,8 @@ set hidden " Switch between buffers without saving them
set incsearch " Automatically move to text as you search for it
set wildmenu " Show a menu of the different options when you tab in command mode
set display+=lastline " Show as much of a long line as possible
set laststatus=0 " Disable the status line (removes filename and increases working space)
set laststatus=2 " Enable the status line (set to 0 to remove)
set noshowmode " Disable the --MODE-- text (enable if not using the status line)
set history=100 " Only keep the last 100 commands
set tabpagemax=50 " Set the maximum number of tabs to be opened in any window to 50

View File

@ -6,46 +6,22 @@ let mapleader = ' '
" ================== Top row
nnoremap <silent> <leader>e :set nu!<CR>
nnoremap <silent> <leader>r :call matchadd('OverLength', '\%101v', 100)<CR>
nnoremap <silent> <leader>t :OverCommandLine<CR>%s/
nnoremap <silent> <leader>y :bn<CR>
nnoremap <silent> <leader>u <C-w>w
nnoremap <silent> <leader>i <C-w><C-p>
nnoremap <silent> <leader>o <C-d>
nnoremap <silent> <leader>p <C-u>
" ================== Middle row
"nnoremap <silent> <leader>a :NERDTreeToggle<CR>
nnoremap <silent> <leader>a :Files<CR>
"nnoremap <silent> <leader>d :TagbarToggle<CR>
nnoremap <silent> <leader>f :Files<CR>
nnoremap <silent> <leader>g :set hlsearch!<CR>
" Easily jump between lines in all open files
nnoremap <silent> <leader>j :Buffers<CR>
nnoremap <silent> <leader>k :Lines<CR>
" This is the same as f, but I haven't figured out which
" letter I like using better yet
nnoremap <silent> <leader>l :Files<CR>
" Easily open new files in horizontal and vertical splits
nnoremap <silent> <leader>; :split<CR> <C-w>w :Files<CR>
nnoremap <silent> <leader>' :vsplit<CR> <C-w>w :Files<CR>
nnoremap <silent> <leader>l :Rg<CR>
" ================== Bottom row
nnoremap <silent> <leader>v :Ack! "\b<cword>\b"<CR>
nnoremap <silent> <leader>n o<Esc>
nnoremap <silent> <leader>m O<Esc>
" Bind the right beautify function based on what file is open
autocmd FileType javascript nnoremap <silent> <leader>b :call JsBeautify()<CR>
autocmd FileType json nnoremap <silent> <leader>b :call JsonBeautify()<CR>
autocmd FileType jsx nnoremap <silent> <leader>b :call JsxBeautify()<CR>
autocmd FileType html nnoremap <silent> <leader>b :call HtmlBeautify()<CR>
autocmd FileType css nnoremap <silent> <leader>b :call CSSBeautify()<CR>
" Easily enter 'zen mode' with Goyo and Pencil
" We have to explicitly set vertsplit again since Goyo resets it for some reason
nnoremap <silent> <leader>2 :PencilSoft<CR>:Goyo<CR>:hi vertsplit ctermfg=8 ctermbg=none<CR>
" Easily enter 'zen mode' with Goyo and Pencil (Note: Goyo resets the color scheme)
nnoremap <silent> <leader>2 :PencilSoft<CR>:Goyo<CR>:hi vertsplit ctermfg=0 ctermbg=none<CR>
" Save and load vim sessions
nnoremap <silent> <leader>3 :mksession! ~/.vim_session<CR>
nnoremap <silent> <leader>4 :source ~/.vim_session<CR>
" Close the current buffer without closing the window
" Useful for when you want to close a buffer with VimFiler open
nnoremap <silent> <leader>5 :bp<bar>sp<bar>bn<bar>bd<CR>

View File

@ -1,54 +1,37 @@
" New Start: A modern Arch workflow built with an emphasis on functionality.
" Copyright (C) 2017-2018 Donovan Glover
call plug#begin('~/.vim/plugged') " Use vim-plug as our package manager of choice
Plug 'airblade/vim-gitgutter' " Add git diff support
Plug 'dylanaraps/wal.vim' " Add wal support
Plug 'osyo-manga/vim-over' " Automatically highlight find and replace
Plug 'jiangmiao/auto-pairs' " Close brackets and other pairs automatically
Plug 'w0rp/ale' " Automatically check language syntax for errors
Plug 'maksimr/vim-jsbeautify' " Make it easier to work with foreign code
Plug 'lervag/vimtex' " Make editing LaTeX a breeze
Plug 'dbeniamine/todo.txt-vim' " Easily manage any part of your todo.txt
Plug 'elixir-editors/vim-elixir' " Add syntax highlighting and autoindent for Elixir
Plug 'tpope/vim-fugitive' " Add fugitive.vim, enabling us to use git in vim
Plug 'junegunn/fzf' " Add fuzzy finding to easily move between files
Plug 'junegunn/fzf.vim' " Add the vim functionality of fuzzy finding
Plug 'rhysd/vim-crystal' " Add support for the crystal language
Plug 'scrooloose/nerdtree' " Add a file browser to vim
Plug 'rust-lang/rust.vim' " Add rust support to vim
Plug 'jamessan/vim-gnupg' " Easily use GPG encryption inside of vim
Plug 'reedes/vim-pencil' " Use vim as a tool for writing
Plug 'mileszs/ack.vim' " Testing ack.vim with ag
Plug 'tpope/vim-endwise' " Automatically add end
call plug#begin('~/.vim/plugged')
Plug 'dylanaraps/wal.vim' " Color scheme
Plug 'airblade/vim-gitgutter' " Git diff
Plug 'itchyny/lightline.vim' " Status line
Plug 'w0rp/ale' " Syntax checker
Plug 'sgur/vim-editorconfig' " EditorConfig
Plug 'tpope/vim-fugitive' " Git wrapper
Plug 'junegunn/fzf.vim' " fzf wrapper
Plug 'jiangmiao/auto-pairs' " {Pair} completion
Plug 'tpope/vim-endwise' " 'End' completion
Plug 'reedes/vim-pencil' " Word wrap
Plug 'junegunn/goyo.vim' " Distraction-free writing
Plug 'Yggdroot/indentLine' " Show indentation levels
Plug 'Shougo/unite.vim' " Required by vimfiler
Plug 'Shougo/vimfiler.vim' " Yet another file explorer
Plug 'osyo-manga/vim-over', {'on': 'OverCommandLine'}
Plug 'maksimr/vim-jsbeautify', {'on': ['JsBeautify', 'JsonBeautify',
\ 'JsxBeautify', 'HtmlBeautify', 'CSSBeautify']}
Plug 'mattn/emmet-vim' " Add emmet support
Plug 'sgur/vim-editorconfig' " Add editorconfig support
Plug 'baskerville/vim-sxhkdrc' " Add sxhkdrc support
Plug 'cespare/vim-toml' " Add toml support
Plug 'dag/vim-fish' " Add fish support
Plug 'slim-template/vim-slim' " Add slim support
Plug 'pangloss/vim-javascript' " Improve JavaScript support
Plug 'othree/html5.vim' " Improve HTML support
Plug 'alvan/vim-closetag' " Automatically close tags when writing HTML
Plug 'tpope/vim-surround' " Easily add or remove surrounding characters
Plug 'chrisbra/csv.vim' " Add CSV support
Plug 'Glench/Vim-Jinja2-Syntax' " Add Jinja2 support
Plug 'mustache/vim-mustache-handlebars' " Add mustache and handlebars support
Plug 'plasticboy/vim-markdown' " Add more markdown support (LaTeX, frontmatter, etc.)
Plug 'quabug/vim-gdscript' " Add Godot support
Plug 'posva/vim-vue' " Add Vue support
Plug 'mxw/vim-jsx' " Add React support
Plug 'digitaltoad/vim-pug' " Add Pug support
Plug 'kchmck/vim-coffee-script' " Add CoffeeScript support
Plug 'leafgarland/typescript-vim' " Add TypeScript support
call plug#end() " Start the plugins
Plug 'pangloss/vim-javascript', {'for': 'javascript'}
Plug 'alvan/vim-closetag', {'for': 'html'}
Plug 'rhysd/vim-crystal', {'for': 'crystal'}
Plug 'rust-lang/rust.vim', {'for': 'rust'}
Plug 'baskerville/vim-sxhkdrc', {'for': 'sxhkdrc'}
Plug 'cespare/vim-toml', {'for': 'toml'}
Plug 'dag/vim-fish', {'for': 'fish'}
Plug 'slim-template/vim-slim', {'for': 'slim'}
Plug 'Glench/Vim-Jinja2-Syntax', {'for': 'jinja2'}
Plug 'plasticboy/vim-markdown', {'for': 'markdown'}
Plug 'posva/vim-vue', {'for': 'vue'}
Plug 'mxw/vim-jsx', {'for': 'javascript'}
Plug 'digitaltoad/vim-pug', {'for': 'pug'}
Plug 'leafgarland/typescript-vim', {'for': 'typescript'}
Plug 'dbeniamine/todo.txt-vim', {'for': 'todo'}
Plug 'lervag/vimtex', {'for': 'tex'}
call plug#end()

147
.vimrc
View File

@ -11,145 +11,70 @@ source ~/.vim/keybindings.vim
colorscheme wal
" Wal Themes: Tomorrow, Tomorrow_Night, one, materia, material, nord
" Other Themes: wombat, solarized, powerline, jellybeans, Tomorrow_Night_Blue,
" Tomorrow_Night_Eighties, PaperColor, seoul256, landscape,
" darcula, molokai, OldHope, deus
let g:lightline = {
\ 'colorscheme': 'Tomorrow_Night',
\ 'active': {
\ 'left': [
\ [ 'mode', 'paste' ], [ 'gitbranch' ],
\ ['readonly', 'filename', 'modified']
\ ]
\ },
\ 'component_function': {
\ 'gitbranch': 'fugitive#head'
\ },
\ }
" =================================== Plugin-Specific ===================================
let g:ale_lint_on_text_changed = 'never' " Do not lint while typing
let g:ale_lint_on_insert_leave = 1 " Only lint after leaving insert mode
let g:ackprg = 'rg --vimgrep' " Use rg instead of ag / ack / grep
let g:plug_window = 'rightbelow topleft new' " Show vim-plug above instead of to the left
let g:vimfiler_as_default_explorer = 1 " Replace netrw with vimfiler as the default FileEx
let g:indentLine_enabled = 0 " Disable indent lines by default
let g:indentLine_color_term = 8 " Set the color for the indent line
"let g:vimfiler_no_default_key_mappings = 1
let g:ale_linters = {'javascript': ['standard']}
" Note that indent lines breaks with pencil mode, although you really
" shouldn't be using both at the same time anyway.
" Don't show the separator for vertical splits
hi vertsplit ctermfg=0 ctermbg=none
" NOTE: To view all the items you can change the color of, use:
" :so $VIMRUNTIME/syntax/hitest.vim
" Set the color for the vertical split line (6 is as good as 8 here)
hi vertsplit ctermfg=8 ctermbg=none
" Remove the background color from the status line
hi StatusLine ctermbg=none
hi StatusLineNC ctermbg=none
" Remove the background color from tabs
hi TabLine ctermbg=none
hi TabLineFill ctermbg=none
hi TabLineSel ctermbg=none
" Finally, an easier way to read search results
hi Search ctermbg=240 ctermfg=255
" We have to set the color for while we search as well
" To keep things simple, we'll just invert the colors here
" As an added bonus, this looks rather nice as well
hi IncSearch ctermbg=255 ctermfg=240
" Disable all vimtex keybindings so we can define our own
let g:vimtex_mappings_enabled = 0
let g:vimtex_imaps_enabled = 0
let g:vimtex_view_method = 'zathura'
let g:vimtex_index_show_help = 0
let g:vimtex_index_split_width = 50
let g:vimtex_index_split_pos = 'vert rightbelow'
let g:vimtex_compiler_latexmk = {'build_dir': '.tex'}
map <localleader>a <plug>(vimtex-toc-toggle)
map <localleader>f <plug>(vimtex-view)
map <localleader>g <plug>(vimtex-compile)
map <localleader>c <plug>(vimtex-errors)
map <localleader>w :VimtexCountWords<CR>
" Delete the surrounding environment
map <localleader>d <plug>(vimtex-env-delete)
map <localleader>c <plug>(vimtex-env-change)
" Toggle stars
nnoremap <localleader>s <plug>(vimtex-env-toggle-star)
nnoremap <localleader>e <plug>(vimtex-cmd-toggle-star)
nnoremap <localleader>f <plug>(vimtex-view)
nnoremap <localleader>g <plug>(vimtex-compile)
nnoremap <localleader>d <plug>(vimtex-env-delete)
nnoremap <localleader>c <plug>(vimtex-env-change)
inoremap ]] <plug>(vimtex-delim-close)
" Use incsearch and tab / shift+tab to go through the results
cno <expr> <tab> getcmdtype() =~ '[?/]' ? '<c-g>' : feedkeys('<tab>', 'int')[1]
cno <expr> <s-tab> getcmdtype() =~ '[?/]' ? '<c-t>' : feedkeys('<s-tab>', 'int')[1]
" Easily repeat a command on multiple lines through visual mode
vnoremap . :normal .<CR>
" Easily show lines that go past the character count
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
highlight OverLength ctermbg=240 ctermfg=230
call matchadd('OverLength', '\%80v')
" Automatically close the file viewer when it's the only thing left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Use w!! to force write a file as sudo
" cmap w!! w !sudo tee > /dev/null %
" Make the tabline not have an X in it
function MyTabLine()
let s = ''
for i in range(tabpagenr('$'))
" select the highlighting
if i + 1 == tabpagenr()
let s .= '%#TabLineSel#'
else
let s .= '%#TabLine#'
endif
" set the tab page number (for mouse clicks)
let s .= '%' . (i + 1) . 'T'
" the label is made by MyTabLabel()
let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
endfor
" after the last tab fill with TabLineFill and reset tab page nr
let s .= '%#TabLineFill#%T'
return s
endfunction
function MyTabLabel(n)
let buflist = tabpagebuflist(a:n)
let winnr = tabpagewinnr(a:n)
return bufname(buflist[winnr - 1])
endfunction
set tabline=%!MyTabLine()
" Custom highlighting
" Highlight key words that we like to use
match Function /@requires/
" Use syntax highlighting for .ecr files
autocmd BufNewFile,BufRead *.ecr set syntax=html
" Use syntax highlighting for .slang files
autocmd BufNewFile,BufRead *.slim setlocal filetype=slim
autocmd BufNewFile,BufRead *.slang setlocal filetype=slim
" autocmd BufReadPost *.slang set syntax=slim
" Use htmldjango for html files
" autocmd BufNewFile,BufRead *.html setlocal filetype=htmldjango
" autocmd BufNewFile,BufRead *.html setlocal filetype=html
autocmd BufNewFile,BufRead *.html setlocal filetype=jinja
autocmd BufNewFile,BufRead *.ecr setlocal syntax=html
autocmd BufNewFile,BufRead *.slang setlocal filetype=slim
" Disable vim-markdown folding
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
autocmd BufNewFile,BufRead *.md set conceallevel=2
" au BufNewFile,BufRead,BufWrite *.md syntax match Comment /\%^---\_.\{-}---$/
" Change cursor back to blink after exiting neovim
au VimLeave * set guicursor=a:block-blinkon1
" Only hide the dots we don't need
let g:vimfiler_ignore_pattern = ['^\.git$', '^\.shards$', '^\.sass-cache$']
" Only use standard for JavaScript
let g:ale_linters = {'javascript': ['standard']}
" Ignore syntax concealing for markdown files
let g:vim_markdown_conceal = 0
let g:tex_conceal = ""
let g:vim_markdown_math = 1
" Hide the status line showing "fzf" when using fzf.vim
" NOTE: You must add "showmode" if your setup depends on it
autocmd! FileType fzf
autocmd FileType fzf set laststatus=0 noshowmode noruler
\| autocmd BufLeave <buffer> set laststatus=2 ruler