lervag / vimtex

VimTeX: A modern Vim and neovim filetype plugin for LaTeX files.
MIT License
5.57k stars 391 forks source link

problem about #402

Closed hanqing0521 closed 8 years ago

hanqing0521 commented 8 years ago

Explain the issue

my system is feodra 22 . I just write my physics paper by vimtex. There are some problem.

  1. sometimes, my equations( \ref{labels} ) will show ?? . this is a real random thing.
  2. you know, After run lk(K) the compile should be stop and # kill the compile proccess. But i also find a process\ /usr/bin/perl -w /user/bin/latexm**k ....... more terrible, more this process more slow my pc. and then i find vimtex will clean and run again automatically ( open a file manage application you will find it)

I do not think this is a conflict.

lervag commented 8 years ago

These are two separate and unrelated issues. It's OK for now, but please consider in the future to open separate issues in separate threads.

Regarding the first problem: If I understand correctly, you are saying that the compiled pdf document shows ?? in some random cases. To me, this sounds like something that is completely unrelated to vimtex. Instead, I think it has to do with your code and/or latex in general. For example, if you mistype the label inside the \ref{...}, or if the document is not properly compiled for some reason.

Regarding the second problem: This used to be a problem. Please make sure that you are using the latest version of vimtex. If the problem persists, please explain exact steps for how to reproduce the problem. In addition, it is helpful if you can mention which Vim version you are on.

hanqing0521 commented 8 years ago

After I find that problem I update my vimtex, so now it is the last version. fortunately, it can show right label. I test almost ten times it work well. but the latexmk process also run after stop by lk(K) /usr/bin/latexmk -verbose -pdf -e $pdflatex =~ s/ / -file-line-error / ... and if i run ll two times there are two this process. In my opinion there should be only one compile process an it should be killed when I stop or reload vimtex or stop compile or close my vim. thank you

hanqing0521 commented 8 years ago

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 20 2015 09:52:41) 包含补丁: 1-207, 209-801, 803-808, 810-827 修改者 bugzilla@redhat.com 编译者 bugzilla@redhat.com 巨型版本 无图形界面。 可使用(+)与不可使用(-)的功能: +acl +farsi +mouse_netterm +syntax +arabic +file_in_path +mouse_sgr +tag_binary +autocmd +find_in_path -mouse_sysmouse +tag_old_static -balloon_eval +float +mouse_urxvt -tag_any_white -browse +folding +mouse_xterm -tcl ++builtin_terms -footer +multi_byte +terminfo +byte_offset +fork() +multi_lang +termresponse +cindent +gettext -mzscheme +textobjects -clientserver -hangul_input +netbeans_intg +title -clipboard +iconv +path_extra -toolbar +cmdline_compl +insert_expand +perl +user_commands +cmdline_hist +jumplist +persistent_undo +vertsplit +cmdline_info +keymap +postscript +virtualedit +comments +langmap +printer +visual +conceal +libcall +profile +visualextra +cryptv +linebreak +python/dyn +viminfo +cscope +lispindent +python3/dyn +vreplace +cursorbind +listcmds +quickfix +wildignore +cursorshape +localmap +reltime +wildmenu +dialog_con +lua/dyn +rightleft +windows +diff +menu +ruby/dyn +writebackup +digraphs +mksession +scrollbind -X11 -dnd +modify_fname +signs -xfontset -ebcdic +mouse +smartindent -xim +emacs_tags -mouseshape -sniff -xsmp +eval +mouse_dec +startuptime -xterm_clipboard +ex_extra +mouse_gpm +statusline -xterm_save +extra_search -mouse_jsbterm -sun_workshop -xpm 系统 vimrc 文件: "/etc/vimrc" 用户 vimrc 文件: "$HOME/.vimrc" 第二用户 vimrc 文件: "~/.vim/vimrc" 用户 exrc 文件: "$HOME/.exrc" $VIM 预设值: "/etc" $VIMRUNTIME 预设值: "/usr/share/vim/vim74" 编译方式: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall - Werror=format-security -fexceptions -fstack-protector-strong --param=ssp-buffer- size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 - U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
链接方式: gcc -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld - fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,- z,relro -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -L/usr/local/lib -Wl,--as-needed -o vim -lm -lnsl -lselinux -lncurses -lacl -lattr -lgpm -ldl
-Wl,--enable-new-dtags -Wl,-z,relro -Wl,-z,relro -fstack-protector-strong - L/usr/local/lib -L/usr/lib64/perl5/CORE -lperl -lpthread -lresolv -lnsl -ldl -lm - lcrypt -lutil -lc

