Compare commits
No commits in common. "437ddcbc87aedcab5c3b70266e43682abd4703dd" and "22adcf0fb847147cba67ec6f05f4153cb302508a" have entirely different histories.
437ddcbc87
...
22adcf0fb8
3 changed files with 46 additions and 140 deletions
62
README.org
62
README.org
|
|
@ -30,37 +30,11 @@ you to add anything extra to your ~init.el~.
|
||||||
cmd = { "OrgExecute", "OrgTangle" },
|
cmd = { "OrgExecute", "OrgTangle" },
|
||||||
opts = {
|
opts = {
|
||||||
-- by default, none are enabled
|
-- by default, none are enabled
|
||||||
langs = { "python", "lua", ... },
|
langs = { "python", "lua", ... }
|
||||||
|
|
||||||
-- paths to emacs packages to additionally load
|
|
||||||
load_paths = {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
*** Packer
|
|
||||||
|
|
||||||
#+begin_src lua
|
|
||||||
use {
|
|
||||||
"mrshmllow/orgmode-babel.nvim",
|
|
||||||
requires = {
|
|
||||||
"nvim-orgmode/orgmode",
|
|
||||||
"nvim-treesitter/nvim-treesitter"
|
|
||||||
},
|
|
||||||
cmd = { "OrgExecute", "OrgTangle" },
|
|
||||||
opt = true,
|
|
||||||
config = function ()
|
|
||||||
require("orgmode-babel").setup({
|
|
||||||
-- by default, none are enabled
|
|
||||||
langs = { "python", "lua", ... },
|
|
||||||
|
|
||||||
-- paths to emacs packages to additionally load
|
|
||||||
load_paths = {}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** Usage
|
** Usage
|
||||||
|
|
||||||
All commands accept a ~!~ to skip confirmation.
|
All commands accept a ~!~ to skip confirmation.
|
||||||
|
|
@ -93,37 +67,3 @@ Tangles all blocks in range. If the range is NOT ~%~, the tangled file will
|
||||||
likely only contain the contents of the last block, which is expected
|
likely only contain the contents of the last block, which is expected
|
||||||
behaviour.
|
behaviour.
|
||||||
|
|
||||||
** Advanced Configuration
|
|
||||||
*** Adding extra org-mode languages
|
|
||||||
|
|
||||||
Your emacs ~init.el~ will *not* be sourced during execution of ~:OrgExecute~ and
|
|
||||||
~:OrgTangle~, so packages you install there wont be available.
|
|
||||||
|
|
||||||
However, ~orgmode-babel.nvim~ allows us to specify extra load paths, so we can
|
|
||||||
make packages available that way.
|
|
||||||
|
|
||||||
**** Example
|
|
||||||
|
|
||||||
As an example, lets add [[https://github.com/arnm/ob-mermaid][ob-mermaid]] for
|
|
||||||
mermaid functionality in ~orgmode-babel.nvim~!
|
|
||||||
|
|
||||||
We have two options to get the package. We could either create an
|
|
||||||
=~/.emacs.d/init.el= and install it through a package manager, which will likely
|
|
||||||
have a randomish name, or for the sake of simplicity and this being a neovim
|
|
||||||
plugin, we can simply manually clone the repo to a known location.
|
|
||||||
|
|
||||||
#+begin_example
|
|
||||||
git clone https://github.com/arnm/ob-mermaid ~/.../clone-location/ob-mermaid
|
|
||||||
#+end_example
|
|
||||||
|
|
||||||
#+begin_src lua
|
|
||||||
{
|
|
||||||
"mrshmllow/orgmode-babel.nvim",
|
|
||||||
...
|
|
||||||
opts = {
|
|
||||||
langs = { ..., "mermaid" }
|
|
||||||
load_paths = { "~/.../clone-location/ob-mermaid" }
|
|
||||||
}
|
|
||||||
},
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
*orgmode-babel.nvim.txt* For NVIM v0.9.0 Last change: 2023 July 23
|
*orgmode-babel.nvim.txt* For NVIM v0.9.0 Last change: 2023 June 27
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
Table of Contents *orgmode-babel.nvim-table-of-contents*
|
Table of Contents *orgmode-babel.nvim-table-of-contents*
|
||||||
|
|
@ -46,39 +46,12 @@ LAZY.NVIM ~
|
||||||
cmd = { "OrgExecute", "OrgTangle" },
|
cmd = { "OrgExecute", "OrgTangle" },
|
||||||
opts = {
|
opts = {
|
||||||
-- by default, none are enabled
|
-- by default, none are enabled
|
||||||
langs = { "python", "lua", ... },
|
langs = { "python", "lua", ... }
|
||||||
|
|
||||||
-- paths to emacs packages to additionally load
|
|
||||||
load_paths = {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<
|
<
|
||||||
|
|
||||||
|
|
||||||
PACKER ~
|
|
||||||
|
|
||||||
>lua
|
|
||||||
use {
|
|
||||||
"mrshmllow/orgmode-babel.nvim",
|
|
||||||
requires = {
|
|
||||||
"nvim-orgmode/orgmode",
|
|
||||||
"nvim-treesitter/nvim-treesitter"
|
|
||||||
},
|
|
||||||
cmd = { "OrgExecute", "OrgTangle" },
|
|
||||||
opt = true,
|
|
||||||
config = function ()
|
|
||||||
require("orgmode-babel").setup({
|
|
||||||
-- by default, none are enabled
|
|
||||||
langs = { "python", "lua", ... },
|
|
||||||
|
|
||||||
-- paths to emacs packages to additionally load
|
|
||||||
load_paths = {}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
}
|
|
||||||
<
|
|
||||||
|
|
||||||
|
|
||||||
USAGE *orgmode-babel.nvim-orgmode-babel.nvim-usage*
|
USAGE *orgmode-babel.nvim-orgmode-babel.nvim-usage*
|
||||||
|
|
||||||
All commands accept a `!` to skip confirmation.
|
All commands accept a `!` to skip confirmation.
|
||||||
|
|
@ -122,33 +95,43 @@ ADVANCED CONFIGURATION*orgmode-babel.nvim-orgmode-babel.nvim-advanced-configurat
|
||||||
|
|
||||||
ADDING EXTRA ORG-MODE LANGUAGES ~
|
ADDING EXTRA ORG-MODE LANGUAGES ~
|
||||||
|
|
||||||
Your emacs `init.el` will **not** be sourced during execution of `:OrgExecute`
|
Your emacs `init.el` will be sourced during execution of `:OrgExecute` and
|
||||||
and `:OrgTangle`, so packages you install there wont be available.
|
`:OrgTangle`, so packages you install there that provide extra babel languages
|
||||||
|
will be available!
|
||||||
|
|
||||||
However, `orgmode-babel.nvim` allows us to specify extra load paths, so we can
|
Follow the package's installation steps, and if they tell you to include it in
|
||||||
make packages available that way.
|
`org-babel-load-languages`, additionally make sure that you include it in
|
||||||
|
`opts.langs`.
|
||||||
|
|
||||||
1. Example
|
1. Example
|
||||||
|
|
||||||
As an example, lets add ob-mermaid <https://github.com/arnm/ob-mermaid> for
|
As an example, lets add ob-mermaid <https://github.com/arnm/ob-mermaid> for
|
||||||
mermaid functionality in `orgmode-babel.nvim`!
|
mermaid functionality in `orgmode-babel.nvim`!
|
||||||
|
|
||||||
We have two options to get the package. We could either create an
|
First, lets create a `~/.emacs.d/init.el`.
|
||||||
`~/.emacs.d/init.el` and install it through a package manager, which will
|
|
||||||
likely have a randomish name, or for the sake of simplicity and this being a
|
|
||||||
neovim plugin, we can simply manually clone the repo to a known location.
|
|
||||||
|
|
||||||
>example
|
>
|
||||||
git clone https://github.com/arnm/ob-mermaid ~/.../clone-location/ob-mermaid
|
; ~/.emacs.d/init.el
|
||||||
|
|
||||||
|
; Add the melpa package manager
|
||||||
|
(require 'package)
|
||||||
|
(add-to-list 'package-archives
|
||||||
|
'("melpa" . "https://melpa.org/packages/") t)
|
||||||
|
(package-initialize)
|
||||||
|
|
||||||
|
; Install ob-mermaid
|
||||||
|
(unless (package-installed-p 'ob-mermaid)
|
||||||
|
(package-install 'ob-mermaid))
|
||||||
<
|
<
|
||||||
|
|
||||||
|
Then, in our plugin configuration, we can add `mermaid` to our `opts.langs`.
|
||||||
|
|
||||||
>lua
|
>lua
|
||||||
{
|
{
|
||||||
"mrshmllow/orgmode-babel.nvim",
|
"mrshmllow/orgmode-babel.nvim",
|
||||||
...
|
...
|
||||||
opts = {
|
opts = {
|
||||||
langs = { ..., "mermaid" }
|
langs = { ..., "mermaid" }
|
||||||
load_paths = { "~/.../clone-location/ob-mermaid" }
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
<
|
<
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,9 @@ local M = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function M.setup(opts)
|
function M.setup(opts)
|
||||||
opts = opts or {}
|
opts = opts or opts
|
||||||
|
|
||||||
M.langs = opts.langs and opts.langs or {}
|
M.langs = opts.langs and opts.langs or {}
|
||||||
M.load_paths = opts.load_paths and opts.load_paths or {}
|
|
||||||
|
|
||||||
M._here = vim.fn.fnamemodify(debug.getinfo(1).source:sub(2), ":p:h")
|
M._here = vim.fn.fnamemodify(debug.getinfo(1).source:sub(2), ":p:h")
|
||||||
M._run_by_name = M._here .. "/run_by_name.el"
|
M._run_by_name = M._here .. "/run_by_name.el"
|
||||||
|
|
@ -27,17 +26,6 @@ function M.setup(opts)
|
||||||
"(setq make-backup-files nil)",
|
"(setq make-backup-files nil)",
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.list_extend(
|
|
||||||
M._base_cmd,
|
|
||||||
vim.fn.reduce(M.load_paths, function(acc, value)
|
|
||||||
vim.list_extend(acc, {
|
|
||||||
"--eval",
|
|
||||||
[[(add-to-list 'load-path "]] .. value .. [[")]],
|
|
||||||
})
|
|
||||||
return acc
|
|
||||||
end, {})
|
|
||||||
)
|
|
||||||
|
|
||||||
vim.list_extend(M._base_cmd, {
|
vim.list_extend(M._base_cmd, {
|
||||||
"--eval",
|
"--eval",
|
||||||
"(org-babel-do-load-languages 'org-babel-load-languages '(" .. vim.fn.reduce(M.langs, function(acc, value)
|
"(org-babel-do-load-languages 'org-babel-load-languages '(" .. vim.fn.reduce(M.langs, function(acc, value)
|
||||||
|
|
@ -89,10 +77,8 @@ function M.get_names_in_buffer(bufnr, line1, line2)
|
||||||
local passed = not range
|
local passed = not range
|
||||||
local name
|
local name
|
||||||
|
|
||||||
for id, nodes in pairs(match) do
|
for id, node in pairs(match) do
|
||||||
for _, node in ipairs(nodes) do
|
|
||||||
local row1, col1, row2, col2 = node:range()
|
local row1, col1, row2, col2 = node:range()
|
||||||
|
|
||||||
local text = vim.api.nvim_buf_get_text(bufnr, row1, col1, row2, col2, {})[1]
|
local text = vim.api.nvim_buf_get_text(bufnr, row1, col1, row2, col2, {})[1]
|
||||||
|
|
||||||
if named_blocks_query.captures[id] == "block" and not passed then
|
if named_blocks_query.captures[id] == "block" and not passed then
|
||||||
|
|
@ -112,7 +98,6 @@ function M.get_names_in_buffer(bufnr, line1, line2)
|
||||||
table.insert(names, name)
|
table.insert(names, name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
return names
|
return names
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -133,8 +118,7 @@ function M.get_blocks_in_buffer(bufnr, line1, line2)
|
||||||
for _, match in unnamed_blocks_query:iter_matches(root, bufnr, 0, -1) do
|
for _, match in unnamed_blocks_query:iter_matches(root, bufnr, 0, -1) do
|
||||||
local passed = not range
|
local passed = not range
|
||||||
|
|
||||||
for id, nodes in pairs(match) do
|
for id, node in pairs(match) do
|
||||||
for _, node in ipairs(nodes) do
|
|
||||||
local row1, _, row2 = node:range()
|
local row1, _, row2 = node:range()
|
||||||
|
|
||||||
if unnamed_blocks_query.captures[id] == "block" and not passed then
|
if unnamed_blocks_query.captures[id] == "block" and not passed then
|
||||||
|
|
@ -145,7 +129,6 @@ function M.get_blocks_in_buffer(bufnr, line1, line2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if passed then
|
if passed then
|
||||||
table.insert(indexes, encountered)
|
table.insert(indexes, encountered)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue