-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de64441
commit 8359e8c
Showing
3 changed files
with
40 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- 自动浮窗展示diagnostic | ||
local function create_floating_window_autocmd() | ||
vim.api.nvim_create_augroup("nvim_lsp_floating_window", {}) | ||
vim.api.nvim_create_autocmd("CursorHold", { | ||
group = "nvim_lsp_floating_window", | ||
callback = function() | ||
local opts = { | ||
focusable = false, | ||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" }, | ||
border = 'rounded', | ||
source = 'always', | ||
prefix = ' ', | ||
scope = 'cursor', | ||
} | ||
vim.diagnostic.open_float(nil, opts) | ||
end | ||
}) | ||
end | ||
|
||
vim.g.nvim_lsp_diagnostic_enable_auto_floating_window = vim.fn.get(vim.g, 'nvim_lsp_diagnostic_enable_auto_floating_window', false) | ||
local function toggle_auto_floating_window() | ||
if vim.g.nvim_lsp_diagnostic_enable_auto_floating_window then | ||
vim.api.nvim_del_augroup_by_name("nvim_lsp_floating_window") | ||
else | ||
create_floating_window_autocmd() | ||
end | ||
vim.g.nvim_lsp_diagnostic_enable_auto_floating_window = not vim.g.nvim_lsp_diagnostic_enable_auto_floating_window | ||
end | ||
vim.api.nvim_create_user_command('LspFloatToggle', toggle_auto_floating_window, {}) | ||
|
||
if vim.g.nvim_lsp_diagnostic_enable_auto_floating_window then | ||
create_floating_window_autocmd() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*neovim.txt* | ||
|
||
Toggle lsp diagnostic auto floating window *:LspFloatToggle* | ||
|
||
Enable lsp diagnostic auto floating window *g:nvim_lsp_diagnostic_enable_auto_floating_window* |