mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-08-03 01:25:03 +02:00
refactor autocommands
This commit is contained in:
parent
d8cf871a38
commit
9e7ad60747
14 changed files with 283 additions and 298 deletions
|
@ -7,17 +7,27 @@
|
|||
-- 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" },
|
||||
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"),
|
||||
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, {
|
||||
["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,
|
||||
|
@ -26,3 +36,20 @@ require'lspconfig'.tsserver.setup {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
if O.lang.tsserver.autoformat then
|
||||
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)'
|
||||
}
|
||||
})
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue