GithubHelp home page GithubHelp logo

donraphaco / neotex Goto Github PK

View Code? Open in Web Editor NEW
178.0 6.0 8.0 12.78 MB

latex live preview - plugin for neovim and vim 8

License: MIT License

Vim Script 100.00%
neovim neovim-plugin vim-plugin latex latexdiff pdf vim8

neotex's Issues

Paths with special characters or spaces don't work

If the pathname of your .tex file has a space the plugin fails to change the directory and then never gets to compiling the latex code. I've created a patch cless/neotex@2c3f26f and while that works it's probably not an ideal way to go about solving this issue.

I'm guessing vim passes the b:neotex_jobexe to the current shell, and I guess that means that how you escape your string depends heavily on your environment. Can the job be executed from python instead, using the subprocess api, or is there a special reason that it needs to be done from vimscript?

Latexdiff clarifications

Could you please clarify how to use latexdiff? I installed your plugin and it works perfectly, exactly what I was looking for, however, I do not see how I can use the diff feature.

[Feature request] Support for certain TeX directives

Hi there and thanks for creating and maintaining this plugin.

This is more of a feature request and less of an issue. I am hoping that neotex can also support certain TeX directives used in other editors and also vimtex. Here's an example of one of the directives:

% !TEX TS-program = lualatex

On editors / plugins that support this, they will automatically use the specified engine to compile their tex file. This is useful as one may use different engines to render their documents, while neotex currently only allows us to specify one engine. I tried setting the variable g:neotex_pdflatex_alternative while in a buffer that that did not work.

Here are two links for your reference about these directives: TeX SE and TeXWorks Docs

Supporting these directives will also resolve #8 through % !TeX root.

[Feature request] Add support for bibtex compilation

It would be great to have an option to compile bibtex references together with the whole document. In essence, a convention that the .bib file should be called the same as the .tex file would be sufficient I think.

As for now I post-compile .aux file with bibtex manually to make the whole thing working.

The general pipeline would be the following (source):

pdflatex <options> doc.tex &&
bibtex doc && # compiles doc.bib
pdflatex && <options> doc.tex
pdflatex <options> doc.tex

Though I think adding it as a permanent pipeline might break the compilation process in case there is no .bib file so it definitely should be an option.

I would try to tuckle the problem myself but I doubt I will succeed in a short term as I'm not a vim-script ninja.

P.S. Sadly, there is no feature-request label to add

[Feature request] compile the main.tex while editing a subfile

Things work fine when I'm in main.tex. But it issues errors when I move to other tex files, for example, files in sections/ subdirectory. So live preview doesn't work when I'm editing non-main files.

Error detected while processing function <SNR>50_latex_compile:
line    7:
E121: Undefined variable: b:neotex_jobexe
E116: Invalid arguments for function jobstart
E15: Invalid expression: jobstart(['bash', '-c', b:neotex_jobexe], {'cwd': expand('%:p:h'), 'on_exit': function('s:job_exit')})

Error on startup

Hi,
i installed neotex via a package manager, and upon opening a .tex file i get the error:

Error detected while processing .../tex.vim:
line 20:
E117: Unknown function: _neotex_init

I looked through the code but unfortunately i know nothing about vimscript or how nvim handles the call to python.
Any help would be appreciated, thanks.

// edit: user error :x

Synctex forward search implementation

First of all, thank you for making this plugin.

I would like to suggest you the implementation of synctex forward search. I've managed to get it working, but its far from good.

Here is my modified version of tex.vim:

if !get(g:, 'neotex_enabled', 1)
    finish
endif

if !exists('s:neotex_loaded')
    if !has('timers')
        echohl Error | echomsg 'NeoTex requires timers support' | echohl None
    endif
    if !has('nvim') && !has('job')
        echohl Error | echomsg 'NeoTex requires neovim or vim 8 with job support' | echohl None
    endif

    let s:neotex_buffer_tempname = tempname()
    if get(g:, 'neotex_latexdiff', 0)
        let s:neotex_preview_tempname = tempname()
    else
        let s:neotex_preview_tempname = s:neotex_buffer_tempname
    endif

    if !exists('g:neotex_delay')
        let g:neotex_delay = 1000
    endif

    augroup _neotex_
        au!
    augroup END

    command! NeoTexOn au! _neotex_ TextChanged,TextChangedI <buffer> call s:latex_compile_delayed()
    command! NeoTexOff au! _neotex_ TextChanged,TextChangedI <buffer>
    command! NeoTex call s:latex_compile(0)
    command! NeoTexFS call s:zathura_forward_search()

    let s:neotex_loaded = 1
