diff options
author | Squibid <me@zacharyscheiman.com> | 2024-08-09 02:45:31 -0400 |
---|---|---|
committer | Squibid <me@zacharyscheiman.com> | 2024-08-09 02:45:31 -0400 |
commit | c489d393695e90d424f9ae51e35c4d42358e6a71 (patch) | |
tree | 12ea97ec4684fd82cd6b73dd127d0137b115837b /lua/conf/plugins/treesitter.lua | |
parent | ad76983d969c318e6e234bc82384b4b025d70447 (diff) | |
download | nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.gz nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.tar.bz2 nvim-c489d393695e90d424f9ae51e35c4d42358e6a71.zip |
yes there's a bit of java in my nvim config why do you ask?
Diffstat (limited to '')
-rw-r--r-- | lua/conf/plugins/treesitter.lua | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lua/conf/plugins/treesitter.lua b/lua/conf/plugins/treesitter.lua new file mode 100644 index 0000000..c24d454 --- /dev/null +++ b/lua/conf/plugins/treesitter.lua @@ -0,0 +1,59 @@ +table.contains = function(self, string) + for _, v in pairs(self) do + if v == string then + return true + end + end + return false +end + +return { 'nvim-treesitter/nvim-treesitter', + disable = vim.version.lt(vim.version(), { 0, 9, 2 }), + config = function() + vim.cmd("TSUpdate") + end, + function() + require('nvim-treesitter.configs').setup { + -- good default parsers + ensure_installed = { "c", "lua", "vim", "vimdoc", "markdown", + "markdown_inline", "java", "bash", "css", "html", "luadoc" + }, + + -- install missing parsers + auto_install = true, + + -- indentation + indent = { + enable = true, + + disable = function(lang, buf) + -- disable indenting in php (it's more broken with than without) + return table.contains({ + "php" + }, lang) + end + }, + + -- enable highlighting + highlight = { + enable = true, + -- use vim highlighting in addition to treesitter + additional_vim_regex_highlighting = true, + + disable = function(lang, buf) + -- disable in diff files + local langs = { "diff" } + if table.contains(langs, lang) then + return true + end + + -- disable in big files + local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf)) + if ok and stats and stats.size > (1024 * 100 * 10) --[[1MB]] then + return true + end + end + } + } + end +} |