home/neovim: Add pyls-black

Black’s integrated vim plugin does some virtualenv wizardry that does
not work on nixos.
This commit is contained in:
Simon Bruder 2020-11-08 12:17:22 +01:00
parent 3191c9119f
commit 5fb1304dae
No known key found for this signature in database
GPG key ID: 6F03E0000CC5B62F

View file

@ -30,6 +30,41 @@ let
sha256 = "1ss065b2psalli46bs3v13fhaplqydh13bg3jg3zr98wbdn70cws";
};
};
pyls-black = pkgs.python3Packages.buildPythonPackage rec {
pname = "pyls-black";
version = "0.4.6";
src = pkgs.python3Packages.fetchPypi {
inherit pname version;
sha256 = "0qsnjrpqhws7ajwg5y01fcpn1y6jc89ql61rpaknwqq5srg0ww1k";
};
propagatedBuildInputs = with pkgs.python3Packages; [
black
toml
];
# circular dependency
doCheck = false;
postPatch = ''
sed -i 's/python-language-server; //' setup.cfg
'';
};
pyls = (pkgs.python3Packages.python-language-server.override {
providers = [
# everything except autopep8 and yapf (conflicts with black)
"mccabe"
"pycodestyle"
"pydocstyle"
"pyflakes"
"pylint"
"rope"
];
}).overrideAttrs (oldAttrs: oldAttrs // {
propagatedBuildInputs = oldAttrs.propagatedBuildInputs ++ [
pyls-black
];
});
in
{
programs.neovim = {
@ -119,7 +154,7 @@ in
let g:LanguageClient_serverCommands = {
\ 'rust': ['rustup', 'run', 'stable', 'rls'],
\ 'go': ['${pkgs.gopls}/bin/gopls'],
\ 'python': ['${pkgs.python3Packages.python-language-server}/bin/pyls'],
\ 'python': ['${pyls}/bin/pyls'],
\ 'typescript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'],
\ 'javascript': ['${pkgs.nodePackages.javascript-typescript-langserver}/bin/javascript-typescript-stdio'],
\ 'haskell': ['${pkgs.haskellPackages.haskell-language-server}/bin/haskell-language-server', '--lsp'],
@ -134,7 +169,9 @@ in
nnoremap <buffer> <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <buffer> <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <buffer> <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
nnoremap <buffer> <silent> <Leader>f :call LanguageClient#textDocument_formatting()<CR>
" disable since it breaks most code
"set formatexpr=LanguageClient#textDocument_rangeFormatting_sync()
endif
endfunction
@ -226,7 +263,6 @@ in
rainbow_csv
vim-openscad
];
# TODO: add psf/black
};
xdg.configFile = {