aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/lua/vim/tree_sitter.lua8
-rw-r--r--runtime/plugin/ts_test.vim2
2 files changed, 6 insertions, 4 deletions
diff --git a/runtime/lua/vim/tree_sitter.lua b/runtime/lua/vim/tree_sitter.lua
index a7830bc312..1b5f416b67 100644
--- a/runtime/lua/vim/tree_sitter.lua
+++ b/runtime/lua/vim/tree_sitter.lua
@@ -32,11 +32,13 @@ local function change_cb(self, ev, bufnr, tick, start_row, oldstopline, stop_row
self.valid = false
end
-local function create_parser(bufnr)
+local function create_parser(bufnr, ft)
if bufnr == 0 then
bufnr = a.nvim_get_current_buf()
end
- local ft = a.nvim_buf_get_option(bufnr, "filetype")
+ if ft == nil then
+ ft = a.nvim_buf_get_option(bufnr, "filetype")
+ end
local self = setmetatable({bufnr=bufnr, valid=false}, Parser)
self._parser = vim._create_ts_parser(ft)
self:parse_tree()
@@ -51,5 +53,5 @@ end
-- TODO: weak table with reusable parser per buffer.
-return {create_parser=create_parser}
+return {create_parser=create_parser, add_language=vim._ts_add_language}
diff --git a/runtime/plugin/ts_test.vim b/runtime/plugin/ts_test.vim
index 76318163f6..9420c2c9d3 100644
--- a/runtime/plugin/ts_test.vim
+++ b/runtime/plugin/ts_test.vim
@@ -6,7 +6,7 @@ func! TSTest()
return
end
" TODO: module!
- lua theparser = require'vim.tree_sitter'.create_parser(0)
+ lua theparser = vim.tree_sitter.create_parser(0)
lua require'tree_sitter_demo'
let g:has_ts = v:true
endfunc