feat(nvim): add formatter.nvim

This commit is contained in:
Price Hiller 2023-08-28 15:58:41 -05:00
parent dab7611441
commit 92b6ca2052
Signed by: Price
SSH Key Fingerprint: SHA256:Y4S9ZzYphRn1W1kbJerJFO6GGsfu9O70VaBSxJO7dF8
2 changed files with 30 additions and 7 deletions

View File

@ -0,0 +1,30 @@
return {
{
"mhartington/formatter.nvim",
keys = {
{
"<leader>lf",
function()
local active_clients = vim.lsp.get_clients({ bufnr = 0, method = "textDocument/formatting" })
if #active_clients > 0 then
vim.lsp.buf.format({ async = true })
else
vim.cmd.Format()
end
end,
-- I know this is a lie below, but I'm used to the key being LSP bound, so fuck it
desc = "LSP: Format",
},
},
opts = function()
local filetypes = require("formatter.filetypes")
return {
logging = true,
log_level = vim.log.levels.WARN,
filetype = {
markdown = filetypes.markdown.prettierd,
},
}
end,
},
}

View File

@ -125,13 +125,6 @@ return {
end,
desc = "LSP: Diagnostic Open Float",
},
{
"<leader>lf",
function()
vim.lsp.buf.format({ async = true })
end,
desc = "LSP: Format",
},
{ "[l", vim.diagnostic.goto_prev, desc = "LSP: Diagnostic Previous" },
{ "]l", vim.diagnostic.goto_next, desc = "LSP: Diagnostic Next" },
{