mirror of
https://github.com/mintycube/dotfiles.git
synced 2024-10-22 14:05:41 +02:00
Fix autocompilation of suckless software
This commit is contained in:
parent
ecb9b45a3d
commit
819e8661c3
@ -2,50 +2,50 @@
|
|||||||
|
|
||||||
-- [[ Highlight on yank ]]
|
-- [[ Highlight on yank ]]
|
||||||
vim.api.nvim_create_autocmd("TextYankPost", {
|
vim.api.nvim_create_autocmd("TextYankPost", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.highlight.on_yank({ timeout = 100 })
|
vim.highlight.on_yank({ timeout = 100 })
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }),
|
group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }),
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Disable Autocommenting on new lines ]]
|
-- [[ Disable Autocommenting on new lines ]]
|
||||||
vim.api.nvim_create_autocmd("BufEnter", {
|
vim.api.nvim_create_autocmd("BufEnter", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.opt.formatoptions:remove({ "c", "r", "o" })
|
vim.opt.formatoptions:remove({ "c", "r", "o" })
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("DisableAutocommenting", { clear = true }),
|
group = vim.api.nvim_create_augroup("DisableAutocommenting", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Update file on Focus ]]
|
-- [[ Update file on Focus ]]
|
||||||
vim.api.nvim_create_autocmd("FocusGained", {
|
vim.api.nvim_create_autocmd("FocusGained", {
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd("checktime")
|
vim.cmd("checktime")
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("UpdateOnFocus", { clear = true }),
|
group = vim.api.nvim_create_augroup("UpdateOnFocus", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Open lf when it's a Directory ]]
|
-- [[ Open lf when it's a Directory ]]
|
||||||
vim.api.nvim_create_autocmd("VimEnter", {
|
vim.api.nvim_create_autocmd("VimEnter", {
|
||||||
callback = function(data)
|
callback = function(data)
|
||||||
local directory = vim.fn.isdirectory(data.file) == 1
|
local directory = vim.fn.isdirectory(data.file) == 1
|
||||||
if directory then
|
if directory then
|
||||||
require("lf").start()
|
require("lf").start()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("lf_ifDirectory", { clear = true }),
|
group = vim.api.nvim_create_augroup("lf_ifDirectory", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Remove trailing whitespaces ]]
|
-- [[ Remove trailing whitespaces ]]
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||||
pattern = { "*" },
|
pattern = { "*" },
|
||||||
callback = function()
|
callback = function()
|
||||||
local save_cursor = vim.fn.getpos(".")
|
local save_cursor = vim.fn.getpos(".")
|
||||||
vim.cmd([[%s/\s\+$//e]])
|
vim.cmd([[%s/\s\+$//e]])
|
||||||
vim.cmd([[%s/\n\+\%$//e]])
|
vim.cmd([[%s/\n\+\%$//e]])
|
||||||
vim.fn.setpos(".", save_cursor)
|
vim.fn.setpos(".", save_cursor)
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("RemoveTrailingWhitespaces", { clear = true }),
|
group = vim.api.nvim_create_augroup("RemoveTrailingWhitespaces", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Restore last cursor position ]]
|
-- [[ Restore last cursor position ]]
|
||||||
@ -54,10 +54,10 @@ vim.api.nvim_create_autocmd("BufReadPost", {
|
|||||||
callback = function()
|
callback = function()
|
||||||
local line = vim.fn.line "'\""
|
local line = vim.fn.line "'\""
|
||||||
if
|
if
|
||||||
line > 1
|
line > 1
|
||||||
and line <= vim.fn.line "$"
|
and line <= vim.fn.line "$"
|
||||||
and vim.bo.filetype ~= "commit"
|
and vim.bo.filetype ~= "commit"
|
||||||
and vim.fn.index({ "xxd", "gitrebase" }, vim.bo.filetype) == -1
|
and vim.fn.index({ "xxd", "gitrebase" }, vim.bo.filetype) == -1
|
||||||
then
|
then
|
||||||
vim.cmd 'normal! g`"zz'
|
vim.cmd 'normal! g`"zz'
|
||||||
end
|
end
|
||||||
@ -66,24 +66,27 @@ vim.api.nvim_create_autocmd("BufReadPost", {
|
|||||||
|
|
||||||
-- [[ Reload xresources on write ]]
|
-- [[ Reload xresources on write ]]
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
pattern = vim.fn.resolve(vim.fn.expand("~/.config/x11/xresources")),
|
pattern = vim.fn.resolve(vim.fn.expand("~/.config/x11/xresources")),
|
||||||
callback = function()
|
callback = function()
|
||||||
-- cmd([[!xrdb % ; killall -USR1 st ; renew-dwm ; notify-send " - xresources reloaded"]])
|
-- cmd([[!xrdb % ; killall -USR1 st ; renew-dwm ; notify-send " - xresources reloaded"]])
|
||||||
vim.cmd([[!xrdb % ; killall -USR1 st ; renew-dwm]])
|
vim.cmd([[!xrdb % ; killall -USR1 st ; renew-dwm]])
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("ReloadXresources", { clear = true }),
|
group = vim.api.nvim_create_augroup("ReloadXresources", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Recompile suckless software on write and show notification ]]
|
-- [[ Recompile suckless software on write and show notification ]]
|
||||||
local function recompile(path)
|
local function recompile(path)
|
||||||
vim.api.nvim_create_augroup("RecompileGroup_" .. path, { clear = true })
|
vim.api.nvim_create_augroup("RecompileGroup_" .. path, { clear = true })
|
||||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||||
pattern = vim.fn.resolve(vim.fn.expand(path)),
|
pattern = vim.fn.resolve(vim.fn.expand(path)),
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.cmd("!sudo make install; renew-dwm")
|
local dir = vim.fn.fnamemodify(path, ":h")
|
||||||
end,
|
local shell_cmd = string.format("cd %s && sudo make install && renew-dwm", dir)
|
||||||
})
|
vim.cmd("!" .. shell_cmd)
|
||||||
|
end,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
recompile("~/.config/suckless/dwm/config.h")
|
recompile("~/.config/suckless/dwm/config.h")
|
||||||
recompile("~/.config/suckless/dmenu/config.h")
|
recompile("~/.config/suckless/dmenu/config.h")
|
||||||
recompile("~/.config/suckless/st/config.h")
|
recompile("~/.config/suckless/st/config.h")
|
||||||
@ -91,17 +94,17 @@ recompile("~/.config/suckless/dwmblocks/config.h")
|
|||||||
|
|
||||||
--[[ Close nvim if toggleterm or Outline is the last buffer ]]
|
--[[ Close nvim if toggleterm or Outline is the last buffer ]]
|
||||||
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
vim.api.nvim_create_autocmd({ "BufEnter" }, {
|
||||||
pattern = "*",
|
pattern = "*",
|
||||||
callback = function()
|
callback = function()
|
||||||
if
|
if
|
||||||
vim.fn.tabpagenr("$") == 1
|
vim.fn.tabpagenr("$") == 1
|
||||||
and vim.fn.winnr("$") == 1
|
and vim.fn.winnr("$") == 1
|
||||||
and (vim.bo.ft == "toggleterm" or vim.bo.ft == "Outline")
|
and (vim.bo.ft == "toggleterm" or vim.bo.ft == "Outline")
|
||||||
then
|
then
|
||||||
vim.cmd("bd! | q")
|
vim.cmd("bd! | q")
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
group = vim.api.nvim_create_augroup("CloseLast", { clear = true }),
|
group = vim.api.nvim_create_augroup("CloseLast", { clear = true }),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- [[ Autosave ]]
|
-- [[ Autosave ]]
|
||||||
|
Loading…
Reference in New Issue
Block a user