lervag commented 8 years ago

Of course, if you kill the process, it should die. But as I asked before, I need more info in order to investigate! Please, read the issue template. I want a minimal vimrc file and a minimal tex file, as well as detailed steps for how to reproduce the problem.

You mentioned you were using Fedora 22. I also see you have a relatively recent version of Vim. Which version of latexmk and pgrep do you have? pgrep --version and latexmk --version.

hanqing0521 commented 8 years ago

Ok as your require, show my files for you. I give you the file of my laptop which is fedora 23 with same problem. and vim are same configure and version.

> pgrep --version
pgrep from procps-ng 3.3.10

 > latexmk --version
Latexmk, John Collins, 5 February 2015. Version 4.43a
\documentclass{article}
\usepackage{graphics}
\begin{document}
Hello world!   Fig.\ref{Eq:cos}
\begin{equation}
  f(x)=cos(x)
  \label{Eq:cos}
\end{equation}
\end{document}
set nocampatible 
......................
filetype plugin indent on
....................................
*"-----------vimtex----------*
*let &rtp  = '~/.vim/bundle/vimtex,' . &rtp*
*let &rtp .= ',~/.vim/bundle/vimtex/after'*
*"----------------fortran--------------*
*let fortran_free_source=1*
*"-----------------latex---------------*
*let g:tex_conceal = ''*
*let @e='o\begin{YourEnvironment}*
*\end{YourEnvironmentjkkb'*
*"-------------------some maps--------------*
*imap <c-l> <Right>*
*nnoremap w <ESC>:w<CR>*
*nnoremap <localleader>qq :q<CR>*
*nnoremap <localleader>qa :qa<CR>*
*"autocmd CursorMovedI * if pumvisible() == 0|pclose|endif*
*"autocmd InsertLeave *,if pumvisible() == 0|pclose|endif*
*set shiftwidth=4*
*set t_Co=256*
lervag commented 8 years ago

Wow, you should REALLY learn to write replies/comments in markdown! See the mardkown links provided by github as an example, i.e. this.

However, the information seems good. One thing: Does your vim file really say set nocampatible? It should be set nocompatible. Also, the vim configuration file you sent seems very strange. Did you leave a lot of stuff out? Could you please, again, use a MINIMAL vimrc file as I've already described before? And I've also asked several times now for a complete and detailed description for how to reproduce you problem. Perhaps you don't understand what I mean?

Let me instead ask this. Could you do the following steps and report the outcome?

  1. Ensure that there are NO latexmk processes currently alive
  2. Open vim (or du you use gvim?)
  3. Open a LaTeX file
  4. Report output from \li (or :VimtexInfo)
  5. Do \ll to start compilation
  6. Report output from \li again (this should now show a nonzero PID for the latexmk process)
  7. On the terminal, verify that there is a single latexmk process with the same PID as the one you see in step 5
  8. Do \ll or \lk to stop/abort the compilation
  9. Again report output from \li
  10. Again check the terminal to see if there remains a latexmk process

Finally, please don't simply reply to the email as you've done before. Please go to the github site and write a full comment with proper formatting. It makes it much easier for me to understand what you write!

hanqing0521 commented 8 years ago

Sorry this is my first time to write a issue in github. thank you for reading my obscure infomation. In fact, I even do not understand your mean of minimal vimrc, so I give you a part you may want. but now I give you my full $HOME/.vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
"---------------------------------------------------
Plugin 'https://github.com/Shougo/neocomplete.vim'
Plugin 'https://github.com/terryma/vim-multiple-cursors'
Plugin 'https://github.com/jiangmiao/auto-pairs'
Plugin 'https://github.com/Shougo/neoinclude.vim'
Plugin 'https://github.com/scrooloose/nerdtree.git'
Plugin 'https://github.com/tpope/vim-surround'
Plugin 'https://github.com/godlygeek/tabular'
Plugin 'https://github.com/scrooloose/syntastic'
Plugin 'https://github.com/bling/vim-airline'
"Plugin 'https://github.com/Rip-Rip/clang_complete'
Plugin 'https://github.com/vim-scripts/AutoComplPop'
"Plugin 'https://github.com/ervandew/supertab'
Plugin  'https://github.com/mbbill/undotree'
"Plugin 'https://github.com/vim-scripts/fcitx.vim'
Plugin 'https://github.com/vim-scripts/SyntaxComplete'
Plugin 'https://github.com/kien/ctrlp.vim'
Plugin 'https://github.com/dyng/ctrlsf.vim'
Plugin 'https://github.com/yonchu/accelerated-smooth-scroll'
Plugin 'https://github.com/Shougo/neco-syntax'
Plugin 'https://github.com/Yggdroot/indentLine'
Plugin 'https://github.com/vim-scripts/Conque-GDB'
Plugin 'https://github.com/lervag/vimtex'
" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
"----------------leadermap-----
let maplocalleader = ','
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"-------------------------------------------------------------------------------------------
"--------------------neocomplete-------------------
"Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'

" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }

" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
    let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplete#undo_completion()
inoremap <expr><C-l>     neocomplete#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return (pumvisible() ? "\<C-y>" : "" ) . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? "\<C-y>" : "\<CR>"
endfunction
" <TAB>: completion.
" ---- lixun delete the tab completion ----
"inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? "\<C-y>" : "\<Space>"

" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
set completeopt-=preview
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
  let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
"------------------syntastic----------------------
"execute pathogen#infect()
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0

    let g:syntastic_mode_map = {
        \ "mode": "active",
        \ "active_filetypes": ["ruby", "php"],
        \ "passive_filetypes": ["tex"] }

nmap <F8> <ESC>:SyntasticCheck<CR>
imap <F8> <ESC>:SyntasticCheck<CR>
nmap <S-F8> <ESC>:SyntasticReset<CR>
imap <S-F8> <ESC>:SyntasticReset<CR>
"----- nerdtree ---------------------
"autocmd vimenter * NERDTree
"autocmd StdinReadPre * let s:std_in=1
"autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"" close windows if only a explorer windows on left
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif 
nnoremap  <localleader>E :NERDTreeToggle<CR><C-w>l
"-------------------vim-airline------------------
set laststatus=2
let g:airline#extensions#tabline#left_sep=' '
let g:airline#extensions#tabline#left_alt_sep='|'
"----------------undotree---------------------
if has("persistent_undo")
    set undodir='~/.undodir/'
    set undofile
endif
"-------------------CtrlSF------------------
nmap     <localleader>ff <Plug>CtrlSFPrompt
vmap     <localleader>ff <Plug>CtrlSFVwordPath
vmap     <localleader>fF <Plug>CtrlSFVwordExec
nmap     <localleader>fn <Plug>CtrlSFCwordPath
nmap     <localleader>fp <Plug>CtrlSFPwordPath
nnoremap <localleader>fo :CtrlSFOpen<CR>
nnoremap <localleader>ft :CtrlSFToggle<CR>
inoremap <C-F>ft <Esc>:CtrlSFToggle<CR>

"------------------------------------syntaxcomplete------------------
 if has("autocmd") && exists("+omnifunc")
    autocmd Filetype *
            \   if &omnifunc == "" |
            \       setlocal omnifunc=syntaxcomplete#Complete |
            \   endif
    endif
"------------------------
"-----------vimtex----------
let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
"----------------fortran--------------
let fortran_free_source=1
"-----------------latex---------------
let g:tex_conceal = ''
let @e='o\begin{YourEnvironment}
\end{YourEnvironmentjkkb'
"-------------------some maps--------------
imap <c-l> <Right>
nnoremap w <ESC>:w<CR>
nnoremap <localleader>qq :q<CR>
nnoremap <localleader>qa :qa<CR>
"autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
"autocmd InsertLeave *,if pumvisible() == 0|pclose|endif
set shiftwidth=4
set t_Co=256

Following your 10 step

  1. No latexmk runing
  2. I use vim
  3. open a minimal tex (hello_world.tex)

    \documentclass{article} 
    \usepackage{graphics}
    \begin{document} 
    Hello world! Fig.\ref{Eq:cos} 
    \begin{equation}
     f(x)=cos(x) 
     \label{Eq:cos} 
    \end{equation} 
    \end{document}
  4. Output from \li

    b:vimtex : hello_world
     pid : 0
     root : '/home/lixun/Documents/tex/test'
     aux : '/home/lixun/Documents/tex/test/hello_world.aux'
     log : '/home/lixun/Documents/tex/test/hello_world.log'
     out : '/home/lixun/Documents/tex/test/hello_world.pdf'
     tex : '/home/lixun/Documents/tex/test/hello_world.tex'
     base : 'hello_world.tex'
     viewer
       init : function('428')
       view : function('429')
       latexmk_append_argument : function('430')
  5. Output info after \ll

    b:vimtex : hello_world
     pid : 0
     root : '/home/lixun/Documents/tex/test'
     aux : '/home/lixun/Documents/tex/test/hello_world.aux'
     log : '/home/lixun/Documents/tex/test/hello_world.log'
     out : '/home/lixun/Documents/tex/test/hello_world.pdf'
     tex : '/home/lixun/Documents/tex/test/hello_world.tex'
     tmp : '/tmp/vMYG8Yo/4'
     cmd_latexmk_compile : 'cd ''/home/lixun/Documents/tex/test'' && max_print_line=2000
     latexmk -verbose -pdf  -e ''$pdflatex =~ s/ / -file-line-error /'' -pvc -e ''$success_
     cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(1)\""'' -e ''$f
    ailure_cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(0)\""''
    -e ''$pdf_previewer = "xdg-open"'' ''hello_world.tex'' >/tmp/vMYG8Yo/4 2>&1'
     base : 'hello_world.tex'
     viewer
         init : function('428')
         view : function('429')
         latexmk_append_argument : function('430')
  6. There is only one latexmk process
  7. If i run \ll ,it wil start a new latexmk process . after \lk process still run .it use my 1% cpu and memory.
  8. \li agin

    b:vimtex : hello_world
     pid : 0
     root : '/home/lixun/Documents/tex/test'
     aux : '/home/lixun/Documents/tex/test/hello_world.aux'
     log : '/home/lixun/Documents/tex/test/hello_world.log'
     out : '/home/lixun/Documents/tex/test/hello_world.pdf'
     tex : '/home/lixun/Documents/tex/test/hello_world.tex'
     tmp : '/tmp/vMYG8Yo/6'
     cmd_latexmk_compile : 'cd ''/home/lixun/Documents/tex/test'' && max_print_line=2000
    latexmk -verbose -pdf  -e ''$pdflatex =~ s/ / -file-line-error /'' -pvc -e ''$success_
    cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(1)\""'' -e ''$f
    ailure_cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(0)\""''
    -e ''$pdf_previewer = "xdg-open"'' ''hello_world.tex'' >/tmp/vMYG8Yo/6 2>&1'
     base : 'hello_world.tex'
     viewer
       init : function('428')
       view : function('429')
       latexmk_append_argument : function('430')
  9. Now there are two processes . and now i close my vim, also two processes

I hope it may help you.

lervag commented 8 years ago

Thanks, now we're getting somewhere! I don't mean to be rude, and I can understand that there are some things to learn if you are new to github. Notice that I've updated your comment so that the code blocks are highlighted. I recommend that you read more about Markdown and learn to write good and formatted comments, since that will make it easier for me and others to understand what you want/mean.

What I mean with a minimal vimrc file is that instead of your normal vimrc file, you make a temporary file, call it minivimrc. This file may for instance look like this:

set nocompatible
let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'
filetype plugin indent on
syntax enable

" Vimtex options go here

As you see, it is a very short file. You must update the paths, that is, ~/.vim/bundle/vimtex is correct for me, but it might not be for you. With a minimal LaTeX file, you can now use the minimal vimrc as follows: vim -u minivimrc mwe.tex (or gvim if you prefer). This will open the mwe.tex file with the minimal vimrc file. The reason for doing all this is to verify and check that the problem is really with vimtex, and not with other settings or plugins.

So, to the steps. Notice that in step 5, the PID is still 0. It should be set to the real PID of the latexmk process. This implies that there is a problem with detecting the PID, and without the PID, vimtex can't kill the process.

The next step is now more difficult, but we'll try: Open the file in the vimtex repo: autoload/vimtex/latexmk.vim at line 527. Add these lines above:

echom 'start'
echom system('pgrep -nf "^perl.*latexmk"')
echom 'finish'

Now open the example file and start compilation again. You should see some messages, including the start and finish, and hopefully something in between. If the messages go away, do :messages to print them again. Please copy the messages here, so I can see them.

Finally: I would be happy if you could repeat the first 5 steps in my previous post with a minimal vimrc file. Please report back whether the PID is still 0 with the minimal vimrc file. If it is not 0, then this will imply that the problem might be due to something in your real vimrc file.

hanqing0521 commented 8 years ago

1. about minimal vimrc and 0 process

Now i understand your meaning , using my your minimal vimrc install of my vimrc. As you see my full vimrc, i install vimtex by vundle. i also check vimtex path. it's right1! under minimal vimrc there are problems the same, without any difference.

vimtexinfo

  pid : 0
  root : '/home/lixun/Documents/tex/test'
  aux : '/home/lixun/Documents/tex/test/hello_world.aux'
  log : '/home/lixun/Documents/tex/test/hello_world.log'
  out : '/home/lixun/Documents/tex/test/hello_world.pdf'
  tex : '/home/lixun/Documents/tex/test/hello_world.tex'
  base : 'hello_world.tex'
  viewer
    init : function('17')
    view : function('18')
    latexmk_append_argument : function('19') 

run VimtexStop show can not kill process (it can't find pid)

2. modified vimtex code

run VimtexCompile I don't find infomation about start and finish... :message

简体中文消息维护者: Yuheng Xie <elephant@linux.net.cn>
"hello_world.tex" 9L, 179C
已位于最旧的改变
请按 ENTER 或其它命令继续

I run VimtexStatus --latexmk status: not running open my tex file with minimal vimrc this is VimtexInfo

pid : 0
  root : '/home/lixun/Documents/tex/test'
  aux : '/home/lixun/Documents/tex/test/hello_world.aux'
  log : '/home/lixun/Documents/tex/test/hello_world.log'
  out : '/home/lixun/Documents/tex/test/hello_world.pdf'
  tex : '/home/lixun/Documents/tex/test/hello_world.tex'
  tmp : '/tmp/vkAcb3L/2'
  cmd_latexmk_compile : 'cd ''/home/lixun/Documents/tex/test'' && max_print_line=2000
latexmk -verbose -pdf  -e ''$pdflatex =~ s/ / -file-line-error /'' -pvc -e ''$success_
cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(1)\""'' -e ''$f
ailure_cmd = "\"vim\" --servername  --remote-expr \"vimtex\#latexmk\#callback(0)\""''
-e ''$pdf_previewer = "xdg-open"'' ''hello_world.tex'' >/tmp/vkAcb3L/2 2>&1'
  base : 'hello_world.tex'
  viewer
    init : function('17')
    view : function('18')
    latexmk_append_argument : function('19')

It seems vimtex can't find my latexmk real pid

lervag commented 8 years ago

First, I noticed that you have

let &rtp  = '~/.vim/bundle/vimtex,' . &rtp
let &rtp .= ',~/.vim/bundle/vimtex/after'

in your own vimrc file. These are not necessary. These lines essentially loads the vimtex plugin, and they are used as part of the minimal vimrc files.

We continue to investigate with the minimal vimrc file and with a simple hello_world file. This time, can you start compilation with \ll, then on the command line/terminal/console type:

> pgrep -nf "^perl.*latexmk"

This should return the PID. Let me know if this works.

hanqing0521 commented 8 years ago

Thank you for you remind, I have delete this two line.

I find some interesting thing after run pgrep -nf "^perl.*latexml":

> pgrep -nf "^perl.*latexmk"
> pgrep -nf "perl.*latexmk"       
32255

From htop:

PID   USER   ....       Command
32255 lixun  ....      /usr/bin/perl -w /user/bin/latexmk -verbose ......

the first word of command is not perl but /usr/bin/perl.

lervag commented 8 years ago

Hmm, that's interesting! Could you try to change the line I mentioned earlier, i.e. this line: Remove the ^, and check if things now work.

hanqing0521 commented 8 years ago

NO, it can not work ..... I mean though I add this line and remove ^ . command message do not show useful info .

lervag commented 8 years ago

Ok, that is very strange. It seems the code isn't even run. Let's try something else. In the same file, latexmk.vim, change lines 187 to 196 (the last part of the function vimtex#latexmk#compile() to this:

  echom 'start'
  call vimtex#util#execute(exe)
  echom 1

  if g:vimtex_latexmk_continuous
    echom 2
    call s:latexmk_set_pid()
    echom 3
    call vimtex#echo#status(['latexmk compile: ',
          \ ['VimtexSuccess', 'started continuous mode']])
  else
    call vimtex#echo#status(['latexmk compile: ',
          \ ['VimtexSuccess', 'compiling ...']])
  endif
  echom 'finish'

