diff options
| author | Robert Günzler <r@gnzler.io> | 2022-05-27 13:00:45 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2022-05-27 13:16:15 +0200 |
| commit | fd0ddda95e879b8f1924fb65136a5faa306ffa9b (patch) | |
| tree | b757cc185bdece6af61af47d7735ed97a2f17bad /.vim | |
| parent | 4ffb2681870dba1f9e09ef734ace2c90a03b983c (diff) | |
vim: add gotmpl tree-sitter support
Diffstat (limited to '.vim')
| -rw-r--r-- | .vim/init.lua | 16 | ||||
| -rw-r--r-- | .vim/lua/plugins.lua | 9 |
2 files changed, 25 insertions, 0 deletions
diff --git a/.vim/init.lua b/.vim/init.lua index c6c1d4f..9494694 100644 --- a/.vim/init.lua +++ b/.vim/init.lua @@ -341,3 +341,19 @@ local local_vimrc = vim.fn.getcwd()..'/.nvimrc' if vim.loop.fs_stat(local_vimrc) then cmd('source ' .. local_vimrc) end + +-- TODO: remove eventually +vim.filetype.add { + extension = { + html = function(_, bufnr) + for ln = 1, vim.api.nvim_buf_line_count(bufnr), 1 do + local line = vim.api.nvim_buf_get_lines(bufnr, ln-1, ln, true) + if #line == 0 then break end + if line[1]:match('{{.+}}') then + return 'gotmpl' + end + end + return 'html' + end, + }, +} diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua index 9efd513..96b1e89 100644 --- a/.vim/lua/plugins.lua +++ b/.vim/lua/plugins.lua @@ -244,6 +244,7 @@ return require('packer').startup({function() 'norg_meta', 'norg_table', 'hare', + 'gotmpl', } use {'nvim-treesitter/nvim-treesitter', -- {{{ run = ':TSUpdate', @@ -281,6 +282,14 @@ return require('packer').startup({function() files = {'src/parser.c'}, } } + tsconf.gotmpl = { + install_info = { + url = 'https://github.com/ngalaiko/tree-sitter-go-template', + files = {'src/parser.c'}, + }, + filetype = 'gotmpl', + used_by = {'gohtmltmpl', 'gotexttmpl', 'gotmpl', 'yaml'}, + } require('nvim-treesitter.configs').setup { ensure_installed = _G.treesitter_enabled, |