fiatjaf / neuron.vim Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nadrieril/neuron.vim
π Manage your Zettelkasten in {n}vim.
License: MIT License
This project forked from nadrieril/neuron.vim
π Manage your Zettelkasten in {n}vim.
License: MIT License
I've started using the new dirtree plugin and organizing notes into subfolders.
If a note is in a subfolder, <Leader>gzo
isn't able to open it, instead trying to open the zettel's ID at the root of the Neuron project.
Based on some hacking with JS on the web interface, I think Neuron maintains a zettelPath
in addition to the zettelID
(it is at least available in /cache.json
). So it may be a matter of looking up the path with the ID instead of just calling :e zettelID
? I haven't had much time to look into how neuron.vim
is interacting with Neuron in this case yet.
I'm cross-referencing from the upstream repo since this one claims to be actively-maintained.
https://github.com/ihsanturk/neuron.vim/issues/14
There appears to have been updates on the virtual title API (see last comment in above-linked issue)
OS: Debian 10.5
Instance type: 512 MB RAM, 1 vCPU, 20 GB SSD
curl -L https://nixos.org/nix/install | sh
. /home/admin/.nix-profile/etc/profile.d/nix.sh
nix-env -iA cachix -f https://cachix.org/api/v1/install
cachix use srid
#Turn on the aggressive garbage collector mode
sudo passwd
su
echo 1 > /proc/sys/vm/overcommit_memory
exit
nix-env -if https://github.com/srid/neuron/archive/master.tar.gz
Check if it's working:
neuron --version
It's 1.1.6.3.
sudo apt update
sudo apt upgrade
Install prerequisites for VIM
sudo apt install libncurses5-dev libgtk2.0-dev libatk1.0-dev libcairo2-dev \
libx11-dev libxpm-dev libxt-dev python3-dev lua5.2 git
Remove old VIM and build a new one
sudo apt remove vim-tiny vim-common vim-gui-common vim-nox
cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge --enable-multibyte --enable-python3interp=yes \
--with-python3-config-dir=$(python3-config --configdir) --enable-gui=gtk2 \
--enable-cscope --prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim82
cd ~/vim
sudo make install
Create symbolic links to VIM
sudo update-alternatives --install /usr/bin/editor editor /usr/local/bin/vim 1
sudo update-alternatives --set editor /usr/local/bin/vim
sudo update-alternatives --install /usr/bin/vi vi /usr/local/bin/vim 1
sudo update-alternatives --set vi /usr/local/bin/vim
To set VIM as default editor, open ~/.bashrc
and add
export EDITOR=vim
Reload .bashrc
source ~/.bashrc
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Open .vimrc
vim ~/.vimrc
Fill .vimrc with:
let g:neuron_dir=expand("~/zettelkasten/")
call plug#begin()
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'fiatjaf/neuron.vim'
call plug#end()
In the command mode of VIM, run:
source ~/.vimrc
PlugInstall
PlugUpdate
mkdir ~/zettelkasten
cd ~/zettelkasten
touch neuron.dhall
neuron new -e
...
neuron new index -e
Now,
~/zettelkasten/
β 28176420.md
β 943814ae.md
β c95d9e66.md
β index.md
β neuron.dhall
The problem is that when I open a zettel, say index.md
, I see the following errors:
"index.md" 3L, 31B
Error detected while processing function <SNR>13 refresh_cache_callback_vim:
line 1:
E484: Can't open file /tmp/neuronzettelsbuffer
Error detected while processing function <SNR>13_refresh_cache_callback_vim[3]..<SNR>13_refresh_cache_callback:
line 4:
E909: Cannot index a special variable
line 6:
E121: Undefined variable: l:zettels
E116: Invalid arguments for function sort
line 13:
E121: Undefined variable: l:zettels
line 20:
E121: Undefined variable: l:zettels
Also, when I try to open another zettel by typing gzz
, it opens a search window but other zettels are not shown like the drawing below
+---------------------------------------------------------------------+
| |
| +-------------------------------+ |
| | | |
| | | |
| | | |
| | | |
| | | |
| 0/0 | | |
| | | |
| Search Zettel:| | | |
| +-------------------------------+ |
| |
+---------------------------------------------------------------------+
Another issue is that if I create a link from a zettel like [[943814ae.md]], place text cursor on it, and gzo
, it says Word under cursor is not a known zettel!
What am I missing something here? Have I skipped an important plugin?
Allow adding in an existing tag.
Hello. So far I'm loving this fork in vim
. But in nvim
I'm having the following issue:
When opening any zettel file I get neuron executable not found!
in the status bar.
I also don't see any virtual text, but I assume it may be because neuron.vim
can't find the neuron
backend it likely requires.
nvim version: 0.4.4
neuron version: 1.0.0.0
If I run :!neuron --version
from within neovim, it does locate the command properly.
As I said, this only happens in nvim
, which I'm fairly new to. Perhaps I have neovim misconfigured?
Update:
I've tried adding: let g:path_neuron = "/home/vcavallo/.nix-profile/bin/neuron"
to my vimrc but the problem remains
Hi, I am trying out neuron on ubuntu environment.
I have installed the necessary dependencies.
I'm unable to run commands like gzi, gzz on vim.
On opening any of the files I get few errors before the content is visible momentarily.
While using the commands with 'e' suffix for creating a new index, i get error:
-e option can only be used with EDITOR environment variable set
Here is the error I encounter while running gzi:
Error detected while processing function neuron#insert_zette
l_select:
line 13:
E117: Unknown function: fzf#wrap
E116: Invalid arguments for function fzf#run
version of neuron: 1.9.3.0
Have updated the plugin to the latest version via PlugUpdate
I have the neuron.dhall with only plugin information
Using vim 8.1
Ubuntu with regolith linux environment(Basically, i3)
Thanx
I have no idea why.
Hi,
It took me a while to realize where this error came from
I happened to have an [[invalid link]] inside a very old note which make Neuron raise an exception. Could you please handle this case for better meaningful error such as "Invalid link has been found at {Zetter Title}" rather than above encrypted exception error?
I never did a Vim plugin so I have no idea why we have an ftdetect/
, a plugin/
and an autoload/
directories. I would like to have a single file or perhaps two, definitely a single directory, this structure is confusing me, is it needed?
It will be nice to be able to use ripgrep instead of Ag, at least as an option.
When the cache is filled, sometimes it will find errors. For example, errors include:
The description of gzN
does not say that a Folgezettel link will be created:
creates a new zettel using the current word under the cursor as its title.
However since other commands with a capital letter also create Folgezettels, I think this is the correct behavior and should be documented. Would it be possible to add the same functionality to gzn
?
I would ideally like to be able to have the title replace the link id rather than have it appear at the end of the line.
I can spend some time looking into doing this, but I'm not sure my vim-foo is good enough to manage it without spending a really long time.
Do people think this is generally an improvement or would we want to also maintain backwards compatibility with the current UI if we implement this kind of approach?
The query has changed; will need something like this to quickly pull in all zettels.
let l:cmd = g:neuron_executable.' -d "'.g:neuron_dir.'" query --cached | jq ".result | .vertices | to_entries[] | [.value]"'
Hey team-
I use home-manager
to manage my neovim plugins, so it would be super convenient to be able to grab neuron.vim from nixpkgs. I see that the original neuron.vim has an entry in pkgs.vimPlugins
, so hopefully that's a good starting point.
I'm happy to tackle this on my own, but I'm still pretty new to nix (and to nixpkgs governance) so I thought I'd post this here in case someone a little more seasoned has a quick fix.
Many thanks!
I'm looking for.
I've been encountering the following error repeatedly upon opening Vim. Shallowly, it appear similar to the error described in #37 and #53.
Error detected while processing function <SNR>30_refresh_cache_callback_vim[3]..<SNR>30_refresh_cache_callback:
line 4:
E491: json decode error at 'Invalid option `--uri' Usage: neuron [--version] [-d PATH] [-o PATH] COMMAND Neuron, future-proof Zettelkasten app <https://neuron.zettel.page/>'
E909: Cannot index a special variable
line 6:
E121: Undefined variable: l:zettels
E116: Invalid arguments for function sort
line 13:
E121: Undefined variable: l:zettels
line 20:
E121: Undefined variable: l:zettels
I get the following error when I start vim with the plugin installed
rror detected while processing function <SNR>66_refresh_cache_callback_vim:
12 line 1:
11 E484: Can't open file /tmp/neuronzettelsbuffer
10 Error detected while processing function <SNR>66_refresh_cache_callback_vim[ 3]..<SNR>66_refresh_cache_callback:
9 line 1:
8 E909: Cannot index a special variable
7 line 3:
6 E121: Undefined variable: l:zettels
5 E116: Invalid arguments for function sort
4 line 10:
3 E121: Undefined variable: l:zettels
2 line 17:
1 E121: Undefined variable: l:zettels
Currently when you do a search for tags it doesn't show any hierarchy - it would be great to include that along with the individual terms. e.g. if you have a tag of blog/idea
ideally in the list it would have:
blog
blog/idea
idea
Following [this guide], I've got neuron running as a Docker container in my own AWS Lightsail instance. On top of that, I installed neuron.vim. The problem is, when I run vim, I see the following message: neuron executable is not found!
Perhaps neuron.vim doesn't find neuron when it is running as a docker container? What can I do to make it recognized? Thanks.
Using gzN
is wildly useful and helps with keeping a smooth flow state while writing and linking. Using the selected text as the note title is very convenient, but using the same for the note filename is problematic. I rely on neruon's unique filename ID to make sure I don't have duplicate filenames and to ensure all zettels have a random ID (rather than some having readable filenames and some having random IDs).
It would be great if there were a configuration option that allowed the user to set whether they want gzN
to create a random ID or to use the selected text as the filename (all while keeping the selected text as the title).
Sorry I don't have a PR to add for this. I've never written a line of vimscript, but it seems like an if g:the_option_name
around this line https://github.com/fiatjaf/neuron.vim/blob/master/autoload/neuron.vim#L149 would do the trick. If I have free time and the will to learn how to test this properly for backwards-compatibility I may be able to submit a PR in the future.
Most of the time, when adding a link to another zettel one does it at the bottom of a particular section e.g.
---
date: xxx
---
# Title
Text...
## Links
- [[abcd1234]]
A nice feature would be to specify the name of a section and when you add a zettel it ends up there. If you don't have the variable or it can't find the section then it would just add it at the cursor. Inline insertion via <c-x><c-u>
would be unaffected.
As mentioned in #47 (comment)_ , nix install fails when trying to install the vim plugin. Steps to reproduce
{ config, lib, pkgs, ... }:
let
plugins = pkgs.vimPlugins;
myVimPlugins = with plugins; [
fzfWrapper
fzf-vim
neuron-vim
];
in
{
programs.neovim = {
enable = true;
plugins = myVimPlugins;
};
}
This results in the following error
Error detected while processing /nix/store/dx1va7x8856kw8dnx1y6xprxamsg83ba-vimplugin-neuron-vim-2020-10-29/share/vim-plugins/neuron-vim/plugin/neuron.vim:
line 66:
E121: Undefined variable: g:neuron_dir
E116: Invalid arguments for function filereadable
E15: Invalid expression: filereadable(g:neuron_dir."neuron.dhall")
remote/host: generated rplugin manifest: /nix/store/016na3sirjhj4iisg54c0yd4l28sdrrr-neovim-0.4.4/rplugin.vim
Generating rplugin.vim failed!
builder for '/nix/store/84wqqx84g4p1knm7s587l54z0w4ig7hv-neovim-0.4.4.drv' failed with exit code 1
cannot build derivation '/nix/store/ypnc90vhcxw0dlyxcv12ybac511723bp-home-manager-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/paky0b068vfd2a66zzk8cc32ndj7ddsj-neovim-0.4.4-fish-completions.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/22rf12j1k9qpn561fcz3xj4mf5646khd-home-manager-generation.drv': 1 dependencies couldn't be built
error: build of '/nix/store/22rf12j1k9qpn561fcz3xj4mf5646khd-home-manager-generation.drv' failed
neuron_dir
value to the current directory which is standard in the neuron project(see 4a0ab55). This value can then be overridden in a users vimrc if needed.let g:neuron_dir="/home/<user-name>/zettelkasten/"
---
date: 2020-10-31T01:47
tags:
- vim
- pinned
---
# Vim shortcuts for neuron
---
date: 2020-10-31T01:47
tags:
---
- totot
# Vim shortcuts for neuron
here's the αΊhole file:
---
date: 2020-10-31T01:47
tags:
- vim
- pinned
---
# Vim shortcuts for neuron
| **Shortcut** | **Command** |
| ------------ | ---------------------------------------------------- |
| `gzn` | Edit new Zettel |
| `gzN` | Edit new Zettel from current word |
| `gzN` | Edit new Zettel from selected (visual) |
| `gzr` | Refresh cache |
| `gzu` | Edit last zettel |
| `gzU` | `:<C-U>call neuron#move_history(-1)<cr>` |
| `gzP` | `:<C-U>call neuron#move_history(1)<cr>` |
| `gzz` | Select a Zettel to edit |
| `gzZ` | `<Plug>EditZettelBacklink` |
| `gzo` | Open Zettel under cursor |
| `gzs` | `<Plug>EditZettelSearchContent` |
| `gzS` | `<Plug>EditZettelSearchContentUnderCursor` |
| `gzl` | `<Plug>InsertZettelLast` |
| `gzi` | `<Plug>InsertZettelSelect` |
| `gzL` | `:<C-U>call neuron#insert_zettel_last(1)<cr>` |
| `gzI` | `:<C-U>call neuron#insert_zettel_select(1)<cr>` |
| `gzv` | `<Plug>ToggleBacklinks` |
| `gzt` | Add new Tag |
| `gzT` | Add new Tag by selecting an existing one |
| `gzts` | Search through Tags |
*nix tools on Windows like to be a hassle. Maybe I've been trying to push the square peg through the round hole, but I thought I'd report my findings.
First, I followed the instructions to use neuron through Ubuntu WSL2. Next...
C:\WINDOWS\system32\wsl.exe /home/me/.nix-profile/bin/neuron
This is the 'Target' address I put in my neuron.lnk shortcut on the PATH. It's important to keep the 'Start in' field empty.
It works great for using the program in cmd. :!neuron
also works fine in nvim.
The plugin seems to have an issue with this solution. Any idea why?
As per the title, running :call neuron#edit_zettel_select()
before opening a zettel fails because the cache is not yet populated. The same likely applies to other methods that use the cache.
Error detected while processing function neuron#edit_zettel_select:
line 1:
E121: Undefined variable: g:list_pair_zettelid_zetteltitle
E116: Invalid arguments for function fzf#wrap
E116: Invalid arguments for function fzf#run
If I manually run :call neuron#refresh_cache()
and then :call neuron#edit_zettel_select()
it does works, confirming the problem is the cache.
I'd expect that any method that needs data from the cache would first populate this cache if this hasn't happened yet.
When selecting tags it would be nice if fzf multiselect was supported.
Hi there, I have :
remapped to q:i
, in order to view my entire command history anytime I enter command mode (see: https://vim.fandom.com/wiki/Using_command-line_history)
But now when I try to use any of the mappings in neuron.vim, the before every mapping deletes my current command line and merges it with the one before it. This means it'll call something like:
xacall neuron#edit_zettel_new()
Because xa
was the command I entered previously. I might fork the plugin and just remove the mappings in plugin/neuron.vim but was wondering if there was a more general solution. I haven't run into this before. I was able to find this re: why some mappings include C-U but it's unclear to me if they're necessary here:
https://stackoverflow.com/questions/13830874/why-do-some-vim-mappings-include-c-u-after-a-colon
Thanks for the great work!
If I enable the plugin and start neovim inside of a ~
directory without specifying a file then it hangs.
It seems to be due to trying to go up the directories until it hits "/" (in `ftdetect/neuron.vim) but I think what is happening is:
.
(current directory)and so it keeps trying to go up the tree when there is none.
[[Some note, with puctuation]]
is now a valid link in neuron.
cf.
It would be great to be able to multiselect zettels to insert and then for it to be formatted as a list. Could have a default setting for which style and a command to do either. An example of a list would be:
- [[zettel1]]
- [[zettel2]]
---
date: 2020-10-31T01:47
tags:
- vim
- pinned
---
# Vim shortcuts for neuron
---
date: 2020-10-31T01:47
tags:
---
- totot
# Vim shortcuts for neuron
here's the αΊhole file:
---
date: 2020-10-31T01:47
tags:
- vim
- pinned
---
# Vim shortcuts for neuron
| **Shortcut** | **Command** |
| ------------ | ---------------------------------------------------- |
| `gzn` | Edit new Zettel |
| `gzN` | Edit new Zettel from current word |
| `gzN` | Edit new Zettel from selected (visual) |
| `gzr` | Refresh cache |
| `gzu` | Edit last zettel |
| `gzU` | `:<C-U>call neuron#move_history(-1)<cr>` |
| `gzP` | `:<C-U>call neuron#move_history(1)<cr>` |
| `gzz` | Select a Zettel to edit |
| `gzZ` | `<Plug>EditZettelBacklink` |
| `gzo` | Open Zettel under cursor |
| `gzs` | `<Plug>EditZettelSearchContent` |
| `gzS` | `<Plug>EditZettelSearchContentUnderCursor` |
| `gzl` | `<Plug>InsertZettelLast` |
| `gzi` | `<Plug>InsertZettelSelect` |
| `gzL` | `:<C-U>call neuron#insert_zettel_last(1)<cr>` |
| `gzI` | `:<C-U>call neuron#insert_zettel_select(1)<cr>` |
| `gzv` | `<Plug>ToggleBacklinks` |
| `gzt` | Add new Tag |
| `gzT` | Add new Tag by selecting an existing one |
| `gzts` | Search through Tags |
This plugin uses quite a few global variables with pretty generic names (e.g. g:fzf_options
, g:history
, g:last_file
) that could easily conflict with variables used by other plugins or by people in their own functions/scripts. Some of these are for options (should be set/accessed by user), but most are internal and should not be touched by the end user.
I propose config variables are prefixed with neuron_
(e.g. g:fzf_options
becomes g:neuron_fzf_options
). This is a pretty common pattern for the configuration of a plugin, and it makes it immediately obvious what plugin these options belong to. This would be a breaking change, but considering this fork only just became it's own thing this seems like a good moment for it.
For the variables that aren't meant to be touched by the user I propose most of them are moved to the s:
scope (e.g. g:history
becomes s:history
) if possible. For the ones that need to be used by multiple scripts the variable should be prefixed with something neuron specific to avoid collisions. I propose _neuron_
, with the extra leading underscore to clearly differentiate it from config variables (e.g. g:must_refresh_on_write
becomes g:_neuron_must_refresh_on_write
).
After resolving #45 I just noticed that starting up my vim shows an error in the refresh_callback_nvim function. The below image is of the error. Functionality of the plugin seems to otherwise be fine from what I can tell.
There is a loop in the ftdetect file that attempts to determine the zettelkasten root by looking for neuron.dhall
. The result of this loop is never used though, and the autocommands are still based on g:zkdir
, which seems odd.
First check the following:
neuron.dhall
file in you zettelkasten directoryHelpful information to know when reporting a bug:
While editing Zetteln, I don't see any backlinks in the top of the file, instead it shows a constant '0 backlinks'.
This was on a freshly installed Neuron + neovim + neuron.vim.
I checked the served rib generated html pages to make sure that the backlinks that should be visible in nvim are. The backlinks are displayed on the bottom of the HTML pages, but the same zettel in neuron.vim still shows '0 backlinks' at the top of the file.
Neuron Version: 1.1.6.1
neuron.vim version: downloaded on 10th Nov. 2020
using neuron.dhall inside flat directory containing Zetteln
I don't use these things and to me it feels very weird to run a server from inside vim. Am I crazy? Do people use it?
If there's even one person using this feature then I won't remove it.
It is worth dedicating a brief paragraph in README describing how this repo differs from upstream ihsanturk/neuron.vim (eg: "This fork is actively maintained, and works with newer versions of neuron supporting features like X, Y, Z").
Just having a look at: https://github.com/felko/neuron-mode - would be great to add in some tag handling stuff such as add tag/s
, maybe edit tags
too.
Again, I could work on this if you want? Thoughts?
I think add tag
would ask you to enter a tag, which would then add it to the yaml. Edit tags would jump you up to tags in the yaml. If the tags section in the yaml doesn't exist, both functions would add it in.
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.