Skip to content

Commit ab7690f

Browse files
committed
打磨
1 parent b4cdd78 commit ab7690f

File tree

8 files changed

+111
-116
lines changed

8 files changed

+111
-116
lines changed

colors/gruvboxl.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,15 @@ hl({
7676
PmenuExtraSel = { link = "PmenuSel" },
7777
PmenuSbar = { bg = "#353535" },
7878
PmenuThumb = { bg = dark_ext3 },
79+
QuickFixLine = { bg = dark1 },
7980

8081
NormalFloat = {},
8182
FloatBorder = { fg = dark_ext0 },
82-
StatusLine = { bg = dark_ext2 },
83+
StatusLine = { bg = dark_ext2, fg = light1 },
84+
StatusLineNC = { bg = dark_ext2 },
85+
86+
TabLine = { bg = dark_ext2, fg = gray_ext0 },
87+
TabLineSel = { fg = light1, bg = dark0 },
8388
Directory = { fg = bright_blue },
8489
Title = { fg = bright_blue, bold = true },
8590
Question = { fg = bright_blue },

init.lua

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
-- 清理 jumps 列表,防止跳转整到其他项目
2+
vim.cmd([[
3+
augroup kide_clearjumps
4+
autocmd!
5+
autocmd VimEnter * :clearjumps
6+
augroup END
7+
]])
8+
vim.opt_global.jumpoptions = "stack"
19
vim.opt_global.encoding = "UTF-8"
210
vim.opt.fileencoding = "UTF-8"
311
vim.g.mapleader = " "
@@ -27,7 +35,6 @@ vim.diagnostic.config({
2735
})
2836
vim.fn.sign_define("DapBreakpoint", { text = "", texthl = "Debug", linehl = "", numhl = "" })
2937

30-
vim.g.nvim_jdtls = 1
3138
if vim.g.neovide then
3239
vim.g.neovide_cursor_vfx_mode = "railgun"
3340
vim.opt_global.guifont = "CaskaydiaCove Nerd Font Mono:h15"

lua/autocmds.lua

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,6 @@ autocmd("LspDetach", {
181181
end,
182182
})
183183

184-
-- jdtls
185-
autocmd({ "BufReadCmd" }, {
186-
group = augroup("jdtls_open"),
187-
pattern = { "*.class" },
188-
callback = function(event)
189-
require("jdtls").open_classfile(event.file)
190-
end,
191-
})
192184

193185
require("kide.tools.maven").setup()
194186
require("kide.tools.plantuml").setup()

lua/kide/init.lua

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,55 @@
11
local M = {}
2+
local uv = vim.uv or vim.loop
3+
local git_repo = true
24
-- 参考 https://github.com/mfussenegger/dotfiles
35
function M.statusline()
4-
local counts = vim.diagnostic.count(0, { severity = { min = vim.diagnostic.severity.WARN } })
5-
local fstatus = M.file_or_lsp_status()
66
local parts = {
7-
"%< ",
8-
fstatus,
7+
"%<",
98
}
9+
local git = M.git_status()
10+
if git then
11+
table.insert(parts, " %#DiagnosticError# %#StatusLine#" .. git.head)
12+
if git.added and git.added > 0 then
13+
vim.list_extend(parts, { " %#Added# ", tostring(git.added) })
14+
end
15+
if git.removed and git.removed > 0 then
16+
vim.list_extend(parts, { " %#Removed#󰍵 ", tostring(git.removed) })
17+
end
18+
if git.changed and git.changed > 0 then
19+
vim.list_extend(parts, { " %#Changed# ", tostring(git.changed) })
20+
end
21+
end
22+
local fstatus = M.file_or_lsp_status()
23+
vim.list_extend(parts, fstatus)
24+
25+
local counts = vim.diagnostic.count(0, { severity = { min = vim.diagnostic.severity.WARN } })
1026
local num_errors = counts[vim.diagnostic.severity.ERROR] or 0
1127
local num_warnings = counts[vim.diagnostic.severity.WARN] or 0
12-
table.insert(parts, "%#DiagnosticWarn#%r%m")
28+
table.insert(parts, " %#DiagnosticWarn#%r%m")
1329
if num_errors > 0 then
1430
vim.list_extend(parts, { "%#DiagnosticError#", " 󰅙 ", tostring(num_errors), " " })
1531
elseif num_warnings > 0 then
1632
vim.list_extend(parts, { "%#DiagnosticWarn#", "", tostring(num_warnings), " " })
1733
end
1834
table.insert(parts, "%=")
1935
vim.list_extend(parts, { "%#StatusLine#", "%l:%c", " " })
20-
vim.list_extend(parts, { "%#StatusLine#", "%y", " " })
36+
local ft = vim.bo.filetype
37+
if ft and ft ~= "" then
38+
local clients = vim.lsp.get_clients({ bufnr = 0 })
39+
if clients and #clients > 0 then
40+
vim.list_extend(parts, { "%#DiagnosticInfo#", "[ ", clients[1].name, "] " })
41+
end
42+
vim.list_extend(parts, { "%#StatusLine#", ft, " " })
43+
end
2144
vim.list_extend(parts, { "%#StatusLine#", "%{&ff}", " " })
2245
vim.list_extend(parts, { "%#StatusLine#", "%{&fenc}", " " })
2346
return table.concat(parts, "")
2447
end
2548

49+
function M.git_status()
50+
return vim.b[0].gitsigns_status_dict
51+
end
52+
2653
function M.file_or_lsp_status()
2754
local mode = vim.api.nvim_get_mode().mode
2855
local lsp_status = vim.lsp.status()
@@ -32,12 +59,12 @@ function M.file_or_lsp_status()
3259
local devicons = require("nvim-web-devicons")
3360
local icon, name = devicons.get_icon_by_filetype(vim.bo[buf].filetype, { default = true })
3461
if name then
35-
return string.format("%%#%s#%s %%#StatusLine#%s", name, icon, M.format_uri(filename))
62+
return { " ", "%#" .. name .. "#", icon, " %#StatusLine#", M.format_uri(filename) }
3663
else
37-
return string.format("%s %s", icon, M.format_uri(filename))
64+
return { " ", icon, " ", M.format_uri(filename) }
3865
end
3966
end
40-
return lsp_status
67+
return { " ", "%#StatusLine#", lsp_status }
4168
end
4269
function M.format_uri(uri)
4370
if vim.startswith(uri, "jdt://") then
@@ -62,4 +89,30 @@ function M.dap_status()
6289
return ""
6390
end
6491

92+
function M.tabline()
93+
local parts = {}
94+
local devicons = require("nvim-web-devicons")
95+
for i = 1, vim.fn.tabpagenr("$") do
96+
local tabpage = vim.fn.gettabinfo(i)[1]
97+
local winnr = tabpage.windows[1]
98+
local bufnr = vim.fn.winbufnr(winnr)
99+
local bufname = vim.fn.bufname(bufnr)
100+
local filename = vim.fn.fnamemodify(bufname, ":t")
101+
102+
local icon, name = devicons.get_icon_by_filetype(vim.bo[bufnr].filetype, { default = true })
103+
table.insert(parts, " %#" .. name .. "#")
104+
table.insert(parts, icon)
105+
table.insert(parts, " ")
106+
if i == vim.fn.tabpagenr() then
107+
table.insert(parts, "%#TabLineSel#")
108+
else
109+
table.insert(parts, "%#TabLine#")
110+
end
111+
if not filename or filename == "" then
112+
filename = "[No Name]"
113+
end
114+
table.insert(parts, filename)
115+
end
116+
return table.concat(parts, "")
117+
end
65118
return M

lua/kide/tools/ai.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ end
207207
local charwin = nil
208208
local charbuf = nil
209209
local chatclosed = false
210+
local chatruning = false
210211
local chat_request_json = {
211212
messages = {
212213
{
@@ -233,8 +234,8 @@ local chat_request_json = {
233234
}
234235

235236
M.chat_config = {
236-
user_title = "User:",
237-
system_title = "DeepseekChat:",
237+
user_title = ":",
238+
system_title = ":",
238239
system_prompt = "You are a general AI assistant.\n\n"
239240
.. "The user provided the additional info about how they would like you to respond:\n\n"
240241
.. "- If you're unsure don't guess and say you don't know instead.\n"
@@ -246,6 +247,7 @@ M.chat_config = {
246247
.. "- Take a deep breath; You've got this!\n",
247248
}
248249
local close_gpt_win = function()
250+
chatruning = false
249251
if charwin then
250252
pcall(vim.api.nvim_win_close, charwin, true)
251253
charwin = nil
@@ -301,6 +303,10 @@ M.gpt_chat = function()
301303
if charwin == nil then
302304
create_gpt_win()
303305
end
306+
if chatruning then
307+
return
308+
end
309+
chatruning = true
304310
local list = vim.api.nvim_buf_get_lines(charbuf, 0, -1, false)
305311
local json = chat_request_json
306312
json.messages[1].content = M.chat_config.system_prompt
@@ -335,6 +341,7 @@ M.gpt_chat = function()
335341
end
336342
if done then
337343
vim.api.nvim_put({ "", "", M.chat_config.user_title, "" }, "c", true, true)
344+
chatruning = false
338345
return
339346
end
340347
if charbuf and vim.api.nvim_buf_is_valid(charbuf) then

lua/mappings.lua

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ map("v", "<A-i>", function()
1515
require("kide.term").toggle()
1616
require("kide.term").send_line(text[1])
1717
end, { desc = "toggle term" })
18+
19+
map("n", "<leader>w", function()
20+
vim.print("---close--")
21+
vim.print(vim.bo.bufhidden)
22+
vim.print(vim.bo.buflisted)
23+
end, { desc = "close buf" })
24+
1825
map("n", "<leader>gb", require("gitsigns").blame_line, { desc = "gitsigns blame line" })
1926
map("n", "<ESC>", "<CMD>noh<CR>", { desc = "Clear Highlight" })
2027

@@ -34,10 +41,6 @@ map("n", "<C-k>", "<C-w>k", { desc = "switch window up" })
3441
-- terminal
3542
map("t", "<C-x>", "<C-\\><C-N>", { desc = "terminal escape terminal mode" })
3643

37-
map("n", "==", function()
38-
require("conform").format({ lsp_fallback = true })
39-
end, { desc = "format file" })
40-
4144
-- dap
4245
map("n", "<leader>db", "<CMD>lua require'dap'.toggle_breakpoint()<CR>", { desc = "Dap toggle breakpoint" })
4346
map(
@@ -67,7 +70,10 @@ command("TaskRunLast", function()
6770
require("kide.term").input_run(true)
6871
end, { desc = "Restart Last Task" })
6972

70-
map("v", "<leader>fm", function()
73+
map("n", "<C-l>", function()
74+
require("conform").format({ lsp_fallback = true })
75+
end, { desc = "format file" })
76+
map("v", "<C-l>", function()
7177
vim.api.nvim_feedkeys("\027", "xt", false)
7278
local start_pos = vim.api.nvim_buf_get_mark(0, "<")
7379
local end_pos = vim.api.nvim_buf_get_mark(0, ">")
@@ -210,14 +216,6 @@ command("Bp", function()
210216
require("nvchad.tabufline").prev()
211217
end, { desc = "buffer goto prev" })
212218

213-
-- jdtls
214-
command("JdtWipeDataAndRestart", function()
215-
require("jdtls.setup").wipe_data_and_restart()
216-
end, { desc = "Jdt Wipe Data And Restart" })
217-
command("JdtShowLogs", function()
218-
require("jdtls.setup").show_logs()
219-
end, { desc = "Jdt Show Logs" })
220-
221219
-- find files
222220
if vim.fn.executable("fd") == 1 then
223221
command("Fd", function(opt)
@@ -322,15 +320,23 @@ if vim.fn.executable("fzy") == 1 then
322320
local text = require("kide.tools").get_visual_selection()
323321
local fzy = require("kide.fzy")
324322
local param = vim.fn.shellescape(text[1])
325-
fzy.execute("fd --type file " .. param, fzy.sinks.edit_file, "Files  ", text)
323+
fzy.execute("fd --type file " .. param, fzy.sinks.edit_file, "Files  ", text[1])
326324
end, { desc = "fzy find files", silent = true, noremap = true })
327325

328326
map("v", "<leader>fw", function()
329327
vim.api.nvim_feedkeys("\027", "xt", false)
330328
local text = require("kide.tools").get_visual_selection()
331329
local fzy = require("kide.fzy")
332330
local param = vim.fn.shellescape(text[1])
333-
fzy.execute("rg --no-heading --trim -nH --smart-case " .. param, fzy.sinks.edit_live_grep, "Grep  ", text)
331+
fzy.execute("rg --no-heading --trim -nH --smart-case " .. param, fzy.sinks.edit_live_grep, "Grep  ", text[1])
332+
end, { desc = "fzy live grep", silent = true, noremap = true })
333+
map("n", "<leader>fw", function()
334+
local ok, text = pcall(vim.fn.input, "rg: ")
335+
if ok and text and text ~= "" then
336+
local fzy = require("kide.fzy")
337+
local param = vim.fn.shellescape(text)
338+
fzy.execute("rg --no-heading --trim -nH --smart-case " .. param, fzy.sinks.edit_live_grep, "Grep  ", text)
339+
end
334340
end, { desc = "fzy live grep", silent = true, noremap = true })
335341

336342
command("FzyFiles", function(opt)

lua/options.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ vim.opt.numberwidth = 2
2525
vim.opt.signcolumn = "yes"
2626
vim.opt.scrollback = 100000
2727

28-
vim.opt_global.jumpoptions = "stack"
2928

3029
-- 高亮所在行
3130
vim.opt.cursorline = true
@@ -156,3 +155,7 @@ vim.opt.backup = false
156155
-- vim.opt.cmdheight=0
157156
-- set statusline=%!v:lua.require'me'.statusline()
158157
vim.opt.statusline = "%!v:lua.require('kide').statusline()"
158+
-- 1 只有多个 tab 时显示
159+
-- 2 一直显示(99% 情况下不需要)
160+
vim.opt.showtabline = 1
161+
vim.opt.tabline = "%!v:lua.require('kide').tabline()"

0 commit comments

Comments
 (0)