diff --git a/lsp/angularls.lua b/lsp/angularls.lua index e562bf5..7d8abed 100644 --- a/lsp/angularls.lua +++ b/lsp/angularls.lua @@ -1,6 +1,6 @@ return { cmd = { 'ngserver', '--stdio', '--tsProbeLocations', '', '--ngProbeLocations', '' }, - filetypes = { 'typescript', 'html', 'htmlangular' }, + filetypes = { 'typescript', 'htmlangular' }, root_markers = { 'angular.json' }, on_new_config = function(new_config, new_root_dir) local node_modules = new_root_dir .. '/node_modules' diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 4cde7e8..3125feb 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -32,16 +32,29 @@ return { 'astro', 'vue', 'java', + 'angular', } for _, parser in ipairs(parsers) do ts.install(parser) 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 local ft_to_parser = { typescriptreact = 'tsx', javascriptreact = 'jsx', + htmlangular = 'angular', } vim.api.nvim_create_autocmd('FileType', { diff --git a/lua/settings.lua b/lua/settings.lua index 9fac2e3..5945604 100644 --- a/lua/settings.lua +++ b/lua/settings.lua @@ -47,5 +47,3 @@ vim.diagnostic.config({ update_in_insert = false, -- update diagnostics in insert mod severity_sort = true, -- sort diagnostics by severity }) - -require('vim._core.ui2').enable({})