feat(nvim): add formatter.nvim
This commit is contained in:
parent
dab7611441
commit
92b6ca2052
30
dots/.config/nvim/lua/plugins/configs/formatter.lua
Normal file
30
dots/.config/nvim/lua/plugins/configs/formatter.lua
Normal 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,
|
||||||
|
},
|
||||||
|
}
|
@ -125,13 +125,6 @@ return {
|
|||||||
end,
|
end,
|
||||||
desc = "LSP: Diagnostic Open Float",
|
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_prev, desc = "LSP: Diagnostic Previous" },
|
||||||
{ "]l", vim.diagnostic.goto_next, desc = "LSP: Diagnostic Next" },
|
{ "]l", vim.diagnostic.goto_next, desc = "LSP: Diagnostic Next" },
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user