config conform.nvim

- removed sqlfmt and replaced with sql-formatter
This commit is contained in:
Sam 2024-08-25 23:22:24 +01:00
parent 6f5f8867fd
commit 1af24715ff
3 changed files with 54 additions and 18 deletions

View File

@ -1,5 +1,8 @@
{ inputs, pkgs, ... }:
{
inputs,
pkgs,
...
}: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
./plugins
@ -11,10 +14,18 @@
# Install home packages needed for nixvim
home.packages = [
pkgs.nixpkgs-fmt
pkgs.black
pkgs.yamllint
pkgs.yamlfmt
pkgs.prettierd
pkgs.sqlfmt
pkgs.nodePackages_latest.sql-formatter
pkgs.alejandra
pkgs.shellcheck
pkgs.shellharden
pkgs.shfmt
pkgs.stylua
];
programs.nixvim = {
enable = true;
enableMan = true; # install man pages for nixvim options
@ -44,9 +55,8 @@
let wiki_0.ext = '.md'
" ==== dbui
let g:db_ui_hide_schemas = ['pg_catalog', 'pg_toast_temp.*']
let g:db_ui_hide_schemas = ['pg_catalog', 'pg_toast_temp.*', 'pg_toast']
let g:db_ui_use_nerd_fonts = 1
'';
};
}

View File

@ -6,16 +6,29 @@
timeoutMs = 500;
};
notifyOnError = true;
logLevel = "debug";
formattersByFt = {
html = [["prettierd" "prettier"]];
css = [["prettierd" "prettier"]];
javascript = [["prettierd" "prettier"]];
html = ["prettierd"];
css = ["prettierd"];
javascript = ["prettierd"];
python = ["black"];
lua = ["stylua"];
nix = ["alejandra"];
markdown = [["prettierd" "prettier"]];
yaml = ["yamllint" "yamlfmt"];
sql = ["sqlfmt"];
markdown = ["prettierd"];
yaml = ["yamlfmt"];
sql = ["sql-formatter"];
bash = [
"shellcheck"
"shellharden"
"shfmt"
];
};
formatters = {
sql-formatter = {
"inherit" = "false";
command = "sql-formatter";
args = "--config ~/.config/sql-formatter/config.json $FILENAME";
};
};
};
}

View File

@ -1,8 +1,10 @@
{ pkgs, config, ... }:
let
user = config.home.username;
in
{
pkgs,
config,
...
}: let
user = config.home.username;
in {
imports = [
./cmp.nix
./colorizer.nix
@ -108,7 +110,18 @@ in
path = "/home/${user}/.local/share/notes",
},
}
'';
-- Format function for conform.nvim
vim.api.nvim_create_user_command("Format", function(args)
local range = nil
if args.count ~= -1 then
local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1]
range = {
start = { args.line1, 0 },
["end"] = { args.line2, end_line:len() },
}
end
require("conform").format({ async = true, lsp_format = "fallback", range = range })
end, { range = true })
'';
}