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
|
scientific community (but [not
|
||||||
only](https://www.ctan.org/pkg/latex-sciences-humaines)) as it allows writing
|
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
|
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.
|
cross-referencing and automatically generates table of contents.
|
||||||
|
|
||||||
It is based on a markup language that allows the writers to focus on the content
|
It is based on a markup language that allows writers to focus on the content of
|
||||||
of the document and leaves the typesetting to the software (at least most of the
|
the document and leaves the typesetting to the software (at least most of the
|
||||||
time).
|
time).
|
||||||
It moreover enjoys [many](https://ctan.org/) libraries that span from enabling
|
It moreover enjoys [many](https://ctan.org/) libraries that span from enabling
|
||||||
[new features](https://ctan.org/pkg/algorithm2e) to [simpler
|
[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
|
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
|
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.
|
`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
|
# vimtex
|
||||||
|
|
||||||
It will be a bit anti-climatic after the previous teasing, but we will use
|
It will be a bit anti-climatic after the previous teasing, but we will use
|
||||||
`vimtex` as vanilla as possible…
|
`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
|
```lua
|
||||||
vim.g.vimtex_view_method = "zathura"
|
vim.g.vimtex_view_method = "zathura"
|
||||||
```
|
```
|
||||||
|
|
||||||
This will allow `vimtex` to automatically open `zathura` after compilation,
|
This will allow `vimtex` to automatically open `zathura` upon compilation,
|
||||||
which is by default bound to `<LocalLeader>ll`. We now have to define
|
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
|
[`<LocalLeader>`](https://neovim.io/doc/user/map.html#%3CLocalLeader%3E), which
|
||||||
I usually set to “`,`”:
|
I usually set to be a comma: “`,`”:
|
||||||
```lua
|
```lua
|
||||||
vim.g.maplocalleader = ","
|
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)
|
default (contrary to what [vim-latex](https://github.com/vim-latex/vim-latex)
|
||||||
was doing, which is the former plugin I used):
|
was doing, which is the former plugin I used):
|
||||||
|
|
||||||
@ -154,13 +155,14 @@ is possible now:
|
|||||||
|
|
||||||
- Compile the document: `,ll`
|
- Compile the document: `,ll`
|
||||||
- This also automatically generates a [quickfix
|
- This also automatically generates a [quickfix
|
||||||
buffer](https://vimhelp.org/quickfix.txt.html) which is quite complete… a
|
buffer](https://vimhelp.org/quickfix.txt.html) which is quite complete… even
|
||||||
bit too much sometimes. I used it as is to hunt for over/underfull hboxes,
|
a tad bit too much sometimes.
|
||||||
but you can filter them out by setting the
|
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)
|
[`vim.g.vimtex_quickfix_ignore_filters`](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L2365-L2378)
|
||||||
variable.
|
variable.
|
||||||
- View the current location in the document: `,lv`
|
- View the current location in the document: `,lv`.
|
||||||
- Show table of content navigation: `,lt`
|
- Show table of content navigation: `,lt`.
|
||||||
* Using latex-specific text objects such as `$` for math or `e` for environment
|
* Using latex-specific text objects such as `$` for math or `e` for environment
|
||||||
(defined by `\begin{…}` and `\end{…}`).
|
(defined by `\begin{…}` and `\end{…}`).
|
||||||
- Insert command/environment : `<F6>/<F7>` (in normal and visual mode; these are not very accessible, but can be remapped).
|
- 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),
|
tools](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L5577-L5610),
|
||||||
such as [languagetool](https://languagetool.org/). I didn't check for
|
such as [languagetool](https://languagetool.org/). I didn't check for
|
||||||
[grammalecte](https://grammalecte.net/) support for French yet, but it may
|
[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
|
**Remark:** vimtex
|
||||||
[claims](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L6549-L6624)
|
[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):
|
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
|
> The goal of the [language server] protocol is to allow programming language
|
||||||
> implemented and distributed independently of any given editor or IDE. In
|
> support to be implemented and distributed independently of any given editor or
|
||||||
> the early 2020s LSP quickly became a "norm" for language intelligence tools
|
> IDE. In the early 2020s LSP quickly became a "norm" for language intelligence
|
||||||
> providers.
|
> tools providers.
|
||||||
|
|
||||||
Source: <https://en.wikipedia.org/wiki/Language_Server_Protocol>
|
Source: <https://en.wikipedia.org/wiki/Language_Server_Protocol>
|
||||||
|
|
||||||
@ -206,10 +209,10 @@ Let us now address these two issues.
|
|||||||
# Language Server Protocol
|
# Language Server Protocol
|
||||||
|
|
||||||
Setting up language server protocol with Vim is a big morsel, and have been the
|
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.
|
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
|
```lua
|
||||||
-- Minimal lsp config
|
-- Minimal lsp config
|
||||||
@ -217,15 +220,16 @@ local lspconfig = require("lspconfig")
|
|||||||
lspconfig.texlab.setup {}
|
lspconfig.texlab.setup {}
|
||||||
```
|
```
|
||||||
|
|
||||||
Okay, that's all and good, we can see errors and warnings decorating the file
|
Easy, innit? Well, that's all and good, we can now see errors and warnings
|
||||||
like Christmas decorations, but we can't use any of the LSP tools such as
|
decorating the file like Christmas decorations, but we can not use any of the LSP
|
||||||
obtaining information on a bibliography key, or rename a macro.
|
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
|
However, let us just remark that texlab is a pretty minimal LSP server, and
|
||||||
don't implement the myriads of possible functionalities.
|
does not implement the myriads of possible functionalities.
|
||||||
Henceforth, I just copy-pasted the default example from the [nvim-lspconfig
|
Henceforth, I simply copy-pasted the default example from the [nvim-lspconfig
|
||||||
Readme](https://github.com/neovim/nvim-lspconfig), tried the shortcuts one by
|
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
|
```lua
|
||||||
-- Use LspAttach autocommand to only map the following keys
|
-- 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
|
* 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
|
or not, but if you're using it, it may be useful to leave. I personally
|
||||||
@ -256,22 +260,26 @@ Which enables:
|
|||||||
bibliography reference.
|
bibliography reference.
|
||||||
* Show the information about the element under the cursor using `K`, it can be
|
* 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
|
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.
|
for it somewhere else for instance.
|
||||||
* Rename a macro/variable among **all** files in the current working documents
|
* 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
|
using `gR`.
|
||||||
|
It's a lifesaver when renaming macros as it avoids writing [regular
|
||||||
expressions](https://xkcd.com/1171/).
|
expressions](https://xkcd.com/1171/).
|
||||||
* Show each places where a reference appears with `gr` in a quickfix window. It
|
* Show each place where a reference appears with `gr` in a
|
||||||
allows checking where a formula is referenced or verifying if you cited
|
[quickfix](https://vimhelp.org/quickfix.txt.html) window.
|
||||||
yourself enough. I personally use
|
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
|
[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.
|
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
|
And that is about it.
|
||||||
configuration from the [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) readme
|
We now follow the same steps as before: enable the completion engine by fetching
|
||||||
file and the [vimtex
|
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),
|
documentation](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L4586-L4625),
|
||||||
then pruning it.
|
then prune it.
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
-- nvim-cmp
|
-- nvim-cmp
|
||||||
@ -296,22 +304,22 @@ but it's not the purpose of this blogpost.
|
|||||||
# Plug it into zathura
|
# Plug it into zathura
|
||||||
|
|
||||||
Now that you tweaked your Neovim configuration so much that it now consumes 10GB
|
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
|
of memory and takes 12s to launch using all your 24 CPU cores, we can move onto
|
||||||
zathura.
|
configuring zathura.
|
||||||
|
|
||||||
One of the reasons I moved from
|
One of the reasons I moved from
|
||||||
[vim-latex](https://github.com/vim-latex/vim-latex) to
|
[vim-latex](https://github.com/vim-latex/vim-latex) to
|
||||||
[vimtex](https://github.com/lervag/vimtex) is reverse search: to enable it with
|
[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
|
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
|
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
|
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.
|
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
|
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
|
directive to `vimtex` upon which it will look for the corresponding buffer and
|
||||||
the file at the right location while following its state (which can be viewed
|
then open the file at the corresponding location while following its state
|
||||||
with `,li`).
|
(which can be viewed with `,li`).
|
||||||
To do so, the
|
To do so, the
|
||||||
[documentation](https://github.com/lervag/vimtex/blob/master/doc/vimtex.txt#L5985-L6033)
|
[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
|
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'"
|
nvim --headless -c "VimtexInverseSearch %l '%f'"
|
||||||
```
|
```
|
||||||
|
|
||||||
That's all and good, now we just have to tell Zathura which command to launch
|
That's all and good, we just have to tell Zathura which command to launch when
|
||||||
when doing backward search, which by default is done with `Ctrl` + `left mouse
|
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.
|
button` on the portion of the text you want to view in the code.
|
||||||
To do that, the
|
To do that, the following configuration that you can put in
|
||||||
following configuration that you can put in `$HOME/.config/zathura/zathurarc`
|
`$HOME/.config/zathura/zathurarc` should do the trick:
|
||||||
should do the trick:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
set synctex true
|
set synctex true
|
||||||
set synctex-editor-command "nvim --headless -c \"VimtexInverseSearch %{line} '%{input}'\""
|
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,
|
And… that's it! You can now go to the location you want in your source file,
|
||||||
compile it on the fly, scrutinise the warnings to look for overfull hboxes!
|
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.
|
can otherwise still recover it somehow.
|
||||||
|
|
||||||
# Conclusion
|
# Conclusion
|
||||||
@ -453,8 +460,8 @@ end
|
|||||||
That's nice and all but… it conflicts with the [vimtex default
|
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)
|
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`
|
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
|
with `align*` for instance. Meaning that going back one character would trigger
|
||||||
to wait for the next input, which is kind of annoying.
|
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`
|
Hence the need to remap the vimtex default shortcuts starting with `c`, `t`, `s`
|
||||||
or `r`.
|
or `r`.
|
||||||
|
Loading…
Reference in New Issue
Block a user