diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/formatter.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/formatter.lua index 4958617..041be1e 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/formatter.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/formatter.lua @@ -2,39 +2,58 @@ return { "stevearc/conform.nvim", event = "VeryLazy", opts = { + -- log_level = vim.log.levels.DEBUG, + -- See aviable formatters in: https://github.com/stevearc/conform.nvim#formatters -- Formatters can be installed by mason formatters_by_ft = { -- Conform will run multiple formatters sequentially - -- Use a sub-list to run only the first available formatter + -- Use a stop_after_first = true to run only the first available formatter -- Use the "_" filetype to run formatters on filetypes that don't -- have other formatters configured. - ["_"] = { "trim_whitespace" }, + ["_"] = { "trim_whitespace", "injected" }, blade = { "blade-formatter" }, - css = { { "prettierd", "prettier" } }, - go = { { "gofumpt", "goimports_reviser", "golines" } }, - html = { "prettierd" }, - javascript = { { "prettierd", "prettier" } }, - javascriptreact = { { "prettierd", "prettier" } }, - json = { { "prettierd", "prettier" } }, - jsonc = { { "prettierd", "prettier" } }, + css = { "prettierd", "prettier" }, + go = { "gofumpt", "goimports_reviser", "golines" }, + html = { "djlint", "prettierd", stop_after_first = true }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + javascriptreact = { "prettierd", "prettier", stop_after_first = true }, + json = { "prettierd", "prettier", stop_after_first = true }, + jsonc = { "prettierd", "prettier", stop_after_first = true }, lua = { "stylua" }, markdown = { "markdownlint" }, nim = { "nimpretty" }, php = { "pint" }, python = { "blue" }, - scss = { { "prettierd", "prettier" } }, + scss = { "prettierd", "prettier", stop_after_first = true }, sh = { "shfmt" }, - typescript = { { "prettierd", "prettier" } }, - typescriptreact = { { "prettierd", "prettier" } }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + typescriptreact = { "prettierd", "prettier", stop_after_first = true }, xml = { "lemminx" }, zsh = { "shfmt" } }, + formatters = { + djlint = { + prepend_args = { + "--format-css", + "--indent-css", + "2", + "--format-js", + "--indent-js", + "2", + "--indent", + "2", + "--preserve-blank-lines", + "--quiet" + } + } + }, format_on_save = function(bufnr) -- Disable with a global or buffer-local variable if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then return end + return { timeout_ms = 2000, lsp_fallback = true } end, }, @@ -45,15 +64,17 @@ return { -- to make this global, change b to g if vim.b.disable_autoformat == nil then vim.b.disable_autoformat = true + print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat)) return end vim.b.disable_autoformat = not vim.b.disable_autoformat + print("Autoformat set to: " .. tostring(not vim.b.disable_autoformat)) end MAP("n", "uf", toggleAutoFormat, "Toggle auto format") - vim.api.nvim_create_user_command("Format", function(args) + vim.api.nvim_create_user_command("Fmt", 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] @@ -62,7 +83,38 @@ return { ["end"] = { args.line2, end_line:len() }, } end - require("conform").format({ async = true, lsp_format = "fallback", range = range }) - end, { range = true }) + + local function callback(err, did_edit) + if not did_edit then + vim.notify("The file was not formatted:\n" .. tostring(err), vim.log.levels.ERROR) + return + end + + if args.bang then + vim.cmd("w") + end + end + + require("conform").format( + { + async = true, + lsp_format = "fallback", + range = range, + formatters = args.fargs + }, + callback + ) + end, { + range = true, + bang = true, + force = true, + desc = "Format the document", + nargs = '*', + -- complete = function() + -- local formatters = require('conform').formatters_by_ft + -- + -- return vim.tbl_keys(formatters) + -- end + }) end, } diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/init.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/init.lua index f0cf148..8dbb557 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/init.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/init.lua @@ -30,6 +30,10 @@ return { auto_enable = true, lsp = true, }, + keys = { + { "uc", "CccPick", desc = "Open Color picker" }, + { "uC", "CccHighlighterToggle", desc = "Toggle Color highlight" }, + }, }, -- Dotfiles management { diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua index b18351a..75d6799 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/lsp.lua @@ -56,7 +56,26 @@ return { bashls = {}, cssls = {}, dockerls = {}, - emmet_ls = {}, + emmet_ls = { + filetypes = { + "astro", + "css", + "eruby", + "html", + "htmldjango", + "javascriptreact", + "less", + "pug", + "sass", + "scss", + "svelte", + "typescriptreact", + "vue", + "htmlangular", + "php", + "blade" + }, + }, html = {}, marksman = {}, pyright = {}, diff --git a/chezmoi/dot_config/nvim/lua/aleidk/plugins/treesitter.lua b/chezmoi/dot_config/nvim/lua/aleidk/plugins/treesitter.lua index 4d97095..6246d99 100644 --- a/chezmoi/dot_config/nvim/lua/aleidk/plugins/treesitter.lua +++ b/chezmoi/dot_config/nvim/lua/aleidk/plugins/treesitter.lua @@ -4,9 +4,9 @@ return { event = { "BufReadPost", "BufNewFile", "BufWritePre", "VeryLazy" }, dependencies = { "nvim-treesitter/nvim-treesitter-textobjects", - "windwp/nvim-ts-autotag", "JoosepAlviste/nvim-ts-context-commentstring", "nvim-treesitter/nvim-treesitter-context", + { "windwp/nvim-ts-autotag", opts = {} }, }, build = ":TSUpdate", config = function() @@ -82,7 +82,7 @@ return { }, }, }, - autotag = { enable = true }, + -- autotag = { enable = true }, }) require('ts_context_commentstring').setup { diff --git a/chezmoi/dot_config/nvim/original_lazy-lock.json b/chezmoi/dot_config/nvim/original_lazy-lock.json index 4733d95..edbb388 100644 --- a/chezmoi/dot_config/nvim/original_lazy-lock.json +++ b/chezmoi/dot_config/nvim/original_lazy-lock.json @@ -14,7 +14,7 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "comment-box.nvim": { "branch": "main", "commit": "06bb771690bc9df0763d14769b779062d8f12bc5" }, - "conform.nvim": { "branch": "master", "commit": "cd75be867f2331b22905f47d28c0c270a69466aa" }, + "conform.nvim": { "branch": "master", "commit": "0ebe875d9c306f5fc829db38492ffff2a70d8e9d" }, "debugprint.nvim": { "branch": "main", "commit": "8f2a335fb0e6ebf0291a3551e0198363437e3a38" }, "diffview.nvim": { "branch": "main", "commit": "4516612fe98ff56ae0415a259ff6361a89419b0a" }, "dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" }, @@ -73,4 +73,4 @@ "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-sleuth": { "branch": "master", "commit": "1cc4557420f215d02c4d2645a748a816c220e99b" }, "zen-mode.nvim": { "branch": "main", "commit": "2694c5a2bc4dc26c7a9e74b9e2b812920c90a830" } -} \ No newline at end of file +} diff --git a/chezmoi/dot_config/tmux/tmux.conf b/chezmoi/dot_config/tmux/tmux.conf index 06d309c..4ea8b36 100644 --- a/chezmoi/dot_config/tmux/tmux.conf +++ b/chezmoi/dot_config/tmux/tmux.conf @@ -44,7 +44,7 @@ unbind '"' # Split horizontally bind s split-window -h -c "#{pane_current_path}" bind v split-window -v -c "#{pane_current_path}" -bind D kill-pane +bind D respawn-pane -k bind -r m resize-pane -Z # maximize pane