michal-h21 / vim-zettel

VimWiki addon for managing notes according to Zettelkasten method
MIT License
557 stars 73 forks source link

ZettelSearch does not seem to work when macvim starts in da locale #71

Open kiil opened 3 years ago

kiil commented 3 years ago

I get the following error when using:

:ZettelSearch

or [[ in insert mode:

Fejl registreret ved behandling af function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf[9]..fzf#vim#ag[8]..fzf#vim#ag_raw[4]..f zf#vim#grep[28]..function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf[9]..fzf#vim#ag[8]..fzf#vim#ag_raw[4]..fzf#vim#grep[25]..< SNR>99_fzf[18]..99_wrap[9]..fzf#wrap[30]..17_default_layout: linje 1: E806: bruger flydende kommatal som en streng Fejl registreret ved behandling af function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf: linje 9: E171: Manglende :endif

I have no problems in the terminal.

kiil commented 3 years ago

If I do

:language en_US

the error disappears and it works in macvim also.

So maybe it has to do with locale in combination with macvim since in the terminal there is no error regardless of language.

michal-h21 commented 3 years ago

I don't have access to Mac, but I can try to replicate it in Gvim. Could you please post a minimal .vimrc that shows this issue.

zdflower commented 3 years ago

I have this problem too.

Vim version: 8.2 OS: Manjaro with linux 5.4.74-1

In vimrc:

let g:vimwiki_list = [{'path': '~/vimwiki/','syntax': 'markdown', 'ext': '.md', 'links_space_char': '_', 'auto_tags': 1, 'auto_diary_index': 1}]
let g:vimwiki_global_ext = 0
let g:vimwiki_auto_chdir = 1
let g:vimwiki_auto_header = 1

let g:zettel_fzf_command = 'rg'

Either with [[ in insert mode or ZettelInsertNote in command mode, when I select an item in the provided list and hit enter then the error shows up.

In the terminal, the error shown is:

Error detected while processing function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf[12]..fzf#vim#grep[28]..function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf[12]..fzf#vim#grep[25]..SNR>107_fzf[20]..fzf#run[64]..<SNR>23_callback:
line   21:
Vim(let):E484: Can't open file zsh.md:
Error detected while processing function zettel#fzf#sink_onefile[4]..zettel#fzf#execute_fzf:
line   12:
E171: Missing :endif

In gvim the error message doesn't show but neither is the link inserted.

kiil commented 3 years ago

In my case putting language da_DK.UTF-8 including the suffix .UTF-8 in .vimrc seems to have solved the problem.

Before I only had the first part and that was not enough, it seems.

So language en_US seems to be sufficient but language da_DK was not, apparently.

zdflower commented 3 years ago

In my case the problem remains the same despite of changing the language. I use the spanish locale in my system. I changed it in vim to english (with utf-8) to see if that made any difference, and to post here, but the problem keeps appearing. And lately I found another problem, maybe related to this, with the command ZettelOpen. For example, after execute :ZettelOpen there is a list with filenames and a line of text from the file The problem arises when the selected line has a link, i.e:
> Syncthing.md:[Syncthing web](https://syncthing.net/) and after hitting enter I get this message:

[DEBUG] filename: Syncthing.md:[Syncthing web](https://syncthing.net/)
[DEBUG] wikiname: Syncthing.md:[Syncthing web](https://syncthing
[DEBUG] dir: /mnt/sda1/vimwiki/
[DEBUG] wikidir: /mnt/sda1/vimwiki/
Vimwiki: Make new directory: /mnt/sda1/vimwiki/Syncthing.md:[Syncthing web](ht
tps:
[y]es/[N]o?

If I select a line without a link, it opens the file, but shows this message before:

[DEBUG] filename: Syncthing.md:
[DEBUG] wikiname: Syncthing
[DEBUG] dir: /mnt/sda1/vimwiki/
"Syncthing.md" 39 lines --87%--
michal-h21 commented 2 years ago

I managed to reproduce this issue. It seems that if you use just

 let g:zettel_fzf_command = 'rg'

then vim-zettel cannot correctly extract the selected filename. You need to use the --column option. So the minimal configuration for Ripgrep and g:zettel_fzf_command is this:

 let g:zettel_fzf_command = "rg --column"