mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Compare commits
No commits in common. "a8a1b929212c9d2a015a14215dd58d94bc7bdfe8" and "f005a8303d5e275a07ec423a0b42c5e0f4083c21" have entirely different histories.
a8a1b92921
...
f005a8303d
@ -1,3 +1,4 @@
|
|||||||
|
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
|
||||||
@ -30,16 +31,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 = "single", max_height = 25 }
|
vim.lsp.buf.hover { border = "rounded" }
|
||||||
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 }
|
diagnostic.jump { count = -1, float = true }
|
||||||
end, { desc = "previous diagnostic" })
|
end, { desc = "previous diagnostic" })
|
||||||
map("n", "]d", function()
|
map("n", "]d", function()
|
||||||
diagnostic.jump { count = 1 }
|
diagnostic.jump { count = 1, float = true }
|
||||||
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" })
|
||||||
@ -63,6 +64,33 @@ 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([[
|
||||||
@ -260,7 +288,6 @@ 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] = "🆇",
|
||||||
@ -270,30 +297,4 @@ 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,
|
|
||||||
})
|
|
||||||
|
|||||||
@ -170,11 +170,7 @@ api.nvim_create_autocmd("ColorScheme", {
|
|||||||
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
|
vim.api.nvim_set_hl(0, "Cursor2", { fg = "red", bg = "red" })
|
||||||
|
|
||||||
-- For floating windows border highlight
|
-- For floating windows border highlight
|
||||||
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen", bg = "None", bold = true })
|
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "LightGreen" })
|
||||||
|
|
||||||
local hl = vim.api.nvim_get_hl(0, { name = "NormalFloat" })
|
|
||||||
-- change the background color of floating window to None, so it blenders better
|
|
||||||
vim.api.nvim_set_hl(0, "NormalFloat", { fg = hl.fg, bg = "None" })
|
|
||||||
|
|
||||||
-- highlight for matching parentheses
|
-- highlight for matching parentheses
|
||||||
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
|
vim.api.nvim_set_hl(0, "MatchParen", { bold = true, underline = true })
|
||||||
|
|||||||
@ -69,6 +69,3 @@ 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,6 +23,19 @@ 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,8 +115,6 @@ 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