jbyuki / nabla.nvim Goto Github PK
View Code? Open in Web Editor NEWtake your scientific notes :pencil2: in Neovim
License: MIT License
take your scientific notes :pencil2: in Neovim
License: MIT License
Description of the issue
When writing fractions the bar separating the numerator and denominator is longer than it should be to cover the area between the two numbers.
Possible fixes
Use a different character for the fraction bar, or ensure that it does not overlap any other characters.
Additional Information
This may be an error on my end, see the following image for an example of the issue:
I am using the JetBrainsMono Nerd Font
font for my terminal and neovim if that helps.
How should the input text representation look like
f(x) = x^2\: +3x\: +2
f(x) = x^2\; +3x\; +2
f(x) = x^2\ +3x\ +2
f(x) = x^2\quad +3x\quad +2
f(x) = x^2\qquad +3x\qquad +2
How should the ASCII art output look like
f(x) = x^2 +3x +2
f(x) = x^2 +3x +2
f(x) = x^2 +3x +2
f(x) = x^2 +3x +2
f(x) = x^2 +3x +2
(see https://de.overleaf.com/learn/latex/Spacing_in_math_mode)
Describe in what context you would use this notation
I use these pretty often because they make stuff look nicer when rendered, having the popup not show up just because they are in an equation blows.
How should the input text representation look like
{5 \choose 3}
How should the ASCII art output look like
⎛ 5 ⎞
⎝ 3 ⎠
Describe in what context you would use this notation
Discrete Math, Probability, Counting, Statistics
Additional context
Given the design of the "choose" notation adding a third, middle row is also an option.
⎛ 5 ⎞
⎜ ⎟
⎝ 3 ⎠
Tried disabling all plugings except TS and nabla.
I've tried multiple maps, aswel as just writing ":lua require("nabla").popup()" in command mode.
Latex parser is installed.
Canot get any feedback at all.
NVIM 0.7.2
How should the input text representation look like
$$ T^{i_1 i_2 \dots i_p}_{j_1 j_2 \dots j_q} = T(x^{i_1},\dots,x^{i_p},e_{j_1},\dots,e_{j_q}) $$
How should the ASCII art output look like
i₁i₂...iₚ ⎛ i₁ iₚ ⎞
T =T⎜x ,...,x ,e ,...,e ⎟
j₁j₂...j ⎜ j₁ j ⎟
q ⎝ q⎠
Describe in what context you would use this notation
Math
...nvim/site/pack/packer/opt/nabla.nvim/lua/nabla/ascii.lua:1723: attempt to concatenate field 'sym' (a nil value)
some equations where this error occurs:
\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
\begin{matrix} x^2 & a_H \\ \frac{1}{2} & d^2 \end{matrix}
(from test file)
it seems to occur with every thing that uses pmatrix
I'm quite (not 100% though) sure that it didn't occur with my pr before you made it be generated by ntangle
Title says pretty much everything. When i press the binding the popup window flashes for a fraction of a second and then disappears never to be seen again.
How should the input text representation look like
\text{\# Of People Reading This}=1
How should the ASCII art output look like
# Of People Reading This=1
Describe in what context you would use this notation
Useful when previewing LaTeX in nvim before compiling to the final product.
Additional context
Right now the only thing displayed is text
in place of the actual text block. Not sure if this is an option I have to turn off (was unable to find a list of config options) or just nabla doing its best to render an unknown \
command.
I really like this plugin, and I wish I could use it more often. The problem is that although I use LaTeX a lot for typsetting mathematical notation, this is hardly ever done in .tex
files. Most of the time it's in .md
files, and more recently I've become interested in doing so for .norg
files.
At first I thought this would be a feature I could implement in not too much time, but the literate programming style of the project has left me with no idea how to tackle the change I want to make. I did some research online on how this paradigm works, but I haven't found much that could help me, and the code structure doesn't feel intuitive to change to me. This may be a mix of ntangle.nvim
not seeming to work for me (It doesn't detect the .t
filetype, and seems to not work. There's also not a lot of documentation on how to set it up, so it may be all on me) and me feeling overwhelmed.
I just wanted to open up this issue to request for the feature I wanted: having the toggle_virt
work in other filetypes. If implementing it is too much of a chore, I also wouldn't mind being pointed to someplace to better learn how to contribute.
If these types of issues are not permitted (It does not fit with the templates in the project), feel free to delete it.
Regardless, have a nice day.
For most of my notes I use the equation
environment for numbered equations, etc. Would it be possible for nabla.nvim
to support previewing math in an equation
? I understand that parsing this could be messy so I'm thinking a good alternative would be to provide a method to preview a visual-selected region of text -- and then the user can map/bind that as they see fit, perhaps with vimtex
textobjects or treesitter, etc.
Thanks for the great plugin! If there is a way I can help with this let me know.
You could use treesitter which imo would be way cleaner to detect math areas.
this could be done with a function like this
https://github.com/max397574/nabla.nvim/blob/390d1a2a12df22e3f797c629aa82fe98ac9aa5d2/lua/nabla/utils.lua#L2-L67
you could also use get_node_range
and nvim_buf_get_text
or directly get_node_text
to get the actual math
If a tag is not recognized, it should output it out verbatim and not remove it.
For example
$x \gets y$
should output
x \gets y
Hey @jbyuki,
I'm using nabla after along time, I'm used to nabla.action to toggle the view. Now when I call it I get
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:879: attempt to perform arithmetic on global 'forward' (a nil value)
Any ideas what may be causing this
Thanks
How should the input text representation look like
$\int_0^x y \sin(y) dy $
\f$ \int_0^x y \sin(y) dy \f$
How should the ASCII art output look like
x
∫ ysin(y)dy
0
x
∫ ysin(y)dy
0
Detecting or ignoring doxygen math block would be helpful for documenting source code.
Now, if accidentally trigger plugin on doxygen math block it tries to render all doxygen math blocks in document (and obviously fails.
LaTeX math mode is entered using \( \)
and \[ \]
, but I could only get the plugin to work inside $ $
and $$ $$
. Also, is it possible to add the math display environments?
This is needs to be fixed. The rendering is not correct.
I was wondering if anyone has come up with an autocommand that opens the popup if you hover the cursor over a math block? I am currently looking into it, but I honestly still really struggle with autocommands so I figured I would check here. Many thanks :)
I have the example test file from the repo here
when I comment out everything except for the first three equations and :lua require"nabla".toggle_virt()
I get errors from #46, #47 and #48
when I delete the other equations I don't get problems
is it possible that the virt_lines don't recognize comments?
...nvim/site/pack/packer/opt/nabla.nvim/lua/nabla/ascii.lua:1262: attempt to index global 'exp' (a nil value)
this makes sense because that variable isn't defined anywhere
so this is a mistake made in the lua.t file or by ntangle
some exampels:
(H_A+x^x)+\sqrt{x}
\alpha_{\omega}(x)
Hi! I've just installed this plugin but I couldn't get it to work. When I pressed <leader>p
, an error occurred. This was the error message:
E5108: Error executing lua ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:730: attempt to perform arithmetic on local 'srow' (a nil value)
stack traceback:
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:730: in function 'popup'
[string ":lua"]:1: in main chunk
Expected behavior: An error doesn't occur
Actual behavior: An error occurred
Formula such as
requires nvim 0.8.0+
A safe way to get inline visualization. The implementation is currently very simplistic.
Enable with:
require"nabla".enable_virt()
Disable with:
require"nabla".disable_virt()
Note: enable_virt
only supports the inline syntax which is $ .. $
. Currently $$ .. $$
will likely throw an error.
Works as expected with the new treesitter support.
Options:
require"nabla".enable_virt({
autogen = true, -- auto-regenerate ASCII art when exiting insert mode
silent = true, -- silents error messages
})
TODO:
I'm having trouble using nabla with vimwiki, i think it would be very helpfull if these two could work together because one organizes everything and makes it very handy and the other one lets me write my scientific formulas on my notes.
The problem im having is that when i open a file through vimwiki, the F5 doesn't convert the latex syntax into the ASCII formula.
If i try a couple of times it gives an error:
I don't know if this can be solved through the init.vim file, im pretty new with neovim.
Thanks in advance.
Thank you for creating this plugin. Would it be possible to modify this for a concealment layer which just displays the underlying LaTeX as ASCII math but doesn't modify the source? I don't know how something like tex-conceal works, so what I'm asking for might be impossible after all.
E5108: Error executing lua .....nabla.lua:482: Expected lua number
On pressing <F5> on this
\frac{x}{dx}
See Title. Anyway very nice plugin, though I think this should be default behaviour.
Also what do you think about making the ASCII equation hide when moving the cursor on it? I.e smooth switching between view and edit mode.
Hi @jbyuki , is it possible to support vector notation?
Examples
Hey, thank you for the plugin, I have yet to find anything like nabla.nvim. I am trying to use Vim to take scientific notes, which often contain chemical and mathematical formulas.
Though, the plugin is quite primitive (naturally), so it doesn't really help me to take notes in Vim. See the image below where I am getting an error.
This is how it is supposed to be rendered:
I have to add that the italic letters are of no significance, what's important is formulas like H_{12} to work.
How should the input text representation look like
Example: \mathcal{F} \mathcal{L}
How should the ASCII art output look like
Example: 𝓕 𝓛
Describe in what context you would use this notation
Symbols I often need to write for notes on eg. lectures.
Example: Fourier or Laplace transform symbol as \mathcal{F} and \mathcal{L}
Additional context
An alternative is to add the \mathscr notation from the mathrsfs package.
How should the input text representation look like
\left(\frac{x}{2}\right)^5
How should the ASCII art output look like
⎛x⎞⁵
⎜―⎟
⎝2⎠
Describe in what context you would use this notation
Basic math, especially when raising fractions to a power.
Additional context
The feature already exists to extend the parenthesis, LaTeX just uses \left and \right to do that so they show up as well as the parentheses like this:
Greetings, I finally got Nabla to work with Neorg (by giving up and coming back to it the next day :p) and have been loving your plugin. I noticed that Nabla doesn't factor in indention outside the first line. I get this isn't a huge issue, especially if you aren't using Neorg or Vimwiki, but I feel like it would be a nice level of polish.
here are some equations which aren't parse correctly
Greetings,
I am trying to get this to work with Neorg but keep getting these errors no matter what equation:
E5108: Error executing lua ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:482: Expected lua number
My Neorg doc looks like this:
@document.meta
title: index
description:
author: vm
categories:
created: 2021-09-30
version: 0.1
@end
[Specification for Neorg](https://github.com/nvim-neorg/neorg/blob/main/docs/NFF-0.1-spec.md)
[test](:index:/book_o_everything)
* test
** test
*** Tess
@code latex
$ \frac{1}{n} $
$ \left(1+\frac{1}{n}\right)^n $
@end
Any help is deeply appreciated :)
How should the input text representation look like
Example:
$A \vee B$
,$A \wedge B$
,$A \cup B$
,$A cap B$
.
How should the ASCII art output look like
Example:
A⋁B
,A⋀B
,A⋃B
,A⋂B.
I have been taking discrete mathematics, and these symbols would be quite helpful.
Also, I was wondering if there was any sort of plans for new lines in equations.
:lua require("nabla").place_inline()
E5108: Error executing lua ...clstb/.local/share/nvim/plugged/nabla.nvim/lua/nabla.lua:257: bad argument #1 to 'len' (string expected, got nil)
Tried with this latex \frac{ 1 - \sum_{l \leq k+n} (1-p)^{l-1}p }{ 1 - \sum_{l \leq k} (1-p)^{l-1}p }
there is a function in nabla/ascii.lua which is called before it's defined
I only encountered that error when trying to implement treesitter though.
But it has nothing directly to do with treesitter.
it's an error in the code
It can be fixed like this:
diff --git a/lua/nabla/ascii.lua b/lua/nabla/ascii.lua
index f78ffd1..8dd34e2 100644
--- a/lua/nabla/ascii.lua
+++ b/lua/nabla/ascii.lua
@@ -7,6 +7,8 @@ local put_if_only_sub
local put_if_only_sup
+local to_ascii
+
local style = {
plus_sign = " + ",
@@ -1352,7 +1354,7 @@ function put_if_only_sup(exp, g)
return g
end
-local function to_ascii(exp)
+to_ascii=function(exp)
local g = grid:new()
if not exp then
print(debug.traceback())
E5108: Error executing lua ...smeer/.local/share/nvim/plugged/nabla.nvim/lua/nab
la.lua:730: attempt to perform arithmetic on local 'srow' (a nil value)
stack traceback:
...smeer/.local/share/nvim/plugged/nabla.nvim/lua/nabla.lua:730: in func
tion 'popup'
[string ":lua"]:1: in main chunk
which seems to appear sometimes? In the examples it happens when I'm in the last column of a line delimited by $
, and in general the error appears everywhere outside $
signs including equation environments
Hey! I think it would help you a lot if you gave us documentation on how to add support for certain latex symbols/equations so you don't have to create everything and people can quickly get up and started in contributing.
I'd be more than happy to contribute some symbols. If it's not tedious enough, having that documentation would be awesome!
When executing require("nabla").popup()
on an markdown latex block:
$$
2 + 2 = 4
$$
I get:
E5108: Error executing lua: ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:643: bad argument #1 to 'len' (string expected,
stack traceback:
[builtin:len]: in function 'len'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:643: in function 'popup'
[string "..."]: in function <[string "..."]:0>
Press ENTER or type command to continue
When executing require("nabla").popup()
once nothing happens, after that I get:
E5108: Error executing lua: ...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:505: Expected lua number
stack traceback:
[C]: in function 'nvim_buf_get_extmarks'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:505: in function 'edit_formula'
...are/nvim/site/pack/packer/start/nabla.nvim/lua/nabla.lua:495: in function 'action'
[string "..."]: in function <[string "..."]:0>
:version
:version
NVIM v0.7.0-dev
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nixbld
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/nix/store/cs0wi57nzwn6729rbfkqq2p4f4hc5qf5-neovim-unwrapped-master/share/nvim"
Run :checkhealth for more info
How should the input text representation look like
\mathbb(R), \mathbb(Z), ...
How should the ASCII art output look like
ℜ, ℕ, ...
Describe in what context you would use this notation
Mathematics
The opening bracket character \{
is correctly handled, but the closing bracket \}
produces the sequence:
}\}
it looks like there is an offset somewhere
when I got an equation in the format $x...$
it says empty expression detected
when I'm on x
but correctly displays the equation when I'm on the second $
How should the input text representation look like
\forall \exists \in \notin \subset \subseteq \supset \supseteq \cup \cap \setminus \R \N \Z \Q
How should the ASCII art output look like
∀ ∃ ∈ ∉ ⊂ ⊆ ⊃ ⊇ ∪ ∩ ∖ ℝ ℕ ℤ ℚ
Describe in what context you would use this notation
Mathematics
Quantifiers and set-related operators and symbols are often needed in all kinds of different mathematical fields when dealing with sets. There are other important related symbols, these ones just were the ones I tend to use most often right now. They don't require any special formatting but are impossible to type on almost all keyboard layouts, so a simple replacement when converting from LaTeX would be really helpful.
...nvim/site/pack/packer/opt/nabla.nvim/lua/nabla/ascii.lua:1423: attempt to compare nil with number
examples:
\sqrt{\frac{1}{2}
\frac{1}{2\xi \sqrt{1+\xi^2}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.