1
0
Fork 0

nvim: Improve diagnostic sign click

This commit is contained in:
Daniel Kempkens 2023-01-11 23:48:51 +01:00
parent 68b7947137
commit 4038101664
Signed by: daniel
SSH key fingerprint: SHA256:Ks/MyhQYcPRQiwMKLAKquWCdCPe3JXlb1WttgnAoSeM
3 changed files with 16 additions and 7 deletions

View file

@ -12,7 +12,9 @@
(vim.diagnostic.config {:underline true
:virtual_text false
:signs true
:float {:border :rounded :source true}
:float {:border :rounded
:source true
:focusable false}
:update_in_insert false
:severity_sort true})
(sign "define DiagnosticSignError text= texthl=DiagnosticSignError linehl= numhl=")

View file

@ -51,6 +51,8 @@
{:desc "Show Diagnostics"})
(keymap.set :n :<leader>dli :<cmd>LspInfo<CR> {:desc "LSP Info"})
(keymap.set :n :<leader>dlr :<cmd>LspRestart<CR> {:desc "Restart LSP"})
(keymap.set :n :<leader>ds #(vim.diagnostic.open_float {:scope :line})
{:desc "Show Diagnostics"})
(keymap.set :n :<leader>dtp :<cmd>TSPlaygroundToggle<CR>
{:desc "Toggle Treetsitter Playground"})
(keymap.set :n :<leader>dn #(noice.cmd :telescope)

View file

@ -61,11 +61,16 @@
$1.sign.name)
:on_click {:name :heirline_statuscolumn_diagnostic
:callback (fn [self]
(let [mouse (vim.fn.getmousepos)]
(vim.schedule #(vim.diagnostic.open_float {:bufnr self.bufnr
:pos (- mouse.line
1)
:scope :line
:focusable false}))))}})
(let [mouse (vim.fn.getmousepos)
line (- mouse.line 1)
cursor-pos [mouse.line 0]]
(api.nvim_win_set_cursor mouse.winid
cursor-pos)
(vim.schedule #(vim.diagnostic.goto_next {:win_id mouse.winid
:float false}))
(vim.defer_fn #(vim.diagnostic.open_float {:bufnr self.bufnr
:pos line
:scope :line})
200)))}})
mod)