Bläddra i källkod

feat(document highlight): use illuminate rather than autocommand to avoid flashing (#3029)

Christian Chiarulli 2 år sedan
förälder
incheckning
352147158b

+ 1 - 0
lua/lvim/core/builtins/init.lua

@@ -10,6 +10,7 @@ local builtins = {
   "lvim.core.treesitter",
   "lvim.core.nvimtree",
   "lvim.core.lir",
+  "lvim.core.illuminate",
   "lvim.core.project",
   "lvim.core.bufferline",
   "lvim.core.autopairs",

+ 53 - 0
lua/lvim/core/illuminate.lua

@@ -0,0 +1,53 @@
+local M = {}
+
+M.config = function()
+  local status_ok, illuminate = pcall(require, "illuminate")
+  if not status_ok then
+    return
+  end
+  -- default configuration
+  illuminate.configure {
+    -- providers: provider used to get references in the buffer, ordered by priority
+    providers = {
+      "lsp",
+      "treesitter",
+      "regex",
+    },
+    -- delay: delay in milliseconds
+    delay = 120,
+    -- filetypes_denylist: filetypes to not illuminate, this overrides filetypes_allowlist
+    filetypes_denylist = {
+      "dirvish",
+      "fugitive",
+      "alpha",
+      "NvimTree",
+      "packer",
+      "neogitstatus",
+      "Trouble",
+      "lir",
+      "Outline",
+      "spectre_panel",
+      "toggleterm",
+      "DressingSelect",
+      "TelescopePrompt",
+    },
+    -- filetypes_allowlist: filetypes to illuminate, this is overriden by filetypes_denylist
+    filetypes_allowlist = {},
+    -- modes_denylist: modes to not illuminate, this overrides modes_allowlist
+    modes_denylist = {},
+    -- modes_allowlist: modes to illuminate, this is overriden by modes_denylist
+    modes_allowlist = {},
+    -- providers_regex_syntax_denylist: syntax to not illuminate, this overrides providers_regex_syntax_allowlist
+    -- Only applies to the 'regex' provider
+    -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
+    providers_regex_syntax_denylist = {},
+    -- providers_regex_syntax_allowlist: syntax to illuminate, this is overriden by providers_regex_syntax_denylist
+    -- Only applies to the 'regex' provider
+    -- Use :echom synIDattr(synIDtrans(synID(line('.'), col('.'), 1)), 'name')
+    providers_regex_syntax_allowlist = {},
+    -- under_cursor: whether or not to illuminate under the cursor
+    under_cursor = true,
+  }
+end
+
+return M

+ 0 - 1
lua/lvim/lsp/handlers.lua

@@ -12,7 +12,6 @@ function M.setup()
     float = lvim.lsp.diagnostics.float,
   }
   vim.diagnostic.config(config)
-  vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, lvim.lsp.float)
   vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, lvim.lsp.float)
 end
 

+ 4 - 0
lua/lvim/plugins.lua

@@ -256,6 +256,10 @@ local core_plugins = {
   {
     "b0o/schemastore.nvim",
   },
+
+  {
+    "RRethy/vim-illuminate",
+  },
 }
 
 local default_snapshot_path = join_paths(get_lvim_base_dir(), "snapshots", "default.json")

+ 3 - 0
snapshots/default.json

@@ -115,5 +115,8 @@
   },
   "which-key.nvim": {
     "commit": "d5f0c63"
+  },
+  "vim-illuminate": {
+    "commit": "b545262"
   }
 }