update
This commit is contained in:
parent
360ebbd27c
commit
b734872a1b
4 changed files with 58 additions and 16 deletions
File diff suppressed because one or more lines are too long
44
init.lua
44
init.lua
|
|
@ -404,11 +404,48 @@ local function open_nvim_tree(data)
|
||||||
end
|
end
|
||||||
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|
||||||
|
|
||||||
|
local timers = {}
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("TermOpen", {
|
vim.api.nvim_create_autocmd("TermOpen", {
|
||||||
group = vim.api.nvim_create_augroup("HideTerminal", { clear = true }),
|
group = vim.api.nvim_create_augroup("TermOpenCallback", { clear = true }),
|
||||||
pattern = "term://*",
|
pattern = "term://*",
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd("PinBuftype")
|
vim.cmd("PinBuftype")
|
||||||
|
|
||||||
|
local timer = vim.loop.new_timer()
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
timers[bufnr] = timer
|
||||||
|
timer:start(1000, 750, function()
|
||||||
|
vim.schedule(function()
|
||||||
|
local tji = vim.api.nvim_buf_get_var(bufnr, "terminal_job_id")
|
||||||
|
local pid = vim.fn.jobpid(tji)
|
||||||
|
local result = vim.fn.system("pgrep -lP " .. pid)
|
||||||
|
local first_child = result:gmatch("([^\n]*)\n?")()
|
||||||
|
|
||||||
|
local words_iterator = first_child:gmatch("%S+")
|
||||||
|
words_iterator()
|
||||||
|
|
||||||
|
local words = {}
|
||||||
|
for word in words_iterator do
|
||||||
|
table.insert(words, word)
|
||||||
|
end
|
||||||
|
|
||||||
|
local process_name = table.concat(words, " ")
|
||||||
|
if process_name ~= "" then
|
||||||
|
vim.api.nvim_buf_set_name(bufnr, process_name)
|
||||||
|
else
|
||||||
|
vim.api.nvim_buf_set_name(bufnr, "Terminal " .. bufnr)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
vim.api.nvim_create_autocmd("TermClose", {
|
||||||
|
group = vim.api.nvim_create_augroup("TermCloseCallback", { clear = true }),
|
||||||
|
pattern = "term://*",
|
||||||
|
callback = function()
|
||||||
|
local bufnr = vim.api.nvim_get_current_buf()
|
||||||
|
timers[bufnr]:close()
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -684,3 +721,8 @@ dap.configurations.rust = {
|
||||||
runInTerminal = true,
|
runInTerminal = true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
|
pattern = { "*" },
|
||||||
|
command = [[%s/\s\+$//e]],
|
||||||
|
})
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,8 @@
|
||||||
"bash": {
|
"bash": {
|
||||||
"path": "bash",
|
"path": "bash",
|
||||||
"icon": "terminal-bash",
|
"icon": "terminal-bash",
|
||||||
"args": [
|
"args": ["--login"]
|
||||||
"--login"
|
}
|
||||||
]
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"editor.fontLigatures": true,
|
"editor.fontLigatures": true,
|
||||||
"vim.handleKeys": {
|
"vim.handleKeys": {
|
||||||
|
|
@ -40,7 +38,6 @@
|
||||||
"[json]": {
|
"[json]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
"editor.minimap.enabled": false,
|
|
||||||
"editor.renderWhitespace": "all",
|
"editor.renderWhitespace": "all",
|
||||||
"window.menuBarVisibility": "toggle",
|
"window.menuBarVisibility": "toggle",
|
||||||
"workbench.startupEditor": "none",
|
"workbench.startupEditor": "none",
|
||||||
|
|
@ -48,5 +45,8 @@
|
||||||
"zenMode.centerLayout": false,
|
"zenMode.centerLayout": false,
|
||||||
"editor.rulers": [
|
"editor.rulers": [
|
||||||
80
|
80
|
||||||
]
|
],
|
||||||
|
"[jsonc]": {
|
||||||
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue