Persistent Vim error (E1031: Cannot use void value)

My Vim config:
((vim-full.override {}).customize {
name = "vim";
# 1. Nix pulls down and installs all your plugins here
vimrcConfig.packages.myplugins = {
start = with vimPlugins; [
vim-nix # Native Nix language highlighting & indenting
nerdtree # Standard file tree
vim-airline # Standard status bar
nnn-vim
vim-sensible
coc-pairs
coc-nvim
fzf-vim
fzf-wrapper
ayu-vim
vim-airline-themes
coc-basedpyright
coc-clangd
];
};

# 2. Your custom keymaps and settings go here (NO plug#begin lines!)
vimrcConfig.customRC = ''
set rtp+=${pkgs.fzf}/share/vim

syntax on
filetype plugin indent on

" Set global indentation preferences
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
set autoindent
set termguicolors
set smartindent
set number
set relativenumber

" Keymaps
let mapleader = " "
nnoremap <C-n> :NERDTreeToggle<CR>
let g:airline#extensions#tabline#enabled = 1
let g:airline_theme='ayu_mirage'

colorscheme ayu
let ayucolor="dark"

" Cursor configuration
" Change cursor shape based on Vim mode for modern terminals (like Kitty)
let &t_SI = "\e[5 q" " Enter Insert mode: Thin vertical line
let &t_SR = "\e[4 q" " Enter Replace mode: Underline
let &t_EI = "\e[2 q" " Exit to Normal mode: Block cursor

autocmd VimEnter * highlight Normal guibg=NONE ctermbg=NONE
autocmd VimEnter * highlight NonText guibg=NONE ctermbg=NONE

" Keep standard Markdown indentation rules
autocmd FileType markdown setlocal autoindent expandtab tabstop=4 shiftwidth=4

" Prevent Vim from treating list items as broken code indentation
let g:markdown_recommended_style = 0

" FIX: Declaratively inject CoC configuration settings inside the RC context
call coc#config('languageserver', {
\ 'nix': {
\ 'command': 'nixd',
\ 'filetypes': ['nix'],
\ 'rootPatterns': ['flake.nix', '.git'],
\ 'settings': {
\ 'nixd': {
\ 'formatting': {
\ 'command': ['nixfmt']
\ }
\ }
\ }
\ }
\})

" Enable concealing syntax characters
set conceallevel=2

" Conceal links, keeping only the descriptive text visible
let g:vim_markdown_conceal = 1
let g:vim_markdown_conceal_code_blocks = 1

" Tell Vim to search for files relative to the current file's directory
set path+=.
" Allow Vim to recognize files without explicitly typing the .md extension
set suffixesadd+=.md

set mouse=a

'';
})

Error:
Error detected while processing function coc#rpc#request[4]..32_request[34]..function coc#rpc#request[4]..32_request:
line 29:
E605: Exception not caught: Error on "doKeymap" request: Vim(let):E1031: Cannot use void value - on request "call_function" ^@function coc#rpc#request[4]..
32_request[5]..coc#api#Call, line 4

Whenever I type " or ’ in vim with coc-pairs installed it shows this, doesn’t show in vim --clean.

Hi there, and welcome to the community!

Perhaps I’m missing something, but can you explain a bit more clearly what has led you to think this is a nix problem instead of a vim/coc problem? If you have a working configuration for this outside nix, the community can help you express it in nix perhaps.

Hello!

This issue only persists when I press the ’ " ’ key in Vim with the coc-pairs plugin/extension. If it’s uninstalled or removed, the error doesn’t show up. I do have another .vimrc but it’s a little different, hope that’s no issue. Also, this error happened right after I reverted from the NixVim module to the vim-full.override.

Sorry for the late reply!

Not a late reply, it’s a forum not a chat :slight_smile:

It helps to know that you previously had a working NixVim config and that you are now trying to use vim-full and .override it to produce the nix derivation you want. However, I’m not sure you answered why you think this might be a nix problem, nor do I think I see a vim config that was working in a non-nix system that the community can help you express in nix.

What I have done is wrapped what you provided into something that someone trying to help can nix-build and more easily get started maybe reproducing your issue.

Summary
{
  pkgs ? import <nixpkgs> {},
  vim-full ? pkgs.vim-full,
  vimPlugins ? pkgs.vimPlugins
}:

((vim-full.override {}).customize {
name = "vim";
# 1. Nix pulls down and installs all your plugins here
vimrcConfig.packages.myplugins = {
  start = with vimPlugins; [
    vim-nix        # Native Nix language highlighting & indenting
    nerdtree       # Standard file tree
    vim-airline    # Standard status bar
    nnn-vim
    vim-sensible
    coc-pairs
    coc-nvim
    fzf-vim
    fzf-wrapper
    ayu-vim
    vim-airline-themes
    coc-basedpyright
    coc-clangd
  ];
};

# 2. Your custom keymaps and settings go here (NO plug#begin lines!)
vimrcConfig.customRC = ''
  set rtp+=${pkgs.fzf}/share/vim

  syntax on
  filetype plugin indent on

  " Set global indentation preferences
  set tabstop=2
  set shiftwidth=2
  set softtabstop=2
  set expandtab
  set autoindent
  set termguicolors
  set smartindent
  set number
  set relativenumber

  " Keymaps
  let mapleader = " "
  nnoremap <C-n> :NERDTreeToggle<CR>
  let g:airline#extensions#tabline#enabled = 1
  let g:airline_theme='ayu_mirage'

  colorscheme ayu
  let ayucolor="dark"

  " Cursor configuration
  " Change cursor shape based on Vim mode for modern terminals (like Kitty)
  let &t_SI = "\e[5 q" " Enter Insert mode: Thin vertical line
  let &t_SR = "\e[4 q" " Enter Replace mode: Underline
  let &t_EI = "\e[2 q" " Exit to Normal mode: Block cursor

  autocmd VimEnter * highlight Normal guibg=NONE ctermbg=NONE
  autocmd VimEnter * highlight NonText guibg=NONE ctermbg=NONE

  " Keep standard Markdown indentation rules
  autocmd FileType markdown setlocal autoindent expandtab tabstop=4 shiftwidth=4

  " Prevent Vim from treating list items as broken code indentation
  let g:markdown_recommended_style = 0

  " FIX: Declaratively inject CoC configuration settings inside the RC context
  call coc#config('languageserver', {
  \  'nix': {
  \    'command': 'nixd',
  \    'filetypes': ['nix'],
  \    'rootPatterns': ['flake.nix', '.git'],
  \    'settings': {
  \      'nixd': {
  \        'formatting': {
  \          'command': ['nixfmt']
  \        }
  \      }
  \    }
  \  }
  \})

  " Enable concealing syntax characters
  set conceallevel=2

  " Conceal links, keeping only the descriptive text visible
  let g:vim_markdown_conceal = 1
  let g:vim_markdown_conceal_code_blocks = 1

  " Tell Vim to search for files relative to the current file's directory
  set path+=.
  " Allow Vim to recognize files without explicitly typing the .md extension
  set suffixesadd+=.md

  set mouse=a

'';
})

It does seem like it might need node to work:

$ ./result/bin/vim
[coc.nvim] "node" is not executable, checkout https://nodejs.org/en/download/
Press ENTER or type command to continue

I’ll admit that installing and figuring out node and then debugging vimscript is just a bit further than I am able to help. Without a working node install, the above does not cause me issues when I type " into an empty buffer, so I am unable to reproduce you issue, for whatever that’s worth. Best of luck and I hope you do figure this out.