switch to null-ls formatting

This commit is contained in:
Charlotte 🦝 Delenk 2022-09-04 15:01:32 +01:00
parent 32bb424a61
commit 2cdec36b2d
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
6 changed files with 116 additions and 100 deletions

View file

@ -1,5 +1,5 @@
{ pkgs, ... }: {
output.plugins = with pkgs.vimPlugins; [ rust-tools-nvim ];
{pkgs, ...}: {
output.plugins = with pkgs.vimPlugins; [rust-tools-nvim];
output.config_file = ''
lua require("rust-analyzer-config")
'';

View file

@ -1,11 +1,6 @@
# Largely copied from a great blog post:
# https://sharksforarms.dev/posts/neovim-rust/
{
pkgs,
lib,
config,
...
}:
{ pkgs, lib, config, ... }:
with lib; {
vim.opt = {
completeopt = "menuone,noinsert,noselect";
@ -20,14 +15,15 @@ with lib; {
};
vim.keybindings.keybindings-shortened = {
"K" = {command = "<cmd>lua vim.lsp.buf.hover()<cr>";};
"K" = { command = "<cmd>lua vim.lsp.buf.hover()<cr>"; };
};
vim.g.lightline.component_expand.lsp_status = "LspStatus";
vim.g.lightline.active.right = mkAfter [["lsp_status"]];
vim.g.lightline.active.right = mkAfter [ [ "lsp_status" ] ];
# https://discourse.nixos.org/t/rust-src-not-found-and-other-misadventures-of-developing-rust-on-nixos/11570/2
output.makeWrapper = "--set RUST_SRC_PATH ${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
output.makeWrapper =
"--set RUST_SRC_PATH ${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
output.config_file = ''
set shortmess+=c
@ -50,8 +46,7 @@ with lib; {
lsp_status.on_attach(client)
-- Disable formatting for all LS, let null-ls handle this
client.resolved_capabilities.document_formatting = false
client.resolved_capabilities.document_range_formatting = false
client.resolved_capabilities.documentFormattingProvider = false
end
-- Setup all LSPs
@ -84,7 +79,6 @@ with lib; {
endfunction
autocmd InsertLeave,BufEnter,BufWritePost * call lightline#update()
autocmd User LspDiagnosticsChanged call lightline#update()
autocmd BufWritePre * lua vim.lsp.buf.formatting_sync()
" Show diagnostic popup on cursor hold
autocmd CursorHold * lua vim.diagnostic.open_float()

View file

@ -8,23 +8,7 @@ with lib; {
output.plugins = with pkgs.vimPlugins; [null-ls-nvim plenary-nvim];
output.config_file = ''
lua << EOF
local n = require'null-ls'
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
n.setup({
sources = {
n.builtins.formatting.stylua,
n.builtins.formatting.rustfmt,
n.builtins.formatting.nixfmt,
-- https://github.com/jose-elias-alvarez/null-ls.nvim/issues/640
n.builtins.formatting.black.with({ args = { "--quiet", "-" }, }),
},
})
EOF
lua require("null-ls-config")
'';
output.path.path = with pkgs; [

View file

@ -0,0 +1,39 @@
local n = require("null-ls")
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")
local FORMATTING = methods.internal.FORMATTING
n.setup({
sources = {
n.builtins.formatting.stylua,
n.builtins.formatting.rustfmt,
n.builtins.formatting.nixfmt,
-- https://github.com/jose-elias-alvarez/null-ls.nvim/issues/640
n.builtins.formatting.black.with({ args = { "--quiet", "-" } }),
},
})
local lsp_formatting = function(bufnr)
vim.lsp.buf.format({
filter = function(client)
return client.name == "null-ls"
end,
bufnr = bufnr,
})
end
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local on_attach = function(client, bufnr)
if client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
lsp_formatting(bufnr)
end,
})
end
end

View file

@ -1 +1 @@
{ pkgs, ... }: { output.plugins = with pkgs.vimPlugins; [ editorconfig-nvim ]; }
{pkgs, ...}: {output.plugins = with pkgs.vimPlugins; [editorconfig-nvim];}

View file

@ -1,88 +1,87 @@
{ lib
, stdenv
, runCommand
, fetchFromGitHub
, fetchYarnDeps
, writeText
, jq
, yarn
, fixup_yarn_lock
, nodejs
, jitsi-meet
, conf ? { }
}:
let
{
lib,
stdenv,
runCommand,
fetchFromGitHub,
fetchYarnDeps,
writeText,
jq,
yarn,
fixup_yarn_lock,
nodejs,
jitsi-meet,
conf ? {},
}: let
pinData = lib.importJSON ./pin.json;
noPhoningHome = {
disable_guests = true; # disable automatic guest account registration at matrix.org
piwik = false; # disable analytics
};
configOverrides = writeText "element-config-overrides.json" (builtins.toJSON (noPhoningHome // conf));
in
stdenv.mkDerivation rec {
pname = "element-web";
inherit (pinData) version;
in stdenv.mkDerivation rec {
pname = "element-web";
inherit (pinData) version;
src = fetchFromGitHub {
owner = "vector-im";
repo = pname;
rev = version;
sha256 = pinData.webSrcHash;
};
src = fetchFromGitHub {
owner = "vector-im";
repo = pname;
rev = version;
sha256 = pinData.webSrcHash;
};
yarnLock = ./element-web-yarn.lock;
offlineCache = fetchYarnDeps {
inherit yarnLock;
sha256 = pinData.webYarnHash;
};
yarnLock = ./element-web-yarn.lock;
offlineCache = fetchYarnDeps {
inherit yarnLock;
sha256 = pinData.webYarnHash;
};
nativeBuildInputs = [yarn fixup_yarn_lock jq nodejs];
nativeBuildInputs = [ yarn fixup_yarn_lock jq nodejs ];
configurePhase = ''
runHook preConfigure
configurePhase = ''
runHook preConfigure
export HOME=$PWD/tmp
mkdir -p $HOME
export HOME=$PWD/tmp
mkdir -p $HOME
cp ${./element-web-package.json} package.json
cp $yarnLock yarn.lock
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror $offlineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
cp ${./element-web-package.json} package.json
cp $yarnLock yarn.lock
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror $offlineCache
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
runHook postConfigure
'';
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
buildPhase = ''
runHook preBuild
export VERSION=${version}
yarn build:res --offline
yarn build:module_system --offline
yarn build:bundle --offline
export VERSION=${version}
yarn build:res --offline
yarn build:module_system --offline
yarn build:bundle --offline
runHook postBuild
'';
runHook postBuild
'';
installPhase = ''
runHook preInstall
installPhase = ''
runHook preInstall
cp -R webapp $out
cp ${jitsi-meet}/libs/external_api.min.js $out/jitsi_external_api.min.js
echo "${version}" > "$out/version"
jq -s '.[0] * .[1]' "config.sample.json" "${configOverrides}" > "$out/config.json"
cp -R webapp $out
cp ${jitsi-meet}/libs/external_api.min.js $out/jitsi_external_api.min.js
echo "${version}" > "$out/version"
jq -s '.[0] * .[1]' "config.sample.json" "${configOverrides}" > "$out/config.json"
runHook postInstall
'';
runHook postInstall
'';
meta = {
description = "A glossy Matrix collaboration client for the web";
homepage = "https://element.io/";
changelog = "https://github.com/vector-im/element-web/blob/v${version}/CHANGELOG.md";
maintainers = lib.teams.matrix.members;
license = lib.licenses.asl20;
platforms = lib.platforms.all;
};
}
meta = {
description = "A glossy Matrix collaboration client for the web";
homepage = "https://element.io/";
changelog = "https://github.com/vector-im/element-web/blob/v${version}/CHANGELOG.md";
maintainers = lib.teams.matrix.members;
license = lib.licenses.asl20;
platforms = lib.platforms.all;
};
}