From 2927afe3e2c50ea22b02209945cf25d5e8ae1f68 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Salinas Date: Sun, 23 Jun 2024 21:27:18 -0400 Subject: [PATCH] conform: initial config --- .gitmodules | 3 ++ init.lua | 65 +++++++++++++++------------------ pack/general/start/conform.nvim | 1 + 3 files changed, 34 insertions(+), 35 deletions(-) create mode 160000 pack/general/start/conform.nvim diff --git a/.gitmodules b/.gitmodules index 74d94fb..de40046 100644 --- a/.gitmodules +++ b/.gitmodules @@ -149,3 +149,6 @@ [submodule "pack/general/start/playground"] path = pack/general/start/playground url = https://github.com/nvim-treesitter/playground +[submodule "pack/general/start/conform.nvim"] + path = pack/general/start/conform.nvim + url = https://github.com/stevearc/conform.nvim diff --git a/init.lua b/init.lua index 2ac3104..cdc6467 100644 --- a/init.lua +++ b/init.lua @@ -221,17 +221,12 @@ vim.api.nvim_create_autocmd({ "FileType" }, { end, }) ----- formatter.nvim ---- -require("formatter").setup({ - filetype = { - terraform = { - require("formatter.filetypes.terraform").terraformfmt, - }, - }, - ["*"] = { - -- "formatter.filetypes.any" defines default configurations for any - -- filetype - require("formatter.filetypes.any").remove_trailing_whitespace, +---- conform.nvim ---- +require("conform").setup({ + format_on_save = { + -- These options will be passed to conform.format() + timeout_ms = 500, + lsp_format = "fallback", }, }) @@ -332,9 +327,9 @@ vim.api.nvim_create_autocmd({ "FileType" }, { vim.keymap.set("n", "[d", vim.diagnostic.goto_prev) vim.keymap.set("n", "]d", vim.diagnostic.goto_next) vim.keymap.set("n", "q", vim.diagnostic.setloclist) - vim.keymap.set("n", "", function() - vim.lsp.buf.format({ async = true }) - end) + -- vim.keymap.segcjk("n", "", function() + -- vim.lsp.buf.format({ async = true }) + -- end) end -- Use a loop to conveniently call 'setup' on multiple servers and @@ -416,26 +411,26 @@ vim.api.nvim_create_autocmd({ "FileType" }, { end, }) --- Auto format on save -vim.api.nvim_create_autocmd({ "BufWritePre" }, { - callback = function() - if vim.b.disable_format then - return - end - local lsp_format = false - for _, client in pairs(vim.lsp.buf_get_clients()) do - if client.server_capabilities.documentFormattingProvider then - lsp_format = true - break - end - end - if lsp_format then - vim.lsp.buf.format({ async = false }) - else - vim.cmd("Format") - end - end, -}) +-- -- Auto format on save +-- vim.api.nvim_create_autocmd({ "BufWritePre" }, { +-- callback = function() +-- if vim.b.disable_format then +-- return +-- end +-- local lsp_format = false +-- for _, client in pairs(vim.lsp.get_clients()) do +-- if client.server_capabilities.documentFormattingProvider then +-- lsp_format = true +-- break +-- end +-- end +-- if lsp_format then +-- vim.lsp.buf.format({ async = false }) +-- else +-- vim.cmd("Format") +-- end +-- end, +-- }) ---- nvim-lint ---- local lint = require("lint") @@ -680,7 +675,7 @@ vim.api.nvim_create_autocmd({ "BufEnter" }, { vim.cmd("packadd crates.nvim") local crates = require("crates") - crates.setup() + crates.setup({}) vim.keymap.set("n", "cv", crates.show_versions_popup) vim.keymap.set("n", "cf", crates.show_features_popup) vim.keymap.set("n", "cd", crates.show_dependencies_popup) diff --git a/pack/general/start/conform.nvim b/pack/general/start/conform.nvim new file mode 160000 index 0000000..9a06e83 --- /dev/null +++ b/pack/general/start/conform.nvim @@ -0,0 +1 @@ +Subproject commit 9a06e83527407a7600a2fe4e0d10adf432b6215e