vim.g.mapleader = "," -- Auto-install vim-plug if not present local install_path = vim.fn.stdpath('config')..'/autoload/plug.vim' if vim.fn.empty(vim.fn.glob(install_path)) > 0 then print("Downloading junegunn/vim-plug to manage plugins...") vim.fn.system({ 'curl', '-fLo', install_path, '--create-dirs', 'https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' }) vim.cmd('autocmd VimEnter * PlugInstall') end -- Plugin declarations in pure Lua local Plug = vim.fn['plug#'] vim.call('plug#begin', vim.fn.stdpath('config')..'/plugged') Plug('bling/vim-airline') Plug('ap/vim-css-color') Plug('vimwiki/vimwiki') Plug('michal-h21/vimwiki-sync') vim.call('plug#end') -- General settings vim.opt.title = true vim.opt.mouse = "a" vim.opt.clipboard:append("unnamedplus") vim.opt.showmode = false vim.opt.ruler = false vim.opt.laststatus = 0 vim.opt.showcmd = false vim.opt.scrolloff = 7 vim.opt.swapfile = false vim.opt.backup = false vim.cmd('colorscheme bloomberg') --vim.cmd('hi Normal ctermbg=NONE') --vim.cmd('hi NonText ctermbg=NONE') -- Basics vim.keymap.set('n', 'c', '"_c') vim.cmd('filetype plugin on') vim.cmd('syntax on') vim.opt.encoding = "utf-8" vim.opt.number = true vim.opt.relativenumber = true -- Enable autocmpletion: vim.opt.wildmode = "longest,list,full" -- Disable automatic commenting on new line vim.opt.formatoptions:remove({'c', 'r', 'o'}) -- Splits open at the bottom and right, which is non-retarded, unlike vim defaults. vim.opt.splitbelow = true vim.opt.splitright = true -- Autocommands -- Automatically deletes all trailing whitespace and newlines at end of file on save & reset cursor position. vim.api.nvim_create_augroup('Format', {clear = true}) vim.api.nvim_create_autocmd('BufWritePre', { group = 'Format', pattern = '*', callback = function() local pos = vim.fn.getpos('.') vim.cmd([[silent! keeppatterns %s/\s\+$//e]]) vim.cmd([[silent! keeppatterns %s/\n\+\%$//e]]) local fname = vim.fn.expand('%') if fname:match('%.c$') or fname:match('%.h$') then vim.cmd([[silent! keeppatterns %s/\%$/\r/e]]) end if fname:match('neomutt') then vim.cmd([[silent! keeppatterns %s/^--$/-- /e]]) end vim.fn.cursor(pos[2], pos[3]) end }) -- When shortcut files are updated, renew configs with new material: vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "bm-files", "bm-dirs" }, command = "!shortcuts" }) -- Run xrdb whenever Xdefaults or Xresources are updated. vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, command = "set filetype=xdefaults" }) vim.api.nvim_create_autocmd("BufWritePost", { pattern = { "Xresources", "Xdefaults", "xresources", "xdefaults" }, command = "!xrdb %" }) -- Vimwiki configuration vim.g.vimwiki_ext2syntax = {['.Rmd'] = 'markdown', ['.rmd'] = 'markdown', ['.md'] = 'markdown', ['.markdown'] = 'markdown', ['.mdown'] = 'markdown'} vim.g.vimwiki_list = { {path = '~/.local/share/vimwiki', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/Finance', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/Finance/Fundamentals', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/Finance/Research', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/Finance/Research/Tickers', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/cs', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/cs/Gentoo', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/vimwiki/arcana', syntax = 'markdown', ext = '.md'}, {path = '~/.local/share/Cuisine', syntax = 'markdown', ext = '.md'} } vim.g.vimwiki_sync_commit_message = 'Auto from nzxt - %c' vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "/tmp/calcurse*", "~/.calcurse/notes/*" }, command = "set filetype=markdown" }) vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = { "*.ms", "*.me", "*.mom", "*.man" }, command = "set filetype=groff" }) vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" }, { pattern = "*.tex", command = "set filetype=tex" }) -- Runs a script that cleans out tex build files whenever I close out of a .tex file. vim.api.nvim_create_autocmd("VimLeave", { pattern = "*.tex", command = "!texclear %" }) -- Save file as sudo on files that require root permission vim.cmd([[cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' \| edit!]]) -- Bindings -- Spell-check set to o, 'o' for 'orthography' vim.keymap.set("n", "o", ":setlocal spell! spelllang=en_us", { desc = "Toggle spell-check (en_us)" }) -- Compile document, be it groff/LaTeX/markdown/etc. vim.keymap.set("n", "c", ':w! | !compiler "%"', { desc = "Compile document, be it groff/LaTeX/markdown/etc." }) -- Open corresponding .pdf/.html or preview vim.keymap.set("n", "p", ':!opout "%"', { desc = "Open PDF/HTML/preview for current file" })