2024-08-05 09:04:09 +02:00
@import template.nml
%<make_doc({}, "Getting Started", "Getting Started")>%
2024-11-03 11:52:26 +01:00
#{building_nml} Building NML
2024-08-05 09:04:09 +02:00
You need at least the nightly version of rustc to compile NML.
Instruction for your operating system can be found on [Rust's website](https://forge.rust-lang.org/infra/other-installation-methods.html).
You'll also need liblua 5.4 installed. You can then move the `nml` executable in `target/release/nml` into your `\$PATH`
``cargo build --bin nml`` or for release mode: ``cargo build --release --bin nml``
2024-11-03 11:52:26 +01:00
*(Note: The release build binary is much smaller than the debug build one)*
2024-08-05 09:04:09 +02:00
# Building your first document
* ``nml -i input.nml -o output.html``
# Using the cache
2024-11-03 11:52:26 +01:00
NML relies on sqlite to keep a cache of pre-compiled elements that take a long time to process (e.g $|[kind=inline] \LaTeX|$).
2024-08-05 09:04:09 +02:00
To enable caching, use option `-d` with a path: ``-d cache.db``. You can reuse the same cache for multiple documents and benefit from cached elements.
Note that in directory-processing mode, a cache is required so that only modified ``.nml`` files get reprocessed.
2024-11-03 11:52:26 +01:00
**Elements that will use the cache:**
* All $|[kind=inline] \LaTeX|$ elements
(*NOTE: Upon modification of the $|[kind=inline] \LaTeX|$ environment, they will be reprocessed, see &{#tex_cache}[caption=TeX Cache] for more information*)
* All Graphviz elements
* All code blocks
2024-08-05 09:04:09 +02:00
# Directory-Processing mode
To use directory-processing mode, you need to pass an input directory and an output directory. Directory-processing mode requires that you use a database, so that it knows which documents have already been compiled. If the output directory doesn't exist, it will be automatically created.
Compiling the docs:
2024-11-03 11:52:26 +01:00
``Plain Text
2024-08-05 09:04:09 +02:00
nml -i docs -o docs_out -d cache.db
``
If you modify an ``Plain Text,@import``ed file, you will need to use the ``--force-rebuild`` option, as NML currently doesn't track which files are imported by other files.
2024-11-03 11:52:26 +01:00
# Building the Language Server
NML comes with it's own language server, ready to be used in any LSP-compatible text editor, such as NeoVim.
Build it by using the following command: ``cargo build --bin nmlls`` or for release mode: ``cargo build --release --bin nmlls``
*(Note: The release build binary is much smaller than the debug build one)*
You should move the language server somewhere in your ``$PATH``.
##* Integrating the LSP
Below is a list of integration steps the language server in various editors.
###* NeoVim
The first step is to add the `.nml` extension to NeoVim, so it is recognized:
``Lua
vim.filetype.add({
pattern = {
['.*%.nml'] = 'nml',
},
})
``
Then you need to register the language server in NeoVim. I recommend the ``lsp-zero`` plugin for that purpose:
``Lua
{
"VonHeikemen/lsp-zero.nvim",
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({buffer = bufnr})
end)
lsp_zero.new_client({
name = 'nmlls',
cmd = {'<PATH TO BINARY IF NOT IN $PATH/>nmlls'},
filetypes = {'nml'},
})
end,
}
``