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

View File

@ -6,16 +6,29 @@
timeoutMs = 500; timeoutMs = 500;
}; };
notifyOnError = true; notifyOnError = true;
logLevel = "debug";
formattersByFt = { formattersByFt = {
html = [["prettierd" "prettier"]]; html = ["prettierd"];
css = [["prettierd" "prettier"]]; css = ["prettierd"];
javascript = [["prettierd" "prettier"]]; javascript = ["prettierd"];
python = ["black"]; python = ["black"];
lua = ["stylua"]; lua = ["stylua"];
nix = ["alejandra"]; nix = ["alejandra"];
markdown = [["prettierd" "prettier"]]; markdown = ["prettierd"];
yaml = ["yamllint" "yamlfmt"]; yaml = ["yamlfmt"];
sql = ["sqlfmt"]; 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 = [ imports = [
./cmp.nix ./cmp.nix
./colorizer.nix ./colorizer.nix
@ -108,7 +110,18 @@ in
path = "/home/${user}/.local/share/notes", 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 })
''; '';
} }