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 ]] -- Quit even if there are more files to edit (files passed from the command line) vim.cmd 'au QuitPre * args %' -- Go to previous file, but faster vim.cmd 'command! P previous' -- 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 set spell! spell?' -- Toggle wrap with alt W vim.cmd 'nnoremap set wrap! wrap?' -- find + replace with alt S vim.cmd 'nnoremap :%s//g' -- find + replace a word with alt S vim.cmd 'nnoremap ye:%s//g"/' -- open current file with nvim in alacritty (useful if it gets opened in some other terminal) vim.cmd 'nnoremap !nohup alacritty -e nvim % > /dev/null 2>&1 &; disownq' -- Escape to enter normal mode in the terminal vim.cmd 'tnoremap ' vim.cmd 'nnoremap = :exe "resize " . (winheight(0) * 3/2)' vim.cmd 'nnoremap + :exe "resize " . (winheight(0) * 3/2)' vim.cmd 'nnoremap - :exe "resize " . (winheight(0) * 2/3)' -- Switch panes with ctrl hjkl vim.cmd 'nnoremap h' vim.cmd 'nnoremap j' vim.cmd 'nnoremap 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=' -- 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 @ :call ExecuteMacroOverVisualRange() function! ExecuteMacroOverVisualRange() echo "@".getcmdline() execute ":'<,'>normal @".nr2char(getchar()) endfunction ]] -- vim: nospell