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:
parent
60188ff1da
commit
e80a1034a5
16
home/packages/sqlformat/default.nix
Normal file
16
home/packages/sqlformat/default.nix
Normal 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 -)
|
||||
'';
|
||||
}
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue