Use vim-illuminate

Sun, 19 Feb 2023 13:25:46 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Sun, 19 Feb 2023 13:25:46 -0600
changeset 1031
ceb2e56c6e8f
parent 1030
03d507b3c122
child 1032
b0497894f69b

Use vim-illuminate

.config/nvim/lazy-lock.json file | annotate | diff | comparison | revisions
.config/nvim/lua/config/lsp.lua file | annotate | diff | comparison | revisions
.config/nvim/lua/plugins/editing.lua file | annotate | diff | comparison | revisions
--- a/.config/nvim/lazy-lock.json
+++ b/.config/nvim/lazy-lock.json
@@ -22,9 +22,9 @@
   "undotree": { "branch": "master", "commit": "1a23ea84bd02c34f50d8e10a8b4bfc89597ffe4e" },
   "vim-asciidoc": { "branch": "master", "commit": "81530e5e9228cb0da1132fdcd51a89df3bf8e585" },
   "vim-endwise": { "branch": "master", "commit": "43301cf9a0fafd78cec7c2e5b9c0e2cfd9436e8a" },
+  "vim-illuminate": { "branch": "master", "commit": "49062ab1dd8fec91833a69f0a1344223dd59d643" },
   "vim-perl": { "branch": "dev", "commit": "f40ece108099df561157ed7fdb764f8c183a8bfc" },
   "vim-plugin-viewdoc": { "branch": "master", "commit": "c9d4e2c3ce6c932091f500053681638f1b39870d" },
-  "vim-polyglot": { "branch": "master", "commit": "bc8a81d3592dab86334f27d1d43c080ebf680d42" },
   "vim-signature": { "branch": "master", "commit": "6bc3dd1294a22e897f0dcf8dd72b85f350e306bc" },
   "vim-unimpaired": { "branch": "master", "commit": "6d44a6dc2ec34607c41ec78acf81657248580bf1" },
   "vim-vinegar": { "branch": "master", "commit": "bb1bcddf43cfebe05eb565a84ab069b357d0b3d6" },
--- a/.config/nvim/lua/config/lsp.lua
+++ b/.config/nvim/lua/config/lsp.lua
@@ -22,32 +22,6 @@ vim.api.nvim_create_autocmd("LspAttach",
     local bufnr = args.buf
     local client = vim.lsp.get_client_by_id(args.data.client_id)
 
-    -- Enable highlight-under-cursor
-    if client.server_capabilities.documentHighlightProvider then
-      vim.cmd [[
-        hi! LspReferenceRead ctermfg=0 ctermbg=11 guifg=#f0a0c0 guibg=#302028
-        hi! LspReferenceText ctermfg=0 ctermbg=11 guifg=#f0a0c0 guibg=#302028
-        hi! LspReferenceWrite ctermfg=0 ctermbg=11 cterm=underline guifg=#f0a0c0 guibg=#302028 gui=underline
-      ]]
-      vim.api.nvim_create_augroup('lsp_document_highlight', {
-        clear = false
-      })
-      vim.api.nvim_clear_autocmds({
-        buffer = bufnr,
-        group = 'lsp_document_highlight',
-      })
-      vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
-        group = 'lsp_document_highlight',
-        buffer = bufnr,
-        callback = vim.lsp.buf.document_highlight,
-      })
-      vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
-        group = 'lsp_document_highlight',
-        buffer = bufnr,
-        callback = vim.lsp.buf.clear_references,
-      })
-    end
-
     -- enable auto diags in message area for below threshold
     vim.api.nvim_create_augroup('lsp_diags', {clear = false})
 
--- a/.config/nvim/lua/plugins/editing.lua
+++ b/.config/nvim/lua/plugins/editing.lua
@@ -24,4 +24,21 @@ return {
   "tpope/vim-vinegar",
   "kshenoy/vim-signature",
   {"majutsushi/tagbar", cmd = "TagbarToggle"},
+
+  {
+    "RRethy/vim-illuminate",
+    event = {"BufReadPost", "BufNewFile"},
+    opts = {
+      delay = 250,
+      large_file_cutoff = 15000,
+    },
+    config = function(_, opts)
+      require("illuminate").configure(opts)
+      vim.cmd([[
+        hi! IlluminatedWordRead ctermfg=0 ctermbg=11 guifg=#f0a0c0 guibg=#302028
+        hi! IlluminatedWordText ctermfg=0 ctermbg=11 guifg=#f0a0c0 guibg=#302028
+        hi! IlluminatedWordWrite ctermfg=0 ctermbg=11 cterm=underline guifg=#f0a0c0 guibg=#302028 gui=underline
+      ]])
+    end,
+  },
 }

mercurial