mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
update various config after nvim 0.11 release (#386)
This commit is contained in:
parent
f005a8303d
commit
5f662f143b
@ -1,4 +1,3 @@
|
|||||||
local fn = vim.fn
|
|
||||||
local api = vim.api
|
local api = vim.api
|
||||||
local keymap = vim.keymap
|
local keymap = vim.keymap
|
||||||
local lsp = vim.lsp
|
local lsp = vim.lsp
|
||||||
@ -31,16 +30,16 @@ local custom_attach = function(client, bufnr)
|
|||||||
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
|
map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" })
|
||||||
map("n", "<C-]>", vim.lsp.buf.definition)
|
map("n", "<C-]>", vim.lsp.buf.definition)
|
||||||
map("n", "K", function()
|
map("n", "K", function()
|
||||||
vim.lsp.buf.hover { border = "rounded" }
|
vim.lsp.buf.hover { border = "single", max_height = 25 }
|
||||||
end)
|
end)
|
||||||
map("n", "<C-k>", vim.lsp.buf.signature_help)
|
map("n", "<C-k>", vim.lsp.buf.signature_help)
|
||||||
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
|
map("n", "<space>rn", vim.lsp.buf.rename, { desc = "varialbe rename" })
|
||||||
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
|
map("n", "gr", vim.lsp.buf.references, { desc = "show references" })
|
||||||
map("n", "[d", function()
|
map("n", "[d", function()
|
||||||
diagnostic.jump { count = -1, float = true }
|
diagnostic.jump { count = -1 }
|
||||||
end, { desc = "previous diagnostic" })
|
end, { desc = "previous diagnostic" })
|
||||||
map("n", "]d", function()
|
map("n", "]d", function()
|
||||||
diagnostic.jump { count = 1, float = true }
|
diagnostic.jump { count = 1 }
|
||||||
end, { desc = "next diagnostic" })
|
end, { desc = "next diagnostic" })
|
||||||
-- this puts diagnostics from opened files to quickfix
|
-- this puts diagnostics from opened files to quickfix
|
||||||
map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
|
map("n", "<space>qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" })
|
||||||
@ -64,33 +63,6 @@ local custom_attach = function(client, bufnr)
|
|||||||
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
|
-- but disable this feature by default, so you may need to enable inlay hint in the LSP server config.
|
||||||
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
|
-- vim.lsp.inlay_hint.enable(true, {buffer=bufnr})
|
||||||
|
|
||||||
api.nvim_create_autocmd("CursorHold", {
|
|
||||||
buffer = bufnr,
|
|
||||||
callback = function()
|
|
||||||
local float_opts = {
|
|
||||||
focusable = false,
|
|
||||||
close_events = { "BufLeave", "CursorMoved", "InsertEnter", "FocusLost" },
|
|
||||||
border = "rounded",
|
|
||||||
source = "always", -- show source in diagnostic popup window
|
|
||||||
prefix = " ",
|
|
||||||
}
|
|
||||||
|
|
||||||
if not vim.b.diagnostics_pos then
|
|
||||||
vim.b.diagnostics_pos = { nil, nil }
|
|
||||||
end
|
|
||||||
|
|
||||||
local cursor_pos = api.nvim_win_get_cursor(0)
|
|
||||||
if
|
|
||||||
(cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2])
|
|
||||||
and #diagnostic.get() > 0
|
|
||||||
then
|
|
||||||
diagnostic.open_float(nil, float_opts)
|
|
||||||
end
|
|
||||||
|
|
||||||
vim.b.diagnostics_pos = cursor_pos
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- The blow command will highlight the current variable and its usages in the buffer.
|
-- The blow command will highlight the current variable and its usages in the buffer.
|
||||||
if client.server_capabilities.documentHighlightProvider then
|
if client.server_capabilities.documentHighlightProvider then
|
||||||
vim.cmd([[
|
vim.cmd([[
|
||||||
@ -288,6 +260,7 @@ end
|
|||||||
diagnostic.config {
|
diagnostic.config {
|
||||||
underline = false,
|
underline = false,
|
||||||
virtual_text = false,
|
virtual_text = false,
|
||||||
|
virtual_lines = false,
|
||||||
signs = {
|
signs = {
|
||||||
text = {
|
text = {
|
||||||
[diagnostic.severity.ERROR] = "🆇",
|
[diagnostic.severity.ERROR] = "🆇",
|
||||||
@ -297,4 +270,30 @@ diagnostic.config {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
severity_sort = true,
|
severity_sort = true,
|
||||||
|
float = {
|
||||||
|
source = true,
|
||||||
|
header = "Diagnostics:",
|
||||||
|
prefix = " ",
|
||||||
|
border = "single",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
api.nvim_create_autocmd("CursorHold", {
|
||||||
|
pattern = "*",
|
||||||
|
callback = function()
|
||||||
|
if #vim.diagnostic.get(0) == 0 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if not vim.b.diagnostics_pos then
|
||||||
|
vim.b.diagnostics_pos = { nil, nil }
|
||||||
|
end
|
||||||
|
|
||||||
|
local cursor_pos = api.nvim_win_get_cursor(0)
|
||||||
|
if cursor_pos[1] ~= vim.b.diagnostics_pos[1] or cursor_pos[2] ~= vim.b.diagnostics_pos[2] then
|
||||||
|
diagnostic.open_float()
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.b.diagnostics_pos = cursor_pos
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|||||||
@ -69,3 +69,6 @@ vim.g.loaded_matchparen = 1
|
|||||||
|
|
||||||
-- Disable sql omni completion, it is broken.
|
-- Disable sql omni completion, it is broken.
|
||||||
vim.g.loaded_sql_completion = 1
|
vim.g.loaded_sql_completion = 1
|
||||||
|
|
||||||
|
-- control how to show health check window
|
||||||
|
vim.g.health = { style = nil }
|
||||||
|
|||||||
@ -23,19 +23,6 @@ keymap.set("n", "<leader>q", "<cmd>x<cr>", { silent = true, desc = "quit current
|
|||||||
-- Quit all opened buffers
|
-- Quit all opened buffers
|
||||||
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
|
keymap.set("n", "<leader>Q", "<cmd>qa!<cr>", { silent = true, desc = "quit nvim" })
|
||||||
|
|
||||||
-- Navigation in the location and quickfix list
|
|
||||||
keymap.set("n", "[l", "<cmd>lprevious<cr>zv", { silent = true, desc = "previous location item" })
|
|
||||||
keymap.set("n", "]l", "<cmd>lnext<cr>zv", { silent = true, desc = "next location item" })
|
|
||||||
|
|
||||||
keymap.set("n", "[L", "<cmd>lfirst<cr>zv", { silent = true, desc = "first location item" })
|
|
||||||
keymap.set("n", "]L", "<cmd>llast<cr>zv", { silent = true, desc = "last location item" })
|
|
||||||
|
|
||||||
keymap.set("n", "[q", "<cmd>cprevious<cr>zv", { silent = true, desc = "previous qf item" })
|
|
||||||
keymap.set("n", "]q", "<cmd>cnext<cr>zv", { silent = true, desc = "next qf item" })
|
|
||||||
|
|
||||||
keymap.set("n", "[Q", "<cmd>cfirst<cr>zv", { silent = true, desc = "first qf item" })
|
|
||||||
keymap.set("n", "]Q", "<cmd>clast<cr>zv", { silent = true, desc = "last qf item" })
|
|
||||||
|
|
||||||
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
|
-- Close location list or quickfix list if they are present, see https://superuser.com/q/355325/736190
|
||||||
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
keymap.set("n", [[\x]], "<cmd>windo lclose <bar> cclose <cr>", {
|
||||||
silent = true,
|
silent = true,
|
||||||
|
|||||||
@ -115,6 +115,8 @@ set shortmess+=S
|
|||||||
" Disable showing intro message (:intro)
|
" Disable showing intro message (:intro)
|
||||||
set shortmess+=I
|
set shortmess+=I
|
||||||
|
|
||||||
|
set messagesopt=wait:5000,history:500
|
||||||
|
|
||||||
" Completion behaviour
|
" Completion behaviour
|
||||||
" set completeopt+=noinsert " Auto select the first completion entry
|
" set completeopt+=noinsert " Auto select the first completion entry
|
||||||
set completeopt+=menuone " Show menu even if there is only one item
|
set completeopt+=menuone " Show menu even if there is only one item
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user