修改 orgmode
保存 archive
时的文件重命名。
file_name vs base_name
1
|
vim ~/.config/nvim/lazy/orgmode/lua/orgmode/config/init.lua
|
在函数 function Config:parse_archive_location(file, archive_loc)
,将其改成 base_name.x.org
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
|
---@return string|nil
function Config:parse_archive_location(file, archive_loc)
if self:is_archive_file(file) then
return nil
end
archive_loc = archive_loc or self.opts.org_archive_location
-- TODO: Support archive to headline
local parts = vim.split(archive_loc, '::')
local archive_location = vim.trim(parts[1])
if not archive_location:find('%%s') then
return vim.fn.fnamemodify(archive_location, ':p')
end
local file_path = vim.fn.fnamemodify(file, ':p:h')
-- local file_name = vim.fn.fnamemodify(file, ':t')
-- use base_name.x.org to
local base_name = vim.fn.fnamemodify(file, ':t:r')
local file_name = base_name .. '.x.org'
-- utils.echo_warning(string.format('Base file name: %s', base_name))
-- utils.echo_warning(string.format('Archive file name: %s', file_name))
-- vim.notify(base_name, vim.log.levels.INFO)
-- vim.notify(file_name, vim.log.levels.INFO)
local archive_filename = string.format(archive_location, file_name)
-- If org_archive_location is defined as relative path (example: "archive/%s_archive")
-- then we need to prepend the file path to it
local is_full_path = fs.substitute_path(archive_filename)
if not is_full_path then
return string.format('%s/%s', file_path, archive_filename)
end
return vim.fn.fnamemodify(archive_filename, ':p')
end
|
conf 配置 archive 保存路径
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
|
local org_path = function(path)
local org_directory = '~/orgfiles'
return ('%s/%s'):format(org_directory, path)
end
local org_directory = {}
org_directory.root = os.getenv("HOME") .. "/orgfiles/"
org_directory.archive = org_directory.root .. "archive/"
local meeting_notes = org_directory.root .. "meeting-notes/%<%Y-%m-%d %A>.org"
return {
'nvim-orgmode/orgmode',
dependencies = {
{ 'nvim-orgmode/org-bullets.nvim' },
{ "dhruvasagar/vim-table-mode" },
{ 'nvim-treesitter/nvim-treesitter' },
{ "folke/todo-comments.nvim" },
},
lazy = true,
ft = { 'org', 'orgagenda' },
config = function()
-- Setup orgmode
require('orgmode').setup({
-- org_archive_location = "~/orgfiles/archive/%s::",
org_archive_location = org_directory.archive .. "%s::",
})
end
}
|