endif

let b:neotex_jobexe=''

if get(g:, 'neotex_latexdiff', 0)
    let b:neotex_jobexe .= 'latexdiff '
    if exists('neotex_latexdiff_options')
        let b:neotex_jobexe .= g:neotex_latexdiff_options . ' '
    endif
    let b:neotex_jobexe .= fnameescape(expand('%:t')) . ' ' . s:neotex_buffer_tempname . ' > ' . s:neotex_preview_tempname . ' && '
endif

let b:neotex_jobexe .= get(g:, 'neotex_pdflatex_alternative', 'pdflatex') . ' -shell-escape -jobname=' . fnameescape(expand('%:t:r')) . ' -interaction=nonstopmode' . ' -synctex=1 '
if exists('neotex_pdflatex_add_options')
    let b:neotex_jobexe .= g:neotex_pdflatex_add_options . ' '
endif

let b:neotex_jobexe .= s:neotex_preview_tempname

if get(g:, 'neotex_enabled', 1) == 2
    au! _neotex_ TextChanged,TextChangedI <buffer> call s:latex_compile_delayed()
endif

function! s:job_exit(...)
    if exists('s:job')
        unlet s:job
    endif
endfunction

function! s:latex_compile(_)
    if exists('s:job')
        call s:latex_compile_delayed()
        return
    endif
    call writefile(getline(1, '$'), s:neotex_buffer_tempname)
    if has('nvim')
        let s:job = jobstart(['bash', '-c', b:neotex_jobexe], {'cwd': expand('%:p:h'), 'on_exit': function('s:job_exit')})
    else
        let s:job = job_start(['bash', '-c', b:neotex_jobexe], {'cwd': expand('%:p:h'), 'out_io':'null', 'exit_cb': function('s:job_exit')})
    endif
    if exists('s:timer')
        unlet s:timer
    endif
endfunction

function! s:latex_compile_delayed()
    if exists('s:timer')
        call timer_stop(s:timer)
    endif
    let s:timer = timer_start(g:neotex_delay, function('s:latex_compile'))
endfunction

function! s:zathura_forward_search()
    exec "silent !zathura --synctex-forward ".line(".").":".col(".").":".s:neotex_preview_tempname." ".fnameescape(expand('%:p:r')).".pdf &"
endfunction

There is one caveat. Since the tempfile changes, the function works only if NeoTex has compiled the file in the current session.

I can try to make this implementation if you wish, but I'm totally new to plugins. Let me know if you need something more.

Sorry for bad grammar.

NeoTex on windows chokes on temporary file path

NeoTex doesn't work in neovim on windows (running a build from late march 2017).
Turns out, that the file path of the temporary file ( tempname() ) is not affected by
set shellslash
which should make paths use a forward slash instead of the windows backslash. A pathname such as C:\ble\rex.tex causes errors, while C:/ble/rex.tex is ok.

using
expand(tempname()) seems to be a solution, the following patch fixes this

---
 ftplugin/tex.vim | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ftplugin/tex.vim b/ftplugin/tex.vim
index 4172163..d1d9bcb 100644
--- a/ftplugin/tex.vim
+++ b/ftplugin/tex.vim
@@ -3,9 +3,9 @@ if !get(g:, 'neotex_enabled', 1)
 endif

 if !exists('s:neotex_loaded')
-       let s:neotex_buffer_tempname = tempname()
+       let s:neotex_buffer_tempname = expand(tempname())
        if get(g:, 'neotex_latexdiff', 0)
-               let s:neotex_preview_tempname = tempname()
+               let s:neotex_preview_tempname = expand(tempname())
        else
                let s:neotex_preview_tempname = s:neotex_buffer_tempname
        endif
--

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.