2021-09-08 23:58:29 -07:00
|
|
|
-- TODO: translate this to lua
|
2021-09-03 01:18:44 -07:00
|
|
|
vim.cmd [[
|
2021-09-08 23:58:29 -07:00
|
|
|
""" Settings
|
|
|
|
set suffixes+=.aux,.bbl,.blg,.brf,.cb,.dvi,.idx,.ilg,.ind,.inx,.jpg,.log,.out,.png,.toc
|
|
|
|
set suffixes-=.h
|
|
|
|
set suffixes-=.obj
|
|
|
|
set tabstop=3 softtabstop=3
|
|
|
|
set shiftwidth=3
|
|
|
|
set expandtab
|
|
|
|
set smartindent
|
2021-11-02 21:23:44 -07:00
|
|
|
"set foldmethod=indent
|
|
|
|
"set foldlevel=0
|
2021-09-08 23:58:29 -07:00
|
|
|
set undofile
|
2021-11-02 21:23:44 -07:00
|
|
|
set swapfile
|
2021-09-08 23:58:29 -07:00
|
|
|
set hlsearch
|
|
|
|
set hidden
|
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
2021-10-26 02:51:13 -07:00
|
|
|
set nowrap
|
2021-09-08 23:58:29 -07:00
|
|
|
set linebreak
|
2021-11-02 21:23:44 -07:00
|
|
|
"set guicursor= " always use the block cursor
|
2021-10-20 01:31:45 -07:00
|
|
|
syntax enable
|
2021-10-24 11:42:40 -07:00
|
|
|
set syntax=on
|
2021-11-02 21:23:44 -07:00
|
|
|
" max syntax highlight time in ms
|
|
|
|
set redrawtime=200
|
|
|
|
set updatetime=300
|
2021-09-27 02:04:54 -07:00
|
|
|
set number "relativenumber
|
2021-11-02 21:23:44 -07:00
|
|
|
" Automatically toggle relative line numbers
|
|
|
|
"autocmd InsertEnter * :set norelativenumber
|
2021-09-27 02:04:54 -07:00
|
|
|
"autocmd InsertLeave * :set relativenumber
|
2021-09-08 23:58:29 -07:00
|
|
|
set noerrorbells
|
|
|
|
set encoding=UTF-8
|
|
|
|
set cursorline
|
|
|
|
set mouse=a
|
|
|
|
set incsearch
|
|
|
|
set scrolloff=5
|
2021-11-02 21:23:44 -07:00
|
|
|
"set wildmenu
|
|
|
|
"set wildmode=full
|
2021-09-08 23:58:29 -07:00
|
|
|
" TextEdit might fail if hidden is not set.
|
|
|
|
set hidden
|
|
|
|
set cmdheight=1 " Give more space for displaying messages.
|
|
|
|
" Don't pass messages to |ins-completion-menu|.
|
|
|
|
set shortmess+=c
|
|
|
|
" Spell check!
|
|
|
|
set spelllang=en_us
|
|
|
|
" spell check in git commits
|
|
|
|
autocmd Filetype gitcommit setlocal spell
|
|
|
|
set showcmd
|
|
|
|
set signcolumn=yes
|
2021-11-02 21:23:44 -07:00
|
|
|
|
|
|
|
""" autocmd's
|
|
|
|
" Disable spell check in help files
|
2021-09-08 23:58:29 -07:00
|
|
|
autocmd FileType help setlocal nospell
|
|
|
|
filetype plugin on
|
2021-11-02 21:23:44 -07:00
|
|
|
" Automatically disable line numbers when in terminal mode
|
|
|
|
autocmd TermOpen * setlocal nospell nonumber norelativenumber
|
2021-09-03 01:18:44 -07:00
|
|
|
|
2021-09-08 23:58:29 -07:00
|
|
|
""" Key bindings
|
|
|
|
let mapleader = " "
|
2021-09-16 02:17:07 -07:00
|
|
|
|
|
|
|
" *sigh*...
|
2021-09-08 23:58:29 -07:00
|
|
|
command! Q q
|
|
|
|
command! W w
|
|
|
|
command! Wq wq
|
|
|
|
command! WQ wq
|
2021-09-28 01:52:37 -07:00
|
|
|
command! Wa wa
|
|
|
|
command! WA wa
|
|
|
|
command! Qa qa
|
|
|
|
command! QA qa
|
|
|
|
command! Wqa wqa
|
|
|
|
command! WQa wqa
|
|
|
|
command! WQA wqa
|
2021-09-16 02:17:07 -07:00
|
|
|
|
2021-11-02 21:23:44 -07:00
|
|
|
" Macro for opening a new terminal
|
|
|
|
command! Term tabnew | term
|
|
|
|
|
2021-09-16 02:17:07 -07:00
|
|
|
" Press Alt h to toggle highlighting on/off, and show current value.
|
2021-10-20 01:31:45 -07:00
|
|
|
nnoremap <M-h> <cmd>noh<CR>
|
2021-10-19 22:21:53 -07:00
|
|
|
|
|
|
|
" Toggle spell check with alt S
|
2021-10-20 01:31:45 -07:00
|
|
|
nnoremap <M-S> <cmd>set spell! spell?<CR>
|
2021-09-16 02:17:07 -07:00
|
|
|
|
2021-10-19 22:21:53 -07:00
|
|
|
" find + replace with alt S
|
2021-11-01 10:59:35 -07:00
|
|
|
nnoremap <M-s> :%s//g<Left><Left>
|
2021-10-19 22:21:53 -07:00
|
|
|
|
2021-09-16 02:17:07 -07:00
|
|
|
" Escape to enter normal mode in the terminal
|
2021-09-08 23:58:29 -07:00
|
|
|
tnoremap <Esc> <C-\><C-n>
|
2021-09-16 02:17:07 -07:00
|
|
|
|
2021-10-18 17:34:45 -07:00
|
|
|
nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR>
|
|
|
|
nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
|
|
|
|
nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
|
|
|
|
|
|
|
|
" Switch panes with ctrl hjkl
|
|
|
|
nnoremap <C-h> <C-w>h
|
|
|
|
nnoremap <C-j> <C-w>j
|
|
|
|
nnoremap <C-k> <C-w>k
|
|
|
|
nnoremap <C-l> <C-w>l
|
|
|
|
|
2021-09-16 02:17:07 -07:00
|
|
|
" Move lines around in visual mode with J and K
|
2021-09-09 01:03:02 -07:00
|
|
|
vnoremap J :m '>+1<CR>gv=gv
|
|
|
|
vnoremap K :m '<-2<CR>gv=gv
|
2021-09-03 01:18:44 -07:00
|
|
|
|
2021-10-01 01:34:19 -07:00
|
|
|
" Format text with Q, rather than gw
|
|
|
|
nnoremap Q gw
|
|
|
|
|
|
|
|
colorscheme slate
|
|
|
|
]]
|
|
|
|
|
|
|
|
-- 24-bit color
|
|
|
|
vim.cmd [[
|
|
|
|
"Use 24-bit (true-color) mode in Vim/Neovim when outside tmux.
|
|
|
|
"If you're using tmux version 2.2 or later, you can remove the outermost $TMUX check and use tmux's 24-bit color support
|
|
|
|
"(see < http://sunaku.github.io/tmux-24bit-color.html#usage > for more information.)
|
|
|
|
if (empty($TMUX))
|
|
|
|
if (has("nvim"))
|
|
|
|
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
|
|
|
|
let $NVIM_TUI_ENABLE_TRUE_COLOR=1
|
|
|
|
endif
|
|
|
|
"For Neovim > 0.1.5 and Vim > patch 7.4.1799 < https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162 >
|
|
|
|
"Based on Vim patch 7.4.1770 (`guicolors` option) < https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd >
|
|
|
|
" < https://github.com/neovim/neovim/wiki/Following-HEAD#20160511 >
|
|
|
|
if (has("termguicolors"))
|
|
|
|
"set termguicolors
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
]]
|
|
|
|
|
|
|
|
|
|
|
|
-- Make vim a hex editor
|
|
|
|
-- Edit *.bin files as binaries rather than text files (if your file isn't a .bin,
|
|
|
|
-- make a symlink that points to it with the .bin extension and edit the symlink ;)
|
|
|
|
vim.cmd [[
|
2021-09-23 17:13:45 -07:00
|
|
|
augroup Binary
|
|
|
|
au!
|
|
|
|
au BufReadPre *.bin let &bin=1
|
|
|
|
au BufReadPost *.bin if &bin | %!xxd
|
|
|
|
au BufReadPost *.bin set ft=xxd | endif
|
|
|
|
au BufWritePre *.bin if &bin | %!xxd -r
|
|
|
|
au BufWritePre *.bin endif
|
|
|
|
au BufWritePost *.bin if &bin | %!xxd
|
|
|
|
au BufWritePost *.bin set nomod | endif
|
|
|
|
augroup END
|
2021-09-03 01:18:44 -07:00
|
|
|
]]
|
|
|
|
|
|
|
|
-- 'Visual At' plugin (https://github.com/stoeffel/.dotfiles/blob/master/vim/visual-at.vim)
|
2021-10-01 01:34:19 -07:00
|
|
|
-- basically, record a macro, select some lines, then run it, and the macro
|
|
|
|
-- will be executed on all visual selected lines individually
|
2021-09-03 01:18:44 -07:00
|
|
|
vim.cmd [[
|
2021-10-01 01:34:19 -07:00
|
|
|
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
|
|
|
|
function! ExecuteMacroOverVisualRange()
|
|
|
|
echo "@".getcmdline()
|
|
|
|
execute ":'<,'>normal @".nr2char(getchar())
|
|
|
|
endfunction
|
2021-09-03 01:18:44 -07:00
|
|
|
]]
|
|
|
|
|
|
|
|
-- Automatically jump to the last position in a file when opening
|
|
|
|
vim.cmd [[ au BufReadPost * if expand('%:p') !~# '\m/\.git/' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]]
|
|
|
|
|
2021-10-01 01:34:19 -07:00
|
|
|
-- Highlight trailing whitespace in red
|
|
|
|
vim.cmd [[
|
|
|
|
highlight ExtraWhitespace ctermbg=red guibg=red
|
|
|
|
match ExtraWhitespace /\s\+$/
|
|
|
|
au BufWinEnter * match ExtraWhitespace /\s\+$/
|
|
|
|
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
|
|
|
|
au InsertLeave * match ExtraWhitespace /\s\+$/
|
|
|
|
au BufWinLeave * call clearmatches()
|
|
|
|
]]
|
2021-10-06 23:24:33 -07:00
|
|
|
|