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

i load the zathura or skim, but when i use \lv, it shows not using a previewer #2424

Closed
EdwardWong1994 opened this issue Jun 30, 2022 · 33 comments
Labels

Comments

@EdwardWong1994
Copy link

EdwardWong1994 commented Jun 30, 2022

Description

I have been struggled for almost two days just want to make the pdfviewer show up. But i can not succeed due to the problem "not using a previewer", not much solution i can find.

Here is my environment for mac system:

Darwin MacBook-Pro.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May  8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64

I do not know what's the real problem for this. I do not know whether it is related with dbus. When i use brew services list, the status of dbus is stopped, not runing. But i can not solve.

Here is one of the suspected reason, see below figure:

suspected reason

Steps to reproduce

I am not using minimal.vim, I edit all the setting in ~/.vimrc and using \ll compile the .tex file.

Expected behavior

It run with no error but pdf viewer did not pop up.

Actual behavior

I compile my latex file without errors using \ll, but when I use command \lv to show the pdf, the viewer did not show up. I try to find such problem and find a similar, but the reason is quite different. I use \lo to output the compile information as below figure
error information

I can use zathura a.pdf to open the file in the terminal, but when I try to show up the pdf file after compilation, it did not showup. I also try skim as my default viewer, it occur the same "not using a previewer" information.

Do you use a latexmkrc file?

No

VimtexInfo

System info:
  OS: macOS 11.4 (20F71)
  Vim version: VIM 9.0 ()
  Has clientserver: false

VimTeX project: exercise
  base: exercise.tex
  root: /Users/wangchenchen/Desktop/WCC/Latex
  tex: /Users/wangchenchen/Desktop/WCC/Latex/exercise.tex
  main parser: current file verified
  document class: article
  packages: amsbsy amsgen amsmath amsopn amstext
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
  viewer: Zathura
    xwin id: 0
  qf method: LaTeX logfile
@ejmastnak
Copy link
Contributor

ejmastnak commented Jun 30, 2022

As you guessed, this is quite likely a dbus problem; it seems that getting macOS, dbus and Zathura to interact correctly is a common problem.

It is hard to tell what you have tried or what your configuration is, but my usual recommendation here is the same as in this comment or in this guide: start by uninstalling and re-installing the relevant software and then exactly repeat the steps in :help vimtex-faq-zathura-macos. I also notice your macOS is a bit old, but probably that is not an issue.

In case you haven't already, it would probably useful to read through #2391 from start to finish and see if anything applies to you.

There is also another problem: your VimtexInfo reads

Has clientserver: false

This means using inverse search will be impossible. My guess is you are using command line Vim; you will need GUI MacVim, command line Neovim, or to compile command line Vim from source with client server enabled if you want to use inverse search on macOS. This article might be helpful.

PS: If you post your vimrc and vimtex configuration, I could try to reproduce the issue to help you debug, but right now that is not possible. You should probably take care of this.

@EdwardWong1994
Copy link
Author

EdwardWong1994 commented Jun 30, 2022

