Migrate away from 3rd party vim plugin for sqlformat

It didn't work.
Instead I migrated to nix + python directly.
I keep the way to use autocommand to set the formatting.
But no expression but an external program.
This program is created via nix as shell application.
This one uses the sqlparse, just like the plugin.
This will use the std input as file for input.

That way I can re use this in other places.
Integration is way easier, no additional overhead to write python
embedded as vimscript.
Also full dependency control via nix.
This commit is contained in:
Daniel Siepmann 2022-05-30 10:32:20 +02:00
parent 60188ff1da
commit e80a1034a5
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
3 changed files with 33 additions and 20 deletions

View file

@ -0,0 +1,16 @@
{
writeShellApplication,
python3
}:
let
python = python3.withPackages(python-packages: with python-packages; [
sqlparse
]);
in writeShellApplication {
name = "sqlformat";
text = ''
${python}/bin/python3 -m sqlparse --keywords upper --identifiers lower --reindent_aligned --indent_width 4 <(cat -)
'';
}

View file

@ -1,11 +1,16 @@
{ config, pkgs }:
{
let
sqlformat = pkgs.callPackage ./packages/sqlformat {
};
in {
# Let Home Manager install and manage itself.
home-manager.enable = true;
neovim = import ./programs/neovim.nix {
inherit pkgs;
inherit pkgs sqlformat;
};
git = import ./programs/git.nix {

View file

@ -1,4 +1,7 @@
{ pkgs }:
{
pkgs,
sqlformat
}:
let
@ -106,16 +109,6 @@ let
};
};
sqlformat = pkgs.vimUtils.buildVimPluginFrom2Nix {
name = "sqlformat";
src = pkgs.fetchFromGitHub {
owner = "mpyatishev";
repo = "vim-sqlformat";
rev = "2a2a57d75865526f85d94bf769f4fd54d61c426b";
sha256 = "LPnHcuh+jxEL8CZ1wizHqi3uzYYtIxzMqnE7y7mTrbE=";
};
};
diff-fold = pkgs.vimUtils.buildVimPluginFrom2Nix {
name = "diff-fold";
src = pkgs.fetchFromGitHub {
@ -196,11 +189,6 @@ let
in {
enable = true;
extraPython3Packages = (ps: with ps; [
# Dependency of sqlformat
sqlparse
]);
# TODO: Check out these plugins as additions / replacements:
# - https://github.com/NTBBloodbath/rest.nvim recommended by Sascha, allows to write and execute requests
@ -221,7 +209,12 @@ in {
colorscheme-smyckblue
neotags
configuration
{
plugin = configuration;
config = ''
au FileType sql setlocal formatprg=${sqlformat}/bin/sqlformat
'';
}
syntax-typoscript
# More UI related
@ -272,7 +265,6 @@ in {
# Adding features
ag
sqlformat
diff-fold
BufOnly-vim