Now repeat the above test. The output should be:

start
1
2
3
finish
hanqing0521 commented 8 years ago

yes, it show

hello_world.tex" 9L, 179C
start
1
2
3
finish

and then what should i do?

lervag commented 8 years ago

Now go to the function s:latexmk_set_pid() and edit so that it becomes like this:

echom "a1"
if has('win32')
  echom "a2"
  let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
  let pidinfo = split(system(pidcmd), '\n')[-1]
  let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
else
  echom "a31" b:vimtex.pid
  let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
  echom "a32" b:vimtex.pid
  "let b:vimtex.pid = str2nr(system('pgrep -nf "^perl.*latexmk"')[:-2])
endif
echom "a3"

Rerun the test.

hanqing0521 commented 8 years ago
1
2
a1
a31 0
a3
latexmk compile: started continuous mode
finish
lervag commented 8 years ago

Strange. Now we decompose the system line, i.e. use this:

if has('win32')
  let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
  let pidinfo = split(system(pidcmd), '\n')[-1]
  let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
else
  let l:test = system('pgrep -nf "perl.*latexmk"')
  echom string(l:test)
  let l:test = l:test[:-2]
  echom string(l:test)
  let l:test_2 = str2nr(l:test)
  echom string(l:test_2)
  let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
endif