Thanks for your reply. I follow the strict procedure before I post this question. Except one case that i change the directory /usr/local/opt in /opt/homebrew/opt, because I believe this is the default folder for homebrew run in Mac M1. I tried it many times, the status of dbus always stopped. My .vimrc file is attached here: [configuration vimrc files]{https://github.com/EdwardWong1994/coc-nvim-configuration.git}.

Also it was not just zathura can not running but also skim would the same information not using a previewer. I am quite headache for this issue. I really do not want to quit this plugin because I can not pop up the pdf, otherwise it make my work less interesting.

@ejmastnak
Copy link
Contributor

I follow the strict procedure before i post this question.

Hmm, if you've followed :help vimtex-faq-zathura-macos and PDF preview is still not working, I won't say that it can't be done, but I believe the problem is beyond the scope of what I can help with. I don't have an M1 Mac I could test on (perhaps the dbus and Homebrew Zathura workflow only works on Intel Macs?). And I am mostly on Linux these days, so my macOS knowledge is limited.

Also it was not just zathura can not running but also skim would the same information not using a previewer

It does seem strange the Skim does not work either, I thought Skim did not require dbus to work. Perhaps someone who uses VimTeX on macOS can confirm.

My .vimrc file is attached here: [configuration vimrc files]{https://github.com/EdwardWong1994/coc-nvim-configuration.git}.

@lervag, this appears to be his relevant VimTeX config based on the posted link; I don't see anything suspicious besides setting both vimtex_view_method and latex_view_general_viewer, perhaps you can comment?

let g:tex_flavor='latex'
"let g:vimtex_compiler_method='latexrun'
"set grepprg =grep\ -nH\ $*
"let g: tex_falvor='latex'
"let g:Tex_DefaultTargetFormat='pdf'
let g:vimtex_view_method='zathura'
let g:latex_view_general_viewer='zathura'
let g:vimtex_quickfix_mode =1
let g:vimtex_view_enabled=1
let g:vimtex_view_automatic=1

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

This issue is clearly not only dbus related. Without dbus, Zathura should still work, but forward and backward sync will not work.

Thanks for your reply. I follow the strict procedure before I post this question.

I'm slow, sorry: Which strict procedure are you referring to?

Except one case that i change the directory /usr/local/opt in /opt/homebrew/opt, because I believe this is the default folder for homebrew run in Mac M1.

Do you mean you first tried without changing the directory, and it didn't work? And then afterwards, you tried to change the directory, and it still doesn't work?

My .vimrc file is attached here: [configuration vimrc files]{https://github.com/EdwardWong1994/coc-nvim-configuration.git}.

I'm sorry to be so blunt, but your .vimrc is a mess. You really should clean it up. You have a lot of duplicate lines and it is generally without structure. I get the feeling that you are copying things you find on the internet without understanding what it does. I strongly encourage you to slow down and clean up your vimrc file. Don't copy things before you read up on what it does.

For the VimTeX specific content in your .vimrc file, see my comments below:

" I'm not sure if vimtex and vim-latex-live-preview works well together.
" I would disable this when you are debugging issues with vimtex. Or, MUUUCH
" better, use the minimal example approach explained later!
Plugin 'xuhdev/vim-latex-live-preview'
let g:livepreview_previewer='zathura'
let g:livepreview_engine='latexmk'

Plugin 'lervag/vimtex'
" The following settings for VimTeX can be simplified:
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:latex_view_general_viewer='zathura'
let g:vimtex_quickfix_mode =1
let g:vimtex_view_enabled=1
let g:vimtex_view_automatic=1

" To this:
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 1

" VimTeX provides several similar shortcuts already, see :help vimtex-imaps
autocmd FileType tex inoremap ,alpha    \alpha
autocmd FileType tex inoremap ,beta     \beta
" ...

" Notice that there's a VimTeX extension for coc (coc-vimtex) to allow
" autocomplete with VimTeXs omnicompletion. E.g.:
let g:coc_global_extensions = [ ..., 'coc-vimtex' ]

I am not using minimal.vim, I edit all the setting in ~/.vimrc and using \ll compile the .tex file.

If you want me to spend my time helping you with this, then I expect you to spend time creating a minimal vimrc file. It was explained in the issue template, but I can explain it again:

  1. Create an empty test folder with a test.vim and test.tex file with the below contents:

    " test.vim
    set nocompatible
    set runtimepath^=~/.vim/bundle/vimtex
    set runtimepath+=~/.vim/bundle/vimtex/after
    filetype plugin indent on
    syntax enable
    
    let g:vimtex_view_method = 'zathura'
    % test.tex
    \documentclass{minimal}
    \begin{document}
    Hello World!
    \end{document}
  2. From a terminal, run vim -u test.vim test.tex. Or mvim or whatever dialect of Vim you are using. Check if things work. Explain the necessary steps to reproduce your issue.

  3. If things still don't work, please post:

    1. Output of :scriptnames after you did vim -u test.vim test.tex.
    2. Output of \li after you did both \ll and \lv.
    3. Output of \lo after \ll.

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

Also: You claim that you are not using a .latexmkrc file. But can you double check that?

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

Oh, and thanks, @ejmastnak, for replying early and giving some initial helpful comments!

@EdwardWong1994
Copy link
Author

EdwardWong1994 commented Jun 30, 2022

This issue is clearly not only dbus related. Without dbus, Zathura should still work, but forward and backward sync will not work.

Yes, without dbus, zathura can run in the command line. It just can not pop up when i type in vim and type \lv

Thanks for your reply. I follow the strict procedure before I post this question.

I'm slow, sorry: Which strict procedure are you referring to?
I follow the information given by :help vimtex-faq-zathura-macos

Except one case that i change the directory /usr/local/opt in /opt/homebrew/opt, because I believe this is the default folder for homebrew run in Mac M1.

Do you mean you first tried without changing the directory, and it didn't work? And then afterwards, you tried to change the directory, and it still doesn't work?

No, i did not install twice. because i know for the x86-64 mac, brew will install all the bin,library in\usr\local\homebrew, but for M1, the homebrew change its default install directory, which is \opt\homebrew> > My .vimrc file is attached here: [configuration vimrc files]{https://github.com/EdwardWong1994/coc-nvim-configuration.git}.

I'm sorry to be so blunt, but your .vimrc is a mess. You really should clean it up. You have a lot of duplicate lines and it is generally without structure. I get the feeling that you are copying things you find on the internet without understanding what it does. I strongly encourage you to slow down and clean up your vimrc file. Don't copy things before you read up on what it does.

I am actually new to vimscript and i will learn in the near feature and i believe it will help me to command vim more better. I just roughly know what the command in vimrc does.

For the VimTeX specific content in your .vimrc file, see my comments below:

" I'm not sure if vimtex and vim-latex-live-preview works well together.
" I would disable this when you are debugging issues with vimtex. Or, MUUUCH
" better, use the minimal example approach explained later!
Plugin 'xuhdev/vim-latex-live-preview'
let g:livepreview_previewer='zathura'
let g:livepreview_engine='latexmk'

Plugin 'lervag/vimtex'
" The following settings for VimTeX can be simplified:
let g:tex_flavor='latex'
let g:vimtex_view_method='zathura'
let g:latex_view_general_viewer='zathura'
let g:vimtex_quickfix_mode =1
let g:vimtex_view_enabled=1
let g:vimtex_view_automatic=1

" To this:
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 1

" VimTeX provides several similar shortcuts already, see :help vimtex-imaps
autocmd FileType tex inoremap ,alpha    \alpha
autocmd FileType tex inoremap ,beta     \beta
" ...

" Notice that there's a VimTeX extension for coc (coc-vimtex) to allow
" autocomplete with VimTeXs omnicompletion. E.g.:
let g:coc_global_extensions = [ ..., 'coc-vimtex' ]

I am not using minimal.vim, I edit all the setting in ~/.vimrc and using \ll compile the .tex file.

If you want me to spend my time helping you with this, then I expect you to spend time creating a minimal vimrc file. It was explained in the issue template, but I can explain it again:

  1. Create an empty test folder with a test.vim and test.tex file with the below contents:

    " test.vim
    set nocompatible
    set runtimepath^=~/.vim/bundle/vimtex
    set runtimepath+=~/.vim/bundle/vimtex/after
    filetype plugin indent on
    syntax enable
    
    let g:vimtex_view_method = 'zathura'
    % test.tex
    \documentclass{minimal}
    \begin{document}
    Hello World!
    \end{document}
    
  2. From a terminal, run vim -u test.vim test.tex. Or mvim or whatever dialect of Vim you are using. Check if things work. Explain the necessary steps to reproduce your issue.

  3. If things still don't work, please post:

    1. Output of :scriptnames after you did vim -u test.vim test.tex.
    2. Output of \li after you did both \ll and \lv.
    3. Output of \lo after \ll.

I created the test.vim and test.tex file exactly the same with you. When i type :scriptnames, the following information is given

:scriptnames
  1: ~/Desktop/example/test.vim
  2: ~/.vim/bundle/vimtex/plugin/vimtex.vim

and it seems that the \li and \lv, \lo doesn't response. I am not sure whether i need to add some more in the test.vim, i change the test.vim to :

set nocompatible
set runtimepath=~/.vim/bundle/vimtex
set runtimepath+=~/.vim/bundle/vimtex/after
filetype plugin indent on
let g:vimtex_view_method='zathura'
call vundle#begin()
Plugin 'lervag/vimtex'
call vundle#end()

It gives me errors shown in the following figur

e

Do i need to reinstall vundle ?

@EdwardWong1994
Copy link
Author

Also: You claim that you are not using a .latexmkrc file. But can you double check that?

Yes, i did not configure latexmkrc and also zathura

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

This issue is clearly not only dbus related. Without dbus, Zathura should still work, but forward and backward sync will not work.

Yes, without dbus, zathura can run in the command line. It just can not pop up when i type in vim and type \lv

My point was simply that, since Zathura does not open after \lv, then this is more than simply a problem with dbus, because an issue with dbus would only affect the sync behaviour. So, the main problem here is something else.

Do you mean you first tried without changing the directory, and it didn't work? And then afterwards, you tried to change the directory, and it still doesn't work?

No, i did not install twice. because i know for the x86-64 mac, brew will install all the bin,library in\usr\local\homebrew, but for M1, the homebrew change its default install directory, which is \opt\homebrew

Ok!

I am actually new to vimscript and i will learn in the near feature and i believe it will help me to command vim more better. I just roughly know what the command in vimrc does.

No problem, we all start out with little knowledge and learn as we go. And some of us really enjoy the experience of learning these things; I hope you do or will do to!

I created the test.vim and test.tex file exactly the same with you. When i type :scriptnames, the following information is given

:scriptnames
  1: ~/Desktop/example/test.vim
  2: ~/.vim/bundle/vimtex/plugin/vimtex.vim

That's strange; this should be a much longer list. As a reference, with the same minimal test.vim file, the output looks like this on my end (after vim -u test.vim):

:scriptnames
  1: ~/test/test.vim
  2: /usr/share/vim/vim90/filetype.vim
  3: ~/.local/plugged/vimtex/ftdetect/cls.vim
  4: ~/.local/plugged/vimtex/ftdetect/tex.vim
  5: ~/.local/plugged/vimtex/ftdetect/tikz.vim
  6: /usr/share/vim/vimfiles/ftdetect/conkyrc.vim
  7: /usr/share/vim/vim90/ftplugin.vim
  8: /usr/share/vim/vim90/indent.vim
  9: /usr/share/vim/vim90/syntax/syntax.vim
 10: /usr/share/vim/vim90/syntax/synload.vim
 11: /usr/share/vim/vim90/syntax/syncolor.vim
 12: /usr/share/vim/vim90/colors/lists/default.vim
 13: ~/.local/plugged/vimtex/plugin/vimtex.vim
 14: ~/.dotfiles/vim/.vim/plugin/open-in-browser.vim
 15: ~/.dotfiles/vim/.vim/plugin/windows.vim
 16: /usr/share/vim/vimfiles/plugin/fzf.vim
 17: /usr/share/vim/vimfiles/plugin/redact_pass.vim
 18: /usr/share/vim/vim90/plugin/getscriptPlugin.vim
 19: /usr/share/vim/vim90/plugin/gzip.vim
 20: /usr/share/vim/vim90/plugin/logiPat.vim
 21: /usr/share/vim/vim90/plugin/manpager.vim
 22: /usr/share/vim/vim90/plugin/matchparen.vim
 23: /usr/share/vim/vim90/plugin/netrwPlugin.vim
 24: /usr/share/vim/vim90/plugin/rrhelper.vim
 25: /usr/share/vim/vim90/plugin/spellfile.vim
 26: /usr/share/vim/vim90/plugin/tarPlugin.vim
 27: /usr/share/vim/vim90/plugin/tohtml.vim
 28: /usr/share/vim/vim90/plugin/vimballPlugin.vim
 29: /usr/share/vim/vim90/plugin/zipPlugin.vim

Do i need to reinstall vundle ?

No, we want a minimal example, so don't use Vundle now! Let's take it step by step. In a terminal, do vim then :scriptnames and copy the output here. This should show how it looks with your regular vimrc. With that, I can fully confirm the location of VimTeX, because the set runtimepath needs the correct location.

@EdwardWong1994
Copy link
Author

Here is the out put when i do :scriptnames in vim.

  1: ~/.vimrc
  2: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/syntax.vim
  3: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/synload.vim
  4: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/syncolor.vim
  5: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/colors/lists/default.vim
  6: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/filetype.vim
  7: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/scripts.vim
  8: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/autoload/dist/script.vim
  9: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/colors/desert.vim
 10: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/indent.vim
 11: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/ftplugin.vim
 12: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/nosyntax.vim
 13: ~/.vim/bundle/Vundle.vim/autoload/vundle.vim
 14: ~/.vim/bundle/Vundle.vim/autoload/vundle/config.vim
 15: ~/.vim/bundle/gruvbox/colors/gruvbox.vim
 16: ~/.vim/plugin/acp.vim
 17: ~/.vim/autoload/acp.vim
 18: ~/.vim/plugin/neocomplete/buffer.vim
 19: ~/.vim/plugin/neocomplete/dictionary.vim
 20: ~/.vim/plugin/neocomplete/member.vim
 21: ~/.vim/plugin/neocomplete/tag.vim
 22: ~/.vim/plugin/neocomplete.vim
 23: ~/.vim/bundle/ultisnips/plugin/UltiSnips.vim
 24: ~/.vim/bundle/ultisnips/autoload/UltiSnips/map_keys.vim
 25: ~/.vim/bundle/vim-snippets/plugin/vimsnippets.vim
 26: ~/.vim/bundle/Vundle.vim/plugin/acp.vim
 27: ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim
 28: ~/.vim/bundle/command-t/plugin/command-t.vim
 29: ~/.vim/bundle/command-t/autoload/commandt/mirkwood.vim
 30: ~/.vim/bundle/vim-latex-live-preview/plugin/latexlivepreview.vim
 31: ~/.vim/bundle/vimtex/plugin/vimtex.vim
 32: ~/.vim/bundle/nerdtree/plugin/NERD_tree.vim
 33: ~/.vim/bundle/nerdtree/autoload/nerdtree.vim

The runtimepath ? do i need to add plugin behind ~/.vim/bundle/vimtex/plugin? I try it with additional /plugin, it still only give me same situation.

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

Ok, what's :scriptnames after vim -u NORC?

And further, again with this:

set nocompatible
set runtimepath^=~/.vim/bundle/vimtex
set runtimepath+=~/.vim/bundle/vimtex/after
filetype plugin indent on
syntax enable

What's the output of vim -u test.vim then :scriptnames?

Also, what's the output of :version after you start Vim?

@EdwardWong1994
Copy link
Author

oh, sorry, i though ^= was a typo before, after i add ^ in, the scriptnames when i using vim -u test.vim test.tex

scriptnames
  1: ~/Desktop/example/test.vim
  2: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/filetype.vim
  3: ~/.vim/bundle/vimtex/ftdetect/cls.vim
  4: ~/.vim/bundle/vimtex/ftdetect/tex.vim
  5: ~/.vim/bundle/vimtex/ftdetect/tikz.vim
  6: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/ftplugin.vim
  7: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/indent.vim
  8: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/syntax.vim
  9: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/synload.vim
 10: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/syntax/syncolor.vim
 11: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/colors/lists/default.vim
 12: ~/.vim/bundle/vimtex/plugin/vimtex.vim
 13: ~/.vim/plugin/acp.vim
 14: ~/.vim/autoload/acp.vim
 15: ~/.vim/plugin/neocomplete/buffer.vim
 16: ~/.vim/plugin/neocomplete/dictionary.vim
 17: ~/.vim/plugin/neocomplete/member.vim
 18: ~/.vim/plugin/neocomplete/tag.vim
 19: ~/.vim/plugin/neocomplete.vim
 20: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/getscriptPlugin.vim
 21: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/gzip.vim
 22: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/logiPat.vim
 23: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/manpager.vim
 24: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/matchparen.vim
 25: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/netrwPlugin.vim
 26: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/rrhelper.vim
 27: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/spellfile.vim
 28: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/tarPlugin.vim
 29: /opt/homebrew/Cellar/vim/9.0.0000/share/vim/vim90/plugin/tohtml.vim

the output of li after i press \lland lv, the output is something like this:

The output for \lo is "not using a previewer "

I have been struggled for two days for this problem but no answer can be found

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

I have been struggled for two days for this problem but no answer can be found

I'm trying to understand what's going on. I will find answers for you, but you need to slow down and provide what I ask for. As you said yourself, you are inexperienced. I know what I am doing and what I am asking for.

... the scriptnames when i using vim -u test.vim test.tex ...

Ok, now we are getting somewhere!

Notice how you have several plugins that are loaded:

 13: ~/.vim/plugin/acp.vim
 14: ~/.vim/autoload/acp.vim
 15: ~/.vim/plugin/neocomplete/buffer.vim
 16: ~/.vim/plugin/neocomplete/dictionary.vim
 17: ~/.vim/plugin/neocomplete/member.vim
 18: ~/.vim/plugin/neocomplete/tag.vim
 19: ~/.vim/plugin/neocomplete.vim

I advice that you, for now, remove all of these (move them to a temporary folder). You can add them back afterwards when things work. But notice that these are plugins in your config that are loaded in addition to the ones you load with Vundle.

the output of li after i press \lland lv, the output is something like this:

No, that is not the output after you press \ll and \lv! Please, slow down. Do what I ask, don't assume too much. There is a reason I ask for the output after you do \ll and \li! Specifically, if you do \li afterwards, it will show the commands used to start latexmk and zathura.

The output for \lo is "not using a previewer "

"Not using a previewer" is actually expected. I should have catched this immediately, but I understand part of this now. For the viewer to open automatically, you need +clientserver. See :help vimtex-clientserver for more info.

@EdwardWong1994
Copy link
Author

I have deleted the corresonding vim file. It is very strange that when i press \li after \ll, it is still the following figure.

I guess you want to know the prosess of compile, so i copy the .log file here.

This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021) (preloaded format=pdflatex 2022.1.8)  30 JUN 2022 22:47
entering extended mode
 restricted \write18 enabled.
 file:line:error style messages enabled.
 %&-line parsing enabled.
**exercise.tex
(./exercise.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> (/usr/local/texlive/2021/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
) (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2021-03-18 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count179
\l__pdf_internal_box=\box47
) (./exercise.aux)
\openout1 = `exercise.aux'.

LaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.
LaTeX Font Info:    Checking defaults for TS1/cmr/m/n on input line 2.
LaTeX Font Info:    ... okay on input line 2.

Due to the reason that i press li, no expected outcome, can it be key-binding conflict?

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

I have deleted the corresonding vim file. It is very strange that when i press \li after \ll, it is still the following figure.

No, that figure is not similar to the previous one. I contains what I asked for. But please, don't upload as image. Copy the text and paste it here. Notice that there is text that goes out of the image.

I guess you want to know the prosess of compile, so i copy the .log file here.

Nope, that's not interesting.

Due to the reason that i press li, no expected outcome, can it be key-binding conflict?

Nope. \li gives exactly the output I expect. Please read my last post again and do what I ask (if you already did everything, please confirm that you are doing it).

@lervag
Copy link
Owner

lervag commented Jun 30, 2022

Was out of time earlier. So, to give some further explanations: VimTeX uses the callback and clientserver mechanism of Vim to start the viewers. This is an ubiquitous feature and should be available in most systems. @ejmastnak already mentioned this in the very first post:

There is also another problem: your VimtexInfo reads

Has clientserver: false

This means using inverse search will be impossible. My guess is you are using command line Vim; you will need GUI MacVim, command line Neovim, or to compile command line Vim from source with client server enabled if you want to use inverse search on macOS. This article might be helpful.

When I read this the first time, I forgot that the clientserver is more important that communicated here. That is, it is not only used for inverse search — it is also used for automatically starting the viewers. So, without a proper clientserver, VimTeX will not open a viewer automatically.

This should be relatively easy to address, but I believe it is better that we first figure out why Zathura does not start when you do \lv. Your latter screenshot from \li output shows that VimTeX uses the command string zathura -x "vim -T dumb ..." ... to execute Zathura. My first follow-up question will be that you run this exact command in a terminal outside of Vim. If it does not work, then it will be interesting to see the error message(s).

@EdwardWong1994
Copy link
Author

I run zathura -x "vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'exercise.tex' 'exercise.pdf'& outside of vim, the error information is related with session bus.

[1] 69728
error: Could not connect to session bus: Could not connect: Connection refused
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1] +69728 exit 255 zathura -x --syntex-forward 1:1 `exercise.tex` `exercise.pdf`

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

Great. This shows specifically why Zathura does not work. I'm sorry to say that I can not help very much further with this specific problem. If you are not able to solve this with instructions from :help vimtex-faq-zathura-macos, then I don't know anything else that may work.

You could use Skim; I know a lot of people uses it and it should work quite well. I believe it should already work, and that the only issue would be that you need the clientserver feature for auto open.

@EdwardWong1994
Copy link
Author

I have tried both skim and zathura before, and both of them won't work. I remember i found an article that the author mention that the method to deal with zathura in vim, roughly the same with :help vimtex-faq-zathura-macos, works fine with mac os 12, he did not mentioned that this method did not apply to mac os 11.4. I am not sure if it is the reason and a bit relectant to change the system because it might influence some of my configuration.

Another thing updated is that I can open the pdf file outside the terminal. In the meantime, If i compile the tex and make change to the content, zathura will still automatically update even in display mode. But the unhappy thing is that i need to open two windows not the ideal way like one terminal side by side. This is the compromise way for now. If I run zathura outside terminal, does it support inverse and forward search?

@ejmastnak
Copy link
Contributor

ejmastnak commented Jul 1, 2022

Thought I would chime back in.

I run zathura -x "vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'exercise.tex' 'exercise.pdf'& outside of vim, the error information is related with session bus.

[1] 69728
error: Could not connect to session bus: Could not connect: Connection refused
error: Got no usable data from SyncTeX or D-Bus failed in some way.

[1] +69728 exit 255 zathura -x --syntex-forward 1:1 `exercise.tex` `exercise.pdf`

I notice that this is the same error as in #2391. As a sanity check, @EdwardWong1994, could you please open a .tex file in Vim and output the result of the command :echo $DBUS_SESSION_BUS_ADDRESS?

VimTeX uses the callback and clientserver mechanism of Vim to start the viewers.

This is great to know, and also explains why Skim wouldn't auto-start. I didn't know VimTeX used clientserver to start viewers and will keep it in mind if future issues come up with other users. @EdwardWong1994, as @lervag suggests, you really should use an editor with clientserver enabled. On macOS your choices are basically MacVim or Neovim.

@EdwardWong1994, you write:

If I run zathura outside terminal, does it support inverse and forward search?

The short answer is no, to the best of my knowledge. You'd need both dbus and clientserver for this to work. Your question indicates you have not read (or fully understood) either the relevant VimTeX documentation nor the article I linked earlier, even though you implied earlier that you did. If you want us to spend time helping you, you should put in the time yourself---take 30-40 minutes and read the docs/guides. They will answer your inverse search and clientserver questions.

Finally, @EdwardWong1994, @lervag quite frankly has the patience of a saint to keep helping you through all of this. Even if its not my place to say so, it would be nice to be more explicitly appreciative of his help in this thread.

@ejmastnak
Copy link
Contributor

ejmastnak commented Jul 1, 2022

Also:

You could use Skim; I know a lot of people uses it and it should work quite well. I believe it should already work, and that the only issue would be that you need the clientserver feature for auto open.

I have tried both skim and zathura before, and both of them won't work.

@EdwardWong1994, what happens if in your vimrc you:

  1. temporarily comment out the line let g:vimtex_view_method = 'zathura'
  2. replace it with let g:vimtex_view_method = 'skim'
  3. Open a tex file and compile it with \ll
  4. After compiling, manually call the command :VimtexView? Does Skim open if you manually call this command?

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

I have tried both skim and zathura before, and both of them won't work.

No! I'll be brief, because @ejmastnak already provided good updates here. But it seems to me that you don't read my answers!

I remember i found an article that the author mention that the method to deal with zathura in vim, roughly the same with :help vimtex-faq-zathura-macos, works fine with mac os 12, he did not mentioned that this method did not apply to mac os 11.4.

Stop reading arbitrary articles! I don't care about what you find in a random blog post. Read the documentation that I refer to or blog posts suggested in the thread. Ignore everything else.

Another thing updated is that I can open the pdf file outside the terminal.

What does this mean? With simply zathura file.pdf? Or with the full zathura -x ... file.pdf? Do you mean you figured things out?

In the meantime, If i compile the tex and make change to the content, zathura will still automatically update even in display mode.

Yes; latexmk signals Zathura to update. That's expected.


Please follow the suggestions by @ejmastnak in his last post about Skim and explain the results.

@EdwardWong1994
Copy link
Author

Thanks for both of you to be so patient with me. I really appreciate for the help . I tried what @ejmastnak suggested. comment out let g:vimtex_view_method = 'zathura and replace with let g:vimtex_view_method = 'skim, when use vim -u test.vim test.tex and type \ll, it automatically jump skim. When i use vim test.tex with my own .vimrc, it will not pop up skim.

For the output of $DBUS_SESSION_BUS_ADDRESS, it shows unix:path=/private/tmp/com.apple.launchd.RoOkFJ7Awd/unix_domain_listener

Again, forgive me for keep asking these questions, zathura with vimtex is really what i want

@ejmastnak
Copy link
Contributor

For the output of $DBUS_SESSION_BUS_ADDRESS, it shows unix:path=/private/tmp/com.apple.launchd.RoOkFJ7Awd/unix_domain_listener
Again, forgive me for keep asking these questions, zathura with vimtex is really what i want

Unfortunately I don't know at this point how to get Zathura working with VimTeX on macOS. Your $DBUS_SESSION_BUS_ADDRESS variable seems to be properly set, but Zathura is still not working, so I am out of ideas.

I think your options are to either:

  1. use Skim and VimTeX on macOS, or
  2. If you really want Zathura and VimTeX, I suppose you could switch to Linux.

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

Thanks for both of you to be so patient with me. I really appreciate for the help .

<3

I tried what @ejmastnak suggested. comment out let g:vimtex_view_method = 'zathura and replace with let g:vimtex_view_method = 'skim, when use vim -u test.vim test.tex and type \ll, it automatically jump skim.

What do you mean, i.e. what does "automatically jump skim" mean? That it works as expected? That Skim opens automatically? Does \lv work as expected with forward search?

I don't mean to be difficult, but it is important that we communicate clearly. The details are important to properly understand the various behaviours.

When i use vim test.tex with my own .vimrc, it will not pop up skim.

Let us keep focus on the minimal examples. We can help with your full .vimrc later when we have things working with minimal examples.

Again, forgive me for keep asking these questions, zathura with vimtex is really what i want

It's OK! I advice that you don't make so many assumptions. Especially, don't try things unless you know what you are doing. Just follow up on what we ask and take it slow. I believe it should be possible to get Zathura working.

I think the approach going further is to get Zathura working in the terminal. If we can't get it working from the terminal, then we can't get it working from VimTeX.

  1. Does zathura test.pdf work? In particular, is the dbus issue only relevant when you add the -x ... option?
  2. If you do zathura -x "vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'exercise.tex' 'exercise.pdf' in a terminal, then you probably get this dbus issue; am I right?

After point 2, if I'm right. In the same terminal, is $DBUS_SESSION_BUS_ADDRESS defined? Try echo $DBUS_SESSION_BUS_ADDRESS.

@EdwardWong1994
Copy link
Author

Thanks for both of you to be so patient with me. I really appreciate for the help .

<3

I tried what @ejmastnak suggested. comment out let g:vimtex_view_method = 'zathura and replace with let g:vimtex_view_method = 'skim, when use vim -u test.vim test.tex and type \ll, it automatically jump skim.

What do you mean, i.e. what does "automatically jump skim" mean? That it works as expected? That Skim opens automatically? Does \lv work as expected with forward search?

Automatically jump means that when i compile texfile using \lv, it can automatically pop up. With skim, it works fine including forward search.

I don't mean to be difficult, but it is important that we communicate clearly. The details are important to properly understand the various behaviours.

When i use vim test.tex with my own .vimrc, it will not pop up skim.

Let us keep focus on the minimal examples. We can help with your full .vimrc later when we have things working with minimal examples.

Again, forgive me for keep asking these questions, zathura with vimtex is really what i want

It's OK! I advice that you don't make so many assumptions. Especially, don't try things unless you know what you are doing. Just follow up on what we ask and take it slow. I believe it should be possible to get Zathura working.
Ok. Much thanks. I will do what you let me do
I think the approach going further is to get Zathura working in the terminal. If we can't get it working from the terminal, then we can't get it working from VimTeX.

  1. Does zathura test.pdf work? In particular, is the dbus issue only relevant when you add the -x ... option?

using zathura test.pdf, it can run with content. but with zathura -x test.pdf, the zathura did pop up but with nothing

  1. If you do zathura -x "vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'exercise.tex' 'exercise.pdf' in a terminal, then you probably get this dbus issue; am I right?

Yes. Run above code will complain dbus error. The result is as follow:

error: Could not connect to session bus: Could not connect: Connection refused
error: Got no usable data from SyncTeX or D-Bus failed in some way.

After point 2, if I'm right. In the same terminal, is $DBUS_SESSION_BUS_ADDRESS defined? Try echo $DBUS_SESSION_BUS_ADDRESS.

The variable is defined , the result of the variable is as follow

unix:path=/private/tmp/com.apple.launchd.RoOkFJ7Awd/unix_domain_listener

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

Automatically jump means that when i compile tex file using \lv, it can automatically pop up. With skim, it works fine including forward search.

I would not describe \lv with "automatic", because it is used to specifically open the viewer. So, did you mean \ll here?

  1. If you do zathura -x "vim -T dumb --not-a-term -n -c \"VimtexInverseSearch %{line} '%{input}'\"" --synctex-forward 1:1:'exercise.tex' 'exercise.pdf' in a terminal, then you probably get this dbus issue; am I right?

Yes. Run above code will complain dbus error.

unix:path=/private/tmp/com.apple.launchd.RoOkFJ7Awd/unix_domain_listener

Thanks. Lets continue:

  1. What's the output of cat /usr/local/opt/dbus/share/dbus-1/session.conf|grep auth?

  2. What is the output of brew services list?

  3. Can you again, just for my peace of mind, assure that you really followed the steps in :help vimtex-faq-zathura-macos from start to finish? There are 6 steps. Notice that, if you already had Zathura and Girara installed without following these steps, then it is strongly recommended to first uninstall and unlink them before you start with step 1.

@EdwardWong1994
Copy link
Author

EdwardWong1994 commented Jul 1, 2022

Thanks. Lets continue:

  1. What's the output of cat /usr/local/opt/dbus/share/dbus-1/session.conf|grep auth?

The output of above command is :

  <!-- On Unix systems, the most secure authentication mechanism is
  This authentication mechanism is not available on Windows,
  comment out the <auth> element to allow fallback to DBUS_COOKIE_SHA1. -->
  <auth>DBUS_COOKIE_SHA1</auth>
  <limit name="auth_timeout">240000</limit>
  1. What is the output of brew services list?

The output for brew services list

dbus    stopped  ~/Library/LaunchAgents/org.freedesktop.dbus-session.plist
emacs   none
unbound none
  1. Can you again, just for my peace of mind, assure that you really followed the steps in :help vimtex-faq-zathura-macos from start to finish? There are 6 steps. Notice that, if you already had Zathura and Girara installed without following these steps, then it is strongly recommended to first uninstall and unlink them before you start with step 1.

I follow the procedure and do again, still the same. Because the default homebrew install directory is different with x86-64, i change <auth> <\auth> in /opt/homebrew/opt/dbus/share/dbus-1/session.conf. I list the structure as below:

├── session.conf
└── system.conf

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

I have a feeling that it's a bad sign that the dbus service is stopped. But I'm not sure. To be honest, I don't quite know how to proceed from here.

You seem to think that the problem has to do with x86-64; perhaps you are right. I don't really think so, but I can't be sure.

Sorry that I'm not able to be of more help. As an optional solution, I propose that you use Skim. It should work well, even though I understand that you would prefer Zathura.

@EdwardWong1994
Copy link
Author

I have a feeling that it's a bad sign that the dbus service is stopped. But I'm not sure. To be honest, I don't quite know how to proceed from here.

You seem to think that the problem has to do with x86-64; perhaps you are right. I don't really think so, but I can't be sure.

Sorry that I'm not able to be of more help. As an optional solution, I propose that you use Skim. It should work well, even though I understand that you would prefer Zathura.

It is ok. Appreciate for all of your help. I have to compromise to skim but there are still one thing using skim. The skim can jump out when i use vim -u test.vim test.tex, but will not pop out using vim -u test.tex, do you have any idea solving this.

@lervag
Copy link
Owner

lervag commented Jul 1, 2022

It is ok. Appreciate for all of your help.

I'm glad to hear it. I hope you somehow figure it out; if you do, please give an update, as it may be helpful to others.

I have to compromise to skim but there are still one thing using skim. The skim can jump out when i use vim -u test.vim test.tex, but will not pop out using vim -u test.tex, do you have any idea solving this.

vim -u test.tex will not work, because -u takes a vimrc like argument (a vimscript file for vim initialization).

And yes, I have ideas. First, you really should note what we mentioned earlier, that you want to use a Vim with +clientserver. If you open Vim with vim and do :version, you will see a list of features. It should include +clientserver. If it does not, then you should install a Vim that has this feature (don't ask me how; I don't use MacOS!). In addition, you really should read the :help vimtex-clientserver section in the docs.

Next, I'm assuming that this is still your vimrc file. The following is a slightly cleaned up version where I've removed the comments (you can add them back if you want) and updated the VimTeX related configuration for you. I've grouped things, removed duplicate options and similar. I still think it is somewhat messy, but it should be better. Can you test with the following vimrc file and report if Skim works as expected? I.e., to be fully clear:

  1. Copy the below vimrc and replace it with your own.
  2. In your example directory, do vim example.tex.
  3. Confirm that \ll compiles the file and \lv opens Skim. Notice, again, that Skim will not open automatically after \ll unless the clientserver stuff is correct.
" Options
set encoding=utf-8
set modelines=0
set backspace=2
set nowritebackup
set nocp
set clipboard+=unnamed
set nu
set history=100
set autoread
set nobackup
set nowb
set noswapfile
set mouse=a
set selection=exclusive
set selectmode=mouse,key
set cursorline
set novisualbell
set laststatus=2
set showcmd
set ruler
set cmdheight=3
set complete+=kspell
set completeopt=menuone,longest
"set completeopt=longest,menu
set shortmess+=c
set showmatch
set ignorecase
set hlsearch
set incsearch
set autoindent
set smartindent
set cindent
set tabstop=4
set wildmenu
set shellslash
set hidden
set updatetime=300
if has("nvim-0.5.0") || has("patch-8.1.1564")
  set signcolumn=number
else
  set signcolumn=yes
endif
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
set foldenable

" Load plugins
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'git://git.wincent.com/command-t.git'
Plugin 'xuhdev/vim-latex-live-preview'
Plugin 'lervag/vimtex'
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'scrooloose/nerdtree'
Plugin 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'tiagofumo/vim-nerdtree-syntax-highlight'
Plugin 'ryanoasis/vim-devicons'
Plugin 'airblade/vim-gitgutter'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'prettier/vim-prettier', { 'do': 'yarn install' }
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'yaegassy/coc-pylsp', {'do': 'yarn install --frozen-lockfile'}
Plugin 'morhetz/gruvbox'
Plugin 'HerringtonDarkholme/yats.vim'
Plugin 'neoclide/coc-snippets'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'
Plugin 'mzlogin/vim-markdown-toc'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'ferrine/md-img-paste.vim'
Plugin 'junegunn/goyo.vim'
call vundle#end()

colorscheme gruvbox

" I believe you can remove the following lines, because I think Vundle includes
" them with "vundle#end()"
"filetype plugin indent on
"syntax on

" Plugin configuration
let g:UltiSnipsExpandTrigger = "<Tab>"
let g:UltiSnipsListSnippets = "<c-Tab>"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
let g:UltiSnipsSnippetsDirectories=[$HOME.'/.vim/bundle/vim-snippets/UltiSnips', "~/.vim/UltiSnips"]

let g:livepreview_previewer='zathura'
let g:livepreview_engine='latexmk'

let g:vimtex_view_method = 'skim'
let g:vimtex_quickfix_mode = 1

let g:vim_markdown_math=1

let g:mdip_imgdir='~/Desktop/screenshot/markdown'
let g:mdip_imgname='image'

let g:mkdp_auto_start = 1
let g:mkdp_refresh_slow = 0
let g:mkdp_command_for_global = 1
let g:mkdp_browser = '/Applications/Google Chrome.app'
let g:mkdp_markdown_css='~/Desktop/WCC/markdown/github-css-sytle-markdown/github-markdown-css'

let g:vim_markdown_folding_level=6
autocmd Filetype markdown nmap <C-s> <Plug>MarkdownPreview
autocmd Filetype markdown nmap <C-z> <Plug>MarkdownPreviewStop
autocmd Filetype markdown map <C-q> <Plug>MarkdownPreviewToggle
autocmd Filetype markdown nnoremap <silent> <C-w>:call mdip#MarkdownClipboardImage()<CR>F%i
autocmd Filetype markdown noremap <buffer> <C-x>  :GenTocMarked
autocmd Filetype markdown  nnoremap <silent> <C-c> :UpdateToc

let g:WebDevIconsUnicodeDecorateFolderNodes = 1

let g:NERDTreeGitStatusWithFlags = 1
let g:NERDTreeGitStatusNodeColorization = 1
let g:NERDTreeGitStatusIndicatorMapCustom = {
                \ 'Modified'  :'',
                \ 'Staged'    :'',
                \ 'Untracked' :'',
                \ 'Renamed'   :'',
                \ 'Unmerged'  :'',
                \ 'Deleted'   :'',
                \ 'Dirty'     :'',
                \ 'Ignored'   :'',
                \ 'Clean'     :'✔︎',
                \ 'Unknown'   :'?',
                \ }
let g:NERDTreeGitStatusWithFlags = 1
let g:NERDTreeIgnore = ['^node_modules$']

function! IsNERDTreeOpen()
  return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction
function! SyncTree()
  if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
    NERDTreeFind
    wincmd p
  endif
endfunction

autocmd BufEnter * call SyncTree()
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif

let g:prettier#autoformat = 1
command! -nargs=0 Prettier :CocCommand prettier.formatFile

let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']

let g:coc_snippet_next='<tab>'
let g:coc_global_extensions = [
  \ 'coc-snippets',
  \ 'coc-pairs',
  \ 'coc-tsserver',
  \ 'coc-eslint',
  \ 'coc-prettier',
  \ 'coc-json',
  \ 'coc-vimlsp',
  \ 'coc-css',
  \ 'coc-diagnostic',
  \ 'coc-explorer',
  \ 'coc-flutter-tools',
  \ 'coc-gitignore',
  \ 'coc-html',
  \ 'coc-lists',
  \ 'coc-python',
  \ 'coc-syntax',
  \ 'coc-todolist',
  \ 'coc-translator',
  \ 'coc-tslint-plugin',
  \ 'coc-vetur',
  \ 'coc-yaml',
  \ 'coc-yank',
  \ 'coc-translator',
  \ 'coc-vimtex'
  \]

command! -nargs=0 Format :call CocAction('format')
command! -nargs=? Fold :call     CocAction('fold', <f-args>)
command! -nargs=0 OR   :call     CocAction('runCommand', 'editor.action.organizeImport')

augroup mygroup
  autocmd!
  autocmd CursorHold * silent call CocActionAsync('highlight')
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

" Autocommands
autocmd BufWrite /private/tmp/crontab.* set nowritebackup nobackup
autocmd BufWrite /private/etc/pw.* set nowritebackup nobackup
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complet

" Configuration for options and similar
let skip_defaults_vim=1
let g:pydiction_location = '/Users/wangchenchen/.vim/tools/pydiction/complete-dict'
let g:pydiction_menu_height=20

" Mappings
inoremap jk <ESC>
nmap <C-f> :NERDTreeToggle<CR>
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
nmap tt :TTemplate
vmap ++ <plug>NERDCommenterToggle
nmap ++ <plug>NERDCommenterToggle
inoremap <expr> <Down>  pumvisible() ? "<C-n>" :"<Down>"
inoremap <expr> <Up>  pumvisible() ? "<C-p>" : "<Up>"
inoremap <expr> <Right>  pumvisible() ? "<C-y>" : "<Right>"
inoremap <expr> <CR> pumvisible() ? "<C-y>" :"<CR>"
inoremap <expr> <Left>  pumvisible() ? "<C-e>" : "<Left>"

inoremap <silent><expr> <TAB>
          \ pumvisible() ? "\<C-n>" :
          \CheckBackspace()?"\<TAB>":
          \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:CheckBackspace() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction
inoremap <silent><expr> <c-o> coc#refresh()
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
nnoremap <silent> K :call <SID>ShowDocumentation()<CR>
function! ShowDocumentation()
  if CocAction('hasProvider', 'hover')
    call CocActionAsync('doHover')
  else
    call feedkeys('K', 'in')
  endif
endfunction

nnoremap aa :CocCommand explorer<CR>
nmap <leader>rn <Plug>(coc-rename)
xmap <leader>f  <Plug>(coc-format-selected)
nmap <leader>f  <Plug>(coc-format-selected)
xmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>a  <Plug>(coc-codeaction-selected)
nmap <leader>ac  <Plug>(coc-codeaction)
nmap <leader>qf  <Plug>(coc-fix-current)
nmap <leader>cl  <Plug>(coc-codelens-action)
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
nmap <silent> <C-d> <Plug>(coc-range-select)
xmap <silent> <C-d> <Plug>(coc-range-select)
nnoremap <silent> <space>a  :<C-u>CocList diagnostics<cr>
nnoremap <silent> <space>e  :<C-u>CocList extensions<cr>
nnoremap <silent> <space>c  :<C-u>CocList commands<cr>
nnoremap <silent> <space>o  :<C-u>CocList outline<cr>
nnoremap <silent> <space>s  :<C-u>CocList -I symbols<cr>
nnoremap <silent> <space>j  :<C-u>CocNext<CR>
nnoremap <silent> <space>k  :<C-u>CocPrev<CR>
nnoremap <silent> <space>p  :<C-u>CocListResume<CR>

" You may want to try similar mappings from VimTeX (:help vimtex-imaps)
"autocmd FileType tex inoremap ,alpha    \alpha
"autocmd FileType tex inoremap ,beta     \beta
"autocmd FileType tex inoremap ,gamma    \gamma
"autocmd FileType tex inoremap ,delta    \delta
"autocmd FileType tex inoremap ,del      \Delta
"autocmd FileType tex inoremap ,epsilon  \epsilon
"autocmd FileType tex inoremap ,zeta     \zeta
"autocmd FileType tex inoremap ,eta      \eta
"autocmd FileType tex inoremap ,theta    \theta
"autocmd FileType tex inoremap ,kappa    \kappa
"autocmd FileType tex inoremap ,lambda   \lambda
"autocmd FileType tex inoremap ,mu       \mu
"autocmd FileType tex inoremap ,nu       \nu
"autocmd FileType tex inoremap ,pi       \pi
"autocmd FileType tex inoremap ,rho      \rho
"autocmd FileType tex inoremap ,sigma    \sigma
"autocmd FileType tex inoremap ,tau      \tau
"autocmd FileType tex inoremap ,phi      \phi
"autocmd FileType tex inoremap ,Phi      \Phi
"autocmd FileType tex inoremap ,psi      \psi
"autocmd FileType tex inoremap ,omega    \omega

@EdwardWong1994
Copy link
Author

Thanks for your kind help. @lervag. You are very nice. I need to put this things down a bit cause i need to prepare my oral qualifying exam. After that, i will go back to solve this problem again. Once i have solution, i will also update here.

@vectorsss
Copy link

Thanks for your kind help. @lervag. You are very nice. I need to put this things down a bit cause i need to prepare my oral qualifying exam. After that, i will go back to solve this problem again. Once i have solution, i will also update here.

Hi, Edward! Have you fixed this problem? I met the same issue.

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

No branches or pull requests

4 participants