From: Samir Benmendil Date: Sun, 17 Dec 2023 17:02:51 +0000 (+0000) Subject: nvim: add orgmode plugin X-Git-Url: https://git.rmz.io/dotfiles.git/commitdiff_plain/224c21d484b302ad2c80859138f5076078f68a56 nvim: add orgmode plugin --- diff --git a/nvim/lua/plugins/productivity.lua b/nvim/lua/plugins/productivity.lua new file mode 100644 index 0000000..a612c82 --- /dev/null +++ b/nvim/lua/plugins/productivity.lua @@ -0,0 +1,120 @@ +-- TODO: finish this +-- Create a function that deindents all lines according to the indentation of the first +local function d(s) + local std = require("std") + local _, e = string.find(s, '^%s*') + local ss = std.string.split(s, '') + local dedent = function(str) return str:sub(e + 1) end + return std.functional.map(dedent, std.elems, ss) +end + +---@type LazyPluginSpec +return { + { + "nvim-orgmode/orgmode", + opts = { + org_agenda_files = { "~/org/**/*.org" }, + org_default_notes_file = "~/org/refile.org", + mappings = { + prefix = "go", + global = { + org_agenda = "goa", + org_capture = "goc", + }, + }, + win_split_mode = function(name) + local bufnr = vim.api.nvim_create_buf(false, true) + vim.api.nvim_buf_set_name(bufnr, name) + + if name == "orgagenda" then + vim.cmd("botright 80vsplit") + local win = vim.api.nvim_get_current_win() + vim.api.nvim_win_set_buf(win, bufnr) + return + end + + local fill = 0.8 + local width = math.floor((vim.o.columns * fill)) + local height = math.floor((vim.o.lines * fill)) + local row = math.floor((((vim.o.lines - height) / 2) - 1)) + local col = math.floor(((vim.o.columns - width) / 2)) + vim.api.nvim_open_win(bufnr, true, { + relative = "editor", + width = width, + height = height, + row = row, + col = col, + style = "minimal", + border = "rounded", + }) + end, + org_agenda_span = "week", + org_agenda_start_on_weekday = false, + org_agenda_start_day = "-2d", + org_archive_location = "archive/%s_archive::", + org_log_done = 'time', + org_log_into_drawer = "LOGBOOK", + org_indent_mode = "noindent", + org_tags_column = -80, -- flushright + org_todo_keywords = { "TODO(t)", "NEXT(n)", "WAITING(w)", "|", "DONE", "CANCELLED" }, + org_todo_keyword_faces = { + TODO = ":foreground #bf616a", + NEXT = ":foreground blue", + WAITING = ":foreground yellow", + CANCELLED = ":foreground grey", + }, + org_capture_templates = { + t = { + description = "Task", + template = "* TODO %?\n:PROPERTIES:\n:CREATED: %U\n:END:", + }, + l = "Log Task", + lh = { + description = "Log Task", + template = [[ +* DONE %? +SCHEDULED: %t +]], + }, + lw = { + description = "Log Task (work)", + template = [[ +* DONE %? +SCHEDULED: %t +]], + target = "~/org/work.org", + headline = "Tasks" + }, + j = { + description = "Journal", + template = "\n*** %u\n**** %U - %?", + target = "~/org/journal.org", + }, + m = { + description = "Meeting", + template = "* Meeting %U\n%?", + target = "~/org/work.org", + headline = "Meetings", + }, + }, + }, + dependencies = { + { + "nvim-treesitter", + opts = function(_, opts) + if type(opts.highlight) == "table" then + opts.hightlight = vim.tbl_extend("error", opts.highlight, { + additional_vim_regex_highlighting = { "org" }, + }) + end + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "org" }) + end + end, + }, + }, + init = function() + require("orgmode").setup_ts_grammar() + end, + }, +}