Skip to content

Commit

Permalink
refactor: pull efm settings into separate section
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Sep 3, 2022
1 parent fc52702 commit af7d799
Showing 1 changed file with 38 additions and 33 deletions.
71 changes: 38 additions & 33 deletions nvim/lua/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,43 @@ local options_ruby = {
},
}

--------------------------------------------------------------------------------
-- efm
--------------------------------------------------------------------------------
local options_efm = {
init_options = {
documentFormatting = true,
},
settings = {
rootMarkers = { ".git/" },
languages = {
lua = {
{ formatCommand = "stylua -", formatStdin = true },
},
python = {
{
formatCommand = "black --quiet -",
formatStdin = true,
},
{
formatCommand = "isort --quiet -",
formatStdin = true,
},
{
lintCommand = "flake8 -",
lintStdin = true,
lintFormats = { "%f:%l:%c: %m" },
},
},
yaml = { { formatCommand = "prettierd -", formatStdin = true } },
html = { { formatCommand = "prettierd -", formatStdin = true } },
css = { { formatCommand = "prettierd -", formatStdin = true } },
json = { { formatCommand = "prettier -", formatStdin = true } },
},
},
filetypes = { "lua", "python", "yaml", "html", "css", "json" },
}

--------------------------------------------------------------------------------
-- initialize
--------------------------------------------------------------------------------
Expand Down Expand Up @@ -251,38 +288,6 @@ require("mason-lspconfig").setup_handlers({
lspconfig.rust_analyzer.setup(options_rust)
end,
["efm"] = function()
lspconfig.efm.setup({
init_options = {
documentFormatting = true,
},
settings = {
rootMarkers = { ".git/" },
languages = {
lua = {
{ formatCommand = "stylua -", formatStdin = true },
},
python = {
{
formatCommand = "black --quiet -",
formatStdin = true,
},
{
formatCommand = "isort --quiet -",
formatStdin = true,
},
{
lintCommand = "flake8 -",
lintStdin = true,
lintFormats = { "%f:%l:%c: %m" },
},
},
yaml = { { formatCommand = "prettierd -", formatStdin = true } },
html = { { formatCommand = "prettierd -", formatStdin = true } },
css = { { formatCommand = "prettierd -", formatStdin = true } },
json = { { formatCommand = "prettier -", formatStdin = true } },
},
},
filetypes = { "lua", "python", "yaml", "html", "css", "json" },
})
lspconfig.efm.setup(options_efm)
end,
})

0 comments on commit af7d799

Please sign in to comment.