mattn / efm-langserver

General purpose Language Server
MIT License
1.35k stars 61 forks source link

format for LanguageID not supported: yaml #140

Closed horseinthesky closed 10 months ago

horseinthesky commented 3 years ago

Here is my efm.lua:

local M = {}

M.luafmt = {
  formatCommand = "luafmt -i 2 --stdin",
  formatStdin = true
}

M.flake8 = {
  lintCommand = "flake8 --ignore=E501 --stdin-display-name ${INPUT} -",
  lintStdin = true,
  lintIgnoreExitCode = true,
  lintFormats = {"%f:%l:%c: %m"}
}

M.isort = {
  formatCommand = "isort -",
  formatStdin = true
}

M.autopep8 = {
  formatCommand = "autopep8 --ignore E501 -",
  formatStdin = true
}

M.yapf = {
  formatCommand = "yapf",
  formatStdin = true
}

M.black = {
  formatCommand = "black --quiet -",
  formatStdin = true
}

M.mypy = {
  lintCommand = "mypy --show-column-numbers --ignore-missing-imports",
  lintFormats = {"%f:%l:%c: %trror: %m", "%f:%l:%c: %tarning: %m", "%f:%l:%c: %tote: %m"}
}

M.prettier = {
  formatCommand = "prettier --stdin-filepath ${INPUT}",
  formatStdin = true
}

return M

And hehe is lsp config:

local efm = require "efm"
local flake8 = efm.flake8
local isort = efm.isort
local black = efm.black
local mypy = efm.mypy
local luafmt = efm.luafmt
local prettier = efm.prettier

local languages = {
  python = {isort, flake8, black, mypy},
  lua = {luafmt},
  yaml = {prettier},
  json = {prettier},
  html = {prettier},
  css = {prettier},
  markdown = {prettier}
}

When I try to run lua vim.lsp.buf.formatting() on the file bla.yml:

bla:
  a: 1
    b: 2
    c: 3

I get RPC[Error] code_name = unknown, code = 0, message = "format for LanguageID not supported: yaml" message.

The same prettier formatter works great for JSON.

zeitchef commented 3 years ago

I'm having exactly the same issue. Update: Seems I had installed efm-langserver via Homebrew and then again via lspinstall plugin. Removing the Homebrew install and restarting cleared the issue for me.

gmhpfc commented 10 months ago

try installing pritterd or stylua manully with Mason and config accordingly say in lspsaga.nvim.

horseinthesky commented 10 months ago

Not relevant anymore. Disregard.