From: Stefan Huber Date: Wed, 17 Jul 2024 19:50:47 +0000 (+0200) Subject: plugins: Configure formatter X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=f1d6906558edee82144b15a8fd4da016ef400466;p=vimconf.git plugins: Configure formatter --- diff --git a/plugins-full.vim.example b/plugins-full.vim.example index f1ba0d5..8de5806 100644 --- a/plugins-full.vim.example +++ b/plugins-full.vim.example @@ -149,10 +149,42 @@ EOF -- require("rust-tools").setup {} -- end } + + local formatter = require("formatter") + + -- Provides the Format, FormatWrite, FormatLock, and FormatWriteLock commands + require("formatter").setup { + -- Enable or disable logging + logging = true, + -- Set the log level + log_level = vim.log.levels.WARN, + -- All formatter configurations are opt-in + filetype = { + c = { require("formatter.filetypes.c").clangformat }, + cpp = { require("formatter.filetypes.cpp").clangformat }, + css = require('formatter.filetypes.css').prettier, + html = require('formatter.filetypes.html').prettier, + java = { require("formatter.filetypes.java").clangformat }, + javascript = require('formatter.filetypes.javascript').prettier, + json = require('formatter.filetypes.json').jq, + python = { require("formatter.filetypes.python").black }, + xml = { require("formatter.filetypes.xml").xmllint }, + + -- Use the special "*" filetype for defining formatter configurations on + -- any filetype + ["*"] = { + -- "formatter.filetypes.any" defines default configurations for any + -- filetype + require("formatter.filetypes.any").remove_trailing_whitespace + } + } + } EOF " A gK mapping for hover. The default 'K' is already mapped to :Map nmap gK :lua vim.lsp.buf.hover() + nnoremap f :Format + nnoremap F :FormatWrite endif let g:fastfold_minlines = 0