Again, report the new output.

hanqing0521 commented 8 years ago
function! s:latexmk_set_pid() " {{{1
527   "echom "a1"
528   if has('win32')
529   ¦ let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
530   ¦ let pidinfo = split(system(pidcmd), '\n')[-1]
531   ¦ let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
532   ¦ "echom 'start'
533   ¦ "echom system('pgrep -nf "perl.*latexmk"')
534   ¦ "echom 'finish'
535   else
536   ¦ "echo "a31" b:vimtex.pid
537   ¦ let l:test = system('pgrep -nf "perl.*latexmk"')
538   ¦ echom string(l:test)
539   ¦ let l:test = l:test[:-2]
540   ¦ echom string(l:test)
541   ¦ let l:test_2 = str2nr(l:test)
542   ¦ echom string(l:test_2)
543   ¦ let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
544   endif 
545   "echom "a3"
546 endfunction

output

~                                                                                                                                                                           
1
2
'19172^@'
'19172'
19172
latexmk compile: started continuous mode
finish
lervag commented 8 years ago

Hmm. That's strange. Try this one:

if has('win32')
  let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
  let pidinfo = split(system(pidcmd), '\n')[-1]
  let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
else
  echom 'xx ' b:vimtex.pid type(b:vimtex.pid)
  unlet b:vimtex.pid
  let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
  echom 'yy ' b:vimtex.pid type(b:vimtex.pid)
