bug: Neovim error detected while processing $XDG_CONFIG_HOME/nvim/init.lua
Are you following the right branch?
- [X] My Nixpkgs and Home Manager versions are in sync
Is there an existing issue for this?
- [X] I have searched the existing issues
Issue description
After recently updating when trying to open Neovim, I get the following error message
Error detected while processing /home/kk/.config/nvim/init.lua:
E5112: Error while creating lua chunk: /home/kk/.config/nvim/init.lua:1: '=' expected near '/'
E5422: Conflicting configs: "/home/kk/.config/nvim/init.lua" "/home/kk/.config/nvim/init.vim"
Press ENTER or type command to continue
Possibly caused by #3233
I use home manager as a NixOS module. This is my Neovim config that I import into my Home Manager config:
{ config, pkgs, ... }: {
programs.neovim = {
enable = true;
plugins = with pkgs.vimPlugins; [
{
plugin = lightline-vim;
config = ''
set noshowmode
set laststatus=2
'';
}
{
plugin = nnn-vim;
config = ''
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Comment' } }
" Prevent opening files with 'l'
let g:nnn#command = "nnn -o"
map <F2> :NnnPicker<CR>
'';
}
vim-gitgutter
vim-nix
];
extraConfig = ''
set nocompatible
filetype on
syntax on
set number
set encoding=utf-8
" Hide ~ characters from the end of the file
highlight NonText ctermfg=black ctermbg=black
" Set split bar to be a little better looking
highlight VertSplit ctermfg=darkgray
highlight VertSplit ctermbg=darkgray
" Map tab to be 4 spaces
set tabstop=8 softtabstop=0 expandtab shiftwidth=4 smarttab
" Allow moving screen lines (wrapped lines) with jk
noremap j gj
noremap k gk
'';
};
}
Maintainer CC
@teto
System information
- system: `"x86_64-linux"`
- host os: `Linux 5.15.68, NixOS, 22.11 (Raccoon), 22.11.20220921.d6490a0`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.11.0`
- channels(root): `"home-manager, nixos"`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
This is the line with the bug: https://github.com/nix-community/home-manager/blob/bd83eab6220226085c82e637931a7ae3863d9893/modules/programs/neovim.nix#L374 Just needs an equals sign.
Looked into this a bit more. I can fix the conflict error between vim and lua config manually by renaming $XDG_CONFIG_HOME/nvim/init.vim to $XDG_CONFIG_HOME/nvim/anything-but-init.vim.
I don't know about the equals sign, but I succeeded in fixing the sourcing of the init.vim file by changing the contents of $XDG_CONFIG_HOME/nvim/init.lua to be vim.cmd('source /home/kk/.config/nvim/anything-but-init.vim')
This got rid of all the errors and my config loads normally.
IIUC, the equal sign error is not what is actually the problem, the path needs to be quoted like a string, otherwise it thinks you're trying to do a division.
EDIT: actually, I believe vim.cmd.source does not exist, it should be vim.cmd[[source <some path>]].
EDIT2: @Windore got there before I did :ninja:.
so it should be like this?
"vim.cmd [[source ${config.xdg.configHome}/nvim/init.vim]]"
Does https://github.com/nix-community/home-manager/pull/3256 fix it for you ? hope we can add tests later but just as a way to fix this quickly.
Yeah fixed now 👍