monitor constrain

This commit is contained in:
Acid
2026-05-29 15:03:27 -04:00
parent bc1286b3d0
commit 314b091ce7
5 changed files with 201 additions and 158 deletions
+2 -2
View File
@@ -9,7 +9,7 @@ local menu = "~/.config/rofi/rofimenu/launcher.sh"
local apps = "~/.config/rofi/apps/apps.sh"
local powermenu = "~/.config/rofi/rofipowermenu/powermenu.sh"
local screenshot = 'grim -g "$(slurp)" ' .. os.getenv("HOME") .. "/screenshots/$(date +'%Y-%m-%d-%H%M%S').png"
local mouseConstrain = "~/scripts/mouseConstrain.sh"
local monitorConstrain = require("mods/mouseConstrain")
-- App launchers
hl.bind(mainMod .. " + R", hl.dsp.exec_cmd(terminal))
@@ -22,7 +22,7 @@ hl.bind(mainMod .. " + D", hl.dsp.exec_cmd(menu))
hl.bind(mainMod .. " + S", hl.dsp.exec_cmd(apps))
hl.bind("CTRL + ALT + L", hl.dsp.exec_cmd(powermenu))
hl.bind(mainMod .. " + L", hl.dsp.exec_cmd("loginctl lock-session"))
hl.bind(mainMod .. " + G", hl.dsp.exec_cmd(mouseConstrain))
hl.bind(mainMod .. " + G", monitorConstrain)
hl.bind(mainMod .. " + N", hl.dsp.exec_cmd("~/.config/quickshell/network/network_toggle.sh"))
-- Special workspace (scratchpad)
+37
View File
@@ -0,0 +1,37 @@
local function toggle_monitor_lock()
local function set_monitor(pos)
local cmd = string.format(
'hyprctl eval \'hl.monitor({ output = "DP-2", mode = "3840x2160@60", position = "%s", scale = 2 })\'',
pos
)
os.execute(cmd)
end
local home = os.getenv("HOME")
local state = home .. "/.local/state/togglemonitorlock"
os.execute("mkdir -p " .. home .. "/.local/state")
local booleanvalue = "false"
local f = io.open(state, "r")
if f then
booleanvalue = f:read("*l")
f:close()
end
if booleanvalue == "true" then
set_monitor("-1920x-950")
booleanvalue = "false"
else
set_monitor("50000x50000")
booleanvalue = "true"
end
local out = io.open(state, "w")
if out then
out:write(booleanvalue)
out:close()
end
end
return toggle_monitor_lock
+3 -3
View File
@@ -2,7 +2,7 @@
"LuaSnip": { "branch": "master", "commit": "0abc8f390b278c3b4aabc4c004ac8a088b65cf24" },
"barbar.nvim": { "branch": "master", "commit": "a4bef5b4fc1f064f2f673172252028eae18191c9" },
"buffer-vacuum": { "branch": "main", "commit": "917986d31cce6501c929ab6088c0887beff56b69" },
"catppuccin": { "branch": "main", "commit": "8edd468af4d63212b84d69b2ddb5ffc9023ef5eb" },
"catppuccin": { "branch": "main", "commit": "0303a7208dba448c459767486a38a6ec05c4216b" },
"cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"cmp-nvim-lua": { "branch": "main", "commit": "e3a22cb071eb9d6508a156306b102c45cd2d573d" },
@@ -25,11 +25,11 @@
"nvim-autopairs": { "branch": "master", "commit": "7b9923abad60b903ece7c52940e1321d39eccc79" },
"nvim-cmp": { "branch": "main", "commit": "a1d504892f2bc56c2e79b65c6faded2fd21f3eca" },
"nvim-colorizer.lua": { "branch": "master", "commit": "5cfe7fffbd01e17b3c1e14af85d5febdef88bd8c" },
"nvim-lspconfig": { "branch": "master", "commit": "a4ed4e761c400849e8c9f8bda33e5083f890268c" },
"nvim-lspconfig": { "branch": "master", "commit": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b" },
"nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" },
"nvim-treesitter-textobjects": { "branch": "main", "commit": "851e865342e5a4cb1ae23d31caf6e991e1c99f1e" },
"nvim-ts-autotag": { "branch": "main", "commit": "88c1453db4ba7dd24131086fe51fdf74e587d275" },
"nvim-web-devicons": { "branch": "master", "commit": "0d7d35fa946837b8738b17c18d1faa1ac351e7f9" },
"nvim-web-devicons": { "branch": "master", "commit": "dfbfaa967a6f7ec50789bead7ef87e336c1fa63c" },
"oil.nvim": { "branch": "master", "commit": "b91ee5a77a6a9605d9c1aaf4fda74b66082c8297" },
"plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "a798325b7f36acc62741d1029930a7b96d4dd4bf" },
+3
View File
@@ -29,6 +29,9 @@ vim.keymap.set("n", "d", '"_d', opts) --void d
vim.keymap.set("v", "d", '"_d', opts)
vim.keymap.set("n", "<leader>d", "daw", opts)
vim.keymap.set("n", "cw", "ciw", { noremap = true, nowait = true, silent = true }) -- cw = ciw
vim.keymap.set("n", "!", "^") -- remaps ! to ^
vim.keymap.set("v", "<", "<gv") -- stay in visual mode after indent
vim.keymap.set("v", ">", ">gv")
--use Tab to navigate menu snippets menu
vim.keymap.set("i", "<Tab>", function()
+156 -153
View File
@@ -1,21 +1,21 @@
vim.diagnostic.config({
virtual_text = true,
signs = true,
update_in_insert = false,
underline = true,
severity_sort = false,
float = true,
virtual_text = true,
signs = true,
update_in_insert = false,
underline = true,
severity_sort = false,
float = true,
})
--"'''''''Mason''''''''''''''''''''''''''''''''''''''''''''''''''''''
require("mason").setup({
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
ui = {
icons = {
package_installed = "",
package_pending = "",
package_uninstalled = "",
},
},
})
-- Define capabilities for LSP servers
@@ -24,129 +24,132 @@ capabilities.textDocument.completion.completionItem.snippetSupport = true
-- LSP attach callback
local lsp_attach = function(client, bufnr)
-- Helper function to set buffer-local keymaps
local bufmap = function(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc })
end
-- Helper function to set buffer-local keymaps
local bufmap = function(mode, lhs, rhs, desc)
vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, desc = desc })
end
-- Keymaps for LSP actions
bufmap("n", "gd", vim.lsp.buf.definition, "Go to definition")
bufmap("n", "gD", vim.lsp.buf.declaration, "Go to declaration")
bufmap("n", "K", function()
vim.lsp.buf.hover({
border = "rounded",
})
end, "Show hover documentation")
bufmap("n", "<leader>vws", vim.lsp.buf.workspace_symbol, "Search workspace symbols")
bufmap("n", "<leader>vd", vim.diagnostic.open_float, "Show diagnostics in float")
bufmap("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
bufmap("n", "gr", vim.lsp.buf.references, "Find references")
bufmap("n", "<F2>", vim.lsp.buf.rename, "Rename symbol")
bufmap("n", "<C-k>", vim.lsp.buf.signature_help, "Show signature help")
-- Keymaps for LSP actions
bufmap("n", "gd", vim.lsp.buf.definition, "Go to definition")
bufmap("n", "gD", vim.lsp.buf.declaration, "Go to declaration")
bufmap("n", "K", function()
vim.lsp.buf.hover({
border = "rounded",
})
end, "Show hover documentation")
bufmap("n", "<leader>vws", vim.lsp.buf.workspace_symbol, "Search workspace symbols")
bufmap("n", "<leader>vd", vim.diagnostic.open_float, "Show diagnostics in float")
bufmap("n", "<leader>ca", vim.lsp.buf.code_action, "Code action")
bufmap("n", "gr", vim.lsp.buf.references, "Find references")
bufmap("n", "<F2>", vim.lsp.buf.rename, "Rename symbol")
bufmap("n", "<C-k>", vim.lsp.buf.signature_help, "Show signature help")
bufmap("n", "<F1>", function()
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }))
end, "Toggle inlay hints")
end
-- Mason-LSPconfig setup
local servers = {
"lua_ls",
"clangd",
"vtsls",
"pyright",
"tailwindcss",
"html",
"stimulus_ls",
"cssls",
"gopls",
"yamlls",
"lua_ls",
"clangd",
"vtsls",
"pyright",
"tailwindcss",
"html",
"stimulus_ls",
"cssls",
"gopls",
"yamlls",
}
require("mason-lspconfig").setup({
ensure_installed = servers,
automatic_enable = false,
ensure_installed = servers,
automatic_enable = false,
})
for _, server in ipairs(servers) do
vim.lsp.config(server, {
capabilities = capabilities,
on_attach = lsp_attach,
})
vim.lsp.enable(server)
vim.lsp.config(server, {
capabilities = capabilities,
on_attach = lsp_attach,
})
vim.lsp.enable(server)
end
vim.lsp.config("pyright", {
capabilities = capabilities,
on_attach = lsp_attach,
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
stubPath = "",
diagnosticMode = "off",
autoImportCompletions = true,
},
},
},
capabilities = capabilities,
on_attach = lsp_attach,
settings = {
python = {
analysis = {
autoSearchPaths = true,
useLibraryCodeForTypes = true,
stubPath = "",
diagnosticMode = "off",
autoImportCompletions = true,
},
},
},
})
vim.lsp.enable("pyright")
----------- RUFF
vim.lsp.config("ruff", {
filetypes = { "python" },
init_options = {
settings = {
configuration = "~/.config/ruff/pyproject.toml",
},
},
filetypes = { "python" },
init_options = {
settings = {
configuration = "~/.config/ruff/pyproject.toml",
},
},
})
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client == nil then
return
end
if client.name == "ruff" then
client.server_capabilities.hoverProvider = false
end
end,
desc = "LSP: Disable hover capability from Ruff",
group = vim.api.nvim_create_augroup("lsp_attach_disable_ruff_hover", { clear = true }),
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
if client == nil then
return
end
if client.name == "ruff" then
client.server_capabilities.hoverProvider = false
end
end,
desc = "LSP: Disable hover capability from Ruff",
})
vim.lsp.enable("ruff")
--------- django experimental
vim.lsp.config("djls", {
cmd = { "djls", "serve" },
filetypes = { "htmldjango", "html", "python" },
root_markers = { "manage.py" },
cmd = { "djls", "serve" },
filetypes = { "htmldjango", "html", "python" },
root_markers = { "manage.py" },
})
vim.lsp.enable("djls")
-------------- LUA
vim.lsp.config("lua_ls", {
capabilities = capabilities,
on_attach = lsp_attach,
capabilities = capabilities,
on_attach = lsp_attach,
settings = {
Lua = {
workspace = {
library = {
"/usr/share/hypr/stubs",
-- Neovim Lua runtime completion
vim.env.VIMRUNTIME,
-- Your nvim config Lua files
vim.fn.stdpath("config") .. "/lua",
},
checkThirdParty = false,
},
diagnostics = {
enable = true,
globals = { "vim", "hl" },
},
},
},
settings = {
Lua = {
workspace = {
library = {
"/usr/share/hypr/stubs",
-- Neovim Lua runtime completion
vim.env.VIMRUNTIME,
-- Your nvim config Lua files
vim.fn.stdpath("config") .. "/lua",
},
checkThirdParty = false,
},
diagnostics = {
enable = true,
globals = { "vim", "hl" },
},
},
},
})
vim.lsp.enable("lua_ls")
@@ -157,38 +160,38 @@ local helpers = require("null-ls.helpers")
local methods = require("null-ls.methods")
local ruff_format = helpers.make_builtin({
name = "ruff_format",
method = methods.internal.FORMATTING,
filetypes = { "python" },
generator_opts = {
command = "ruff",
args = { "format", "--stdin-filename", "$FILENAME", "-" },
to_stdin = true,
},
factory = helpers.formatter_factory,
name = "ruff_format",
method = methods.internal.FORMATTING,
filetypes = { "python" },
generator_opts = {
command = "ruff",
args = { "format", "--stdin-filename", "$FILENAME", "-" },
to_stdin = true,
},
factory = helpers.formatter_factory,
})
null_ls.setup({
sources = {
null_ls.builtins.diagnostics.djlint,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.codespell,
null_ls.builtins.diagnostics.hadolint,
null_ls.builtins.formatting.prettierd.with({ extra_args = { "--single-quote" } }),
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.stylua,
ruff_format,
},
on_attach = function(client, bufnr)
if client:supports_method("textDocument/formatting") then -- run formatters on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
sources = {
null_ls.builtins.diagnostics.djlint,
null_ls.builtins.diagnostics.cppcheck,
null_ls.builtins.diagnostics.codespell,
null_ls.builtins.diagnostics.hadolint,
null_ls.builtins.formatting.prettierd.with({ extra_args = { "--single-quote" } }),
null_ls.builtins.formatting.gofumpt,
null_ls.builtins.formatting.stylua,
ruff_format,
},
on_attach = function(client, bufnr)
if client:supports_method("textDocument/formatting") then -- run formatters on save
vim.api.nvim_create_autocmd("BufWritePre", {
buffer = bufnr,
callback = function()
vim.lsp.buf.format({ bufnr = bufnr })
end,
})
end
end,
})
--"'''''''''''''''''''Tree sitter highlight''''''''''''''''''''''''''''''
@@ -196,49 +199,49 @@ require("nvim-treesitter").install({ "lua", "yaml", "bash", "python", "typescrip
local ts_indent_langs = { "html", "javascript", "tsx", "go", "lua" }
vim.api.nvim_create_autocmd("FileType", {
callback = function(ev)
pcall(vim.treesitter.start)
if vim.tbl_contains(ts_indent_langs, ev.match) then
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
callback = function(ev)
pcall(vim.treesitter.start)
if vim.tbl_contains(ts_indent_langs, ev.match) then
vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end,
})
require("nvim-treesitter-textobjects").setup({
select = {
lookahead = true,
selection_modes = {
["@parameter.outer"] = "v",
["@function.outer"] = "V",
["@class.outer"] = "<c-v>",
},
include_surrounding_whitespace = false,
},
move = { set_jumps = true },
select = {
lookahead = true,
selection_modes = {
["@parameter.outer"] = "v",
["@function.outer"] = "V",
["@class.outer"] = "<c-v>",
},
include_surrounding_whitespace = false,
},
move = { set_jumps = true },
})
local select = require("nvim-treesitter-textobjects.select")
local move = require("nvim-treesitter-textobjects.move")
vim.keymap.set({ "x", "o" }, "af", function()
select.select_textobject("@function.outer", "textobjects")
select.select_textobject("@function.outer", "textobjects")
end)
vim.keymap.set({ "x", "o" }, "if", function()
select.select_textobject("@function.inner", "textobjects")
select.select_textobject("@function.inner", "textobjects")
end)
vim.keymap.set({ "x", "o" }, "ac", function()
select.select_textobject("@class.outer", "textobjects")
select.select_textobject("@class.outer", "textobjects")
end)
vim.keymap.set({ "x", "o" }, "ic", function()
select.select_textobject("@class.inner", "textobjects")
select.select_textobject("@class.inner", "textobjects")
end)
vim.keymap.set({ "x", "o" }, "as", function()
select.select_textobject("@local.scope", "locals")
select.select_textobject("@local.scope", "locals")
end)
vim.keymap.set({ "n", "x", "o" }, "<C-f>", function()
move.goto_next_start("@function.outer", "textobjects")
move.goto_next_start("@function.outer", "textobjects")
end)
vim.keymap.set({ "n", "x", "o" }, "<A-f>", function()
move.goto_previous_start("@function.outer", "textobjects")
move.goto_previous_start("@function.outer", "textobjects")
end)