From 7547ef0ff1af956026a4dcc6d5301cfc70dbfa0e Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 11 Jun 2025 17:38:25 +0200 Subject: [PATCH] Updated config --- .config/fish/alias.fish | 2 +- .config/fish/scripts/jpgtoavif | 24 ++++++++ .config/hypr/autostart.conf | 2 +- .config/hypr/keys.conf | 2 +- .config/nvim/lsp/clangd.lua | 2 +- .config/nvim/lsp/gopls.lua | 2 +- .config/nvim/lsp/lua-language-server.lua | 15 +++++ .config/nvim/lsp/rust-analyzer.lua | 2 +- .config/nvim/lua/commands.lua | 70 ++++++++++++++++++++++++ .config/nvim/lua/keys.lua | 11 ++++ .config/nvim/lua/languages.lua | 1 + 11 files changed, 127 insertions(+), 6 deletions(-) create mode 100755 .config/fish/scripts/jpgtoavif create mode 100644 .config/nvim/lsp/lua-language-server.lua diff --git a/.config/fish/alias.fish b/.config/fish/alias.fish index 49a3ace..a61e9e7 100644 --- a/.config/fish/alias.fish +++ b/.config/fish/alias.fish @@ -52,7 +52,7 @@ end # MPV if command -q mpv - alias music "mpv music --shuffle --no-video" + alias m "mpv music --shuffle --no-video" end # Neovim diff --git a/.config/fish/scripts/jpgtoavif b/.config/fish/scripts/jpgtoavif new file mode 100755 index 0000000..430c736 --- /dev/null +++ b/.config/fish/scripts/jpgtoavif @@ -0,0 +1,24 @@ +#!/usr/bin/fish + +if not set -q argv[1] + echo "Usage: $argv[0] /path/to/search" + exit 1 +end + +for jpg in (find $argv[1] -type f -name '*.jpg') + set avif (string replace -r '\.jpg$' '.avif' $jpg) + + if test -f $avif + echo Skip $avif + continue + end + + echo Converting $jpg to $avif + avifenc $jpg $avif + + set json "$jpg.JSON" + if test -f $json + echo Renaming JSON $json to "$avif.JSON" + mv $json "$avif.JSON" + end +end \ No newline at end of file diff --git a/.config/hypr/autostart.conf b/.config/hypr/autostart.conf index c791a3e..8487051 100644 --- a/.config/hypr/autostart.conf +++ b/.config/hypr/autostart.conf @@ -1,5 +1,5 @@ # Autostart -exec-once = swaybg -i ~/pictures/wallpapers/01.png +exec-once = swaybg -i ~/pictures/wallpapers/current exec-once = wl-paste --watch cliphist store exec-once = $statusbar exec-once = ssh-agent -D -a $SSH_AUTH_SOCK diff --git a/.config/hypr/keys.conf b/.config/hypr/keys.conf index b2b2422..8f392d7 100644 --- a/.config/hypr/keys.conf +++ b/.config/hypr/keys.conf @@ -21,7 +21,7 @@ bind =, Print, exec, $screenshot bind = $main, C, killactive, bind = $main, J, togglesplit, bind = $main, V, togglefloating, -bind = $main, Super_R, fullscreen, +bind = $main, X, fullscreen, # Session management bind = $main, Backspace, exit, diff --git a/.config/nvim/lsp/clangd.lua b/.config/nvim/lsp/clangd.lua index 626d4e2..eb917d6 100644 --- a/.config/nvim/lsp/clangd.lua +++ b/.config/nvim/lsp/clangd.lua @@ -1,5 +1,5 @@ return { cmd = { "clangd", "--background-index" }, - root_markers = { "meson_options.txt", "CMakePresets.json", "compile_commands.json" }, + root_markers = { "meson_options.txt", "CMakePresets.json", "compile_commands.json", ".git" }, filetypes = { "c", "cpp" }, } \ No newline at end of file diff --git a/.config/nvim/lsp/gopls.lua b/.config/nvim/lsp/gopls.lua index 9186591..c33db19 100644 --- a/.config/nvim/lsp/gopls.lua +++ b/.config/nvim/lsp/gopls.lua @@ -1,5 +1,5 @@ return { cmd = { "gopls" }, - root_markers = { "go.mod", "go.work" }, + root_markers = { "go.mod", "go.work", ".git" }, filetypes = { "go", "gomod", "gowork", "gotmpl" }, } \ No newline at end of file diff --git a/.config/nvim/lsp/lua-language-server.lua b/.config/nvim/lsp/lua-language-server.lua new file mode 100644 index 0000000..9aa490d --- /dev/null +++ b/.config/nvim/lsp/lua-language-server.lua @@ -0,0 +1,15 @@ +return { + cmd = { "lua-language-server" }, + filetypes = { "lua" }, + root_markers = { "stylua.toml", "init.lua", ".git" }, + settings = { + Lua = { + runtime = { version = "LuaJIT" }, + workspace = { + checkThirdParty = false, + library = vim.api.nvim_get_runtime_file("", true), + }, + telemetry = { enable = false } + } + } +} \ No newline at end of file diff --git a/.config/nvim/lsp/rust-analyzer.lua b/.config/nvim/lsp/rust-analyzer.lua index 69aedd6..2d14327 100644 --- a/.config/nvim/lsp/rust-analyzer.lua +++ b/.config/nvim/lsp/rust-analyzer.lua @@ -1,5 +1,5 @@ return { cmd = { "rust-analyzer" }, - root_markers = { "Cargo.toml" }, + root_markers = { "Cargo.toml", ".git" }, filetypes = { "rust" }, } \ No newline at end of file diff --git a/.config/nvim/lua/commands.lua b/.config/nvim/lua/commands.lua index 12522d1..e179f40 100644 --- a/.config/nvim/lua/commands.lua +++ b/.config/nvim/lua/commands.lua @@ -1,3 +1,73 @@ +-- ToggleComment +vim.api.nvim_create_user_command("ToggleComment", function() + local comments = { + bash = "#", + c = "//", + cpp = "//", + editorconfig = "#", + fish = "#", + gdscript = "#", + gdshader = "//", + gitignore = "#", + glsl = "//", + go = "//", + hyprlang = "#", + javascript = "//", + jsonc = "//", + lua = "--", + rust = "//", + sh = "#", + tmux = "#", + toml = "#", + typescript = "//", + yaml = "#", + zig = "//", + } + + local comment = comments[vim.bo.filetype] + + if comment == nil then + return + end + + local is_visual = vim.fn.mode():match("[vV]") + local start_line + local end_line + + if is_visual then + start_line = vim.fn.line("v") + end_line = vim.fn.line(".") + else + start_line = vim.fn.line(".") + end_line = start_line + end + + if start_line == 0 or end_line == 0 then + vim.notify("No visual selection found. Please make a selection first.", vim.log.levels.WARN) + return + end + + if start_line > end_line then + start_line, end_line = end_line, start_line + end + + local lines = vim.api.nvim_buf_get_lines(0, start_line - 1, end_line, false) + + for i, line in ipairs(lines) do + local indent, rest = line:match("^(%s*)(.*)") + + if vim.startswith(rest, comment) then + rest = rest:sub(#comment + 1):gsub("^%s*", "") + else + rest = comment .. " " .. rest + end + + lines[i] = indent .. rest + end + + vim.api.nvim_buf_set_lines(0, start_line - 1, end_line, false, lines) +end, {}) + -- ToggleWord vim.api.nvim_create_user_command("ToggleWord", function() local inverse = { diff --git a/.config/nvim/lua/keys.lua b/.config/nvim/lua/keys.lua index c5c3936..120dc4e 100644 --- a/.config/nvim/lua/keys.lua +++ b/.config/nvim/lua/keys.lua @@ -17,9 +17,15 @@ map({"n", "v"}, "Q", "qa!", "Force quit") -- Clear search with Esc map({"n", "i"}, "", "noh", "Clear search") +-- Change with c changes the entire word +map("n", "c", "ciw", "Change word") + -- Ctrl S to save the file from any mode map({"n", "i", "s", "v"}, "", "w", "Save file") +-- Ctrl Space for auto complete +map("i", "", "", "Auto complete") + -- Grab the line and move it up/down map("n", "", "set pastem`O``set nopaste", "Add empty line above") map("n", "", "m`-g/\\m^\\s*$/d``noh", "Delete empty line above") @@ -29,6 +35,8 @@ map("n", "", "set pastem`o``set nopaste", "Add empty map("n", "", "m`+g/\\m^\\s*$/d``noh", "Delete empty line below") -- Horizontal movement +map({"n", "v"}, "", "b", "Back one word") +map({"n", "v"}, "", "w", "Forward one word") map({"n", "v"}, "H", "^", "Beginning of line") map({"n", "v"}, "L", "", "End of line") @@ -42,6 +50,9 @@ map("n", "", "V") map("v", "", ">gv") map("v", "", "", "ToggleComment", "Toggle comment") + -- Toggle word map("n", "", "ToggleWord", "Toggle word") diff --git a/.config/nvim/lua/languages.lua b/.config/nvim/lua/languages.lua index 58f4de1..eb7f891 100644 --- a/.config/nvim/lua/languages.lua +++ b/.config/nvim/lua/languages.lua @@ -7,5 +7,6 @@ vim.diagnostic.config({ vim.lsp.enable({ "clangd", "gopls", + "lua-language-server", "rust-analyzer", }) \ No newline at end of file