162 lines
4.9 KiB
Lua
162 lines
4.9 KiB
Lua
local set = vim.o
|
|
|
|
-- Settings
|
|
local tabsize = 3
|
|
set.tabstop = tabsize
|
|
set.softtabstop = tabsize
|
|
set.shiftwidth = tabsize
|
|
set.suffixes = '.bak,~,.o,.h,.info,.swp,.obj,.aux,.bbl,.blg,.brf,.cb,.dvi,.idx,.ilg,.ind,.inx,.jpg,.log,.out,.png,.toc'
|
|
set.expandtab = true
|
|
set.smartindent = true
|
|
set.undofile = true
|
|
set.swapfile = true
|
|
set.hlsearch = true
|
|
set.hidden = true
|
|
set.backspace = 'indent,eol,start'
|
|
set.ignorecase = true
|
|
set.smartcase = true
|
|
set.showmode = false
|
|
set.wrap = false
|
|
set.linebreak = true
|
|
set.redrawtime = 200
|
|
set.updatetime = 300
|
|
set.number = true
|
|
set.relativenumber = true
|
|
set.errorbells = false
|
|
set.encoding = 'UTF-8'
|
|
set.cursorline = true
|
|
set.mouse = 'a'
|
|
set.incsearch = true
|
|
set.scrolloff = 5
|
|
set.hidden = true
|
|
set.shortmess = 'filnxtToOFc' -- the funny thing is this is a short mess
|
|
set.spell = true
|
|
set.spelllang = 'en_us'
|
|
set.showcmd = true
|
|
set.signcolumn = 'yes'
|
|
set.makeprg = 'make -j$(nproc)'
|
|
set.ruler = false
|
|
set.listchars = 'trail:~,tab:│ ,nbsp:␣,lead:·,extends:…,precedes:…'
|
|
set.list = false
|
|
|
|
----------------------------------------------
|
|
--- Key bindings (needs to be translated?) ---
|
|
----------------------------------------------
|
|
|
|
vim.cmd 'let mapleader = " "'
|
|
|
|
-- *sigh*...
|
|
vim.cmd [[
|
|
command! Q q
|
|
command! W w
|
|
command! Wq wq
|
|
command! WQ wq
|
|
command! Wa wa
|
|
command! WA wa
|
|
command! Qa qa
|
|
command! QA qa
|
|
command! Wqa wqa
|
|
command! WQa wqa
|
|
command! WQA wqa
|
|
|
|
command! Set set
|
|
]]
|
|
|
|
-- Macro for opening a new terminal
|
|
vim.cmd 'command! Term tabnew | term'
|
|
|
|
-- Genereate ctags
|
|
vim.cmd 'command! MakeTags !ctags -R .'
|
|
|
|
-- Write buffer as root
|
|
vim.cmd 'cmap w!! w !sudo tee > /dev/null %'
|
|
|
|
-- Toggle spell check with alt S
|
|
vim.cmd 'nnoremap <M-S> <cmd>set spell! spell?<CR>'
|
|
|
|
-- Toggle wrap with alt W
|
|
vim.cmd 'nnoremap <M-W> <cmd>set wrap! wrap?<CR>'
|
|
|
|
-- find + replace with alt S
|
|
vim.cmd 'nnoremap <M-s> :%s//g<Left><Left>'
|
|
|
|
-- find + replace a word with alt S
|
|
vim.cmd 'nnoremap <M-w> ye:%s//g<Left><Left><C-r>"/'
|
|
|
|
-- open current file with nvim in alacritty (useful if it gets opened in some other terminal)
|
|
vim.cmd 'nnoremap <M-a> <cmd>!nohup alacritty -e nvim % > /dev/null 2>&1 &; disown<CR><cmd>q<CR>'
|
|
|
|
-- Escape to enter normal mode in the terminal
|
|
vim.cmd 'tnoremap <C-\\> <C-\\><C-n>'
|
|
|
|
vim.cmd 'nnoremap <silent> <Leader>= :exe "resize " . (winheight(0) * 3/2)<CR>'
|
|
vim.cmd 'nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>'
|
|
vim.cmd 'nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>'
|
|
|
|
-- Switch panes with ctrl hjkl
|
|
vim.cmd 'nnoremap <C-h> <C-w>h'
|
|
vim.cmd 'nnoremap <C-j> <C-w>j'
|
|
vim.cmd 'nnoremap <C-k> <C-w>k'
|
|
|
|
-- Spell correct with Q, rather than z=
|
|
vim.cmd 'nnoremap Q z='
|
|
|
|
----------------------------------------------
|
|
--- Things that can't be translated to lua ---
|
|
----------------------------------------------
|
|
|
|
vim.cmd 'let g:markdown_fenced_languages = [ "bash=sh", "javascript", "cpp=cpp", "c++=cpp", "js=javascript", "json=javascript", "typescript", "ts=typescript", "php", "html", "css", "yml=yaml", "yaml" ]'
|
|
|
|
--- autocmd's ---
|
|
-- Set comment strings
|
|
vim.cmd 'autocmd FileType crontab set commentstring=#%s'
|
|
-- vim.cmd 'autocmd FileType rmd set commentstring=<!--\\ %s\\ -->'
|
|
|
|
-- Enable linewrap in markdown files
|
|
vim.cmd [[ autocmd FileType markdown setlocal wrap ]]
|
|
|
|
-- 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 ]]
|
|
|
|
-- Spell check in git commits by default
|
|
vim.cmd 'autocmd Filetype gitcommit setlocal spell'
|
|
|
|
-- Disable spell check in help files
|
|
vim.cmd 'autocmd FileType help setlocal nospell'
|
|
vim.cmd 'filetype plugin on'
|
|
|
|
-- Automatically disable line numbers when in terminal mode
|
|
vim.cmd 'autocmd TermOpen * setlocal nospell nonumber norelativenumber'
|
|
|
|
-- Automatically toggle relative line numbers
|
|
-- vim.cmd 'autocmd InsertEnter * :set norelativenumber '
|
|
-- vim.cmd 'autocmd InsertLeave * :set relativenumber '
|
|
|
|
-- Make vim a hex editor
|
|
-- Edit *.bin files as binaries rather than text files
|
|
-- (if your file isn't a .bin, do this: `ln -s $file $file.bin; vim $file`)
|
|
vim.cmd [[
|
|
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
|
|
]]
|
|
|
|
-- 'Visual At' plugin (https://github.com/stoeffel/.dotfiles/blob/master/vim/visual-at.vim)
|
|
-- Basically, record a macro that effects one line, select some lines, then run
|
|
-- it, and the macro will be executed on all visual selected lines individually
|
|
vim.cmd [[
|
|
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
|
|
function! ExecuteMacroOverVisualRange()
|
|
echo "@".getcmdline()
|
|
execute ":'<,'>normal @".nr2char(getchar())
|
|
endfunction
|
|
]]
|
|
|
|
-- vim: nospell
|