Search code examples
vimlatex

VimWiki - creating markdown files compatible with VimTex - a setup for math notes


Ok

I've read this thread:

https://github.com/vimwiki/vimwiki/issues/69

They're talking about the possibility to convert VimWiki files to LaTeX. This is close to what i'm trying to create in the world of note-taking setups.

What i want is a feature where you have VimWiki as your main index of your note for a class (let's say math), and then can tab in/tab out and create new files where VimTex runs* using VimWikis FollowLink function.

* My VimTex runs in markdown files

An example of a math_index.md for understanding:

# MATH NOTES
 - [[Link to this subject]] - description
 - [[Link to that subject]] - description
.. and so on

Then you follow a link to a file that supports VimTex where you can write your in depth notes.

They are both working perfectly (VimWiki and VimTex) when i try them separately. But can i combine them?


What i've tried:


1.


I've read about changing the file extension (for the child-file) on the fly here with :saveas %:p:r.tex. Then you could have VimWiki creating a normal .md file and then remap a command changing it to .tex for example, but then (of course) the tabbing back and fourth will not work (it's a mess!).

Is it possible to configure the link options so it's not looking for the extension of the file? Then this would work.

2.


VimTex is working with .md files but then :WikiFollowLink can't be called when working in the math_index.md file.

My .vimrc, so .md files have VimTex:

autocmd FileType,BufNewFile,BufFilePre,BufRead *.md set filetype=tex

If i try setting two filetypes with autocmd ... filetype=tex.wiki it is shown when calling :set ft? on a .md file, but the VimWiki functionality is gone. And also - the local command :VimwikiFollowLink can't be triggered. Error when trying: Not an editor command.

I can't seem to figure out how to get this local command to work in a filetype=tex.wiki environment.

3


I've found that VimTex (in their help) has a debugging tool reloading every plugin using for their functionality: :VimtexReload so i thought just going back to plain VimWiki .md setup and then reloading the VimTex in a child file when necessary. But again i'm bound by the command and can't call it in the .md file.


I'm starting in three days (math notes comming up!) :) and would really appreciate any help.

Best


Solution

  • I made it work! ¨

    Change another plugin a little

    Okay, so there is a small vim plugin called Vim Markdown Wiki that is doing the basics of VimWiki - creating file on Enter in an index.file.

    I thought that it would be easier to trigger into creating tex files instead of md files.

    I changed line 90 in the plugin's file: vim-markdown-wiki/after/ftplugin/markdown.vim

    From:

    let extension = fnamemodify(cur_file_name, ":e")

    To:

    let extension = "tex"

    Now it creates .tex files instead of .md files, when you use it.

    Bot how to add the functionality to both .md (markdown) and .tex (LaTeX) files?

    Create a new syntax and add it to both!

    As you can see from before the file in Vim Markdown Wiki that i've changed is called markdown.vim so its local commands are only added to markdown files (.md).

    So. I had a real problem here. How do i add the functionality to both filetypes without ruining some syntax features.

    My own syntax! I changed the filename in my now forked plugin (repo) to links.vim and added that filetype to both filetypes in my .vimrc:

    autocmd FileType,BufNewFile,BufFilePre,BufRead (*.md|*.tex) set filetype+=.links'

    Success!

    Now i can use the regularly shortcuts for VimWiki, if i want to create a markdown file AND i can use the new plugins shortcut - i've set mine in .vimcr:

    nmap z<CR> :MdwiGotoLink<cr>
    nmap x<CR> :MdwiReturn<cr> 
    

    If i want to create a .tex document with LaTeX support.

    Greeeat!!!