-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathorg.lua
73 lines (61 loc) · 2.34 KB
/
org.lua
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
if vim.b.did_ftplugin or vim.b.org_tmp_edit_window then
return
end
---@diagnostic disable-next-line: inject-field
vim.b.did_ftplugin = true
local config = require('orgmode.config')
vim.treesitter.start()
local bufnr = vim.api.nvim_get_current_buf()
config:setup_mappings('org', bufnr)
config:setup_mappings('text_objects', bufnr)
config:setup_foldlevel()
if config.org_startup_indented then
require('orgmode.ui.virtual_indent'):new(bufnr):attach()
end
vim.bo.modeline = false
vim.opt_local.fillchars:append('fold: ')
vim.opt_local.foldmethod = 'expr'
vim.opt_local.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
if config.ui.folds.colored then
vim.opt_local.foldtext = ''
else
vim.opt_local.foldtext = 'v:lua.require("orgmode.org.indent").foldtext()'
end
vim.opt_local.formatexpr = 'v:lua.require("orgmode.org.format")()'
vim.opt_local.omnifunc = 'v:lua.orgmode.omnifunc'
vim.opt_local.commentstring = '# %s'
vim.bo.indentkeys = ('%s,%s'):format(vim.bo.indentkeys, '=~end_src,=~end_example,<:>')
_G.orgmode.omnifunc = function(findstart, base)
return require('orgmode').completion:omnifunc(findstart, base)
end
local abbreviations = {
[':today:'] = "require('orgmode.objects.date').today():to_wrapped_string(true)",
[':now:'] = "require('orgmode.objects.date').now():to_wrapped_string(true)",
[':itoday:'] = "require('orgmode.objects.date').today():to_wrapped_string(false)",
[':inow:'] = "require('orgmode.objects.date').now():to_wrapped_string(false)",
}
for abbrev, cmd in pairs(abbreviations) do
vim.cmd.inoreabbrev(('<silent><buffer> %s <C-R>=luaeval("%s")<CR>'):format(abbrev, cmd))
end
for _, char in ipairs({ '*', '=', '/', '+', '~', '_' }) do
vim.keymap.set('x', 'i' .. char, ':<C-u>normal! T' .. char .. 'vt' .. char .. '<CR>', { buffer = true })
vim.keymap.set('o', 'i' .. char, ':normal vi' .. char .. '<CR>', { buffer = true })
vim.keymap.set('x', 'a' .. char, ':<C-u>normal! F' .. char .. 'vf' .. char .. '<CR>', { buffer = true })
vim.keymap.set('o', 'a' .. char, ':normal va' .. char .. '<CR>', { buffer = true })
end
if config.org_highlight_latex_and_related then
vim.bo[bufnr].syntax = 'ON'
end
vim.b.undo_ftplugin = table.concat({
'setlocal',
'commentstring<',
'foldmethod<',
'modeline<',
'foldtext<',
'foldlevel<',
'foldexpr<',
'formatexpr<',
'omnifunc<',
'indentkeys<',
'| unlet! b:org_tmp_edit_window',
}, ' ')