I am following this template for configuring my custom vim with Nix. My vim-config/default.nix
is as follows:
{ pkgs }:
let
my_plugins = import ./plugins.nix { inherit (pkgs) vimUtils fetchFromGitHub; };
in with (pkgs // { python = pkgs.python3; }); vim_configurable.customize {
name = "vim";
vimrcConfig = {
customRC = ''
syntax on
filetype on
" ...
'';
vam.knownPlugins = vimPlugins // my_plugins;
vam.pluginDictionaries = [
{ names = [
"ctrlp"
# ...
]; }
];
};
}
Although there is a (pkgs // { python = pkgs.python3; })
override on line 5, python3 is still not used (when I run vim --version
it shows +python -python3
). Am I missing anything?
Since there are still people actively looking at this topic, I'll mention that there is an easier solution than the one I first came to:
my_vim_configurable = pkgs.vim_configurable.override {
python = pkgs.python3;
};
My old answer:
It turns out that with (pkgs // { python = pkgs.python3; });
only modifies python
in the scope following the with
statement. The python
used in vim_configurable
is not affected. What I ended up doing is making a python3 version of vim_configurable
using vimUtils.makeCustomizable
:
vim-config/default.nix
:
{ pkgs }:
let
my_plugins = import ./plugins.nix { inherit (pkgs) vimUtils fetchFromGitHub; };
configurable_nix_path = <nixpkgs/pkgs/applications/editors/vim/configurable.nix>;
my_vim_configurable = with pkgs; vimUtils.makeCustomizable (callPackage configurable_nix_path {
inherit (darwin.apple_sdk.frameworks) CoreServices Cocoa Foundation CoreData;
inherit (darwin) libobjc cf-private;
features = "huge"; # one of tiny, small, normal, big or huge
lua = pkgs.lua5_1;
gui = config.vim.gui or "auto";
python = python3;
# optional features by flags
flags = [ "python" "X11" ];
});
in with pkgs; my_vim_configurable.customize {
name = "vim";
vimrcConfig = {
customRC = ''
syntax on
“...
'';
vam.knownPlugins = vimPlugins // my_plugins;
vam.pluginDictionaries = [
{ names = [
"ctrlp"
# ...
]; }
];
};
}
I have found I needed to do the .override
before the .customize
, like the following, in my systemPackages.
For the benefit of other users going for this, since I wasn't able to find other examples online, here's my entire Vim configuration as of now:
((vim_configurable.override {python = python38;}).customize {
name = "vim";
# add custom .vimrc lines like this:
vimrcConfig.customRC = ''
set nocompatible
syntax on
filetype plugin on
" search in subfolders
set path+=**
" tabcomplete files with :find filename
set wildmenu
set relativenumber
set number
set shiftwidth=4 expandtab
set hidden
set ruler
set colorcolumn=80
set backspace=indent,eol,start
'';
vimrcConfig.packages.myVimPackage = with pkgs.vimPlugins; {
# loaded on launch
start = [ YouCompleteMe elm-vim vim-nix haskell-vim jedi-vim typescript-vim ];
# manually loadable by calling `:packadd $plugin-name`
# opt = [ elm-vim vim-nix haskell-vim jedi-vim typescript-vim ];
# To automatically load a plugin when opening a filetype, add vimrc lines like:
# autocmd FileType php :packadd phpCompletion
};
})
I now have opt
commented, with the contents placed in start
because lazy loading isn't working with the default loader, and the individual packages loaded with start
are supposed to lazy-load anyhow.
I also removed the autocmd
parts that are supposed to work with opt
(but aren't):
autocmd FileType elm :packadd elm-vim
autocmd FileType nix :packadd vim-nix
autocmd FileType hs :packadd haskell-vim
autocmd FileType py :packadd jedi-vim
autocmd FileType ts :packadd typescript-vim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With