diff --git a/home/common/core/nixvim/default.nix b/home/common/core/nixvim/default.nix index b07a144..912ab15 100644 --- a/home/common/core/nixvim/default.nix +++ b/home/common/core/nixvim/default.nix @@ -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 ''; - }; } diff --git a/home/common/core/nixvim/plugins/conform.nix b/home/common/core/nixvim/plugins/conform.nix index 7e27ea0..5a56d03 100644 --- a/home/common/core/nixvim/plugins/conform.nix +++ b/home/common/core/nixvim/plugins/conform.nix @@ -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"; + }; }; }; } diff --git a/home/common/core/nixvim/plugins/default.nix b/home/common/core/nixvim/plugins/default.nix index 742721f..348b687 100644 --- a/home/common/core/nixvim/plugins/default.nix +++ b/home/common/core/nixvim/plugins/default.nix @@ -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 @@ -84,12 +86,12 @@ in -- Custom color for modified buffers vim.api.nvim_set_hl(0, "BufferManagerModified", { fg = "#988100" }) - + local bmui = require("buffer_manager.ui") vim.keymap.set('n', 'b', bmui.toggle_quick_menu, opts) vim.keymap.set('n', 'n', bmui.nav_next, opts) vim.keymap.set('n', 'p', bmui.nav_prev, opts) - + local keys="1234567890" for i = 1, #keys do local key = keys:sub(i,i) @@ -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 }) ''; - } -