Skip to content

Commit

Permalink
[vim] conform for formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
antonk52 committed Nov 3, 2023
1 parent e58ed5f commit 350592f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ local plugins = {
end)
end,
},
{
'stevearc/conform.nvim',
opts = {
formatters_by_ft = {
lua = { 'stylua' },
-- Use a sub-list to run only the first available formatter
javascript = { { 'prettier' } },
javascriptreact = { { 'prettier' } },
typescript = { { 'prettier' } },
typescriptreact = { { 'prettier' } },
},
},
},
{
'antonk52/markdowny.nvim',
opts = { filetypes = { 'markdown', 'hgcommit', 'gitcommit' } },
Expand Down
4 changes: 3 additions & 1 deletion nvim/lua/antonk52/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ function M.on_attach(client, bufnr)
keymap('<leader>]', function()
vim.diagnostic.goto_next({ float = M.diag_float_opts })
end, 'go to next diagnostic')
keymap('<localleader>F', formatLsp, 'lsp format')
keymap('<localleader>F', function()
require('conform').format({ lsp_fallback = false })
end, 'Conform format')
keymap('<localleader>f', function()
vim.lsp.buf.code_action({
filter = function(a)
Expand Down

0 comments on commit 350592f

Please sign in to comment.