DEV Community

Soc Virnyl Estela
Soc Virnyl Estela

Posted on

The Must-Have Neovim Plugins for Julia

Neovim is a fork of Vim that has gained a lot of popularity and users due to its extensibility and strong focus on community contributions. My favorite feature of Neovim is its configuration can be written in Lua. I am no Lua wizard but it does feel like Julia, maybe because of the function ... end syntax. Anyway, I migrated all my configuration from vimscript to Lua and I am quite satisfied with the results ๐Ÿ˜„.

Julia is a high-level, high-performance and dynamic programming language that is designed to be fast and easy to write like a scripting language. Over the years, the language has gained some popularity, mostly data science and the academe. Many of its features is well suited for numerical analysis and computational science. If you want to try Julia, you can download the release version at https://julialang.org. For platform specific instructions, you can go here https://julialang.org/downloads/platform

Julia has a lot of editors that support it. Though Visual Studio Code is the best editor for Julia, I prefer Neovim because it is very lightweight and does not hog that much on system resources. Before we get into the topic, just a reminder: this is not a guide for Neovim and Julia. This is about what plugins that I think is a must-have for any Julian that uses Neovim as their main editor. To start with, below are the Neovim plugins I think is a must-have for Julia:

packer.nvim

There are a lot of package and plugin managers for Neovim. Before, I was using vim-plug as my plugin manager but after a lot of exploring, I found myself falling in love with packer.nvim. Packer is a package/plugin manager for Neovim that is written in Lua which allows for expressive configuration. This allows users to write their configuration fully in Lua. To see what I mean, here is an example for a minimal configuration written in Lua:

local fn = vim.fn
local install_path = fn.stdpath("data") .. "/site/pack/packer/start/packer.nvim"
if fn.empty(fn.glob(install_path)) > 0 then
  packer_bootsrap = fn.system({
        "git",
        "clone",
        "--depth",
        "1",
        "https://github.com/wbthomason/packer.nvim",
        install_path,
    })
    local rtp_addition = vim.fn.stdpath("data") .. "/site/pack/*/start/*"
    if not string.find(vim.o.runtimepath, rtp_addition) then
        vim.o.runtimepath = rtp_addition .. "," .. vim.o.runtimepath
    end
end

local packer_status, packer = pcall(require, "packer")
if not packer_status then
  return
end

return packer.startup({
    function(use)
      use({
          "hrsh7th/nvim-cmp",
          requires = {
            { "hrsh7th/cmp-vsnip", after = "nvim-cmp" },
            { "hrsh7th/vim-vsnip", after = "nvim-cmp", requires = "hrsh7th/vim-vsnip-integ" },
            { "kdheepak/cmp-latex-symbols", after = "nvim-cmp" }
          }

      })
      use({ "neovim/nvim-lspconfig" })
      use({ "tami5/lspsaga.nvim", branch = "main", after = "nvim-lspconfig" })
      use({ "jpalardy/vim-slime" })

      if packer_bootstrap then
        require("packer").sync()
      end
    end
})
Enter fullscreen mode Exit fullscreen mode

That is so beautiful and easy to read right? ๐Ÿ˜› Anyway, do not just mindlessly copy that example config since some of this plugins need its own configuration too to make them work which I won't cover (RTFM moment ๐Ÿฅด).

nvim-lspconfig

Like any Neovim user, I think they already know about this plugin and that Neovim already has a built-in language-server-client so I won't talk much about it. But I will insist using this plugin if you want Neovim to have LSP support.

lspsaga.nvim

If you are using nvim-lspconfig, I am pretty sure you came across with lspsaga.nvim. It is a lightweight lsp plugin that gives you LSP pop-ups and documentations with a cool UI ๐Ÿ˜Ž. However, the current maintainer of the plugin has not been active for quite a while. There is an existing fork though if you want to use it ๐Ÿ˜‰. Link to fork: tami5/lspsaga.nvim.

vim-slime

If you want to run your code inside a Julia REPL like in VSCode, vim-slime is a plugin that lets you do that. This plugin is such a godsend for me since I really like the REPL workflow of Julia and I can test run my code while experimenting in the REPL with tmux or kitty.

nvim-cmp

After looking for a very sane completion plugin for a very long time, I found the best one for Neovim. nvim-cmp is a completion engine plugin for Neovim written in Lua. Instead of being a completion plugin for like everything, nvim-cmp is as described, a completion engine plugin. It gets completion sources from other completion plugins. This makes it easy to configure completion sources and control which completions to disable, enable, or even dynamically enable/disable with Lua configuration. The following plugins I will talk about are the completion sources I use.

cmp-latex-symbols

Any Julian knows that Julia has support for LaTeX symbols. And that is a big problem if an editor does not have a LaTeX completion plugin. Neovim does have plugins for those, thank goodness.

There is a plugin I tried which is called julia-vim. However, this plugin is too broken for me. It conflicts with other completion plugins which makes it so hard to either fix or manage my configuration and keymaps. Fortunately, I found cmp-latex-symbols, a completion plugin that as described in the README

... uses unimathsymbols.txt and LaTeX symbols defined by the Julia REPL. ...

To make the plugin work as intended, it must be sourced to nvim-cmp. I mean, the name implies it, right? ๐Ÿฅด

Now you can finally write LaTeX symbols like how you did them in the Juila REPL. ๐Ÿ˜

vim-vsnip and cmp-vsnip

Have you ever wondered how to have a snippet completion in VSCode so you can write Julia code fast but in Neovim? Fear not! vim-vsnip is the plugin you need. This plugin supports LSP/VSCode's snippet format. But first, you need to install cmp-vsnip for this plugin to be sourced to nvim-cmp. Oh btw, these three plugins: nvim-cmp, vim-vsnip, and cmp-vsnip โ†’ are made by the same person which is actually cool! If you want to support them, become a sponsor! (I am poor so I cannot sponsor yet ๐Ÿ˜”)

End

Those are the must-have Neovim plugins if you are a fellow Julian ๐Ÿ˜‰. I mentioned those plugins because with just those, you can already have a working Neovim configuration for Julia. If you want to see a working configuration, you can check my config at https://github.com/uncomfyhalomacro/erudite-vim. Please forgive me for how messy it is hehe ๐Ÿ˜…

To end this post, I would like to say thanks to all the people who wrote the plugins I have mentioned. Without them, I probably won't ever love Neovim and never even use it. Also thanks to the Neovim community and their creativity for making such awesome plugins, and also thanks to the Julia community as well for their heart-warming community and support.

Do you agree with any of the plugins I mentioned? What do you think? If you have any ideas, stories to share, suggestions and recommendations, do comment below!

Top comments (0)