diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 01:05:06 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-07-07 01:05:06 +0200 |
commit | 0111b31cb0008f4fcc55ddc373e63f124652b156 (patch) | |
tree | 075490fb19c4838fc58129da9f902a3370f6029e /.config/nvim/lua/cfg/lsp/ts-fmt-lint.lua | |
parent | 6fcc69113bd7cc7295ef9dc068da80d043cbb8bb (diff) |
Updated config based on Chris LunarVim release
Diffstat (limited to '.config/nvim/lua/cfg/lsp/ts-fmt-lint.lua')
-rw-r--r-- | .config/nvim/lua/cfg/lsp/ts-fmt-lint.lua | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/.config/nvim/lua/cfg/lsp/ts-fmt-lint.lua b/.config/nvim/lua/cfg/lsp/ts-fmt-lint.lua new file mode 100644 index 0000000..36d4ca8 --- /dev/null +++ b/.config/nvim/lua/cfg/lsp/ts-fmt-lint.lua @@ -0,0 +1,37 @@ +-- Example configuations here: https://github.com/mattn/efm-langserver +-- 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 M = {} + +M.setup = function() + local tsserver_args = {} + + local prettier = { + formatCommand = "prettier --stdin-filepath ${INPUT}", + formatStdin = true + } + + if vim.fn.glob("node_modules/.bin/prettier") ~= "" then + prettier = { + formatCommand = "./node_modules/.bin/prettier --stdin-filepath ${INPUT}", + formatStdin = true + } + end + + require"lspconfig".efm.setup { + -- init_options = {initializationOptions}, + cmd = {DATA_PATH .. "/lspinstall/efm/efm-langserver"}, + init_options = {documentFormatting = true, codeAction = false}, + filetypes = {"html", "css", "yaml", "vue", "javascript", "javascriptreact", "typescript", "typescriptreact"}, + settings = { + rootMarkers = {".git/", "package.json"}, + languages = { + html = {prettier}, + css = {prettier}, + json = {prettier}, + yaml = {prettier} + } + } + } +end + +return M |