diff options
author | Rafael <[email protected]> | 2021-07-04 22:14:01 -0300 |
---|---|---|
committer | Rafael <[email protected]> | 2021-07-04 22:14:01 -0300 |
commit | 9f511bcb594b7e2461c97cb8182603928c773c2f (patch) | |
tree | c08a825ae91201fb0062dbd7a8094357f5c78dc9 /ftplugin/javascriptreact.lua | |
parent | b461c878e6f70a6795d0e9b438335ccfecbb4bd9 (diff) |
start formatting rules
Diffstat (limited to 'ftplugin/javascriptreact.lua')
-rw-r--r-- | ftplugin/javascriptreact.lua | 113 |
1 files changed, 58 insertions, 55 deletions
diff --git a/ftplugin/javascriptreact.lua b/ftplugin/javascriptreact.lua index 16254da3..1c4004c2 100644 --- a/ftplugin/javascriptreact.lua +++ b/ftplugin/javascriptreact.lua @@ -7,64 +7,67 @@ -- require'completion'.on_attach(client) -- require'illuminate'.on_attach(client) -- end -require'lspconfig'.tsserver.setup { - cmd = { - DATA_PATH .. - "/lspinstall/typescript/node_modules/.bin/typescript-language-server", - "--stdio" - }, - filetypes = { - "javascript", "javascriptreact", "javascript.jsx", "typescript", - "typescriptreact", "typescript.tsx" - }, - on_attach = require'lsp'.tsserver_on_attach, - -- This makes sure tsserver is not used for formatting (I prefer prettier) - -- on_attach = require'lsp'.common_on_attach, - root_dir = require('lspconfig/util').root_pattern("package.json", - "tsconfig.json", - "jsconfig.json", ".git"), - settings = {documentFormatting = false}, - handlers = { - ["textDocument/publishDiagnostics"] = vim.lsp.with( - vim.lsp.diagnostic.on_publish_diagnostics, { - virtual_text = O.lang.tsserver.diagnostics.virtual_text, - signs = O.lang.tsserver.diagnostics.signs, - underline = O.lang.tsserver.diagnostics.underline, - update_in_insert = true - - }) - } +require("lspconfig").tsserver.setup { + cmd = { + DATA_PATH .. "/lspinstall/typescript/node_modules/.bin/typescript-language-server", + "--stdio", + }, + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + on_attach = require("lsp").tsserver_on_attach, + -- This makes sure tsserver is not used for formatting (I prefer prettier) + -- on_attach = require'lsp'.common_on_attach, + root_dir = require("lspconfig/util").root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git"), + settings = { documentFormatting = false }, + handlers = { + ["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { + virtual_text = O.lang.tsserver.diagnostics.virtual_text, + signs = O.lang.tsserver.diagnostics.signs, + underline = O.lang.tsserver.diagnostics.underline, + update_in_insert = true, + }), + }, } -require'lsp.ts-fmt-lint'.setup() +require("lsp.ts-fmt-lint").setup() if O.lang.tsserver.autoformat then - require('lv-utils').define_augroups({ - _javascript_autoformat = { - { + require("lv-utils").define_augroups { + _javascript_autoformat = { + { - 'BufWritePre', '*.js', - 'lua vim.lsp.buf.formatting_sync(nil, 1000)' - } - }, - _javascriptreact_autoformat = { - { - 'BufWritePre', '*.jsx', - 'lua vim.lsp.buf.formatting_sync(nil, 1000)' - } - }, - _typescript_autoformat = { - { - 'BufWritePre', '*.ts', - 'lua vim.lsp.buf.formatting_sync(nil, 1000)' - } - }, - _typescriptreact_autoformat = { - { - 'BufWritePre', '*.tsx', - 'lua vim.lsp.buf.formatting_sync(nil, 1000)' - } - } - }) + "BufWritePre", + "*.js", + "lua vim.lsp.buf.formatting_sync(nil, 1000)", + }, + }, + _javascriptreact_autoformat = { + { + "BufWritePre", + "*.jsx", + "lua vim.lsp.buf.formatting_sync(nil, 1000)", + }, + }, + _typescript_autoformat = { + { + "BufWritePre", + "*.ts", + "lua vim.lsp.buf.formatting_sync(nil, 1000)", + }, + }, + _typescriptreact_autoformat = { + { + "BufWritePre", + "*.tsx", + "lua vim.lsp.buf.formatting_sync(nil, 1000)", + }, + }, + } end -vim.cmd("setl ts=2 sw=2") +vim.cmd "setl ts=2 sw=2" |