This commit is contained in:
Jaroslaw Konik 2023-08-02 12:39:07 +02:00
parent 360ebbd27c
commit b734872a1b
4 changed files with 58 additions and 16 deletions

File diff suppressed because one or more lines are too long

View file

@ -257,7 +257,7 @@ for_window [title="Overview Home Assistant"] floating enable
for_window [title="Outlook"] floating enable for_window [title="Outlook"] floating enable
for_window [title="Netflix"] floating enable for_window [title="Netflix"] floating enable
for_window [title="Welcome to Prime Video"] floating enable for_window [title="Welcome to Prime Video"] floating enable
for_window [title="floating_window"] floating enable for_window [title="floating_window"] floating enable
bindsym $mod+Shift+minus move scratchpad bindsym $mod+Shift+minus move scratchpad
bindsym $mod+minus scratchpad show bindsym $mod+minus scratchpad show

View file

@ -12,7 +12,7 @@ end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ require("lazy").setup({
{ "NeogitOrg/neogit", dependencies = "nvim-lua/plenary.nvim" }, { "NeogitOrg/neogit", dependencies = "nvim-lua/plenary.nvim" },
"lewis6991/fileline.nvim", "lewis6991/fileline.nvim",
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
{ {
@ -121,9 +121,9 @@ require("lazy").setup({
-- refer to the configuration section below -- refer to the configuration section below
}, },
}, },
{ "ellisonleao/glow.nvim", config = true, cmd = "Glow" }, { "ellisonleao/glow.nvim", config = true, cmd = "Glow" },
"nvim-pack/nvim-spectre", "nvim-pack/nvim-spectre",
{ "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } }, { "rcarriga/nvim-dap-ui", requires = { "mfussenegger/nvim-dap" } },
{ {
"nvim-neorg/neorg", "nvim-neorg/neorg",
build = ":Neorg sync-parsers", build = ":Neorg sync-parsers",
@ -218,14 +218,14 @@ end, { TablineFileNameBlock })
local function get_terminal_bufs() local function get_terminal_bufs()
return vim.tbl_filter(function(bufnr) return vim.tbl_filter(function(bufnr)
return vim.api.nvim_buf_get_option(bufnr, "buftype") == "terminal" return vim.api.nvim_buf_get_option(bufnr, "buftype") == "terminal"
and vim.api.nvim_buf_get_option(bufnr, "buflisted") and vim.api.nvim_buf_get_option(bufnr, "buflisted")
end, vim.api.nvim_list_bufs()) end, vim.api.nvim_list_bufs())
end end
local function get_non_terminal_bufs() local function get_non_terminal_bufs()
return vim.tbl_filter(function(bufnr) return vim.tbl_filter(function(bufnr)
return vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal" return vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal"
and vim.api.nvim_buf_get_option(bufnr, "buflisted") and vim.api.nvim_buf_get_option(bufnr, "buflisted")
end, vim.api.nvim_list_bufs()) end, vim.api.nvim_list_bufs())
end end
@ -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,
}) })
@ -515,8 +552,8 @@ wk.register({
local current_buf_nr = vim.fn.bufnr() local current_buf_nr = vim.fn.bufnr()
local all = vim.tbl_filter(function(bufnr) local all = vim.tbl_filter(function(bufnr)
return current_buf_nr ~= bufnr return current_buf_nr ~= bufnr
and vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal" and vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal"
and vim.api.nvim_buf_get_option(bufnr, "buflisted") and vim.api.nvim_buf_get_option(bufnr, "buflisted")
end, vim.api.nvim_list_bufs()) end, vim.api.nvim_list_bufs())
for _, bufnr in ipairs(all) do for _, bufnr in ipairs(all) do
require("bufdelete").bufdelete(bufnr, false) require("bufdelete").bufdelete(bufnr, false)
@ -684,3 +721,8 @@ dap.configurations.rust = {
runInTerminal = true, runInTerminal = true,
}, },
} }
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
pattern = { "*" },
command = [[%s/\s\+$//e]],
})

View file

@ -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"
}
} }