Using “pip” is the supported installation method for Ansible and Molecule. In Ubuntu, just using “pip” will lead to the error “externally-managed-environment” because of the Python environment that is “externally managed” by the package manager (this prevents direct use of pip for system-wide installations to avoid conflicts or issues).
Instead, let’s install Python libraries and applications (in this case, Ansible and Molecule) in a Python virtual environment.
First, install the required packages, including the Python virtual environment package:
Create a virtual environment somewhere (in this example, I create it in my home folder as a subdirectory of a folder for all the virtual environments; the directory will be created automatically):
Shell
1
python3-mvenv~/.venv/molecule
Once the virtual environment has been created, “enter” the virtual environment:
Shell
1
source~/.venv/molecule/bin/activate
Install the Python packages for Ansible, Molecule, and its plugins in the virtual environment:
This is the first part of a few tutorials on using the LaTeX typesetting system with Neovim using the LazyVim setup. I highly recommend LazyVim because it has many cool plugins configured with nice defaults. Moreover, as we see in this tutorial, it lets you quickly have VimTeX and the TexLab LSP up and running in Neovim.
You can follow this step-by-step tutorial by implementing the steps starting from a fresh LazyVim installation (see http://www.lazyvim.org/installation). If you already use LazyVim, you might want to do the steps in this tutorial on a fresh, separate Neovim configuration directory before applying all the configurations in your daily-driver Neovim configuration.
For example, if you start with the starter project provided by LazyVim, you can clone it into a separate configuration directory:
And then you start Neovim pointing to that configuration:
Shell
1
NVIM_APPNAME=lazyvim-tex nvim
This way, your existing Neovim configuration won’t be touched, and you’ll be free to experiment with this new configuration.
In these tutorials, the path is always intended relative to the Neovim configuration path when referring to a configuration file. If you follow the above commands, for example, it will be relative to “~/.config/lazyvim-tex”.
I suggest you follow the tutorials by manually executing the configuration steps in a new, separate Neovim configuration.
The final result of this series of tutorials can be found here: https://github.com/LorenzoBettini/lazyvim-tex. Branches will denote the state of the repository according to a specific blog post part.
A few initial notes
The plugin VimTeX needs a LaTeX installation and a compiler; the default is “latexmk”.
In Arch Linux, you can install it like this:
1
sudo pacman-Stexlive-binextra
You must also ensure a working LaTeX installation with all the needed packages.
I’ll use Zathura and Sioyek as PDF viewers, automatically providing bi-directional linking (synchronization) between the LaTeX sources and the PDF.
In Arch Linux, you can install Zathura like this:
1
sudo pacman-Szathura-pdf-poppler
For Sioyek, AUR packages are available.
I’ll use a light theme (“catpuccin-latte”) for Neovim instead of the default dark one in the screenshots.
The “localleader” will be remapped to “\”: VimTeX commands start with “l” and in LazyVim “<leader> l” (that is, “<space> l” is already mapped to “Lazy” commands). This remap is done automatically by the LazyVim “Tex Extra” I’ll use.
Let’s open this file with the fresh Neovim distribution.
Let’s install the LazyVim “Tex Extra”. A LazyVim extra is meant to configure several plugins and configurations with a single mechanism. In this case, it will configure VimTex, the TexLab LSP, and other related plugins and keybindings.
You have some alternatives to enable an “Extra”, which is documented for each available “Extra”; for Java, see http://www.lazyvim.org/extras/lang/tex. I prefer to use the UI: Type “:LazyExtras” to show the LazyVim Extras UI:
The LazyExtras UI proposes some recommended extras based on the files you’ve just opened, so it should recommend “lang.tex”; if not, search for “lang.tex” and when you’re on that line, press “x” to install the extra.
You get the feedback about restarting Neovim so that VimTeX is installed.
Specifying an extra as we’ve just done creates a file in the configuration, “lazyvim.json”, with this content (the numbers for news and version might be different depending on when you follow this tutorial):
Lua
1
2
3
4
5
6
7
8
9
{
"extras":[
"lazyvim.plugins.extras.lang.tex"
],
"news":{
"NEWS.md":"..."
},
"version":...
}
The idea is to keep this file in the Git repository for your configuration as part of your dotfiles for Neovim.
Once you reopen the LaTeX file, you should get feedback about Mason downloading the “texlab” LSP; this is done only the first time.
Of course, you could force the installation of “texlab” beforehand by using the Mason UI, “:Mason”: select “texlab” and install it.
Alternatively, if you want a fully automated solution that, besides installing all the Neovim plugins, also automatically installs the TeXLab LSP, you can add this Lua specification in the Neovim configuration folder (the name does not matter; I call it “extend-lsp” to stress that it extends the Mason configuration of LazyVim, https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/lsp/init.lua) “lua/plugins/extend-lsp.lua” with this content:
Lua
1
2
3
4
5
6
7
8
return{
"williamboman/mason.nvim",
opts={
ensure_installed={
"texlab",
},
},
}
Now, when you start Neovim, “texlab” will automatically install. You might want to check whether Mason has successfully downloaded and installed it or is still installing it through the Mason UI.
You can now try to edit the file using the content assist, providing completions and possible templates:
Let’s explore VimTex commands; remember that we’ll use “\” as the “localleader”. Which-key will show the available keybindings:
Let’s compile the LaTeX file with “\ l l”. This will start the compilation, which, depending on the size and complexity of the LaTeX document, takes a few seconds.
In the end, if there are no compilation errors, it automatically opens the default PDF viewer (I’m on KDE, and the default PDF viewer is Okular):
With “\ l l” we instructed VimTeX to watch for file changes (you can stop it with “\ l k”). VimTeX will automatically retrigger compilation and update the PDF document in the viewer as soon as we change the file and save it. For example, let’s add a sentence, save, and when we get feedback about the completed compilation, we should see the result in the PDF viewer:
Let’s add a LaTeX error, save, and get the list of reported errors (selecting any error will lead to the corresponding line in the source file):
Configure the PDF viewer
Let’s configure Zathura as the viewer.
Let’s add this line in the file “lua/config/options.lua”:
Lua
1
vim.g.vimtex_view_method="zathura_simple"
I’m using “zathura_simple” instead of “Zathura” because, as documented, the latter requires “xdotool”, which I don’t have. This way, we avoid the warning “Viewer cannot find Zathura window ID!”.
Let’s restart Neovim, reopen the LaTeX file, and select “\ l l”.
Now, it will open Zathura with the highlighted part corresponding to the cursor’s current position in the source file!
Let’s move the cursor in the source file to another line and press “\ l v”: the selection in the PDF is updated accordingly:
The other way round also works: from Zathura, use “Ctrl + click”, and the cursor in the source file will be updated to the corresponding line (in the screenshot below, I did “Ctrl + click” on the part of “toggles between”):
This synchronization is super useful when writing in LaTeX, isn’t it? 🙂
Alternatively, I also use Sioyek as a PDF viewer, which works on macOS as well. In this case, the option for the viewer must be changed accordingly:
Lua
1
vim.g.vimtex_view_method="sioyek"
In Sioyek, to return to the source file, enter “synctex” mode with “F4” and right-click with the mouse.
Other features
Let’s open the “Table of Contents” window with “\ l t”:
Note the helpful help contents and the “TODO” elements that were also reported.
Stay tuned for more blog posts on LaTeX and Neovim! 🙂
Similar to what I had already shown in a previous post, in this post, I show how you can install (and keep up-to-date) the “tpm” (Tmux Plugin Manager) with Chezmoi, which I highly recommend!
Typically, you manually install “tpm” by cloning its GitHub repository into the proper directory:
Chezmoi offers mechanisms for such situations: https://www.chezmoi.io/user-guide/include-files-from-elsewhere/. In particular, I use “Include a subdirectory from a git repository”: this way, Chezmoi will clone the external Git repository on the first run and will keep it up to date (i.e., “git pull”) at some specified intervals (remember, the default interval is 0!).
You need to create the file “.chezmoiexternal.toml” in the root folder of your Chezmoi file and follow the syntax in the documentation.
Here’s what I need to install “tpm” by cloning its GitHub repository:
INI
1
2
3
4
[".tmux/plugins/tpm"]
type="git-repo"
url="https://github.com/tmux-plugins/tpm"
refreshPeriod="1h"
Note that I specified a 1-hour refresh interval. Thus, if I issue a “chezmoi update”, it will keep that interval into consideration when deciding whether to check for updates (i.e., “pull”) in the Git repository. However, you also have this option in Chezmoi to force the Git update:
Let’s put Ubuntu Linux on the laptop! I’ll write the installation instructions and the configurations for a fully functional Ubuntu on this MacBook Air, which runs fast and smoothly and brings the laptop back to life!
Although I am a big fan of Arch and EndeavourOS, I first decided to try Ubuntu on this MacBook. Maybe, in the future, I’ll also try using an Arch distribution.
Installation
After having put the Ubuntu 24.10 ISO on a USB stick with Ventoy and inserted the USB stick, Turn on the Mac and immediately press and hold the Option (⌥) key until you see the startup disk selection screen:
Select the entry corresponding to the USB and get to Ventoy menu:
After some time, you should see the familiar Ubuntu splash screen:
Unfortunately, when I got to the desktop, I discovered the WiFi card had not been detected.
I’ll fix that later, after the installation.
I can use my mobile phone: I enabled USB tethering after connecting the phone with a USB cable. USB tethering in Linux works like a charm. I can now go on with the installation with a working Internet connection!
The installation is the standard Ubuntu installation:
Since I don’t want to keep any macOS installation (the space on the SSD wouldn’t be enough anyway), I choose to wipe the entire disk and let Ubuntu select a standard partition scheme.
The installer correctly detected my time zone:
Let’s start the installation, which only takes a few minutes (even considering I’m using my mobile phone connection).
By clicking the terminal icon on the bottom right, you can see the logging of the installation:
Time to restart the installed system!
Configuration
Let’s start fixing the WiFi problem.
This is the WiFi card on the laptop:
Shell
1
2
$lspci-nn|grepNetwork
03:00.0Network controller[0280]:Broadcom Inc.andsubsidiaries BCM4360802.11acDual Band Wireless Network Adapter[14e4:43a0](rev03)
I have already blogged about Thunderbird and Firefox snap packages, which I don’t like, and how to get back to dep packages.
Final thoughts
As I had already anticipated, the laptop works great with Ubuntu. Everything is smooth and reactive. Even more than with the original old macOS operating system.
I noted that concerning sleep, the default configuration already uses the more power save setting:
1
2
❯cat/sys/power/mem_sleep
s2idle[deep]
Everything else works great, including all the volume and screen brightness function keys. Moreover, the screen light automatically adjusts depending on the environment illumination!
Power consumption also works fine after installing the powertop package (running that with the “auto-tune” setting) and setting the power profile to “Power Saver” from the Gnome menu:
MacOS probably used to have better power consumption, but this one is acceptable.
It was a nice decision to put Linux on this laptop! 🙂
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.