" this isn't the 90s anymore
set nocompatible
" Attempt to determine the type of a file based on its name and possibly its
" contents. Use this to allow intelligent auto-indenting for each filetype,
" and for plugins that are filetype specific.
if has('filetype')
filetype indent plugin on
endif
" Enable syntax highlighting
if has('syntax')
syntax on
endif
set encoding=utf-8
" Vim with default settings does not allow easy switching between multiple files
" in the same editor window. Users can use multiple split windows or multiple
" tab pages to edit multiple files, but it is still best to enable an option to
" allow easier switching between files.
"
" One such option is the 'hidden' option, which allows you to re-use the same
" window and switch from an unsaved buffer without saving it first. Also allows
" you to keep an undo history for multiple files when re-using the same window
" in this way. Note that using persistent undo also lets you undo in multiple
" files even in the same window, but is less efficient and is actually designed
" for keeping undo history after closing Vim entirely. Vim will complain if you
" try to quit without saving, and swap files will keep you safe if your computer
" crashes.
set hidden
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <leader>/ to temporarily turn off highlighting)
set hlsearch
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Enable use of the mouse for all modes
if has('mouse')
set mouse=a
endif
" Display line numbers on the left
set number
set relativenumber
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
"
" Leave paste mode so I don't forget
autocmd InsertLeave * set nopaste
autocmd BufNewFile,BufRead *.asm setlocal ts=5 sts=5 sw=5
" Indentation settings for using 4 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=4
set softtabstop=4
set expandtab
" Don't update the screen when executing macros
set lazyredraw
" Easier to reach than \
let mapleader=" "
" plugin config
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
" fzf
nmap <leader>p :Files<cr>
nmap <leader>bb :Buffers<cr>
" lightline
let g:lightline = {
\ 'colorscheme': 'Tomorrow_Night',
\ }
let g:lightline.component_expand = {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_infos': 'lightline#ale#infos',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ }
let g:lightline.component_type = {
\ 'linter_checking': 'right',
\ 'linter_infos': 'right',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'right',
\ }
let g:lightline.active = {
\ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ],
\ [ 'lineinfo' ],
\ [ 'percent' ],
\ [ 'fileformat', 'fileencoding', 'filetype'] ] }
let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_infos = "\uf129"
let g:lightline#ale#indicator_warnings = "\uf071"
let g:lightline#ale#indicator_errors = "\uf05e"
let g:lightline#ale#indicator_ok = "\uf00c"
" end plugin config
set formatoptions=ctqrn1
set showmatch " Show matching brackets.
set matchtime=5 " Bracket blinking.
" start scrolling when we're 8 lines away from margins
set scrolloff=8
set sidescrolloff=15
set sidescroll=1
set noswapfile
set nobackup
set nowb
" Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode.
"set fo+=o
" Do not automatically insert a comment leader after an enter
"set fo-=r
" Do no auto-wrap text using textwidth (does not apply to comments)
"set fo-=t
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/bin/*,*/node_modules/*
" quicker async update time
set updatetime=100
" taller vertical bar for vsplits
set fillchars+=vert:│
set termguicolors
set undodir=~/.vim/backups
set undofile
" When opening a file, always jump to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif
" remove annoying help window
inoremap <F1> <nop>
nnoremap <F1> <nop>
vnoremap <F1> <nop>
" easy .vimrc editing
nnoremap <silent> <Leader>rs :source ~/.vimrc<CR>
nnoremap <silent> <Leader>rt :tabnew ~/.vimrc<CR>
" better window navigation
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
" quickfix
nnoremap <c-n> :cnext<CR>
nnoremap <c-b> :cprevious<CR>
" command line autocomplete
set wildchar=<Tab> wildmenu wildmode=full
" scroll through buffers
noremap <left> :bp<CR>
noremap <right> :bn<CR>
" show menu to switch buffers
set wildcharm=<C-Z>
nnoremap <F10> :b <C-Z>
" unhighlight search results
noremap <silent><Leader>/ :nohls<CR>
" reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" force saving files that require root permission
cmap w!! %!sudo tee > /dev/null %
" Close the current buffer and move to the previous one
" This replicates the idea of closing a tab
nmap <leader>bq :bp <BAR> bd #<CR>
colorscheme base16-tomorrow-night
" ALE
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'javascript': ['eslint'],
\ 'ruby': ['rubocop'],
\}
let g:ale_set_balloons=1
" Set the executable for ALE to call to get Solargraph
" up and running in a given session
let g:ale_ruby_solargraph_executable = 'solargraph'
let g:ale_ruby_solargraph_options = {}
let g:ale_completion_enabled = 1
" Load all plugins now.
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
silent! helptags ALL