neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

conform.lua (1228B)


      1 if not pcall(require, 'conform') then
      2   return
      3 end
      4 
      5 local prettier = { { --[[ 'prettierd', ]] 'prettier' } }
      6 -- local util = require 'conform.util'
      7 require 'conform'.setup {
      8   formatters_by_ft = { html = prettier, css = prettier, scss = prettier },
      9   formatters = {
     10     prettier = {
     11       prepend_args = {
     12         '--plugin=/home/tms/.local/share/npm/lib/node_modules/prettier-plugin-organize-attributes/lib/index.js',
     13       },
     14     },
     15     -- prettierd = {
     16     --   args = {
     17     --     '$FILENAME',
     18     --     '--plugin=/home/tms/.local/share/npm/lib/node_modules/prettier-plugin-organize-attributes/lib/index.js',
     19     --   },
     20     --   range_args = function(_, ctx)
     21     --     local start_offset, end_offset = util.get_offsets_from_range(ctx.buf, ctx.range)
     22     --     return {
     23     --       '$FILENAME',
     24     --       '--range-start=' .. start_offset,
     25     --       '--range-end=' .. end_offset,
     26     --       '--plugin=/home/tms/.local/share/npm/lib/node_modules/prettier-plugin-organize-attributes/lib/index.js',
     27     --     }
     28     --   end,
     29     -- },
     30   },
     31 }
     32 
     33 vim.o.formatexpr = 'v:lua.require"conform".formatexpr()'
     34 
     35 vim.keymap.set('n', 'gQ', function()
     36   require 'conform'.format { lsp_fallback = true }
     37 end, { desc = 'Format' })