Add <leader>dy mapping to yank diagnostic message (wip)

This commit is contained in:
2022-02-01 22:51:02 +03:00
parent 317c8c720f
commit cecf188adc
3 changed files with 30 additions and 1 deletions

View File

@@ -1,3 +1,5 @@
local yank = require("user.utils").yank
function open_terminal(vertically)
vertically = vertically or false
@@ -7,3 +9,20 @@ function open_terminal(vertically)
vim.cmd(":split term://bash")
end
end
function copy_diagnostic_message()
local diagnostics = vim.lsp.diagnostic.get_line_diagnostics()
if #diagnostics == 0 then
print("No diagnostics to yank")
return
end
-- TODO: print all messages available and prompt which one to yank
local message = diagnostics[1].message
yank(message)
print("Diagnostic message was yanked")
end