diff options
author | LostNeophyte <[email protected]> | 2023-01-25 18:55:31 +0100 |
---|---|---|
committer | LostNeophyte <[email protected]> | 2023-01-25 18:55:31 +0100 |
commit | 75b653cc623a8cd6de397e42f21b838a065eb0e0 (patch) | |
tree | 7b43499c99423651d7e75662bb4628569834e28f /lua/lvim/core/treesitter.lua | |
parent | 4f02e54d923414eb6690d64c7e334f624a2a9342 (diff) |
refactor!: put all plugin options under `opts`
Diffstat (limited to 'lua/lvim/core/treesitter.lua')
-rw-r--r-- | lua/lvim/core/treesitter.lua | 152 |
1 files changed, 77 insertions, 75 deletions
diff --git a/lua/lvim/core/treesitter.lua b/lua/lvim/core/treesitter.lua index c7ab4382..96d97a95 100644 --- a/lua/lvim/core/treesitter.lua +++ b/lua/lvim/core/treesitter.lua @@ -3,93 +3,95 @@ local Log = require "lvim.core.log" function M.config() local config = { - -- A list of parser names, or "all" - ensure_installed = {}, + opts = { + -- A list of parser names, or "all" + ensure_installed = {}, - -- List of parsers to ignore installing (for "all") - ignore_install = {}, + -- List of parsers to ignore installing (for "all") + ignore_install = {}, - -- A directory to install the parsers into. - -- By default parsers are installed to either the package dir, or the "site" dir. - -- If a custom path is used (not nil) it must be added to the runtimepath. - parser_install_dir = nil, + -- A directory to install the parsers into. + -- By default parsers are installed to either the package dir, or the "site" dir. + -- If a custom path is used (not nil) it must be added to the runtimepath. + parser_install_dir = nil, - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, + -- Install parsers synchronously (only applied to `ensure_installed`) + sync_install = false, - -- Automatically install missing parsers when entering buffer - auto_install = true, + -- Automatically install missing parsers when entering buffer + auto_install = true, - matchup = { - enable = false, -- mandatory, false will disable the whole extension - -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled - }, - highlight = { - enable = true, -- false will disable the whole extension - additional_vim_regex_highlighting = false, - disable = function(lang, buf) - if vim.tbl_contains({ "latex" }, lang) then - return true - end + matchup = { + enable = false, -- mandatory, false will disable the whole extension + -- disable = { "c", "ruby" }, -- optional, list of language that will be disabled + }, + highlight = { + enable = true, -- false will disable the whole extension + additional_vim_regex_highlighting = false, + disable = function(lang, buf) + if vim.tbl_contains({ "latex" }, lang) then + return true + end - local status_ok, big_file_detected = pcall(vim.api.nvim_buf_get_var, buf, "bigfile_disable_treesitter") - return status_ok and big_file_detected - end, - }, - context_commentstring = { - enable = true, - enable_autocmd = false, - config = { - -- Languages that have a single comment style - typescript = "// %s", - css = "/* %s */", - scss = "/* %s */", - html = "<!-- %s -->", - svelte = "<!-- %s -->", - vue = "<!-- %s -->", - json = "", + local status_ok, big_file_detected = pcall(vim.api.nvim_buf_get_var, buf, "bigfile_disable_treesitter") + return status_ok and big_file_detected + end, }, - }, - indent = { enable = true, disable = { "yaml", "python", "c", "cpp" } }, - autotag = { enable = false }, - textobjects = { - swap = { + context_commentstring = { + enable = true, + enable_autocmd = false, + config = { + -- Languages that have a single comment style + typescript = "// %s", + css = "/* %s */", + scss = "/* %s */", + html = "<!-- %s -->", + svelte = "<!-- %s -->", + vue = "<!-- %s -->", + json = "", + }, + }, + indent = { enable = true, disable = { "yaml", "python", "c", "cpp" } }, + autotag = { enable = false }, + textobjects = { + swap = { + enable = false, + -- swap_next = textobj_swap_keymaps, + }, + -- move = textobj_move_keymaps, + select = { + enable = false, + -- keymaps = textobj_sel_keymaps, + }, + }, + textsubjects = { enable = false, - -- swap_next = textobj_swap_keymaps, + keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" }, }, - -- move = textobj_move_keymaps, - select = { + playground = { enable = false, - -- keymaps = textobj_sel_keymaps, + disable = {}, + updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code + persist_queries = false, -- Whether the query persists across vim sessions + keybindings = { + toggle_query_editor = "o", + toggle_hl_groups = "i", + toggle_injected_languages = "t", + toggle_anonymous_nodes = "a", + toggle_language_display = "I", + focus_language = "f", + unfocus_language = "F", + update = "R", + goto_node = "<cr>", + show_help = "?", + }, }, - }, - textsubjects = { - enable = false, - keymaps = { ["."] = "textsubjects-smart", [";"] = "textsubjects-big" }, - }, - playground = { - enable = false, - disable = {}, - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code - persist_queries = false, -- Whether the query persists across vim sessions - keybindings = { - toggle_query_editor = "o", - toggle_hl_groups = "i", - toggle_injected_languages = "t", - toggle_anonymous_nodes = "a", - toggle_language_display = "I", - focus_language = "f", - unfocus_language = "F", - update = "R", - goto_node = "<cr>", - show_help = "?", + rainbow = { + enable = false, + extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean + max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int }, }, - rainbow = { - enable = false, - extended_mode = true, -- Highlight also non-parentheses delimiters, boolean or table: lang -> boolean - max_file_lines = 1000, -- Do not enable for files with more than 1000 lines, int - }, } ---@cast config +LvimBuiltin require("lvim.core.builtins").extend_defaults(config) @@ -109,7 +111,7 @@ function M.setup() return end - local opts = vim.deepcopy(lvim.builtin.treesitter) + local opts = vim.deepcopy(lvim.builtin.treesitter.opts) treesitter_configs.setup(opts) end |