endif
hanqing0521 commented 8 years ago

**First ,It work well after do your

if has('win32')
  let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
  let pidinfo = split(system(pidcmd), '\n')[-1]
  let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
else
  let l:test = system('pgrep -nf "perl.*latexmk"')
  echom string(l:test)
  let l:test = l:test[:-2]
  echom string(l:test)
  let l:test_2 = str2nr(l:test)
  echom string(l:test_2)
  let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
endif

:Vimtexstop can kill process and :VimCompile can promise only one compile process

then I will finish your last require...

hanqing0521 commented 8 years ago

function

if has('win32')
529   ¦ let pidcmd = 'tasklist /fi "imagename eq latexmk.exe"'
530   ¦ let pidinfo = split(system(pidcmd), '\n')[-1]
531   ¦ let b:vimtex.pid = str2nr(split(pidinfo,'\s\+')[1])
532   ¦ "echom 'start'
533   ¦ "echom system('pgrep -nf "perl.*latexmk"')
534   ¦ "echom 'finish'
535   else
536   ¦ "echo "a31" b:vimtex.pid
537   ¦ "let l:test = system('pgrep -nf "perl.*latexmk"')
538   ¦ "echom string(l:test)
539   ¦ "let l:test = l:test[:-2]
540   ¦ "echom string(l:test)
541   ¦ "let l:test_2 = str2nr(l:test)
542   ¦ "echom string(l:test_2)
543   ¦ "let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
544   ¦ echom 'xx ' b:vimtex.pid type(b:vimtex.pid)
545   ¦ unlet b:vimtex.pid
546   ¦ let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])
547   ¦ echom 'yy ' b:vimtex.pid type(b:vimtex.pid)
548   endif

