From 7931d193b69fa6000eb592962d96d03c5b0738a4 Mon Sep 17 00:00:00 2001 From: tiyn Date: Tue, 5 Mar 2024 19:46:26 +0100 Subject: [PATCH] nvim: added stylua with custom config --- .config/nvim/lua/plugins/conform.lua | 9 +++++---- .config/nvim/lua/plugins/mason.lua | 13 ++++++++----- .config/stylua/stylua.toml | 10 ++++++++++ 3 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 .config/stylua/stylua.toml diff --git a/.config/nvim/lua/plugins/conform.lua b/.config/nvim/lua/plugins/conform.lua index 10cda12..86f4dc2 100644 --- a/.config/nvim/lua/plugins/conform.lua +++ b/.config/nvim/lua/plugins/conform.lua @@ -1,18 +1,19 @@ return { -- improved refactoring { - 'stevearc/conform.nvim', + "stevearc/conform.nvim", config = function() require("conform").setup({ formatters_by_ft = { python = { "isort", "black" }, markdown = { "mdformat" }, tex = { "latexindent" }, - } + lua = { "stylua" }, + }, }) require("conform").formatters.latexindent = { prepend_args = { "-y=defaultIndent: ' '" }, } - end - } + end, + }, } diff --git a/.config/nvim/lua/plugins/mason.lua b/.config/nvim/lua/plugins/mason.lua index 24283c4..f20897c 100644 --- a/.config/nvim/lua/plugins/mason.lua +++ b/.config/nvim/lua/plugins/mason.lua @@ -8,13 +8,15 @@ return { config = function() require("null-ls").setup({ sources = { - -- python - require("null-ls").builtins.formatting.isort, - require("null-ls").builtins.formatting.black, - -- markdown - require("null-ls").builtins.formatting.mdformat, -- latex require("null-ls").builtins.formatting.latexindent, + -- lua + require("null-ls").builtins.formatting.stylua, + -- markdown + require("null-ls").builtins.formatting.mdformat, + -- python + require("null-ls").builtins.formatting.black, + require("null-ls").builtins.formatting.isort, } }) end @@ -28,6 +30,7 @@ return { "isort", "latexindent", "mdformat", + "stylua", } } } diff --git a/.config/stylua/stylua.toml b/.config/stylua/stylua.toml new file mode 100644 index 0000000..bff1a9f --- /dev/null +++ b/.config/stylua/stylua.toml @@ -0,0 +1,10 @@ +column_width = 100 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +call_parentheses = "Always" +collapse_simple_statement = "Never" + +[sort_requires] +enabled = true