LunarVim/lua/lsp/efm-general-ls.lua

59 lines
2.4 KiB
Lua
Raw Normal View History

2021-03-18 05:24:49 +01:00
-- Example configuations here: https://github.com/mattn/efm-langserver
2021-03-27 22:21:52 +01:00
-- tsserver/web javascript react, vue, json, html, css, yaml
local prettier = {formatCommand = "prettier --stdin-filepath ${INPUT}", formatStdin = true}
-- You can look for project scope Prettier and Eslint with e.g. vim.fn.glob("node_modules/.bin/prettier") etc. If it is not found revert to global Prettier where needed.
-- local prettier = {formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", formatStdin = true}
2021-03-19 04:47:03 +01:00
local eslint = {
lintCommand = "./node_modules/.bin/eslint -f unix --stdin --stdin-filename ${INPUT}",
lintIgnoreExitCode = true,
lintStdin = true,
lintFormats = {"%f:%l:%c: %m"},
formatCommand = "./node_modules/.bin/eslint --fix-to-stdout --stdin --stdin-filename=${INPUT}",
formatStdin = true
}
2021-03-27 22:21:52 +01:00
local tsserver_args = {}
2021-03-19 05:10:21 +01:00
2021-06-28 06:36:29 +02:00
if O.lang.tsserver.formatter == 'prettier' then table.insert(tsserver_args, prettier) end
2021-03-19 05:10:21 +01:00
2021-06-28 06:36:29 +02:00
if O.lang.tsserver.linter == 'eslint' then table.insert(tsserver_args, eslint) end
2021-03-27 22:21:52 +01:00
-- local markdownlint = {
-- -- TODO default to global lintrc
-- -- lintcommand = 'markdownlint -s -c ./markdownlintrc',
-- lintCommand = 'markdownlint -s',
-- lintStdin = true,
-- lintFormats = {'%f:%l %m', '%f:%l:%c %m', '%f: %l: %m'}
-- }
2021-03-20 22:22:44 +01:00
2021-03-23 06:44:13 +01:00
local markdownPandocFormat = {formatCommand = 'pandoc -f markdown -t gfm -sp --tab-stop=2', formatStdin = true}
2021-03-19 06:08:11 +01:00
2021-03-17 19:15:20 +01:00
require"lspconfig".efm.setup {
2021-03-19 04:47:03 +01:00
-- init_options = {initializationOptions},
2021-03-27 22:21:52 +01:00
cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"},
2021-03-19 04:47:03 +01:00
init_options = {documentFormatting = true, codeAction = false},
2021-06-29 19:48:58 +02:00
filetypes = {"lua", "python", "javascriptreact", "javascript", "typescript","typescriptreact","sh", "html", "css", "yaml", "markdown", "vue"},
2021-03-17 19:15:20 +01:00
settings = {
rootMarkers = {".git/"},
languages = {
2021-03-27 22:21:52 +01:00
javascript = tsserver_args,
javascriptreact = tsserver_args,
typescript = tsserver_args,
typescriptreact = tsserver_args,
2021-03-27 22:21:52 +01:00
html = {prettier},
css = {prettier},
json = {prettier},
yaml = {prettier},
markdown = {markdownPandocFormat}
2021-03-22 04:14:11 +01:00
-- javascriptreact = {prettier, eslint},
-- javascript = {prettier, eslint},
2021-03-20 22:22:44 +01:00
-- markdown = {markdownPandocFormat, markdownlint},
2021-03-17 19:15:20 +01:00
}
}
}
2021-03-17 20:48:52 +01:00
2021-03-18 05:24:49 +01:00
-- Also find way to toggle format on save
-- maybe this will help: https://superuser.com/questions/439078/how-to-disable-autocmd-or-augroup-in-vim