[英]Overriding python with python3 in vim_configurable.customize
I am following this template for configuring my custom vim with Nix.我正在遵循此模板来使用 Nix 配置我的自定义 vim。 My
vim-config/default.nix
is as follows:我的
vim-config/default.nix
如下:
{ 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
).尽管第 5 行有一个
(pkgs // { python = pkgs.python3; })
覆盖,但仍然没有使用 python3(当我运行vim --version
它显示+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; });
事实证明,
with (pkgs // { python = pkgs.python3; });
only modifies python
in the scope following the with
statement.仅在
with
语句之后的范围内修改python
。 The python
used in vim_configurable
is not affected. vim_configurable
使用的python
不受影响。 What I ended up doing is making a python3 version of vim_configurable
using vimUtils.makeCustomizable
:我落得这样做是做的python3版本
vim_configurable
使用vimUtils.makeCustomizable
:
vim-config/default.nix
: 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.我发现我需要在
.override
之前执行.customize
,如下所示,在我的 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 配置:
((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.我现在有
opt
评论,内容放在start
因为延迟加载不适用于默认加载器,并且使用start
加载的各个包应该无论如何都延迟加载。
I also removed the autocmd
parts that are supposed to work with opt
(but aren't):我还删除了应该与
opt
一起使用的autocmd
部分(但不是):
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
In Darwin(MacOS 10.15) I was not able to compile a vim from vim/configurable due too this error .在 Darwin(MacOS 10.15)中,由于这个错误,我也无法从 vim/configurable 编译 vim。 but I was able to compile it from the more crude version in vim/default.nix.
但我能够从 vim/default.nix 中更粗糙的版本编译它。
this is what worked for me:这对我有用:
let
pkgs = import <nixpkgs>{};
vim = import <nixpkgs/pkgs/applications/editors/vim>;
customVim = (pkgs.callPackage vim {
inherit (pkgs.darwin.apple_sdk.frameworks) Cocoa Carbon;
}).overrideDerivation (self : {
buildInputs = self.buildInputs ++ [ pkgs.python37 ];
configureFlags = self.configureFlags ++
[
#python support
"--enable-python3interp=yes"
"--with-python3-config-dir=${pkgs.python37}/lib"
"--with-python3-command=python3.7"
];
});
in customVim
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.