Proofreading
This commit is contained in:
parent
6505b22d90
commit
480e6a38e2
@ -18,11 +18,11 @@ producing typographically sound printable documents that is mostly used by the
|
||||
scientific community (but [not
|
||||
only](https://www.ctan.org/pkg/latex-sciences-humaines)) as it allows writing
|
||||
mathematics formulae in a somewhat *not-that-much painful* way, is shipped with
|
||||
[bibliography engines](https://www.ctan.org/pkg/biblatex), allows easy
|
||||
[bibliography engines](https://www.ctan.org/pkg/biblatex), enables easy
|
||||
cross-referencing and automatically generates table of contents.
|
||||
|
||||
It is based on a markup language that allows the writers to focus on the content
|
||||
of the document and leaves the typesetting to the software (at least most of the
|
||||
It is based on a markup language that allows writers to focus on the content of
|
||||
the document and leaves the typesetting to the software (at least most of the
|
||||
time).
|
||||
It moreover enjoys [many](https://ctan.org/) libraries that span from enabling
|
||||
[new features](https://ctan.org/pkg/algorithm2e) to [simpler
|
||||
@ -115,28 +115,29 @@ following plugins : `vimtex`, `nvim-lspconfig`, `nvim-cmp` and finally
|
||||
Now it is all good and done, but nothing is configured yet, and if you open a
|
||||
LaTeX file in this state, you will only enjoy the benefits of an unconfigured
|
||||
`vimtex`, which is already nice as is it, but not enough to achieve our goal.
|
||||
And it's a bit sad to have install three other plugins for nothing.
|
||||
And it's a bit sad to have installed three other plugins for nothing.
|
||||
|
||||
# vimtex
|
||||
|
||||
It will be a bit anti-climatic after the previous teasing, but we will use
|
||||
`vimtex` as vanilla as possible…
|
||||
However, we still need, to tell it to use `zathura` as a pdf viewer:
|
||||
We still need to tell it to use `zathura` as a pdf viewer:
|
||||
```lua
|
||||
vim.g.vimtex_view_method = "zathura"
|
||||
```
|
||||
|
||||
This will allow `vimtex` to automatically open `zathura` after compilation,
|
||||
which is by default bound to `<LocalLeader>ll`. We now have to define
|
||||
This will allow `vimtex` to automatically open `zathura` upon compilation,
|
||||
which is bound to `<LocalLeader>ll` by default. Meaning that we have to define
|
||||
[`<LocalLeader>`](https://neovim.io/doc/user/map.html#%3CLocalLeader%3E), which
|
||||
I usually set to “`,`”:
|
||||
I usually set to be a comma: “`,`”:
|
||||
```lua
|
||||
vim.g.maplocalleader = ","
|
||||
```
|
||||
|
||||
Now, you can use `,lv` to view the current line in `zathura`, yay.
|
||||
Now, you can use `,lv` to view the current line in `zathura`, and `,ll` to
|
||||
compile your document. Yay!
|
||||
|
||||
More can be then done, such as using vimtex folds, which are not enabled by
|
||||
More can be then done, such as using vimtex folds, which are disabled by
|
||||
default (contrary to what [vim-latex](https://github.com/vim-latex/vim-latex)
|
||||
was doing, which is the former plugin I used):
|
||||
|
||||
@ -154,13 +155,14 @@ is possible now:
|
||||
|
||||
- Compile the document: `,ll`
|
||||
- This also automatically generates a [quickfix
|
||||
buffer](https://vimhelp.org/quickfix.txt.html) which is quite complete… a
|
||||
bit too much sometimes. I used it as is to hunt for over/underfull hboxes,
|
||||
but you can filter them out by setting the
|
||||
buffer](https://vimhelp.org/quickfix.txt.html) which is quite complete… even
|
||||
a tad bit too much sometimes.
|
||||
I used it as is to hunt for over/underfull hboxes, but you can filter them
|
||||
out by setting the
|
||||
[`vim.g.vimtex_quickfix_ignore_filters`](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L2365-L2378)
|
||||
variable.
|
||||
- View the current location in the document: `,lv`
|
||||
- Show table of content navigation: `,lt`
|
||||
- View the current location in the document: `,lv`.
|
||||
- Show table of content navigation: `,lt`.
|
||||
* Using latex-specific text objects such as `$` for math or `e` for environment
|
||||
(defined by `\begin{…}` and `\end{…}`).
|
||||
- Insert command/environment : `<F6>/<F7>` (in normal and visual mode; these are not very accessible, but can be remapped).
|
||||
@ -172,7 +174,8 @@ is possible now:
|
||||
tools](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L5577-L5610),
|
||||
such as [languagetool](https://languagetool.org/). I didn't check for
|
||||
[grammalecte](https://grammalecte.net/) support for French yet, but it may
|
||||
prove to be an interesting endeavour.
|
||||
prove to be an [interesting
|
||||
endeavour](https://upload.wikimedia.org/wikipedia/commons/9/9f/Rabbit_Hole.jpg).
|
||||
|
||||
**Remark:** vimtex
|
||||
[claims](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L6549-L6624)
|
||||
@ -192,10 +195,10 @@ require("nvim-treesitter.configs").setup({
|
||||
|
||||
Okay, that's all and good, but to quote [wikipedia](https://en.wikipedia.org):
|
||||
|
||||
> The goal of the protocol is to allow programming language support to be
|
||||
> implemented and distributed independently of any given editor or IDE. In
|
||||
> the early 2020s LSP quickly became a "norm" for language intelligence tools
|
||||
> providers.
|
||||
> The goal of the [language server] protocol is to allow programming language
|
||||
> support to be implemented and distributed independently of any given editor or
|
||||
> IDE. In the early 2020s LSP quickly became a "norm" for language intelligence
|
||||
> tools providers.
|
||||
|
||||
Source: <https://en.wikipedia.org/wiki/Language_Server_Protocol>
|
||||
|
||||
@ -206,10 +209,10 @@ Let us now address these two issues.
|
||||
# Language Server Protocol
|
||||
|
||||
Setting up language server protocol with Vim is a big morsel, and have been the
|
||||
topic of [some tuppervim
|
||||
topic of [some tuppervim's
|
||||
sessions](https://tuppervim.org/archives/pads/grenoble-2212.txt) at some point.
|
||||
|
||||
I'll present here a minimal configuration that should work with `texlab`:
|
||||
Here follows a minimal configuration that should work with `texlab`:
|
||||
|
||||
```lua
|
||||
-- Minimal lsp config
|
||||
@ -217,15 +220,16 @@ local lspconfig = require("lspconfig")
|
||||
lspconfig.texlab.setup {}
|
||||
```
|
||||
|
||||
Okay, that's all and good, we can see errors and warnings decorating the file
|
||||
like Christmas decorations, but we can't use any of the LSP tools such as
|
||||
obtaining information on a bibliography key, or rename a macro.
|
||||
Easy, innit? Well, that's all and good, we can now see errors and warnings
|
||||
decorating the file like Christmas decorations, but we can not use any of the LSP
|
||||
tools such as obtaining information on a bibliography key, or rename a macro.
|
||||
|
||||
However, let us just remark that texlab is a pretty minimal LSP server, and
|
||||
don't implement the myriads of possible functionalities.
|
||||
Henceforth, I just copy-pasted the default example from the [nvim-lspconfig
|
||||
does not implement the myriads of possible functionalities.
|
||||
Henceforth, I simply copy-pasted the default example from the [nvim-lspconfig
|
||||
Readme](https://github.com/neovim/nvim-lspconfig), tried the shortcuts one by
|
||||
one, and remove these which raised an error for “not implemented functionality”:
|
||||
one, and removed these which raised an error for “not implemented
|
||||
functionality” 🤡:
|
||||
|
||||
```lua
|
||||
-- Use LspAttach autocommand to only map the following keys
|
||||
@ -247,7 +251,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
||||
})
|
||||
```
|
||||
|
||||
Which enables:
|
||||
Which thus enables:
|
||||
|
||||
* Omnicompletion using LSP (I won't elaborate on this point, either you use it
|
||||
or not, but if you're using it, it may be useful to leave. I personally
|
||||
@ -256,22 +260,26 @@ Which enables:
|
||||
bibliography reference.
|
||||
* Show the information about the element under the cursor using `K`, it can be
|
||||
useful to quickly check a reference. Note that pressing `K` twice jumps into
|
||||
the floating window, which can be useful to copy an article title to search
|
||||
the floating window. That can prove useful to copy an article title to search
|
||||
for it somewhere else for instance.
|
||||
* Rename a macro/variable among **all** files in the current working documents
|
||||
using `gR`. It's a lifesaver when renaming macros as it avoids writing [regular
|
||||
* Rename a macro/variable among **all** files in the current working document
|
||||
using `gR`.
|
||||
It's a lifesaver when renaming macros as it avoids writing [regular
|
||||
expressions](https://xkcd.com/1171/).
|
||||
* Show each places where a reference appears with `gr` in a quickfix window. It
|
||||
allows checking where a formula is referenced or verifying if you cited
|
||||
yourself enough. I personally use
|
||||
* Show each place where a reference appears with `gr` in a
|
||||
[quickfix](https://vimhelp.org/quickfix.txt.html) window.
|
||||
It allows checking where a formula is referenced or verifying if you cited
|
||||
yourself enough.
|
||||
I personally use
|
||||
[telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) for that
|
||||
purpose as it is more readable, but it goes beyond the scope of this blogpost.
|
||||
|
||||
And that's it, we now simply have to enable the completion engine getting the
|
||||
configuration from the [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) readme
|
||||
file and the [vimtex
|
||||
And that is about it.
|
||||
We now follow the same steps as before: enable the completion engine by fetching
|
||||
the configuration from the [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)
|
||||
readme file and the [vimtex
|
||||
documentation](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L4586-L4625),
|
||||
then pruning it.
|
||||
then prune it.
|
||||
|
||||
```lua
|
||||
-- nvim-cmp
|
||||
@ -296,22 +304,22 @@ but it's not the purpose of this blogpost.
|
||||
# Plug it into zathura
|
||||
|
||||
Now that you tweaked your Neovim configuration so much that it now consumes 10GB
|
||||
of memory and takes 12s to launch using all your CPU cores, we can move to
|
||||
zathura.
|
||||
of memory and takes 12s to launch using all your 24 CPU cores, we can move onto
|
||||
configuring zathura.
|
||||
|
||||
One of the reasons I moved from
|
||||
[vim-latex](https://github.com/vim-latex/vim-latex) to
|
||||
[vimtex](https://github.com/lervag/vimtex) is reverse search: to enable it with
|
||||
vim-latex, I was using [nvim-remote](https://github.com/mhinz/neovim-remote)
|
||||
`vim-latex`, I was using [nvim-remote](https://github.com/mhinz/neovim-remote)
|
||||
which is a wrapper for `nvim --listen` with a lot of constraints, while the most
|
||||
annoying one is that if I used reverse search from a detached[^1] zathura window
|
||||
without starting `nvr` first… then it is spawns the process which I cannot
|
||||
recover. Which usually happens when I'm in a rush to fix something quickly.
|
||||
|
||||
Fortunately, this is a thing of the past as it is possible to directly send a
|
||||
directive to vimtex which will look for the corresponding buffer and then open
|
||||
the file at the right location while following its state (which can be viewed
|
||||
with `,li`).
|
||||
directive to `vimtex` upon which it will look for the corresponding buffer and
|
||||
then open the file at the corresponding location while following its state
|
||||
(which can be viewed with `,li`).
|
||||
To do so, the
|
||||
[documentation](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L5985-L6033)
|
||||
states that you have to launch the following command, where `%l` is the line in
|
||||
@ -321,22 +329,21 @@ the file and `%f` is the name of the file:
|
||||
nvim --headless -c "VimtexInverseSearch %l '%f'"
|
||||
```
|
||||
|
||||
That's all and good, now we just have to tell Zathura which command to launch
|
||||
when doing backward search, which by default is done with `Ctrl` + `left mouse
|
||||
That's all and good, we just have to tell Zathura which command to launch when
|
||||
doing backward search, which by default is done with `Ctrl` + `left mouse
|
||||
button` on the portion of the text you want to view in the code.
|
||||
To do that, the
|
||||
following configuration that you can put in `$HOME/.config/zathura/zathurarc`
|
||||
should do the trick:
|
||||
To do that, the following configuration that you can put in
|
||||
`$HOME/.config/zathura/zathurarc` should do the trick:
|
||||
|
||||
```
|
||||
set synctex true
|
||||
set synctex-editor-command "nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\""
|
||||
```
|
||||
|
||||
And… that's it! You can now go to the location you want in your file document,
|
||||
compile it on the fly, scrutinise the warnings to look for overfull hboxes!
|
||||
And… that's it! You can now go to the location you want in your source file,
|
||||
compile it on the fly and scrutinise the warnings to look for overfull hboxes!
|
||||
|
||||
[^1]: meaning that it is not owned by any terminal I have opened, I
|
||||
[^1]: Meaning that it is not owned by any terminal I have opened, I
|
||||
can otherwise still recover it somehow.
|
||||
|
||||
# Conclusion
|
||||
@ -453,8 +460,8 @@ end
|
||||
That's nice and all but… it conflicts with the [vimtex default
|
||||
mappings](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L800-L912)
|
||||
such as `cse` to rename an environment which can be useful to replace an `align`
|
||||
with `align*` for instance. Meaning that going back one char would trigger vim
|
||||
to wait for the next input, which is kind of annoying.
|
||||
with `align*` for instance. Meaning that going back one character would trigger
|
||||
vim to wait for the next key input, which is kind of annoying.
|
||||
|
||||
Hence the need to remap the vimtex default shortcuts starting with `c`, `t`, `s`
|
||||
or `r`.
|
||||
|
Loading…
Reference in New Issue
Block a user