diff --git a/lua/core/globals.lua b/lua/core/globals.lua index 8ace8bc1..85fb1b60 100644 --- a/lua/core/globals.lua +++ b/lua/core/globals.lua @@ -7,3 +7,52 @@ vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal vim.g.have_nerd_font = false + +-- Configs for Programming Languages +-- like LSPs, Tree-sitters, Linters, Fromatters, Debuggers, etc. +Langs = { + treesitter = { + 'bash', + 'c', + 'c_sharp', + 'css', + 'diff', + 'go', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'php', + 'python', + 'query', + 'vim', + 'vimdoc', + 'zig', + }, + + linter = { + markdown = { 'mado' }, -- or rumdl + python = { 'ruff' }, + }, + + fmt = { + lua = { 'stylua' }, + sh = { 'shfmt' }, + bash = { 'shfmt' }, + python = { 'ruff_format' }, + blade = { 'blade-formatter' }, + markdown = { 'mdformat' }, + }, + + fmt_cmd = { + shfmt = { + prepend_args = { '-i', '4' }, + -- The base args are { "-filename", "$FILENAME" } so the final args will be + -- { "-filename", "$FILENAME", "-i", "2" } + }, + ['blade-formatter'] = { + prepend_args = { '-i', '2' }, + }, + }, +} diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua index caacddb8..5792f75c 100644 --- a/lua/plugins/conform.lua +++ b/lua/plugins/conform.lua @@ -16,7 +16,7 @@ return { ---@module 'conform' ---@type conform.setupOpts opts = { - notify_on_error = false, + notify_on_error = true, format_on_save = function(bufnr) -- Disable "format_on_save lsp_fallback" for languages that don't -- have a well standardized coding style. You can add additional @@ -31,13 +31,12 @@ return { } end end, - formatters_by_ft = { - lua = { 'stylua' }, - -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, - -- - -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, + formatters_by_ft = Langs.fmt, + -- Conform can also run multiple formatters sequentially + -- python = { "isort", "black" }, + -- + -- You can use 'stop_after_first' to run the first available formatter from the list + -- javascript = { "prettierd", "prettier", stop_after_first = true }, + formatters = Langs.fmt_cmd, }, } diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua index 1b43d1f3..6e46f0be 100644 --- a/lua/plugins/nvim-lint.lua +++ b/lua/plugins/nvim-lint.lua @@ -7,9 +7,7 @@ return { event = { 'BufReadPre', 'BufNewFile' }, config = function() local lint = require 'lint' - lint.linters_by_ft = { - markdown = { 'markdownlint' }, - } + lint.linters_by_ft = Langs.linter -- To allow other plugins to add linters to require('lint').linters_by_ft, -- instead set linters_by_ft like this: diff --git a/lua/plugins/nvim-treesitter.lua b/lua/plugins/nvim-treesitter.lua index 011fb697..732921b6 100644 --- a/lua/plugins/nvim-treesitter.lua +++ b/lua/plugins/nvim-treesitter.lua @@ -6,20 +6,7 @@ return { branch = 'main', -- [[ Configure Treesitter ]] See `:help nvim-treesitter-intro` config = function() - local parsers = { - 'bash', - 'c', - 'diff', - 'html', - 'lua', - 'luadoc', - 'markdown', - 'markdown_inline', - 'query', - 'vim', - 'vimdoc', - } - require('nvim-treesitter').install(parsers) + require('nvim-treesitter').install(Langs.treesitter) vim.api.nvim_create_autocmd('FileType', { callback = function(args) local buf, filetype = args.buf, args.match