mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-15 03:44:43 +02:00
lsp in ftplugin austonautomoy
This commit is contained in:
parent
9bb4f8a085
commit
20ed47e21e
45 changed files with 404 additions and 142 deletions
68
ftplugin/javascriptreact.lua
Normal file
68
ftplugin/javascriptreact.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
-- npm install -g typescript typescript-language-server
|
||||
-- require'snippets'.use_suggested_mappings()
|
||||
-- local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
-- capabilities.textDocument.completion.completionItem.snippetSupport = true;
|
||||
-- local on_attach_common = function(client)
|
||||
-- print("LSP Initialized")
|
||||
-- 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
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
vim.cmd("setl ts=2 sw=2")
|
Loading…
Add table
Add a link
Reference in a new issue