Přeskočit na hlavní obsah

my switch from vim to neovim

Last month I decided to bite the bullet and switch from Vim to Neovim on my daily-driver. The process was relatively painless, but I have one gripe to share with you, a reader considering to do the same.

As many of us, I've been baited by the one and only Primeagen to switch, Treesitter and Telescope being the main pulls. My expectations were that I would get a major productivity boost from just the two tools listed, and that the configuration would be more straight-forward thanks to Lua, a language specifically designed for configuration files.

For some more context, I'm an embedded software engineer and spend most of my time writing low-level C in a multitude of SDKs, mostly avr-libc with the GNU toolchain for AVR, a lot of ESP-IDF and whenever I need something quick-and-dirty, I use Arduino with arduino-cli. End of disclaimer.

As it turns out, Treesitter is not very useful, since it is not a language server. As I understand it, it only colors your code correctly for keywords defined in the same buffer, othewise it thinks everything is a variable. That's a no from me dawg, I'd rather have the basic syntax highliting that comes with Vim.

As for Telescope, I haven't had the time to look into it more closely, but I haven't yet found a intuitive method to configure it to work for me. Coming from CTags, I'm used to creating the tags file in the directory of the project and linking the external libraries as part of the command. So for AVR, I run something like:

$ ctags -R . <path-to-custom-lib> <path-to-libc>

And then I run vim in that directory. With Telescope, I guess the correct course of action is to run vim from ~/ and that way have access to all files under ~/. This doesn't fit with having the toolchain installed on root. I guess I'll have to install all SDKs into ~/ from now on, I'm starting to think that is the way god intended.


There's some issues I came across and haven't fixed yet. One major one for me is that TODO, FIXME, ETC. aren't highlighted by default.

Another one: Some configuration has to be written in vimscript - mainly highlight and autocmd haven't been very easy to port to my Lua configuration. I've resorted to sourcing my .vimrc from my Lua config.

Also, apparently most of the neovim community fails to grasp the point of Xresources, because the only neovim plugin I found that sets neovim's colors from Xresources is expecting specific colors at arbitrary indexes. I'm sorry, I don't have cyan at color6, nor do I have light_blue at all! Well I've decided to hack away just the good parts, but this issue kind of took up all the time I had budgeted for my switch to neovim.


The productivity boost hasn't happened yet, I don't use Telescope that much and left Treesitter on as of now, though it's kind of annoying to have absolutely everything highlighted as a variable. I still create the tags file manually (sometimes in Makefile) and spend most of my navigation using C-] and C-o, gf and /. I'm hoping that by staying with neovim, learning about the tool and the tool maturing some more, I'll get the promised boost eventually.

Anyways, here's my config:



vim.cmd('source ~/.vimrc')

-- vim.opt.foldmethod     = 'expr'
-- vim.opt.foldexpr       = 'nvim_treesitter#foldexpr()'
vim.api.nvim_create_autocmd({'BufEnter','BufAdd','BufNew','BufNewFile','BufWinEnter'}, {
  group = vim.api.nvim_create_augroup('TS_FOLD_WORKAROUND', {}),
  callback = function()
    vim.opt.foldmethod     = 'expr'
    vim.opt.foldexpr       = 'nvim_treesitter#foldexpr()'

vim.opt.guicursor = ""

vim.opt.nu = true
vim.opt.relativenumber = true

vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true
vim.opt.hlsearch = false
vim.opt.incsearch = true

vim.opt.smartindent = true

vim.opt.wrap = false

require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,
    -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
    -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
    -- Using this option may slow down your editor, and you may see some duplicate highlights.
    -- Instead of true it can also be a list of languages
    additional_vim_regex_highlighting = false,


vim.cmd[[packadd packer.nvim]]

return require('packer').startup(function()
    -- Packer can manage itself
    use 'wbthomason/packer.nvim'
    use {
        run = ':TSUpdate'
    use {
      'nvim-telescope/telescope.nvim', tag = '0.1.0',
      requires = { {'nvim-lua/plenary.nvim'} }


vim.opt.background = "light"

-- ========================================
-- Function to get colors from xresources
-- ========================================
local function get_xresources_color (c)
   local command = io.popen('xrdb -query | grep ' .. c .. ' -m 1 | cut -f 2')
   local color = command:read("*l")
   return color

-- ======================
-- Terminal colors
-- ======================
vim.g.terminal_color_0 = get_xresources_color('color0');
vim.g.terminal_color_1 = get_xresources_color('color1');
vim.g.terminal_color_2 = get_xresources_color('color2');
vim.g.terminal_color_3 = get_xresources_color('color3');
vim.g.terminal_color_4 = get_xresources_color('color4');
vim.g.terminal_color_5 = get_xresources_color('color5');
vim.g.terminal_color_6 = get_xresources_color('color6');
vim.g.terminal_color_7 = get_xresources_color('color7');
vim.g.terminal_color_8 = get_xresources_color('color8');
vim.g.terminal_color_9 = get_xresources_color('color9');
vim.g.terminal_color_10 = get_xresources_color('color10');
vim.g.terminal_color_11 = get_xresources_color('color11');
vim.g.terminal_color_12 = get_xresources_color('color12');
vim.g.terminal_color_13 = get_xresources_color('color13');
vim.g.terminal_color_14 = get_xresources_color('color14');
vim.g.terminal_color_15 = get_xresources_color('color15');