Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when using the rg2vim function #1

Closed
partounian opened this issue Dec 19, 2017 · 3 comments
Closed

Issue when using the rg2vim function #1

partounian opened this issue Dec 19, 2017 · 3 comments

Comments

@partounian
Copy link

I get this issue whenever I use your rg2vim function
E575: Error while reading ShaDa file: mark entry at position 5802 has invalid line number
I use neovim, not sure if that changes anything.

By the way thank you so much for this function, I was originally going to over-engineer some kind of weird parsing tool https://github.com/partounian/srg

@lukaslueg
Copy link
Owner

I don't know about neovim.

rg2vim() {
	vim -c "$(
	FL=0
	while IFS=: read -r fn ln line; do
		if [ "$FL" -eq "0" ]; then
			printf "e %q|" "$fn"
			FL=1
		else
			printf "tabnew %q|" "$fn"
		fi
		printf ":%d|" "$ln"
	done < <(rg -n "$1" | peco --select-1)
	)"
}

So what this does is pass the first argument given to rg2vim to rg -n, which gives us matches including line numbers; those are passed on to peco which will flip up the GUI to narrow down matches; peco writes those matches to stdout which is then processed by the while-loop, one line at a time; for the first line (FL == 0), a e-command is constructed from the filename, all further lines use the tabnew-command; a :-command is appended with the line number. The whole output is then used to construct the argument to vim -c, which causes vim to execute the file-/tab-open commands after startup.

Given this slightly weird error, I could imagine that neovim does not like commands like this. Maybe you can dry-fire a command like nvim -c "e foo/src.c|:123|tabnew foo/src1.c|:321" and see if that works.

@partounian
Copy link
Author

partounian commented Dec 19, 2017

Thank you for the explanation!

I noticed it only happens after the first time running the command, but that command does work.

➜  .dotfiles git:(master) ✗ nvim -c "e zsh/zshenv.symlink|:123"
Alias tip: vim -c "e zsh/zshenv.symlink|:123"
➜  .dotfiles git:(master) ✗ vim -c "e zsh/zshenv.symlink|:123"
E575: Error while reading ShaDa file: mark entry at position 6053 has invalid line number
Press ENTER or type command to continue
➜  .dotfiles git:(master) ✗ nvim -c "e zsh/zshenv.symlink|:123"
Alias tip: vim -c "e zsh/zshenv.symlink|:123"
E575: Error while reading ShaDa file: mark entry at position 6074 has invalid line number
Press ENTER or type command to continue
➜  .dotfiles git:(master) ✗ nvim -c "e zsh/zshenv.symlink|:123"
Alias tip: vim -c "e zsh/zshenv.symlink|:123"
E575: Error while reading ShaDa file: mark entry at position 6073 has invalid line number
Press ENTER or type command to continue

I'll spend some time looking into this, also for curiosity, do you use still use this function or do you use another method of getting to files?

@lukaslueg
Copy link
Owner

I still use it from time to time. This is most likely not the right way to do it, though.

Regarding your shada-problem: This is a neovim-specific mechanism that replaced viminfo. You might need to disable shada-parsing when passing -c. Maybe there is some docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants