Integrate nvim document-highight with LSP attach hook
This commit is contained in:
parent
802b5ba4d1
commit
39d0ec4cdc
2 changed files with 27 additions and 0 deletions
|
@ -46,4 +46,29 @@ return function(_, bufnr)
|
|||
vim.lsp.buf.rename()
|
||||
end
|
||||
end, {nargs = "?"})
|
||||
|
||||
vim.api.nvim_buf_create_user_command(bufnr, "LspDocumentHighlight", function(args)
|
||||
local disable = vim.b.document_highlight
|
||||
arg = args.fargs[1]
|
||||
if arg then
|
||||
if string.lower(arg) == "on" then
|
||||
disable = false
|
||||
elseif string.lower(arg) == "off" then
|
||||
disable = true
|
||||
else
|
||||
error "Argument must be either 'on' or 'off' or absent"
|
||||
end
|
||||
end
|
||||
if disable then
|
||||
require("lsp.document_highlight").stop(bufnr)
|
||||
vim.b.document_highlight = false
|
||||
else
|
||||
require("lsp.document_highlight").start(bufnr)
|
||||
vim.b.document_highlight = true
|
||||
end
|
||||
end, {nargs = "?", complete = function(lead)
|
||||
return vim.fn.filter({ "on", "off" }, function(_, val)
|
||||
return val:find("^" .. lead)
|
||||
end)
|
||||
end})
|
||||
end
|
||||
|
|
2
vimrc
2
vimrc
|
@ -5,6 +5,8 @@ let &rtp=&rtp.','.expand('<sfile>:p:h').'/vim/pack/*/start/*'
|
|||
|
||||
set nocompatible
|
||||
|
||||
set updatetime=600
|
||||
|
||||
au VimEnter * TSEnable highlight
|
||||
au VimEnter * TSEnable incremental_selection
|
||||
au VimEnter * TSEnable indent
|
||||
|
|
Loading…
Reference in a new issue