efm-langserver format on save

This commit is contained in:
Ray Elliott 2021-09-04 11:59:31 +01:00
parent 08ef954cd8
commit cec47a2328
1 changed files with 9 additions and 8 deletions

View File

@ -407,11 +407,12 @@ require'lspconfig'.yamlls.setup{}
require'lspconfig'.stylelint_lsp.setup{} require'lspconfig'.stylelint_lsp.setup{}
-- https://github.com/neovim/nvim-lspconfig/wiki -- https://github.com/neovim/nvim-lspconfig/wiki
require'lspconfig'.tailwindcss.setup{} require'lspconfig'.tailwindcss.setup{}
EOF
"}}} -- EOF
" #efm-langserver {{{ -- "}}}
" npm install -g eslint_d --[efm-langserver] {{{
lua << EOF
-- " npm install -g eslint_d
local eslint = { local eslint = {
lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}", lintCommand = "eslint_d -f unix --stdin --stdin-filename ${INPUT}",
lintStdin = true, lintStdin = true,
@ -447,7 +448,7 @@ local fixjson = {
formatCommand = "fixjson" formatCommand = "fixjson"
} }
local util = require "lspconfig".util local util = require "lspconfig".util
local on_attach = function(client) local on_attach_efm = function(client)
if client.resolved_capabilities.document_formatting then if client.resolved_capabilities.document_formatting then
vim.cmd [[augroup lsp_formatting]] vim.cmd [[augroup lsp_formatting]]
vim.cmd [[autocmd!]] vim.cmd [[autocmd!]]
@ -457,7 +458,7 @@ local on_attach = function(client)
end end
require "lspconfig".efm.setup { require "lspconfig".efm.setup {
init_options = {documentFormatting = true}, init_options = {documentFormatting = true},
on_attach = on_attach, on_attach = on_attach_efm,
filetypes = {"javascript", "typescript", "json", "sh", "python"}, filetypes = {"javascript", "typescript", "json", "sh", "python"},
root_dir = function(fname) root_dir = function(fname)
return util.root_pattern("tsconfig.json")(fname) or return util.root_pattern("tsconfig.json")(fname) or
@ -476,7 +477,7 @@ require "lspconfig".efm.setup {
} }
EOF EOF
" }}} " }}}
" #nvim-lspconfig (keybindings etc) {{{ " #nvim-lspconfig {{{
lua << EOF lua << EOF
local nvim_lsp = require('lspconfig') local nvim_lsp = require('lspconfig')