output

1
2
xx  0 0
yy  20165 0
latexmk compile: started continuous mode
finish

it works well

lervag commented 8 years ago

Hmm, ok. I still works. Now: Remove all the echoes. The only remaining change should be the change from

let b:vimtex.pid = str2nr(system('^pgrep -nf "perl.*latexmk"')[:-2])
" To (remove the hat, ^)
let b:vimtex.pid = str2nr(system('pgrep -nf "perl.*latexmk"')[:-2])

Does it still work?

hanqing0521 commented 8 years ago

I should reinstall vimtex and then change

good it still work

thank your. and i am very curious to know which linux distribution you use?

may you tell me why I com across this problem?

lervag commented 8 years ago

Great! I'm happy it works. I will update and push the change so that it works without manual changes from your side.

lervag commented 8 years ago

Could you do: head $(which latexmk) in your terminal and paste the output here?

hanqing0521 commented 8 years ago

Of Course

  test head $(which latexmk)
#!/usr/bin/perl -w

# !!!!!!!!!! Don't forget to document $silence_logfile_warnings.!!!

# N.B. !!!!!!!!!!!  See 17 July 2012 comments !!!!!!!!!!!!!!!!!!

# On a UNIX-like system, the above enables latexmk to run independently
#   of the location of the perl executable.  This line relies on the 
#   existence of the program /usr/bin/env
# If there is a problem for any reason, you can replace the first line of 
lervag commented 8 years ago

So, that's the reason. Your version of latexmk uses #!/usr/bin/perl -w. My own version (and it seems most people's version) has #!/usr/bin/env perl. It would be interesting to know why your version has this change. Perhaps the env program is not available?

In any case, I think the issue is now solved. Thanks for being patient with my high demands!

I forgot to answer your question: I'm running Arch Linux.

hanqing0521 commented 8 years ago

I do not know why my latexmk use /user/bin/per not /usr/bin/env perl . but i kown env can work. and my fedora23 and fedora22 have this problem the same. *The most important thing is that I change the latexmk as #!/usr/bin/env perl it seems good. maybe it is the common problem in fedora. Just the latexmk has been changed in fedora repo. Thank you for your patience.

lervag commented 8 years ago

No problem. I don't think you need to change anything more, since it now works as it should.