diff options
| author | Steven Sojka <Steven.Sojka@tdameritrade.com> | 2020-09-16 07:03:22 -0500 |
|---|---|---|
| committer | Steven Sojka <steelsojka@gmail.com> | 2020-09-25 10:30:35 -0500 |
| commit | 82a8b859c6377a03e0c4d33b8b045548568c7aef (patch) | |
| tree | b9a2acd3adf5bb32f7a48951e92409d5b2bdf9b4 /lua/nvim-treesitter/refactor/highlight_definitions.lua | |
| parent | 98c12ec23a6df2f2f505304b61c4b2eefc0a568f (diff) | |
chore(modules): remove refactor module
Diffstat (limited to 'lua/nvim-treesitter/refactor/highlight_definitions.lua')
| -rw-r--r-- | lua/nvim-treesitter/refactor/highlight_definitions.lua | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/lua/nvim-treesitter/refactor/highlight_definitions.lua b/lua/nvim-treesitter/refactor/highlight_definitions.lua deleted file mode 100644 index d430d38a..00000000 --- a/lua/nvim-treesitter/refactor/highlight_definitions.lua +++ /dev/null @@ -1,59 +0,0 @@ --- This module highlights reference usages and the corresponding --- definition on cursor hold. - -local ts_utils = require'nvim-treesitter.ts_utils' -local locals = require'nvim-treesitter.locals' -local api = vim.api -local cmd = api.nvim_command - -local M = {} - -local usage_namespace = api.nvim_create_namespace('nvim-treesitter-usages') - -function M.highlight_usages(bufnr) - M.clear_usage_highlights(bufnr) - - local node_at_point = ts_utils.get_node_at_cursor() - local references = locals.get_references(bufnr) - - if not node_at_point or not vim.tbl_contains(references, node_at_point) then - return - end - - local def_node, scope = locals.find_definition(node_at_point, bufnr) - local usages = locals.find_usages(def_node, scope, bufnr) - - for _, usage_node in ipairs(usages) do - if usage_node ~= node_at_point then - ts_utils.highlight_node(usage_node, bufnr, usage_namespace, 'TSDefinitionUsage') - end - end - - if def_node ~= node_at_point then - ts_utils.highlight_node(def_node, bufnr, usage_namespace, 'TSDefinition') - end -end - -function M.clear_usage_highlights(bufnr) - api.nvim_buf_clear_namespace(bufnr, usage_namespace, 0, -1) -end - -function M.attach(bufnr) - cmd(string.format('augroup NvimTreesitterUsages_%d', bufnr)) - cmd 'au!' - -- luacheck: push ignore 631 - cmd(string.format([[autocmd CursorHold <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.highlight_usages(%d)]], bufnr, bufnr)) - cmd(string.format([[autocmd CursorMoved <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr)) - cmd(string.format([[autocmd InsertEnter <buffer=%d> lua require'nvim-treesitter.refactor.highlight_definitions'.clear_usage_highlights(%d)]], bufnr, bufnr)) - -- luacheck: pop - cmd 'augroup END' -end - -function M.detach(bufnr) - M.clear_usage_highlights(bufnr) - cmd(string.format('autocmd! NvimTreesitterUsages_%d CursorHold', bufnr)) - cmd(string.format('autocmd! NvimTreesitterUsages_%d CursorMoved', bufnr)) - cmd(string.format('autocmd! NvimTreesitterUsages_%d InsertEnter', bufnr)) -end - -return M |
