-- TODO: translate this to 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.errorbells = false set.encoding = 'UTF-8' set.cursorline = true set.mouse = 'a' set.incsearch = true set.scrolloff = 5 --set.wildmenu --set.wildmode = full 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 ]] -- Macro for opening a new terminal vim.cmd 'command! Term tabnew | term' -- Genereate ctags vim.cmd 'command! MakeTags !ctags -R .' -- Press Alt h to toggle highlighting on/off, and show current value. vim.cmd 'nnoremap noh' vim.cmd 'inoremap noh' -- 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' -- 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' vim.cmd 'nnoremap l' -- 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 --- -- 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 ' -- 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 [[ 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 ]]