summaryrefslogtreecommitdiff
path: root/lua/nvim-treesitter/parsers.lua
diff options
context:
space:
mode:
authorThomas Vigouroux <39092278+vigoux@users.noreply.github.com>2020-04-19 20:38:51 +0200
committerGitHub <noreply@github.com>2020-04-19 20:38:51 +0200
commit05be31024adc868af782c51dd63c6ccdfbfeb2a9 (patch)
tree45970745e65c16d52bcb93db4a4a466c6f9f105c /lua/nvim-treesitter/parsers.lua
parentf784a0addae1ac9d637d4655cd9095465f103374 (diff)
parentd25549917de8047eb91d6f56ee2bdcd5e667d6ae (diff)
Merge pull request #3 from vigoux/feature/locals
Add locals handling
Diffstat (limited to 'lua/nvim-treesitter/parsers.lua')
-rw-r--r--lua/nvim-treesitter/parsers.lua10
1 files changed, 7 insertions, 3 deletions
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index c8517773..e046ca45 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -8,13 +8,17 @@ function M.has_parser(lang)
return #api.nvim_get_runtime_file('parser/' .. lang .. '.*', false) > 0
end
-function M.get_parser(bufnr)
+function M.get_parser(bufnr, lang)
if M.has_parser() then
local buf = bufnr or api.nvim_get_current_buf()
+ local lang = lang or api.nvim_buf_get_option(buf, 'ft')
if not M[buf] then
- M[buf] = ts.get_parser(buf)
+ M[buf] = {}
end
- return M[buf]
+ if not M[buf][lang] then
+ M[buf][lang] = ts.get_parser(buf, lang)
+ end
+ return M[buf][lang]
end
end