diff --git a/doc/init.txt b/doc/init.txt index 55f08d3..051ffad 100644 --- a/doc/init.txt +++ b/doc/init.txt @@ -20,6 +20,7 @@ CONTENTS *doom-toc* 5. Keybindings |doom-keybindings| 6. Snippets |doom-snippets| 7. Treesitter |doom-treesitter| +8. Neorg |doom-neorg| 8. Help-editing |doom-help-editing| 9. Caveats |doom-caveats| @@ -39,13 +40,42 @@ doom efficiently. ============================================================================== PHILOSOPHY *doom-philosophy* -The philosophy of doom-evim is similar to that emacs itself: DRY (Don't Repeat -Yourself). In implementation, this means that a good distro should allow the -user to use the distro's API themselves so that they can make their -configuration more manageable. - -In order to prevent boilerplate code, doom comes with its own set of functions -which can allow you to do some complex configurations. +Evim tries to be as emacsy as possible regarding certain things: + - Lay things out clearly + Create functions rather than rely on hacky vimscript that cannot be + reused. + + - Convenience ranks higher than ridiculous performance + This does not mean that doom ignores the performance side of the + configuration but it also does not focuses too much on it to avoid + code being convoluted. + + - Try not to distinguish very hard between commands and their underlying + implementations + Unlike many vimscript plugins, doom does not indulge in one-shot + configurations laid across several files. It relies on the simple + model of requiring modules and additionally setting them up anything if + required. + +Evim does not try to be pretentious and focus too much on vain factors such as +'ultra-fast startup times'. On the flip side, Evim tries to be as convenient +as possible regarding its functionality. Any fennel user can figure out much +of doom's implementation without any difficulty if they bother to require/open +doom's modules and check it for themselves. That being said, anything and +everything from doom can be required and used although I do not encourage such +an action to a user who is a beginner/not-familiar-with-lua as it may boggle +their mind. + +As compared to other vim distributions, this distribution tries to be more +transparent and open to tinkering. However, if you are not smitten by the +prospect of configuring your editor, Evim still does the job without getting +in your way. + +That being said, Evim does not provide every small thing for the user. It is +expected that the user will read this documentation and get started with this +distribution. Configuration options may seem very less for this distribution +as compared to doom-nvim or spacevim but don't mistake this distribution for +being any less competent than the others. ============================================================================== FILESYSTEM *doom-fs* @@ -178,6 +208,8 @@ fnl_config {bool} Default: true +theme {str} + Default: everforest default_runner {bool} If set, use utilities in |doom-runner|. Please visit the link to @@ -198,6 +230,12 @@ default_keybindings {bool} Default: true +neorg_keybindings {bool} + Set doom's neorg keybindings? + + Default: true + + essential_packages {list} Contains all the essential package declarations. @@ -1670,6 +1708,61 @@ Other mappings: `[]` Go to the end of previous class +============================================================================== +NEORG *doom-neorg* + +While neorg is a great plugin for vim that competes with orgmode of emacs, it +does not come with too many handy keybindings in contrast to orgmode. Don't +get me wrong, they are not too difficult to setup with neorg but doom provides +its own keybindings for common tasks that the users would like to use: + +> + {:keys "ol" + :help "Display buffer headings in qflist"} + + {:keys "oL" + :help "Display cwd headings in qflist"} + + ; Set the task-type for bullet + {:keys "" + :noremap false + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg"} + + ; Insert heading if cursor is at a heading + ; Insert bullet if cursor is at a bullet + {:keys "" + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg"} + + ; Goto next heading + {:keys "" + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg" + :exec next-heading} + + ; Goto prev heading + {:keys "" + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg"} + + ; Promote heading/bullet + {:keys "" + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg"} + + ; Demote heading/bullet + {:keys "" + :key-attribs ["buffer" "silent"] + :events "BufEnter" + :patterns "*norg"} + + ============================================================================== HELP-EDITING *doom-help-editing* diff --git a/fnl/neorg-config.fnl b/fnl/neorg-config.fnl index 3782ac6..7caa151 100644 --- a/fnl/neorg-config.fnl +++ b/fnl/neorg-config.fnl @@ -3,7 +3,7 @@ org neorg}}) (org.setup {:load {:core.keybinds {:config {:default_keybinds true - :neorg_leader ""}} + :neorg_leader "o"}} :core.norg.concealer {} @@ -33,9 +33,12 @@ (if bullet (let [single (string.match bullet "^.") + task (or (utils.grep contains "\\[[^]]*\\]") false) + contains (utils.sed contains " *\\[[^]]*\\] *" "") len (length bullet) d {:single single :base bullet + :task task :type bullet-type :is "bullet" :whitespace wt @@ -52,8 +55,9 @@ false))))) -(defn- _replace-heading-or-bullet-under-point [?bufnr ?lineno direction by] - (let [sym (get-bullet-or-heading-under-point ?bufnr ?lineno)] +(defn- _replace-heading-or-bullet-under-point [?bufnr ?lineno direction by ?opts] + (let [is-task (?. ?opts :task) + sym (get-bullet-or-heading-under-point ?bufnr ?lineno)] (when sym (let [by (if (= direction -1) (if @@ -75,26 +79,45 @@ (set sym.base (string.rep sym.single (+ by sym.len))) (set sym.base (string.sub sym.base (+ by 1) -1))) - (if (= sym.is :heading) + (if + (= sym.is :heading) (.. sym.base " " sym.contains) + + (and (= sym.is :bullet) + is-task) + (.. sym.whitespace sym.base (or sym.type "") " " is-task " " sym.contains) + + (and (= sym.is :bullet) + sym.task) + (.. sym.whitespace sym.base (or sym.type "") " " sym.task " " sym.contains) + (.. sym.whitespace sym.base (or sym.type "") " " sym.contains)))))) -(defn- replace-heading-or-bullet-under-point [?bufnr ?lineno direction by] - (let [lineno (or ?lineno (utils.linenum)) +(defn- replace-heading-or-bullet-under-point [?bufnr ?lineno direction by ?opts] + (let [is-task (?. ?opts :task) + lineno (or ?lineno (utils.linenum)) bufnr (or ?bufnr 0) - replacement (_replace-heading-or-bullet-under-point bufnr lineno direction by)] + replacement (_replace-heading-or-bullet-under-point bufnr lineno direction by ?opts)] (if replacement (utils.set-lines bufnr [(- lineno 1) lineno] [replacement])))) -(defn- insert-bullet-or-heading [?bufnr ?lineno] - (let [linenum (or ?lineno (utils.linenum)) +(defn- insert-bullet-or-heading [?bufnr ?lineno ?opts] + (let [is-task (?. ?opts :task) + linenum (or ?lineno (utils.linenum)) linenum (- linenum 1) bufnr (or ?bufnr 0) put #(utils.set-lines bufnr [(+ linenum 1) (+ linenum 1)] [$1])] (let [sym (get-bullet-or-heading-under-point bufnr linenum)] (if (?. sym :is) - (if (= sym.is :bullet) + (if + (and (= sym.is :bullet) + (not (utils.grep sym.contains "\\[[^]]*\\]")) + is-task) + (put (utils.fmt "%s" (.. sym.whitespace sym.base (or sym.type "") is-task " "))) + + (= sym.is :bullet) (put (utils.fmt "%s" (.. sym.whitespace sym.base (or sym.type "") " "))) + (put (utils.fmt "%s" (.. sym.base " ")))) (put "* "))))) @@ -110,6 +133,18 @@ -1 (or ?by 1))) +(defn- edit-bullet [?bufnr ?lineno ?task-type] + (let [task-type (match ?task-type + :pending "[-]" + :done "[x]" + :hold "[=]" + :cancelled "[_]" + :urgent "[!]" + :recurring "[+]" + :uncertain "[?]" + _ "[]")] + (replace-heading-or-bullet-under-point ?bufnr ?lineno 1 0 {:task task-type}))) + (defn- next-heading [] (vim.cmd "/^\\*") (vim.cmd "noh")) @@ -118,11 +153,34 @@ (vim.cmd "?^\\*") (vim.cmd "noh")) -(utils.define-keys [{:keys "" - :key-attribs "buffer" +(utils.define-keys [{:keys "ol" + :help "Display buffer headings in qflist" + :exec (.. ":vimgrep \"^\\*\" " (vim.fn.expand "%:p") "")} + + {:keys "oL" + :help "Display cwd headings in qflist" + :exec ":vimgrep \"^\\*\" *norg "} + + {:keys "" + :noremap false + :key-attribs ["buffer" "silent"] :events "BufEnter" :patterns "*norg" - :exec ":normal! o_i* "} + :exec #(let [sym (get-bullet-or-heading-under-point) ] + (when (= sym.is :bullet) + (let [input (utils.get-user-input "Task type (p/d/h/c/u/r/u) > " + #(match $1 + :p :pending + :d :done + :h :hold + :c :cancelled + :u :urgent + :r :recurring + :u :uncertain + _ nil) + true + {:use_function true})] + (edit-bullet nil nil input))))} {:keys "" :key-attribs ["buffer" "silent"]