chipsenkbeil / vimwiki.nvim

Neovim plugin that offers enhanced and alternative functionality for the vimwiki language.
BSD 2-Clause "Simplified" License
50 stars 0 forks source link

vimwiki-server.nvim

Neovim plugin that offers enhanced and alternative functionality for the vimwiki language. This project uses vimwiki-server (part of the part of the vimwiki-rs family) to power its functionality in combination with the neovim Lua engine to provide all of its vimwiki goodness.

Not compatible with vim!

Table of Contents

  1. Installation
  2. Usage
  3. Contributing
  4. License

1. Installation

Prior to installing this plugin, you must have the vimwiki-server binary available on your path. As vimwiki-server is experimental, this plugin uses git tags to associate it with releases of vimwiki-server to ensure compatibility with a given version. Be sure to pair your plugin with the version of the server you are using!

Additionally, it is recommended to include this plugin alongside vimwiki, although it is not required for the functionality covered by this plugin.

Examples

With vim-plug:

Plug 'vimwiki/vimwiki'
Plug 'chipsenkbeil/vimwiki-server.nvim', { 'tag': 'v0.1.0-alpha.5' }

2. Usage

Code Execution

Within vimwiki, you can define preformatted text blocks, also known as code blocks, using the following syntax:

{{{
some code
is here
}}}

This plugin provides the ability to execute a code block under your cursor through the mapping gx, as seen in this example.

To perform code execution, this plugin spawns a new process and pipes the code within the code block into the process via stdin. In order to know which process to spawn, you need to set a global variable in neovim. For example, to execute python code, you would include this definition:

" For python, send code to repl using stdin
let g:vimwiki_server#code#python = 'python3'

The above pattern is to use g:vimwiki_server#code#<LANG> where <LANG> is replaced with the language used for your code block. For the above definition, your code block needs to have a python label:

{{{python
x = 0
while x < 5:
    print(5)
    x += 1
}}}

If you want to have a default language process that is used when a code block does not have a language associated, you can specify it with g:vimwiki_server#code#default.

Lastly, because code execution is trigger by neovim, there is one special exception to code execution, which is defining the code with the vim language. In this case, the vimscript is evaluated within neovim, which can be used to set mappings, override variables, and more.

{{{vim
" Change our setting by evaluating this vimscript code block
let g:vimwiki_server#code#python = 'python2'

" Print out some information to show in our result
echom 'Finished updating variables'
}}}

Text Objects

This plugin provides several bindings to support selection and operation on general elements within vimwiki files. Check out the example in action.

3. Contributing

TODO

4. License

BSD 2-Clause