From e5b73c120b53735eba769b96a7c51a9acb8d7015 Mon Sep 17 00:00:00 2001 From: long Date: Thu, 1 Dec 2022 02:31:18 -0600 Subject: [PATCH] checkpoint: treesitter changes --- ftplugin/c.lua | 1 + lua/base.lua | 5 +++++ lua/plugins/config.lua | 30 ++++++++++++++++++++++++++---- 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 ftplugin/c.lua diff --git a/ftplugin/c.lua b/ftplugin/c.lua new file mode 100644 index 0000000..319e2e5 --- /dev/null +++ b/ftplugin/c.lua @@ -0,0 +1 @@ +require("helpers").set_tab(2) diff --git a/lua/base.lua b/lua/base.lua index 339cfac..70997c0 100644 --- a/lua/base.lua +++ b/lua/base.lua @@ -62,6 +62,11 @@ silent_map("n", "", "gj") silent_map("n", "", "g") silent_map("n", "", "g") +silent_map("v", "", "gk") +silent_map("v", "", "gj") +silent_map("v", "", "g") +silent_map("v", "", "g") + silent_map("i", "", "gk") silent_map("i", "", "gj") silent_map("i", "", "g") diff --git a/lua/plugins/config.lua b/lua/plugins/config.lua index 2dd4bcf..350980c 100644 --- a/lua/plugins/config.lua +++ b/lua/plugins/config.lua @@ -165,19 +165,35 @@ function M.lualine() end function M.nvim_treesitter() - local ts_visual_disable = { "typescript", "tsx", "html", "javascript" } + local highlight_disable = { + typescript = true, + tsx = true, + html = true, + javascript = true, + cpp = true, + } + local rainbow_disable = vim.tbl_extend("force", highlight_disable, { svelte = true }) + + local too_many_lines = function(bufnr) + return vim.api.nvim_buf_line_count(bufnr) > 5000 + end + require("nvim-treesitter.configs").setup({ ensure_installed = "all", highlight = { enable = true, - disable = ts_visual_disable, + disable = function(lang, bufnr) + return highlight_disable[lang] or too_many_lines(bufnr) + end, }, rainbow = { enable = true, - disable = vim.tbl_extend("force", ts_visual_disable, { [5] = "svelte" }), + disable = function(lang, bufnr) + return rainbow_disable[lang] or too_many_lines(bufnr) + end, extended_mode = true, -- Also highlight non-bracket delimiters like html tags, boolean or table: lang -> boolean max_file_lines = nil, -- Do not enable for files with more than n lines, int - -- colors = {}, -- table of hex strings + --colors = {}, -- table of hex strings --termcolors = {}, }, }) @@ -274,6 +290,8 @@ function M.nvim_lsp_installer() htmldjango = "html", }, } + elseif server.name == "ccls" then + opts.capabilities.offsetEncoding = { "utf-32" } end server:setup(opts) @@ -336,6 +354,10 @@ function M.null_ls() sources = sources, on_attach = config.on_attach, root_dir = config.root_dir, + -- removed error "warning: multiple different client offset_encodings detected for buffer, this is not supported yet" + --on_init = function(client, _) + -- client.offset_encoding = "utf-32" + --end, }) end