1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
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 <leader>o, 'o' for 'orthography'
vim.keymap.set("n", "<leader>o", ":setlocal spell! spelllang=en_us<CR>", { desc = "Toggle spell-check (en_us)" })
-- Compile document, be it groff/LaTeX/markdown/etc.
vim.keymap.set("n", "<leader>c", ':w! | !compiler "%"<CR>', { desc = "Compile document, be it groff/LaTeX/markdown/etc." })
-- Open corresponding .pdf/.html or preview
vim.keymap.set("n", "<leader>p", ':!opout "%"<CR><CR>', { desc = "Open PDF/HTML/preview for current file" })
|