From f47268bdb61ea02f6dc1ece2c699473277107947 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Tue, 24 Mar 2026 22:09:32 +0100 Subject: Neovim: conform arbeitet unabhängig von LSP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nvim/lua/config/keymaps.lua | 6 ------ nvim/lua/plugins/format.lua | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/nvim/lua/config/keymaps.lua b/nvim/lua/config/keymaps.lua index b193d5c..29dee94 100644 --- a/nvim/lua/config/keymaps.lua +++ b/nvim/lua/config/keymaps.lua @@ -15,12 +15,6 @@ function M.lsp(buffer, client) map("n", "K", vim.lsp.buf.hover, opts) map("n", "rn", vim.lsp.buf.rename, opts) map("n", "ca", vim.lsp.buf.code_action, opts) - map("n", "cf", function() - require("conform").format({ - async = true, - lsp_fallback = true, - }) - end, opts) local function set_c_bindings() if client and client.name == "clangd" then map("n", "hs", "ClangdSwitchSourceHeader", opts) end diff --git a/nvim/lua/plugins/format.lua b/nvim/lua/plugins/format.lua index 2d6a55c..9010657 100644 --- a/nvim/lua/plugins/format.lua +++ b/nvim/lua/plugins/format.lua @@ -1,12 +1,24 @@ return { "stevearc/conform.nvim", event = { "BufReadPre", "BufNewFile" }, + keys = { + { + "cf", + function() + require("conform").format({ + async = true, + lsp_fallback = true, + }) + end, + desc = "Format file", + }, + }, opts = { formatters_by_ft = { - sh = { "shfmt" }, -- brew install, pkg install shfmt + sh = { "shfmt" }, -- brew install, pkg install shfmt bash = { "shfmt" }, python = { "ruff_format", "black" }, -- brew install ruff, pkg install ruff - lua = { "stylua" }, -- brew install stylua, pkg install stylua + lua = { "stylua" }, -- brew install stylua, pkg install stylua typescript = { "prettierd", "prettier" }, javascript = { "prettierd", "prettier" }, json = { "jq" }, -- brew install jq, pkg install jq -- cgit v1.3