add proper angular support
This commit is contained in:
parent
ae9aa49359
commit
33a5bd4b2a
3 changed files with 14 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
return {
|
return {
|
||||||
cmd = { 'ngserver', '--stdio', '--tsProbeLocations', '', '--ngProbeLocations', '' },
|
cmd = { 'ngserver', '--stdio', '--tsProbeLocations', '', '--ngProbeLocations', '' },
|
||||||
filetypes = { 'typescript', 'html', 'htmlangular' },
|
filetypes = { 'typescript', 'htmlangular' },
|
||||||
root_markers = { 'angular.json' },
|
root_markers = { 'angular.json' },
|
||||||
on_new_config = function(new_config, new_root_dir)
|
on_new_config = function(new_config, new_root_dir)
|
||||||
local node_modules = new_root_dir .. '/node_modules'
|
local node_modules = new_root_dir .. '/node_modules'
|
||||||
|
|
|
||||||
|
|
@ -32,16 +32,29 @@ return {
|
||||||
'astro',
|
'astro',
|
||||||
'vue',
|
'vue',
|
||||||
'java',
|
'java',
|
||||||
|
'angular',
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, parser in ipairs(parsers) do
|
for _, parser in ipairs(parsers) do
|
||||||
ts.install(parser)
|
ts.install(parser)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Detect Angular HTML templates and set filetype to htmlangular
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
pattern = 'html',
|
||||||
|
callback = function(ev)
|
||||||
|
local root = vim.fs.root(ev.buf, { 'angular.json' })
|
||||||
|
if root then
|
||||||
|
vim.bo[ev.buf].filetype = 'htmlangular'
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- Filetypes whose name differs from the parser name
|
-- Filetypes whose name differs from the parser name
|
||||||
local ft_to_parser = {
|
local ft_to_parser = {
|
||||||
typescriptreact = 'tsx',
|
typescriptreact = 'tsx',
|
||||||
javascriptreact = 'jsx',
|
javascriptreact = 'jsx',
|
||||||
|
htmlangular = 'angular',
|
||||||
}
|
}
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
|
|
||||||
|
|
@ -47,5 +47,3 @@ vim.diagnostic.config({
|
||||||
update_in_insert = false, -- update diagnostics in insert mod
|
update_in_insert = false, -- update diagnostics in insert mod
|
||||||
severity_sort = true, -- sort diagnostics by severity
|
severity_sort = true, -- sort diagnostics by severity
|
||||||
})
|
})
|
||||||
|
|
||||||
require('vim._core.ui2').enable({})
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue